Skip to content

Commit

Permalink
#330 frontend: fix interface exports to enable enum exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolkenfarmer committed Sep 16, 2024
1 parent 2acedd0 commit c855937
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 97 deletions.
12 changes: 12 additions & 0 deletions frontend/src/enums.ts
Original file line number Diff line number Diff line change
@@ -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",
}
70 changes: 31 additions & 39 deletions frontend/src/sockets/MessageData.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -32,64 +33,55 @@ interface MessageData {
timeUntilBack: number
}

interface ContinuousState {
export interface ContinuousState {
timeUntilPhaseChange: number
continuousVariables: ContinuousVariable[]
}

interface ContinuousVariable {
export interface ContinuousVariable {
name: ContinuousVariableName
current: number
target: number
function: ContinuousFunctionName
}

enum ContinuousVariableName {
SPO2 = "SpO2",
HEART_RATE = "BPM"
}

enum ContinuousFunctionName {
LINEAR = "linear",
INCREMENT = "increment",
DECREMENT = "decrement",
}


interface Exercise {
export interface Exercise {
exerciseId: string
status: string
speed: number
areas: Area[]
}

interface Area {
export interface Area {
areaId: number
areaName: string
patients: Patient[]
personnel: Personnel[]
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
Expand All @@ -100,18 +92,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
Expand All @@ -124,36 +116,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
Expand All @@ -163,12 +155,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
Expand All @@ -177,17 +169,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
Expand All @@ -198,31 +190,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
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/sockets/SocketPatient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ 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 {
Expand Down
29 changes: 15 additions & 14 deletions frontend/src/sockets/SocketTrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}' +
']}'
},
{
Expand Down
35 changes: 18 additions & 17 deletions frontend/src/stores/ActionCheck.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
})
1 change: 1 addition & 0 deletions frontend/src/stores/ActionOverview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defineStore} from 'pinia'
import type {Action, ActionOverview} from "@/sockets/MessageData"

export const useActionOverviewStore = defineStore('actionOverview', {
state: (): ActionOverview => ({
Expand Down
1 change: 1 addition & 0 deletions frontend/src/stores/Availables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defineStore} from 'pinia'
import type {AvailableAction, AvailableMaterial, AvailablePatient, Availables} from "@/sockets/MessageData"

export const useAvailablesStore = defineStore('availables', {
state: (): Availables => ({
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/stores/ContinuousVariables.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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

Expand Down
1 change: 1 addition & 0 deletions frontend/src/stores/Exercise.ts
Original file line number Diff line number Diff line change
@@ -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 => ({
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/stores/Log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defineStore} from 'pinia'
import type {Log, LogEntry} from "@/sockets/MessageData"

export const useLogStore = defineStore('log', {
state: (): Log => ({
Expand All @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/stores/Patient.ts
Original file line number Diff line number Diff line change
@@ -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: () => ({
Expand Down
Loading

0 comments on commit c855937

Please sign in to comment.