Skip to content

Commit 259e2bf

Browse files
Merge branch 'dev' into feature/870-allow-vehicles-as-leaders-of-a-simulated-region
2 parents f30a32d + 9a22fcf commit 259e2bf

File tree

6 files changed

+78
-15
lines changed

6 files changed

+78
-15
lines changed

shared/src/simulation/activities/load-vehicle.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {
77
Min,
88
} from 'class-validator';
99
import { difference } from 'lodash-es';
10+
import { Type } from 'class-transformer';
1011
import {
12+
ExerciseOccupation,
1113
SimulatedRegionPosition,
1214
VehiclePosition,
1315
getCreate,
1416
isInSpecificSimulatedRegion,
17+
occupationTypeOptions,
1518
} from '../../models/utils';
1619
import {
1720
UUID,
@@ -84,6 +87,10 @@ export class LoadVehicleActivityState implements SimulationActivityState {
8487
@Min(0)
8588
public readonly startTime: number = 0;
8689

90+
@IsOptional()
91+
@Type(...occupationTypeOptions)
92+
readonly successorOccupation?: ExerciseOccupation;
93+
8794
/**
8895
* @deprecated Use {@link create} instead
8996
*/
@@ -95,7 +102,8 @@ export class LoadVehicleActivityState implements SimulationActivityState {
95102
patientsToBeLoaded: UUIDSet,
96103
loadTimePerPatient: number,
97104
personnelLoadTime: number,
98-
key?: string
105+
key?: string,
106+
successorOccupation?: ExerciseOccupation
99107
) {
100108
this.id = id;
101109
this.vehicleId = vehicleId;
@@ -105,6 +113,7 @@ export class LoadVehicleActivityState implements SimulationActivityState {
105113
this.loadTimePerPatient = loadTimePerPatient;
106114
this.personnelLoadTime = personnelLoadTime;
107115
this.key = key;
116+
this.successorOccupation = successorOccupation;
108117
}
109118

110119
static readonly create = getCreate(this);
@@ -275,7 +284,8 @@ export const loadVehicleActivity: SimulationActivity<LoadVehicleActivityState> =
275284
activityState.vehicleId,
276285
activityState.transferDestinationType,
277286
activityState.transferDestinationId,
278-
activityState.key
287+
activityState.key,
288+
cloneDeepMutable(activityState.successorOccupation)
279289
)
280290
);
281291

shared/src/simulation/activities/transfer-vehicle.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { IsOptional, IsString, IsUUID } from 'class-validator';
2+
import { Type } from 'class-transformer';
23
import {
34
MissingTransferConnectionRadiogram,
45
RadiogramUnpublishedStatus,
56
} from '../../models/radiogram';
67
import { publishRadiogram } from '../../models/radiogram/radiogram-helpers-mutable';
78
import {
9+
ExerciseOccupation,
810
getCreate,
911
isInSpecificSimulatedRegion,
1012
isInSpecificVehicle,
1113
NoOccupation,
14+
occupationTypeOptions,
1215
TransferStartPoint,
1316
} from '../../models/utils';
1417
import { VehicleResource } from '../../models/utils/rescue-resource';
@@ -52,6 +55,10 @@ export class TransferVehicleActivityState implements SimulationActivityState {
5255
@IsUUID(4, uuidValidationOptions)
5356
readonly transferDestinationId: UUID;
5457

58+
@IsOptional()
59+
@Type(...occupationTypeOptions)
60+
readonly successorOccupation?: ExerciseOccupation;
61+
5562
@IsOptional()
5663
@IsString()
5764
readonly key?: string;
@@ -64,14 +71,16 @@ export class TransferVehicleActivityState implements SimulationActivityState {
6471
vehicleId: UUID,
6572
transferDestinationType: TransferDestination,
6673
transferDestinationId: UUID,
67-
key?: string
74+
key?: string,
75+
successorOccupation?: ExerciseOccupation
6876
) {
6977
this.id = id;
7078
this.vehicleId = vehicleId;
7179

7280
this.transferDestinationType = transferDestinationType;
7381
this.transferDestinationId = transferDestinationId;
7482
this.key = key;
83+
this.successorOccupation = successorOccupation;
7584
}
7685

7786
static readonly create = getCreate(this);
@@ -157,7 +166,9 @@ export const transferVehicleActivity: SimulationActivity<TransferVehicleActivity
157166

158167
// Do transfer and send event
159168

160-
vehicle.occupation = cloneDeepMutable(NoOccupation.create());
169+
vehicle.occupation = cloneDeepMutable(
170+
activityState.successorOccupation ?? NoOccupation.create()
171+
);
161172

162173
TransferActionReducers.addToTransfer.reducer(draftState, {
163174
type: '[Transfer] Add to transfer',
@@ -207,7 +218,9 @@ export const transferVehicleActivity: SimulationActivity<TransferVehicleActivity
207218

208219
// Do transfer and send event
209220

210-
vehicle.occupation = cloneDeepMutable(NoOccupation.create());
221+
vehicle.occupation = cloneDeepMutable(
222+
activityState.successorOccupation ?? NoOccupation.create()
223+
);
211224

212225
HospitalActionReducers.transportPatientToHospital.reducer(
213226
draftState,

shared/src/simulation/behaviors/transfer.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ export const transferBehavior: SimulationBehavior<TransferBehaviorState> = {
203203
event.transferDestinationId,
204204
{},
205205
behaviorState.loadTimePerPatient,
206-
behaviorState.personnelLoadTime
206+
behaviorState.personnelLoadTime,
207+
undefined,
208+
event.successorOccupation
207209
)
208210
);
209211
vehicle.occupation = cloneDeepMutable(
@@ -279,7 +281,11 @@ export const transferBehavior: SimulationBehavior<TransferBehaviorState> = {
279281
event.transferDestinationId,
280282
{},
281283
behaviorState.loadTimePerPatient,
282-
behaviorState.personnelLoadTime
284+
behaviorState.personnelLoadTime,
285+
undefined,
286+
cloneDeepMutable(
287+
event.successorOccupation
288+
)
283289
)
284290
);
285291
loadableVehicles![index]!.occupation =
@@ -404,7 +410,8 @@ export const transferBehavior: SimulationBehavior<TransferBehaviorState> = {
404410
vehicle.id,
405411
transferEvent!.transferDestinationType,
406412
transferEvent!.transferDestinationId,
407-
transferEvent!.key
413+
transferEvent!.key,
414+
cloneDeepMutable(transferEvent!.successorOccupation)
408415
)
409416
);
410417
}

shared/src/simulation/events/start-transfer.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { IsOptional, IsString, IsUUID } from 'class-validator';
2-
import { getCreate } from '../../models/utils';
2+
import { Type } from 'class-transformer';
3+
import {
4+
ExerciseOccupation,
5+
getCreate,
6+
occupationTypeOptions,
7+
} from '../../models/utils';
38
import { UUID, uuidValidationOptions } from '../../utils';
49
import { IsLiteralUnion, IsValue } from '../../utils/validators';
510
import {
@@ -25,19 +30,25 @@ export class StartTransferEvent implements SimulationEvent {
2530
@IsString()
2631
readonly key?: string;
2732

33+
@IsOptional()
34+
@Type(...occupationTypeOptions)
35+
readonly successorOccupation?: ExerciseOccupation;
36+
2837
/**
2938
* @deprecated Use {@link create} instead
3039
*/
3140
constructor(
3241
vehicleId: UUID,
3342
transferDestinationType: TransferDestination,
3443
transferDestinationId: UUID,
35-
key?: string
44+
key?: string,
45+
successorOccupation?: ExerciseOccupation
3646
) {
3747
this.vehicleId = vehicleId;
3848
this.transferDestinationType = transferDestinationType;
3949
this.transferDestinationId = transferDestinationId;
4050
this.key = key;
51+
this.successorOccupation = successorOccupation;
4152
}
4253

4354
static readonly create = getCreate(this);

shared/src/simulation/events/transfer-specific-vehicle-request.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { IsUUID } from 'class-validator';
2-
import { getCreate } from '../../models/utils';
1+
import { IsOptional, IsUUID } from 'class-validator';
2+
import { Type } from 'class-transformer';
3+
import {
4+
ExerciseOccupation,
5+
getCreate,
6+
occupationTypeOptions,
7+
} from '../../models/utils';
38
import { UUID, uuidValidationOptions } from '../../utils';
49
import { IsLiteralUnion, IsValue } from '../../utils/validators';
510
import {
@@ -21,17 +26,23 @@ export class TransferSpecificVehicleRequestEvent implements SimulationEvent {
2126
@IsUUID(4, uuidValidationOptions)
2227
readonly transferDestinationId: UUID;
2328

29+
@IsOptional()
30+
@Type(...occupationTypeOptions)
31+
readonly successorOccupation?: ExerciseOccupation;
32+
2433
/**
2534
* @deprecated Use {@link create} instead
2635
*/
2736
constructor(
2837
vehicleId: UUID,
2938
transferDestinationType: TransferDestination,
30-
transferDestinationId: UUID
39+
transferDestinationId: UUID,
40+
successorOccupation?: ExerciseOccupation
3141
) {
3242
this.vehicleId = vehicleId;
3343
this.transferDestinationType = transferDestinationType;
3444
this.transferDestinationId = transferDestinationId;
45+
this.successorOccupation = successorOccupation;
3546
}
3647

3748
static readonly create = getCreate(this);

shared/src/simulation/events/transfer-vehicles-request.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { IsOptional, IsString, IsUUID } from 'class-validator';
2-
import { getCreate } from '../../models/utils';
2+
import { Type } from 'class-transformer';
3+
import {
4+
ExerciseOccupation,
5+
getCreate,
6+
occupationTypeOptions,
7+
} from '../../models/utils';
38
import { IsLiteralUnion, IsValue } from '../../utils/validators';
49
import { ResourceDescription } from '../../models/utils/resource-description';
510
import { IsResourceDescription } from '../../utils/validators/is-resource-description';
@@ -23,6 +28,10 @@ export class TransferVehiclesRequestEvent implements SimulationEvent {
2328
@IsUUID(4, uuidValidationOptions)
2429
readonly transferDestinationId: UUID;
2530

31+
@IsOptional()
32+
@Type(...occupationTypeOptions)
33+
readonly successorOccupation?: ExerciseOccupation;
34+
2635
@IsOptional()
2736
@IsString()
2837
readonly key?: string;
@@ -34,12 +43,14 @@ export class TransferVehiclesRequestEvent implements SimulationEvent {
3443
requestedVehicles: ResourceDescription,
3544
transferDestinationType: TransferDestination,
3645
transferDestinationId: UUID,
37-
key?: string
46+
key?: string,
47+
successorOccupation?: ExerciseOccupation
3848
) {
3949
this.requestedVehicles = requestedVehicles;
4050
this.transferDestinationType = transferDestinationType;
4151
this.transferDestinationId = transferDestinationId;
4252
this.key = key;
53+
this.successorOccupation = successorOccupation;
4354
}
4455

4556
static readonly create = getCreate(this);

0 commit comments

Comments
 (0)