-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
55 lines (43 loc) · 2.11 KB
/
build.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
# -*- coding: utf-8 -*-
import json
import os.path
from .oximiterGenerator import OximiterGenerator as ox
from .heartRateGenerator import HeartRateGenerator as hr
from .bloodPressureGenerator import BloodPressureGenerator as bp
from .glucoseGenerator import GlucoseGenerator as gl
from .respiratoryGenerator import RespiratoryGenerator as rs
from .temperatureGenerator import TemperatureGenerator as tm
from .avpuGenerator import AVPUGenerator as avpu
def build(values):
val = values
if type(values) is bytes:
val = json.loads(values.decode("ASCII"))
rpath = os.path.abspath(os.path.dirname(__file__))
file = os.path.join(rpath, 'templates/bundle_upload.json')
with open(file) as f:
data = json.load(f)
arrs = []
if 'oximiter' in val:
arrs.append({"resource": ox(val['patientId'], val['practtionerId'],
val['oximiter']).get_result().as_json()})
if 'heartRate' in val:
arrs.append({"resource": hr(val['patientId'], val['practtionerId'],
val['heartRate']).get_result().as_json()})
if 'glucose' in val:
arrs.append({"resource": gl(val['patientId'], val['practtionerId'],
val['glucose']).get_result().as_json()})
if 'bloodPressure' in val:
arrs.append({"resource": bp(val['patientId'], val['practtionerId'],
val['bloodPressure']['normal'],
val['bloodPressure']['low']).get_result().as_json()})
if 'temperature' in val:
arrs.append({"resource": tm(val['patientId'], val['practtionerId'],
val['temperature']).get_result().as_json()})
if 'respiratory' in val:
arrs.append({"resource": rs(val['patientId'], val['practtionerId'],
val['respiratory']).get_result().as_json()})
if 'avpu' in val:
arrs.append({"resource": avpu(val['patientId'], val['practtionerId'],
val['avpu']).get_result().as_json()})
data['entry'] = arrs
return data