-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObservation.cls
132 lines (115 loc) · 3.81 KB
/
Observation.cls
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
Class sdf.data.Observation Extends (%Persistent, %JSON.Adaptor, sdf.fhirserver.FHIRFacade)
{
Property Id As %String(%JSONINCLUDE = "OUTPUTONLY") [ Calculated ];
Property Identifier As %String;
Property Code As %String;
Property Status As %String;
Property Units As %String;
Property ValueNM As %Numeric;
Property ValueST As %String;
Property TimeStamp As %TimeStamp;
/// referenced Patient
Relationship Patient As Patient(%JSONREFERENCE = "ID") [ Cardinality = one, Inverse = Observations ];
Index PatientIdx On Patient;
Method IdGet() As %String
{
quit ..%Id()
}
/// Transform FHIR Facade to FHIR Resource
Method FacadeToResource() As %DynamicObject
{
// do not include RiskLevel observations
if ..Code="RiskLevel" {
$$$ThrowFHIR($$$HSFHIRErrResourceNotFound, pResourceType, pResourceId, $$$OutcomeNotFound)
}
set resource = {
"resourceType": "Observation",
"id": (..Id),
"status": "final",
"code": {
"coding": [
]
},
"subject": {
"reference": ("Patient/"_..Patient.Id)
},
"effectiveDateTime": ($tr(..TimeStamp, " ", "T")),
"valueQuantity": {
}
}
if ..Code="BodyTemp" {
set resource.code.coding."0" = { "system": "http://loinc.org", "code": "8310-5", "display": "Body temperature" }
set resource.valueQuantity.unit = "C"
set resource.valueQuantity.system = "http://unitsofmeasure.org"
set resource.valueQuantity.code = "Cel"
do resource.valueQuantity.%Set("value", ..ValueNM, "number")
}
elseif ..Code="HeartRate" {
set resource.code.coding."0" = { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" }
set resource.valueQuantity.unit = "beats/minute"
set resource.valueQuantity.system = "http://unitsofmeasure.org"
set resource.valueQuantity.code = "/min"
do resource.valueQuantity.%Set("value", ..ValueNM, "number")
}
elseif ..Code="DiastolicBP" {
set resource.code.coding."0" = { "system": "http://loinc.org", "code": "8462-4", "display": "Diastolic blood pressure" }
set resource.valueQuantity.unit = "mmHg"
set resource.valueQuantity.system = "http://unitsofmeasure.org"
set resource.valueQuantity.code = "mm[Hg]"
do resource.valueQuantity.%Set("value", ..ValueNM, "number")
}
elseif ..Code="SystolicBP" {
set resource.code.coding."0" = { "system": "http://loinc.org", "code": "8480-6", "display": "Systolic blood pressure" }
set resource.valueQuantity.unit = "mmHg"
set resource.valueQuantity.system = "http://unitsofmeasure.org"
set resource.valueQuantity.code = "mm[Hg]"
do resource.valueQuantity.%Set("value", ..ValueNM, "number")
}
elseif ..Code="BloodGlucose" {
set resource.code.coding."0" = { "system": "http://loinc.org", "code": "15074-8", "display": "Glucose [Moles/volume] in Blood" }
set resource.valueQuantity.unit = "mmol/l"
set resource.valueQuantity.system = "http://unitsofmeasure.org"
set resource.valueQuantity.code = "mmol/l"
do resource.valueQuantity.%Set("value", ..ValueNM, "number")
}
return resource
}
Storage Default
{
<Data name="ObservationDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Identifier</Value>
</Value>
<Value name="3">
<Value>Code</Value>
</Value>
<Value name="4">
<Value>Status</Value>
</Value>
<Value name="5">
<Value>Units</Value>
</Value>
<Value name="6">
<Value>ValueNM</Value>
</Value>
<Value name="7">
<Value>ValueST</Value>
</Value>
<Value name="8">
<Value>TimeStamp</Value>
</Value>
<Value name="9">
<Value>Patient</Value>
</Value>
</Data>
<DataLocation>^sdf.data.ObservationD</DataLocation>
<DefaultData>ObservationDefaultData</DefaultData>
<IdLocation>^sdf.data.ObservationD</IdLocation>
<IndexLocation>^sdf.data.ObservationI</IndexLocation>
<StreamLocation>^sdf.data.ObservationS</StreamLocation>
<Type>%Storage.Persistent</Type>
}
}