-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloodPressureGenerator.py
136 lines (117 loc) · 4.21 KB
/
bloodPressureGenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import fhirclient.models.observation as ob
import fhirclient.models.meta as mt
import fhirclient.models.codeableconcept as cc
import fhirclient.models.fhirreference as ref
import fhirclient.models.fhirdate as fd
import fhirclient.models.resource as rs
from datetime import datetime
class BloodPressureGenerator:
def __init__(self, p_id, n_id, normal, low):
self.p_id = p_id
self.n_id = n_id
self.normal = normal
self.low = low
def get_result(self):
self.__model = ob.Observation(self.init_value())
self.__model.meta = self.meta()
self.__model.category = self.category()
self.__model.subject = self.subject()
self.__model.effectiveDateTime = self.effective_date_time()
self.__model.performer = self.performer()
self.__model.component = self.component()
self.__model.device = self.device()
return self.__model
def meta(self):
return mt.Meta({"profile":
["http://hl7.org/fhir/StructureDefinition/vitalsigns"]})
def profile(self):
return {"profile": ["http://hl7.org/fhir/StructureDefinition/vitalsigns"]}
def category(self):
return [cc.CodeableConcept({
"coding": [{
"system": "http://hl7.org/fhir/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}]
})]
def subject(self):
return ref.FHIRReference({"reference": "Patient/{}".format(self.p_id)})
def effective_date_time(self):
return fd.FHIRDate(str(datetime.now()))
def performer(self):
return [ref.FHIRReference({"reference":
"Practitioner/{}".format(self.n_id)})]
def component(self):
interpre_low = cc.CodeableConcept({
"coding": [{
"system": "http://hl7.org/fhir/v2/0078",
"code": "L",
"display": "low"
}],
"text": "Below low normal"
})
interpre_normal = cc.CodeableConcept({
"coding": [{
"system": "http://hl7.org/fhir/v2/0078",
"code": "N",
"display": "normal"
}],
"text": "Normal"
})
code_normal = cc.CodeableConcept({
"coding": [{
"system": "http://loinc.org",
"code": "8480-6",
"display": "Systolic blood pressure"
}, {
"system": "http://snomed.info/sct",
"code": "271649006",
"display": "Systolic blood pressure"
}, {
"system": "http://acme.org/devices/clinical-codes",
"code": "bp-s",
"display": "Systolic Blood pressure"
}]
})
code_low = cc.CodeableConcept({
"coding": [{
"system": "http://loinc.org",
"code": "8462-4",
"display": "Diastolic blood pressure"
}]
})
v1 = ob.ObservationComponent({
"valueQuantity": {
"value": float(self.normal),
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
},
"code": code_normal.as_json(),
"interpretation": interpre_normal.as_json()
})
v2 = ob.ObservationComponent({
"valueQuantity": {
"value": float(self.low),
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
},
"code": code_low.as_json(),
"interpretation": interpre_low.as_json()
})
return [v1, v2]
def device(self):
return ref.FHIRReference({"reference": "DeviceMetric/manual"})
def init_value(self):
return {
"code": {
"coding": [{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Bood pressure panel with all children optional"
}],
"text": "Blood pressure systolic & diastolic"
},
"status": "final"
}