-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpersonnel-template.ts
65 lines (57 loc) · 2.08 KB
/
personnel-template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Type } from 'class-transformer';
import { IsNumber, Max, Min, ValidateNested } from 'class-validator';
import { maxTreatmentRange } from '../state-helpers/max-treatment-range';
import { IsLiteralUnion, IsValue } from '../utils/validators';
import {
PersonnelType,
personnelTypeAllowedValues,
} from './utils/personnel-type';
import { CanCaterFor } from './utils/cater-for';
import { ImageProperties } from './utils/image-properties';
import { getCreate } from './utils/get-create';
// TODO: These are not (yet) saved in the state -> Decide whether they should and if not move this file from the models folder away
export class PersonnelTemplate {
@IsValue('personnelTemplate' as const)
public readonly type = 'personnelTemplate';
@IsLiteralUnion(personnelTypeAllowedValues)
public readonly personnelType: PersonnelType;
@ValidateNested()
@Type(() => CanCaterFor)
public readonly canCaterFor: CanCaterFor;
/**
* Patients in this range are preferred over patients farther away (even if they are less injured).
* Guaranteed to be <= {@link maxTreatmentRange}.
*/
@IsNumber()
@Min(0)
@Max(maxTreatmentRange)
public readonly overrideTreatmentRange: number;
/**
* Only patients in this range around the personnel's position can be treated.
* Guaranteed to be <= {@link maxTreatmentRange}.
*/
@IsNumber()
@Min(0)
@Max(maxTreatmentRange)
public readonly treatmentRange: number;
@ValidateNested()
@Type(() => ImageProperties)
public readonly image: ImageProperties;
/**
* @deprecated Use {@link create} instead
*/
constructor(
personnelType: PersonnelType,
image: ImageProperties,
canCaterFor: CanCaterFor,
overrideTreatmentRange: number,
treatmentRange: number
) {
this.personnelType = personnelType;
this.image = image;
this.canCaterFor = canCaterFor;
this.overrideTreatmentRange = overrideTreatmentRange;
this.treatmentRange = treatmentRange;
}
static readonly create = getCreate(this);
}