Skip to content

Commit

Permalink
correct patient states import from old patients
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaRiewesell committed Sep 9, 2024
1 parent 8dd42b9 commit 5f5fa5b
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import json
import re

from django.conf import settings
from django.core.management.base import BaseCommand
Expand Down Expand Up @@ -53,13 +54,7 @@ def import_from_patient_states_model(self):

states = []
for patient_state in patient_states:
state = {
"id": "State-" + str(patient_state.state_id),
"is_dead": patient_state.is_dead,
"vital_signs": patient_state.vital_signs,
"examination_codes": patient_state.examination_codes,
# "special_events": patient_state.special_events,
}
state = self.import_patient_state(patient_state)
states.append(state)

transitions_to_look_for = []
Expand Down Expand Up @@ -140,6 +135,72 @@ def import_patient_info(self, patient_info):
"pretreatment": patient_info.pretreatment,
"op": patient_info.op,
}

def import_patient_state(self, patient_state):
breathing_field = patient_state.vital_signs.get("Breathing")
breathingRate = 0
if breathing_field:
match = re.search(r"Atemfreq: (\d+) /min", breathing_field)
if match:
breathingRate = int(match.group(1))
oxygenSaturation = 0
if breathing_field:
match = re.search(r"SpO2: (\d+) %", breathing_field)
if match:
oxygenSaturation = int(match.group(1))
breathing_parts = breathing_field.split("\n")
breathing = breathing_parts[-2]
breathingSounds = breathing_parts[-1]

circulation_field = patient_state.vital_signs.get("Circulation")
hearthRate = 0
if circulation_field:
match = re.search(r"Herzfreq: (\d+) /min", circulation_field)
if match:
hearthRate = int(match.group(1))
circulation_parts = circulation_field.split("\n") if circulation_field else []
pulsePalpable = circulation_parts[-2]
rivaRocci = circulation_parts[-1].split(": ")[1] if circulation_parts else ""

skin_field = patient_state.vital_signs.get("Skin")
skin_parts = skin_field.split("\n") if skin_field else ['','']
skinFinding = skin_parts[-2:-1]
skinDiscoloration = skin_parts[-1:]

return {
"id": "State-" + str(patient_state.state_id),
"isDead": patient_state.is_dead,
"airway": patient_state.vital_signs.get("Airway"),
"breathingRate": breathingRate,
"oxygenSaturation": oxygenSaturation,
"breathing": breathing,
"breathingSounds": breathingSounds,
"heartRate": hearthRate,
"pulsePalpable": pulsePalpable,
"rivaRocci": rivaRocci,
"consciousness": patient_state.vital_signs.get("Bewusstsein"),
"pupils": patient_state.vital_signs.get("Pupillen"),
"psyche": patient_state.vital_signs.get("Psyche"),
"skinFinding": skinFinding,
"skinDiscoloration": skinDiscoloration,
"examination_codes": patient_state.examination_codes,
"bgaOxy": patient_state.examination_codes.get("BGA-Oxy"),
"bgaSbh": patient_state.examination_codes.get("BGA-SBH"),
"hb": patient_state.examination_codes.get("Hb"),
"bz": patient_state.examination_codes.get("BZ"),
"clotting": patient_state.examination_codes.get("Gerinnung"),
"liver": patient_state.examination_codes.get("Leber"),
"kidney": patient_state.examination_codes.get("Niere"),
"infarct": patient_state.examination_codes.get("Infarkt"),
"lactate": patient_state.examination_codes.get("Lactat"),
"extremities": patient_state.examination_codes.get("Rö-Extremitäten"),
"thorax": patient_state.examination_codes.get("Rö-Thorax"),
"trauma": patient_state.examination_codes.get("Trauma-CT"),
"ultraschall": patient_state.examination_codes.get("Ultraschall"),
"ekg": patient_state.examination_codes.get("EKG"),
"zvd": patient_state.examination_codes.get("ZVD"),
# "special_events": patient_state.special_events, # not implemented
}

def import_transition(self, transition, output_nodes):
transition_flow = []
Expand Down
25 changes: 19 additions & 6 deletions frontend/src/components/widgets/PatientStateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
<template>
<!-- eslint-disable max-len -->
<!-- eslint-disable vue/max-len -->
<h1>Zustand {{ currentState?.id }}</h1>
<h1>{{ currentState?.id }}</h1>
<FormKit
id="patientStateForm"
v-slot="{ disabled }"
type="form"
:actions="false"
>
<FormKit
id="isDead"
name="isDead"
type="checkbox"
label="Patient ist verstorben"
/>

<h1>Airway</h1>
<FormKit
id="airway"
name="airway"
Expand All @@ -41,7 +43,7 @@
id="breathingRate"
name="breathingRate"
type="number"
label="Atemfrequenz"
label="Atemfrequenz (/min)"
placeholder="Atemzüge pro Minute"
validation="required|min:0"
/>
Expand All @@ -50,11 +52,12 @@
id="oxygenSaturation"
name="oxygenSaturation"
type="number"
label="Sauerstoffsättigung"
label="Sauerstoffsättigung (%)"
placeholder="SpO2 in %"
validation="required|min:0"
/>

<h1>Breathing</h1>
<FormKit
id="breathing"
name="breathing"
Expand All @@ -80,11 +83,12 @@
:options="['normales AG hörbar', 'sehr leises AG hörbar', 'nur einseitiges AG hörbar', 'kein AG hörbar']"
/>

<h1>Circulation</h1>
<FormKit
id="heartRate"
name="heartRate"
type="number"
label="Herzfrequenz"
label="Herzfrequenz (/min)"
placeholder="Herzschläge pro Minute"
validation="required|min:0"
/>
Expand All @@ -107,6 +111,7 @@
validation="required"
/>

<h1>Weiteres</h1>
<FormKit
id="consciousness"
name="consciousness"
Expand Down Expand Up @@ -162,6 +167,7 @@
:options="['rosig', 'blass', 'grau', 'grau/marmoriert', 'marmoriert', 'sichtbare Zyanose', 'leichte Zyanose', 'schwere Zyanose']"
/>

<h1>Befunde</h1>
<FormKit
id="bgaOxy"
name="bgaOxy"
Expand Down Expand Up @@ -587,4 +593,11 @@
]"
/>
</FormKit>
</template>
</template>

<style scoped>
.highlight {
background-color: yellow;
transition: background-color 2s ease-out;
}
</style>

0 comments on commit 5f5fa5b

Please sign in to comment.