-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheartRateGenerator.py
73 lines (62 loc) · 2.17 KB
/
heartRateGenerator.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
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 HeartRateGenerator:
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.device = self.device()
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://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
],
"text": "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 value(self):
return q.Quantity({
"value": float(self.val),
"unit": "beats/minute",
"system": "http://unitsofmeasure.org",
"code": "/min"
})
def device(self):
return ref.FHIRReference({"reference": "DeviceMetric/manual"})
def init_value(self):
return {
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8867-4",
"display": "Heart rate"
}
]
},
"status": "final"
}