-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavpuGenerator.py
128 lines (112 loc) · 3.82 KB
/
avpuGenerator.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
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
import fhirclient.models.identifier as idn
from datetime import datetime
class AVPUGenerator:
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.valueCodeableConcept = self.value_codeable_concept()
self.__model.subject = self.subject()
self.__model.effectiveDateTime = self.effective_date_time()
self.__model.performer = self.performer()
self.__model.device = self.device()
self.__model.code = self.code()
return self.__model
def identifier(self):
return idn.Identifier(
{
"use": "official",
"system": "http://hl7.org/fhir/sid/us-ssn",
"value": "xxxxx"
}
)
def value_codeable_concept(self):
return cc.CodeableConcept({
"coding": [self.mapping(self.val.lower())]
})
def meta(self):
return mt.Meta({"profile":
["http://hl7.org/fhir/StructureDefinition/vitalsigns"]})
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 device(self):
return ref.FHIRReference({"reference": "DeviceMetric/example"})
def code(self):
return cc.CodeableConcept({
"coding": [
{
"system": "https://r.details.loinc.org/LOINC",
"code": "67775-7",
"display": "Level of responsiveness"
}
],
"text": "Level of responsiveness"
})
def category(self):
return cc.CodeableConcept({
"coding": [
{
"system": "http://hl7.org/fhir/observation-category",
"code": "activity",
"display": "Activity"
}
],
"text": "Activity"
})
def init_value(self):
return {
"code": {
"coding": [
{
"system": "https://r.details.loinc.org/LOINC",
"code": "67775-7",
"display": "Level of responsiveness"
}
]
},
"status": "final"
}
def mapping(self, key):
return {
"alert": {
"system": "http://snomed.info/sct",
"code": "3326001",
"display": "Alert"
},
"verbal": {
"system": "http://snomed.nfo/sct",
"code": "3326003",
"display": "Verbal"
},
"pain": {
"system": "http://snomed.info/sct",
"code": "3326005",
"display": "Painful"
},
"unresponsive": {
"system": "http://snomed.info/sct",
"code": "3326007",
"display": "Unresponsive"
},
"uncheck": {
"system": "http://snomed.info/sct",
"code": "unknow",
"display": "Uncheck"
}
}[key]