{{ strings.patientState.breathing }} -
{{ patientStore.breathing }} + {{ breathing }}{{ strings.patientState.circulation }} -
{{ patientStore.circulation }} + {{ circulation }}diff --git a/frontend/src/enums.ts b/frontend/src/enums.ts new file mode 100644 index 00000000..4fb5f845 --- /dev/null +++ b/frontend/src/enums.ts @@ -0,0 +1,12 @@ +export enum ContinuousVariableName { + SPO2 = "SpO2", + HEART_RATE = "BPM" +} + +export enum ContinuousFunctionName { + LINEAR = "linear", + SIGMOID = "sigmoid", + SIGMOID_DELAYED = "delayed sigmoid", + INCREMENT = "increment", + DECREMENT = "decrement", +} \ No newline at end of file diff --git a/frontend/src/sockets/MessageData.ts b/frontend/src/sockets/MessageData.ts index 49906e5e..e2779751 100644 --- a/frontend/src/sockets/MessageData.ts +++ b/frontend/src/sockets/MessageData.ts @@ -1,5 +1,6 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -interface MessageData { +import {type ContinuousFunctionName, ContinuousVariableName} from "@/enums" + +export interface MessageData { messageType: string message?: string triage?: string @@ -17,6 +18,7 @@ interface MessageData { materialName?: string exercise?: Exercise state?: State + continuousState?: ContinuousState logEntries?: LogEntry[] availablePatients: AvailablePatient[] availableActions: AvailableAction[] @@ -31,14 +33,41 @@ interface MessageData { timeUntilBack: number } -interface Exercise { +export interface ContinuousState { + timeUntilPhaseChange: number + continuousVariables: ContinuousVariable[] +} + +export interface ContinuousStateInternal { + timeUntilPhaseChange: number + continuousVariables: ContinuousVariableInternal[] +} + +export interface ContinuousVariable { + name: ContinuousVariableName + current: number + target: number + function: ContinuousFunctionName +} + +export interface ContinuousVariableInternal { + name: ContinuousVariableName + xStart: number + xCurrent: number + xTarget: number + tDelta: number + function: ContinuousFunctionName +} + + +export interface Exercise { exerciseId: string status: string speed: number areas: Area[] } -interface Area { +export interface Area { areaId: number areaName: string patients: Patient[] @@ -46,25 +75,25 @@ interface Area { material: Material[] } -interface Patient { +export interface Patient { patientId: string patientName: string code: number triage: string } -interface Personnel { +export interface Personnel { personnelId: number personnelName: string } -interface Material { +export interface Material { materialId: number materialName: string materialType: string } -interface State { +export interface State { phaseNumber: number airway: string breathing: string @@ -75,18 +104,18 @@ interface State { skin: string } -interface Availables { +export interface Availables { actions: AvailableAction[], patients: AvailablePatient[], material: AvailableMaterial[], } -interface AvailableAction { +export interface AvailableAction { actionName: string actionCategory: string } -interface AvailablePatient { +export interface AvailablePatient { code: number personalDetails: string injury: string @@ -99,36 +128,36 @@ interface AvailablePatient { pretreatment: string } -interface AvailableMaterial { +export interface AvailableMaterial { materialName: string materialType: string } -interface ResourceAssignments { +export interface ResourceAssignments { resourceAssignments: ResourceAssignment[] } -interface ResourceAssignment { +export interface ResourceAssignment { areaId: number personnel: PersonnelAssignments[] material: MaterialAssignments[] } -interface PersonnelAssignments { +export interface PersonnelAssignments { personnelId: number patientId: string } -interface MaterialAssignments { +export interface MaterialAssignments { materialId: number patientId: string } -interface Log { +export interface Log { log: LogEntry[] } -interface LogEntry { +export interface LogEntry { logId: number logMessage: string logTime: Date @@ -138,12 +167,12 @@ interface LogEntry { materialNames: string[] } -interface ActionOverview { +export interface ActionOverview { actions: Action[] timersRunning: boolean } -interface Action { +export interface Action { actionId: number orderId: number actionName: string @@ -152,17 +181,17 @@ interface Action { actionResult: string } -interface VisibleInjuries { +export interface VisibleInjuries { injuries: Injury[] } -interface Injury { +export interface Injury { injuryId: string injuryType: string position: string } -interface ActionCheck { +export interface ActionCheck { actionName: string applicationDuration: number effectDuration: number @@ -173,31 +202,31 @@ interface ActionCheck { prohibitiveActions: string[] } -interface RequiredActions { +export interface RequiredActions { singleActions: string[] actionGroups: ActionGroup[] } -interface ActionGroup { +export interface ActionGroup { groupName: string actions: string[] } -interface CheckPersonnel { +export interface CheckPersonnel { name: string available: number assigned: number needed: number } -interface CheckMaterial { +export interface CheckMaterial { name: string available: number assigned: number needed: number } -interface CheckLabDevice { +export interface CheckLabDevice { name: string available: number needed: number diff --git a/frontend/src/sockets/SocketPatient.ts b/frontend/src/sockets/SocketPatient.ts index b2a7f7c6..67561dc2 100644 --- a/frontend/src/sockets/SocketPatient.ts +++ b/frontend/src/sockets/SocketPatient.ts @@ -10,6 +10,19 @@ import {useActionOverviewStore} from "@/stores/ActionOverview" import {useVisibleInjuriesStore} from "@/stores/VisibleInjuries" import {commonMockEvents} from "./commonMockEvents" import {useActionCheckStore} from "@/stores/ActionCheck" +import {startContinuousLogic, useContinuousVariablesStore} from "@/stores/ContinuousVariables" +import type { + Action, + ActionCheck, + AvailableAction, + AvailablePatient, + ContinuousState, + Exercise, + Injury, + MessageData, + ResourceAssignment, + State +} from "@/sockets/MessageData" class SocketPatient { @@ -23,6 +36,7 @@ class SocketPatient { connect(): void { const patientStore = usePatientStore() const exerciseStore = useExerciseStore() + const patientContinuousStore = useContinuousVariablesStore() const availablesStore = useAvailablesStore() const resourceAssignmentsStore = useResourceAssignmentsStore() const actionOverview = useActionOverviewStore() @@ -68,6 +82,9 @@ class SocketPatient { case 'state': patientStore.loadStatusFromJSON(data.state as State) break + case 'continuous-variable': + patientContinuousStore.loadContinuousVariablesFromJSON(data.continuousState as ContinuousState) + break case 'available-patients': availablesStore.loadAvailablePatients(data.availablePatients as AvailablePatient[]) patientStore.initializePatientFromAvailablePatients() @@ -83,6 +100,7 @@ class SocketPatient { exerciseStore.status = 'running' setScreen(Screens.STATUS, ScreenPosition.LEFT) setScreen(Screens.ACTIONS, ScreenPosition.RIGHT) + startContinuousLogic() break case 'exercise-pause': exerciseStore.status = 'paused' @@ -285,60 +303,60 @@ export const serverMockEvents = [ id: 'resource-assignments', data: '{"messageType":"resource-assignments","resourceAssignments":[' + '{"areaId":1,' + - '"personnel":[' + - '{"personnelId":1,"patientId":"145345"},' + - '{"personnelId":10,"patientId":null}' + - '],' + - '"material":[' + - '{"materialId":1,"patientId":"145345"},' + - '{"materialId":2,"patientId":"256443"}' + - ']' + + '"personnel":[' + + '{"personnelId":1,"patientId":"145345"},' + + '{"personnelId":10,"patientId":null}' + + '],' + + '"material":[' + + '{"materialId":1,"patientId":"145345"},' + + '{"materialId":2,"patientId":"256443"}' + + ']' + '},' + '{"areaId":2,' + - '"personnel":[' + - '{"personnelId":3,"patientId":"123456"},' + - '{"personnelId":8,"patientId":"123456"},' + - '{"personnelId":9,"patientId":null},' + - '{"personnelId":11,"patientId":null},' + - '{"personnelId":2,"patientId":null},' + - '{"personnelId":7,"patientId":null},' + - '{"personnelId":12,"patientId":"105626"},' + - '{"personnelId":13,"patientId":"963733"},' + - '{"personnelId":14,"patientId":"754262"},' + - '{"personnelId":15,"patientId":"754262"}' + - '],' + - '"material":[' + - '{"materialId":3,"patientId":"123456"},' + - '{"materialId":4,"patientId":"123456"},' + - '{"materialId":7,"patientId":null},' + - '{"materialId":8,"patientId":null},' + - '{"materialId":9,"patientId":"126541"},' + - '{"materialId":10,"patientId":null},' + - '{"materialId":11,"patientId":null},' + - '{"materialId":12,"patientId":null},' + - '{"materialId":13,"patientId":null},' + - '{"materialId":14,"patientId":null},' + - '{"materialId":15,"patientId":null},' + - '{"materialId":16,"patientId":null},' + - '{"materialId":17,"patientId":null},' + - '{"materialId":18,"patientId":null},' + - '{"materialId":19,"patientId":null},' + - '{"materialId":20,"patientId":null},' + - '{"materialId":21,"patientId":null},' + - '{"materialId":22,"patientId":null}' + - ']' + + '"personnel":[' + + '{"personnelId":3,"patientId":"123456"},' + + '{"personnelId":8,"patientId":"123456"},' + + '{"personnelId":9,"patientId":null},' + + '{"personnelId":11,"patientId":null},' + + '{"personnelId":2,"patientId":null},' + + '{"personnelId":7,"patientId":null},' + + '{"personnelId":12,"patientId":"105626"},' + + '{"personnelId":13,"patientId":"963733"},' + + '{"personnelId":14,"patientId":"754262"},' + + '{"personnelId":15,"patientId":"754262"}' + + '],' + + '"material":[' + + '{"materialId":3,"patientId":"123456"},' + + '{"materialId":4,"patientId":"123456"},' + + '{"materialId":7,"patientId":null},' + + '{"materialId":8,"patientId":null},' + + '{"materialId":9,"patientId":"126541"},' + + '{"materialId":10,"patientId":null},' + + '{"materialId":11,"patientId":null},' + + '{"materialId":12,"patientId":null},' + + '{"materialId":13,"patientId":null},' + + '{"materialId":14,"patientId":null},' + + '{"materialId":15,"patientId":null},' + + '{"materialId":16,"patientId":null},' + + '{"materialId":17,"patientId":null},' + + '{"materialId":18,"patientId":null},' + + '{"materialId":19,"patientId":null},' + + '{"materialId":20,"patientId":null},' + + '{"materialId":21,"patientId":null},' + + '{"materialId":22,"patientId":null}' + + ']' + '},' + '{"areaId":3,' + - '"personnel":[' + - '{"personnelId":5,"patientId":"126143"},' + - '{"personnelId":6,"patientId":"462455"}' + - '],' + - '"material":[' + - '{"materialId":5,"patientId":"126143"},' + - '{"materialId":6,"patientId":"462455"},' + - '{"materialId":5,"patientId":null},' + - '{"materialId":6,"patientId":null}' + - ']' + + '"personnel":[' + + '{"personnelId":5,"patientId":"126143"},' + + '{"personnelId":6,"patientId":"462455"}' + + '],' + + '"material":[' + + '{"materialId":5,"patientId":"126143"},' + + '{"materialId":6,"patientId":"462455"},' + + '{"materialId":5,"patientId":null},' + + '{"materialId":6,"patientId":null}' + + ']' + '}]}' }, { diff --git a/frontend/src/sockets/SocketTrainer.ts b/frontend/src/sockets/SocketTrainer.ts index cc7650f4..5cda9b58 100644 --- a/frontend/src/sockets/SocketTrainer.ts +++ b/frontend/src/sockets/SocketTrainer.ts @@ -5,6 +5,7 @@ import {Modules, setModule, showErrorToast, showWarningToast} from "@/App.vue" import {useAvailablesStore} from "@/stores/Availables" import {useLogStore} from "@/stores/Log" import {commonMockEvents} from "./commonMockEvents" +import type {AvailableAction, AvailableMaterial, AvailablePatient, Exercise, LogEntry, MessageData} from "@/sockets/MessageData" class SocketTrainer { private readonly url: string @@ -234,20 +235,20 @@ export default socketTrainer export const serverMockEvents = [ { id: "available-material", - data: '{"messageType":"available-materials","availableMaterials":['+ - '{"materialName":"Beatmungsgerät","materialType":"DE"},'+ - '{"materialName":"Blutdruckmessgerät","materialType":"DE"},'+ - '{"materialName":"Defibrillator","materialType":"DE"},'+ - '{"materialName":"Endoskop","materialType":"DE"},'+ - '{"materialName":"Herz-Lungen-Maschine","materialType":"DE"},'+ - '{"materialName":"Blut 0 negativ","materialType":"BL"},'+ - '{"materialName":"Blut 0 positiv","materialType":"BL"},'+ - '{"materialName":"Blut A negativ","materialType":"BL"},'+ - '{"materialName":"Blut A positiv","materialType":"BL"},'+ - '{"materialName":"Blut B negativ","materialType":"BL"},'+ - '{"materialName":"Blut B positiv","materialType":"BL"},'+ - '{"materialName":"Blut AB negativ","materialType":"BL"},'+ - '{"materialName":"Blut AB positiv","materialType":"BL"}'+ + data: '{"messageType":"available-materials","availableMaterials":[' + + '{"materialName":"Beatmungsgerät","materialType":"DE"},' + + '{"materialName":"Blutdruckmessgerät","materialType":"DE"},' + + '{"materialName":"Defibrillator","materialType":"DE"},' + + '{"materialName":"Endoskop","materialType":"DE"},' + + '{"materialName":"Herz-Lungen-Maschine","materialType":"DE"},' + + '{"materialName":"Blut 0 negativ","materialType":"BL"},' + + '{"materialName":"Blut 0 positiv","materialType":"BL"},' + + '{"materialName":"Blut A negativ","materialType":"BL"},' + + '{"materialName":"Blut A positiv","materialType":"BL"},' + + '{"materialName":"Blut B negativ","materialType":"BL"},' + + '{"materialName":"Blut B positiv","materialType":"BL"},' + + '{"materialName":"Blut AB negativ","materialType":"BL"},' + + '{"materialName":"Blut AB positiv","materialType":"BL"}' + ']}' }, { diff --git a/frontend/src/stores/ActionCheck.ts b/frontend/src/stores/ActionCheck.ts index 6efae38d..7a51bcd8 100644 --- a/frontend/src/stores/ActionCheck.ts +++ b/frontend/src/stores/ActionCheck.ts @@ -1,26 +1,27 @@ import {defineStore} from 'pinia' +import type {ActionCheck, CheckLabDevice, CheckMaterial, CheckPersonnel, RequiredActions} from "@/sockets/MessageData" export const useActionCheckStore = defineStore('actionCheck', { state: (): ActionCheck => ({ - actionName: "", + actionName: "", applicationDuration: 0, - effectDuration: 0, - personnel: [] as CheckPersonnel[], - material: [] as CheckMaterial[], - labDevices: [] as CheckLabDevice[], - requiredActions: {} as RequiredActions, - prohibitiveActions: [] as string[], + effectDuration: 0, + personnel: [] as CheckPersonnel[], + material: [] as CheckMaterial[], + labDevices: [] as CheckLabDevice[], + requiredActions: {} as RequiredActions, + prohibitiveActions: [] as string[], }), actions: { - loadActionCheck(actionCheck: ActionCheck) { - this.actionName = actionCheck.actionName - this.applicationDuration = actionCheck.applicationDuration - this.effectDuration = actionCheck.effectDuration - this.personnel = actionCheck.personnel - this.material = actionCheck.material - this.labDevices = actionCheck.labDevices - this.requiredActions = actionCheck.requiredActions - this.prohibitiveActions = actionCheck.prohibitiveActions - } + loadActionCheck(actionCheck: ActionCheck) { + this.actionName = actionCheck.actionName + this.applicationDuration = actionCheck.applicationDuration + this.effectDuration = actionCheck.effectDuration + this.personnel = actionCheck.personnel + this.material = actionCheck.material + this.labDevices = actionCheck.labDevices + this.requiredActions = actionCheck.requiredActions + this.prohibitiveActions = actionCheck.prohibitiveActions + } } }) \ No newline at end of file diff --git a/frontend/src/stores/ActionOverview.ts b/frontend/src/stores/ActionOverview.ts index 41ab7e76..f1fbdbf8 100644 --- a/frontend/src/stores/ActionOverview.ts +++ b/frontend/src/stores/ActionOverview.ts @@ -1,4 +1,5 @@ import {defineStore} from 'pinia' +import type {Action, ActionOverview} from "@/sockets/MessageData" export const useActionOverviewStore = defineStore('actionOverview', { state: (): ActionOverview => ({ diff --git a/frontend/src/stores/Availables.ts b/frontend/src/stores/Availables.ts index 778dfec5..03d591fe 100644 --- a/frontend/src/stores/Availables.ts +++ b/frontend/src/stores/Availables.ts @@ -1,4 +1,5 @@ import {defineStore} from 'pinia' +import type {AvailableAction, AvailableMaterial, AvailablePatient, Availables} from "@/sockets/MessageData" export const useAvailablesStore = defineStore('availables', { state: (): Availables => ({ diff --git a/frontend/src/stores/ContinuousVariables.ts b/frontend/src/stores/ContinuousVariables.ts new file mode 100644 index 00000000..46e7cd0f --- /dev/null +++ b/frontend/src/stores/ContinuousVariables.ts @@ -0,0 +1,151 @@ +import {defineStore} from 'pinia' +import {useExerciseStore} from "@/stores/Exercise" +import {watch} from "vue" +import {ContinuousFunctionName} from "@/enums" +import type {ContinuousState, ContinuousStateInternal, ContinuousVariableInternal} from "@/sockets/MessageData" + +let intervalId: number | null = null + +export const useContinuousVariablesStore = defineStore('patientContinuous', { + state: (): ContinuousStateInternal => ({ + timeUntilPhaseChange: Number.NEGATIVE_INFINITY, + continuousVariables: [], + }), + getters: { + getCurrentValueByName: (state) => { + return (variableName: string) => { + const variable = state.continuousVariables.find(v => v.name === variableName) + return variable ? variable.xCurrent : null + } + } + }, + actions: { + loadContinuousVariablesFromJSON(continuousState: ContinuousState) { + this.timeUntilPhaseChange = continuousState.timeUntilPhaseChange + + continuousState.continuousVariables.forEach(variable => { + const existingVariable = this.continuousVariables.find(v => v.name === variable.name) + if (existingVariable) { + existingVariable.xStart = existingVariable.xCurrent + existingVariable.xTarget = variable.target + existingVariable.tDelta = this.timeUntilPhaseChange + existingVariable.function = variable.function + console.log("Continuous Variable overwritten " + existingVariable.name) + } else this.continuousVariables.push({ + name: variable.name, + xStart: variable.current, + xCurrent: variable.current, + xTarget: variable.target, + tDelta: this.timeUntilPhaseChange, + function: variable.function, + }) + }) + + if (useExerciseStore().status == "running") startContinuousLogic() + }, + + startUpdatingContinuousVariables() { + if (intervalId !== null) return + + intervalId = setInterval(() => { + if (this.timeUntilPhaseChange <= 0) { + this.stopUpdatingContinuousVariables() + return + } + this.continuousVariables.forEach(variable => { + variable.xCurrent = this.calculateVariableIncrement(variable) + }) + + this.timeUntilPhaseChange-- + }, 1000) + }, + + calculateVariableIncrement(variable: ContinuousVariableInternal) { + console.log("Time until phase change: " + this.timeUntilPhaseChange) + switch (variable.function) { + case ContinuousFunctionName.LINEAR: + return variable.xCurrent + linear(variable, this.timeUntilPhaseChange) + case ContinuousFunctionName.SIGMOID: + return variable.xCurrent + sigmoid(variable, this.timeUntilPhaseChange) + case ContinuousFunctionName.SIGMOID_DELAYED: + return variable.xCurrent + sigmoidDelayed(variable, this.timeUntilPhaseChange) + case ContinuousFunctionName.INCREMENT: + return variable.xCurrent + 1 + case ContinuousFunctionName.DECREMENT: + return variable.xCurrent - 1 + default: + console.error("Unrecognized function: " + variable.function) + return variable.xCurrent + } + }, + + stopUpdatingContinuousVariables() { + this.timeUntilPhaseChange = 0 + if (intervalId !== null) { + clearInterval(intervalId) + intervalId = null + } + } + } +}) + +export function startContinuousLogic() { + const patientStore = useContinuousVariablesStore() + const exerciseStore = useExerciseStore() + + watch( + () => exerciseStore.status, + (newVal) => { + if (newVal === "running") { + patientStore.startUpdatingContinuousVariables() + } else { + patientStore.stopUpdatingContinuousVariables() + } + }, + {immediate: true} + ) +} + +function linear(variable: ContinuousVariableInternal, timeUntilPhaseChange: number) { + return ((variable.xTarget - variable.xCurrent) / timeUntilPhaseChange) +} + +function sigmoid(variable: ContinuousVariableInternal, timeUntilPhaseChange: number): number { + const steepness = 8 // = the horizontal range that is taken from the original atan function (higher values = steeper) + + const t = variable.tDelta - timeUntilPhaseChange + const tMid = variable.tDelta / 2 + const tStretchFactor = Math.pow(steepness, 2) / Math.pow(variable.tDelta, 2) + const tStretchCorrector = steepness / variable.tDelta + + const xDelta = variable.xTarget - variable.xStart + const xStretcher = xDelta / (2 * Math.atan(steepness / 2)) + + const atanDerivative = (1 / (Math.pow(t - tMid, 2) * tStretchFactor + 1)) + + return (atanDerivative * xStretcher * tStretchCorrector) +} + +function sigmoidDelayed(variable: ContinuousVariableInternal, timeUntilPhaseChange: number): number { + const steepness = 8 // = the horizontal range that is taken from the original atan function (higher values = steeper) + + const t = variable.tDelta - timeUntilPhaseChange + const tMid = variable.tDelta / 2 + const tShiftFrac = 3 + const t0Shifted = variable.tDelta / tShiftFrac // Time when sigmoid starts (shifted by one tShiftFrac) + const tDeltaShifted = variable.tDelta - t0Shifted + const tShiftedMid = tMid + (variable.tDelta - tMid) / tShiftFrac // Shifted midpoint + + const tStretchFactor = Math.pow(steepness, 2) / Math.pow(tDeltaShifted, 2) + const tStretchCorrector = steepness / tDeltaShifted + + const xDelta = variable.xTarget - variable.xStart + const xStretcher = xDelta / (2 * Math.atan(steepness / 2)) + + const atanDerivative = (1 / (Math.pow(t - tShiftedMid, 2) * tStretchFactor + 1)) + + if (t < t0Shifted) { + console.log("straight") + return 0 + } else return atanDerivative * xStretcher * tStretchCorrector +} \ No newline at end of file diff --git a/frontend/src/stores/Exercise.ts b/frontend/src/stores/Exercise.ts index 5b04ce1e..5a2b1509 100644 --- a/frontend/src/stores/Exercise.ts +++ b/frontend/src/stores/Exercise.ts @@ -1,4 +1,5 @@ import {defineStore} from 'pinia' +import type {Area, Exercise, Material, Patient, Personnel} from "@/sockets/MessageData" export const useExerciseStore = defineStore('exercise', { state: (): Exercise => ({ diff --git a/frontend/src/stores/Log.ts b/frontend/src/stores/Log.ts index 21a721f9..34c56146 100644 --- a/frontend/src/stores/Log.ts +++ b/frontend/src/stores/Log.ts @@ -1,4 +1,5 @@ import {defineStore} from 'pinia' +import type {Log, LogEntry} from "@/sockets/MessageData" export const useLogStore = defineStore('log', { state: (): Log => ({ @@ -21,7 +22,7 @@ export const useLogStore = defineStore('log', { return new Date(b.logTime).getTime() - new Date(a.logTime).getTime() }) }, - addLogEntries(logEntries: LogEntry[]) { + addLogEntries(logEntries: LogEntry[]) { this.log.push(...logEntries) this.sortLogByLogTime() } diff --git a/frontend/src/stores/Patient.ts b/frontend/src/stores/Patient.ts index 52eb516b..390a5c15 100644 --- a/frontend/src/stores/Patient.ts +++ b/frontend/src/stores/Patient.ts @@ -1,6 +1,7 @@ import {defineStore} from "pinia" import {useExerciseStore} from "@/stores/Exercise" import {useAvailablesStore} from "./Availables" +import type {State} from "@/sockets/MessageData" export const usePatientStore = defineStore('patient', { state: () => ({ diff --git a/frontend/src/stores/ResourceAssignments.ts b/frontend/src/stores/ResourceAssignments.ts index fe07abb0..884e3226 100644 --- a/frontend/src/stores/ResourceAssignments.ts +++ b/frontend/src/stores/ResourceAssignments.ts @@ -1,22 +1,23 @@ import {defineStore} from 'pinia' +import type {ResourceAssignment, ResourceAssignments} from "@/sockets/MessageData" export const useResourceAssignmentsStore = defineStore('resourceAssignments', { state: (): ResourceAssignments => ({ - resourceAssignments: [] + resourceAssignments: [] }), - getters: { - getResourceAssignmentsOfArea: (state) => { - return (areaId: number) : ResourceAssignment | null => { - let foundResourceAssignment = null - state.resourceAssignments.forEach((resourceAssignment) => { - if (resourceAssignment.areaId === areaId) { - foundResourceAssignment = resourceAssignment - } - }) - return foundResourceAssignment - } - } - }, + getters: { + getResourceAssignmentsOfArea: (state) => { + return (areaId: number): ResourceAssignment | null => { + let foundResourceAssignment = null + state.resourceAssignments.forEach((resourceAssignment) => { + if (resourceAssignment.areaId === areaId) { + foundResourceAssignment = resourceAssignment + } + }) + return foundResourceAssignment + } + } + }, actions: { setResourceAssignments(json: ResourceAssignment[]) { this.resourceAssignments = json diff --git a/frontend/src/stores/VisibleInjuries.ts b/frontend/src/stores/VisibleInjuries.ts index 431a0776..fa3fe207 100644 --- a/frontend/src/stores/VisibleInjuries.ts +++ b/frontend/src/stores/VisibleInjuries.ts @@ -1,19 +1,20 @@ -import { addInjury } from '@/components/widgets/PatientModel.vue' +import {addInjury} from '@/components/widgets/PatientModel.vue' import {defineStore} from 'pinia' +import type {Injury, VisibleInjuries} from "@/sockets/MessageData" export const useVisibleInjuriesStore = defineStore('visibleInjuries', { state: (): VisibleInjuries => ({ injuries: [] }), - actions: { - loadVisibleInjuries(json: Injury[]) { - this.injuries = json - this.showVisibleInjuries() - }, - showVisibleInjuries() { - for (const injury of this.injuries) { - addInjury(injury.injuryType, injury.position) - } - } - } + actions: { + loadVisibleInjuries(json: Injury[]) { + this.injuries = json + this.showVisibleInjuries() + }, + showVisibleInjuries() { + for (const injury of this.injuries) { + addInjury(injury.injuryType, injury.position) + } + } + } }) \ No newline at end of file