diff --git a/shared/src/simulation/activities/load-vehicle.ts b/shared/src/simulation/activities/load-vehicle.ts index a71656f6b..b6eae437c 100644 --- a/shared/src/simulation/activities/load-vehicle.ts +++ b/shared/src/simulation/activities/load-vehicle.ts @@ -7,11 +7,14 @@ import { Min, } from 'class-validator'; import { difference } from 'lodash-es'; +import { Type } from 'class-transformer'; import { + ExerciseOccupation, SimulatedRegionPosition, VehiclePosition, getCreate, isInSpecificSimulatedRegion, + occupationTypeOptions, } from '../../models/utils'; import { UUID, @@ -84,6 +87,10 @@ export class LoadVehicleActivityState implements SimulationActivityState { @Min(0) public readonly startTime: number = 0; + @IsOptional() + @Type(...occupationTypeOptions) + readonly successorOccupation?: ExerciseOccupation; + /** * @deprecated Use {@link create} instead */ @@ -95,7 +102,8 @@ export class LoadVehicleActivityState implements SimulationActivityState { patientsToBeLoaded: UUIDSet, loadTimePerPatient: number, personnelLoadTime: number, - key?: string + key?: string, + successorOccupation?: ExerciseOccupation ) { this.id = id; this.vehicleId = vehicleId; @@ -105,6 +113,7 @@ export class LoadVehicleActivityState implements SimulationActivityState { this.loadTimePerPatient = loadTimePerPatient; this.personnelLoadTime = personnelLoadTime; this.key = key; + this.successorOccupation = successorOccupation; } static readonly create = getCreate(this); @@ -275,7 +284,8 @@ export const loadVehicleActivity: SimulationActivity = activityState.vehicleId, activityState.transferDestinationType, activityState.transferDestinationId, - activityState.key + activityState.key, + cloneDeepMutable(activityState.successorOccupation) ) ); diff --git a/shared/src/simulation/activities/transfer-vehicle.ts b/shared/src/simulation/activities/transfer-vehicle.ts index 81c1a588e..63d3e3a42 100644 --- a/shared/src/simulation/activities/transfer-vehicle.ts +++ b/shared/src/simulation/activities/transfer-vehicle.ts @@ -1,14 +1,17 @@ import { IsOptional, IsString, IsUUID } from 'class-validator'; +import { Type } from 'class-transformer'; import { MissingTransferConnectionRadiogram, RadiogramUnpublishedStatus, } from '../../models/radiogram'; import { publishRadiogram } from '../../models/radiogram/radiogram-helpers-mutable'; import { + ExerciseOccupation, getCreate, isInSpecificSimulatedRegion, isInSpecificVehicle, NoOccupation, + occupationTypeOptions, TransferStartPoint, } from '../../models/utils'; import { VehicleResource } from '../../models/utils/rescue-resource'; @@ -52,6 +55,10 @@ export class TransferVehicleActivityState implements SimulationActivityState { @IsUUID(4, uuidValidationOptions) readonly transferDestinationId: UUID; + @IsOptional() + @Type(...occupationTypeOptions) + readonly successorOccupation?: ExerciseOccupation; + @IsOptional() @IsString() readonly key?: string; @@ -64,7 +71,8 @@ export class TransferVehicleActivityState implements SimulationActivityState { vehicleId: UUID, transferDestinationType: TransferDestination, transferDestinationId: UUID, - key?: string + key?: string, + successorOccupation?: ExerciseOccupation ) { this.id = id; this.vehicleId = vehicleId; @@ -72,6 +80,7 @@ export class TransferVehicleActivityState implements SimulationActivityState { this.transferDestinationType = transferDestinationType; this.transferDestinationId = transferDestinationId; this.key = key; + this.successorOccupation = successorOccupation; } static readonly create = getCreate(this); @@ -157,7 +166,9 @@ export const transferVehicleActivity: SimulationActivity = { event.transferDestinationId, {}, behaviorState.loadTimePerPatient, - behaviorState.personnelLoadTime + behaviorState.personnelLoadTime, + undefined, + event.successorOccupation ) ); vehicle.occupation = cloneDeepMutable( @@ -279,7 +281,11 @@ export const transferBehavior: SimulationBehavior = { event.transferDestinationId, {}, behaviorState.loadTimePerPatient, - behaviorState.personnelLoadTime + behaviorState.personnelLoadTime, + undefined, + cloneDeepMutable( + event.successorOccupation + ) ) ); loadableVehicles![index]!.occupation = @@ -404,7 +410,8 @@ export const transferBehavior: SimulationBehavior = { vehicle.id, transferEvent!.transferDestinationType, transferEvent!.transferDestinationId, - transferEvent!.key + transferEvent!.key, + cloneDeepMutable(transferEvent!.successorOccupation) ) ); } diff --git a/shared/src/simulation/events/start-transfer.ts b/shared/src/simulation/events/start-transfer.ts index 66ca50f05..52fdae766 100644 --- a/shared/src/simulation/events/start-transfer.ts +++ b/shared/src/simulation/events/start-transfer.ts @@ -1,5 +1,10 @@ import { IsOptional, IsString, IsUUID } from 'class-validator'; -import { getCreate } from '../../models/utils'; +import { Type } from 'class-transformer'; +import { + ExerciseOccupation, + getCreate, + occupationTypeOptions, +} from '../../models/utils'; import { UUID, uuidValidationOptions } from '../../utils'; import { IsLiteralUnion, IsValue } from '../../utils/validators'; import { @@ -25,6 +30,10 @@ export class StartTransferEvent implements SimulationEvent { @IsString() readonly key?: string; + @IsOptional() + @Type(...occupationTypeOptions) + readonly successorOccupation?: ExerciseOccupation; + /** * @deprecated Use {@link create} instead */ @@ -32,12 +41,14 @@ export class StartTransferEvent implements SimulationEvent { vehicleId: UUID, transferDestinationType: TransferDestination, transferDestinationId: UUID, - key?: string + key?: string, + successorOccupation?: ExerciseOccupation ) { this.vehicleId = vehicleId; this.transferDestinationType = transferDestinationType; this.transferDestinationId = transferDestinationId; this.key = key; + this.successorOccupation = successorOccupation; } static readonly create = getCreate(this); diff --git a/shared/src/simulation/events/transfer-specific-vehicle-request.ts b/shared/src/simulation/events/transfer-specific-vehicle-request.ts index 5571fa196..0c99fe04a 100644 --- a/shared/src/simulation/events/transfer-specific-vehicle-request.ts +++ b/shared/src/simulation/events/transfer-specific-vehicle-request.ts @@ -1,5 +1,10 @@ -import { IsUUID } from 'class-validator'; -import { getCreate } from '../../models/utils'; +import { IsOptional, IsUUID } from 'class-validator'; +import { Type } from 'class-transformer'; +import { + ExerciseOccupation, + getCreate, + occupationTypeOptions, +} from '../../models/utils'; import { UUID, uuidValidationOptions } from '../../utils'; import { IsLiteralUnion, IsValue } from '../../utils/validators'; import { @@ -21,17 +26,23 @@ export class TransferSpecificVehicleRequestEvent implements SimulationEvent { @IsUUID(4, uuidValidationOptions) readonly transferDestinationId: UUID; + @IsOptional() + @Type(...occupationTypeOptions) + readonly successorOccupation?: ExerciseOccupation; + /** * @deprecated Use {@link create} instead */ constructor( vehicleId: UUID, transferDestinationType: TransferDestination, - transferDestinationId: UUID + transferDestinationId: UUID, + successorOccupation?: ExerciseOccupation ) { this.vehicleId = vehicleId; this.transferDestinationType = transferDestinationType; this.transferDestinationId = transferDestinationId; + this.successorOccupation = successorOccupation; } static readonly create = getCreate(this); diff --git a/shared/src/simulation/events/transfer-vehicles-request.ts b/shared/src/simulation/events/transfer-vehicles-request.ts index e355cfd6f..8752d7038 100644 --- a/shared/src/simulation/events/transfer-vehicles-request.ts +++ b/shared/src/simulation/events/transfer-vehicles-request.ts @@ -1,5 +1,10 @@ import { IsOptional, IsString, IsUUID } from 'class-validator'; -import { getCreate } from '../../models/utils'; +import { Type } from 'class-transformer'; +import { + ExerciseOccupation, + getCreate, + occupationTypeOptions, +} from '../../models/utils'; import { IsLiteralUnion, IsValue } from '../../utils/validators'; import { ResourceDescription } from '../../models/utils/resource-description'; import { IsResourceDescription } from '../../utils/validators/is-resource-description'; @@ -23,6 +28,10 @@ export class TransferVehiclesRequestEvent implements SimulationEvent { @IsUUID(4, uuidValidationOptions) readonly transferDestinationId: UUID; + @IsOptional() + @Type(...occupationTypeOptions) + readonly successorOccupation?: ExerciseOccupation; + @IsOptional() @IsString() readonly key?: string; @@ -34,12 +43,14 @@ export class TransferVehiclesRequestEvent implements SimulationEvent { requestedVehicles: ResourceDescription, transferDestinationType: TransferDestination, transferDestinationId: UUID, - key?: string + key?: string, + successorOccupation?: ExerciseOccupation ) { this.requestedVehicles = requestedVehicles; this.transferDestinationType = transferDestinationType; this.transferDestinationId = transferDestinationId; this.key = key; + this.successorOccupation = successorOccupation; } static readonly create = getCreate(this);