-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoximiterGenerator.py
114 lines (98 loc) · 3.46 KB
/
oximiterGenerator.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
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
import fhirclient.models.quantity as q
from datetime import datetime
class OximiterGenerator:
def __init__(self, p_id, n_id, val):
self.p_id = p_id
self.n_id = n_id
self.val = val
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.device = self.device()
self.__model.referenceRange = self.ref_range()
self.__model.interpretation = self.interpretation()
self.__model.valueQuantity = self.value()
return self.__model
def meta(self):
return mt.Meta({"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 value(self):
return q.Quantity({
"value": float(self.val),
"unit": "%",
"system": "http://unitsofmeasure.org",
"code": "%"
})
def ref_range(self):
low = {"low": {
"value": float(self.val),
"unit": "%",
"system": "http://unitsofmeasure.org",
"code": "%"
}}
high = {"high": {
"value": float(self.val),
"unit": "%",
"system": "http://unitsofmeasure.org",
"code": "%"
}}
return [ob.ObservationReferenceRange(low),
ob.ObservationReferenceRange(high)]
def interpretation(self):
return cc.CodeableConcept({
"coding": [
{
"system": "http://hl7.org/fhir/v2/0078",
"code": "N",
"display": "Normal"
}
],
"text": "Normal (applies to non-numeric results)"
})
def device(self):
return ref.FHIRReference({"reference": "DeviceMetric/Nonin"})
def init_value(self):
return {
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "59408-5",
"display": "Oxygen saturation in Arterial blood by Pulse oximetry"
},
{
"system": "urn:iso:std:iso:11073:10101",
"code": "150456",
"display": "MDC_PULS_OXIM_SAT_O2"
}
]
},
"status": "final"
}