Skip to content

Commit cdb4548

Browse files
committed
Major tutorial update
1 parent 534f106 commit cdb4548

File tree

5 files changed

+80
-36
lines changed

5 files changed

+80
-36
lines changed

example-smart-app/index.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ <h2>Patient Resource</h2>
4040
<h2>Observation Resource</h2>
4141
<table>
4242
<tr>
43+
<th>Lymph:</th>
44+
<td id='lymph'></td>
45+
</tr>
46+
<!-- <tr>
4347
<th>Height:</th>
4448
<td id='height'></td>
4549
</tr>
@@ -59,7 +63,7 @@ <h2>Observation Resource</h2>
5963
<tr>
6064
<th>HDL:</th>
6165
<td id='hdl'></td>
62-
</tr>
66+
</tr> -->
6367
</table>
6468
</div>
6569

example-smart-app/launch-standalone.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<script>
1616
FHIR.oauth2.authorize({
17-
'client_id': 'CLIENT_ID_HERE',
17+
'client_id': '<stand-alone-launch-client-id>',
1818
'scope': 'patient/Patient.read patient/Observation.read launch/patient online_access openid profile'
1919
});
2020
</script>

example-smart-app/lib/js/fhir-client-v0.1.12.js

+5
Original file line numberDiff line numberDiff line change
@@ -17367,6 +17367,9 @@ BBClient.authorize = function(params, errback){
1736717367
}
1736817368

1736917369
var launch = urlParam("launch");
17370+
17371+
console.log("launch identifier: " + launch);
17372+
1737017373
if (launch){
1737117374
if (!params.client.scope.match(/launch/)){
1737217375
params.client.scope += " launch";
@@ -17381,6 +17384,8 @@ BBClient.authorize = function(params, errback){
1738117384
}
1738217385
}
1738317386

17387+
console.log("iss: " + server)
17388+
1738417389
if (urlParam("patientId")){
1738517390
params.fake_token_response = params.fake_token_response || {};
1738617391
params.fake_token_response.patient = urlParam("patientId");

example-smart-app/src/js/example-smart-app.js

+69-34
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,81 @@
1111
if (smart.hasOwnProperty('patient')) {
1212
var patient = smart.patient;
1313
var pt = patient.read();
14+
15+
// var obv = smart.patient.api.fetchAll({
16+
// type: 'Observation',
17+
// query: {
18+
// code: {
19+
// $or: ['http://loinc.org|8302-2', 'http://loinc.org|8462-4',
20+
// 'http://loinc.org|8480-6', 'http://loinc.org|2085-9',
21+
// 'http://loinc.org|2089-1', 'http://loinc.org|55284-4']
22+
// }
23+
// }
24+
// });
25+
1426
var obv = smart.patient.api.fetchAll({
15-
type: 'Observation',
16-
query: {
17-
code: {
18-
$or: ['http://loinc.org|8302-2', 'http://loinc.org|8462-4',
19-
'http://loinc.org|8480-6', 'http://loinc.org|2085-9',
20-
'http://loinc.org|2089-1', 'http://loinc.org|55284-4']
21-
}
22-
}
23-
});
27+
type: 'Observation',
28+
query: {
29+
code: {
30+
$or: ['http://loinc.org|26478-8', 'http://loinc.org|2345-7']
31+
}
32+
}
33+
});
34+
35+
console.log('patient:');
36+
console.log(patient)
2437

2538
$.when(pt, obv).fail(onError);
2639

2740
$.when(pt, obv).done(function(patient, obv) {
2841
var byCodes = smart.byCodes(obv, 'code');
42+
console.log("byCodes:");
43+
console.log(byCodes('26478-8'));
44+
console.log(byCodes('2345-7'));
45+
2946
var gender = patient.gender;
3047

3148
var fname = '';
3249
var lname = '';
3350

3451
if (typeof patient.name[0] !== 'undefined') {
3552
fname = patient.name[0].given.join(' ');
36-
lname = patient.name[0].family.join(' ');
53+
lname = patient.name[0].family;
3754
}
3855

39-
var height = byCodes('8302-2');
40-
var systolicbp = getBloodPressureValue(byCodes('55284-4'),'8480-6');
41-
var diastolicbp = getBloodPressureValue(byCodes('55284-4'),'8462-4');
42-
var hdl = byCodes('2085-9');
43-
var ldl = byCodes('2089-1');
56+
// Observations
57+
lymph = byCodes('26478-8');
58+
// Cerner SoF Tutorial Observations
59+
// var height = byCodes('8302-2');
60+
// var systolicbp = getBloodPressureValue(byCodes('55284-4'),'8480-6');
61+
// var diastolicbp = getBloodPressureValue(byCodes('55284-4'),'8462-4');
62+
// var hdl = byCodes('2085-9');
63+
// var ldl = byCodes('2089-1');
64+
4465

4566
var p = defaultPatient();
4667
p.birthdate = patient.birthDate;
4768
p.gender = gender;
4869
p.fname = fname;
4970
p.lname = lname;
50-
p.height = getQuantityValueAndUnit(height[0]);
71+
p.lymph = getQuantityValueAndUnit(lymph[0]);
5172

52-
if (typeof systolicbp != 'undefined') {
53-
p.systolicbp = systolicbp;
54-
}
5573

56-
if (typeof diastolicbp != 'undefined') {
57-
p.diastolicbp = diastolicbp;
58-
}
74+
// Cerner SoF Tutorial Observations
75+
// p.height = getQuantityValueAndUnit(height[0]);
5976

60-
p.hdl = getQuantityValueAndUnit(hdl[0]);
61-
p.ldl = getQuantityValueAndUnit(ldl[0]);
77+
// if (typeof systolicbp != 'undefined') {
78+
// p.systolicbp = systolicbp;
79+
// }
6280

81+
// if (typeof diastolicbp != 'undefined') {
82+
// p.diastolicbp = diastolicbp;
83+
// }
84+
85+
// p.hdl = getQuantityValueAndUnit(hdl[0]);
86+
// p.ldl = getQuantityValueAndUnit(ldl[0]);
87+
console.log('p:');
88+
console.log(p);
6389
ret.resolve(p);
6490
});
6591
} else {
@@ -78,14 +104,19 @@
78104
lname: {value: ''},
79105
gender: {value: ''},
80106
birthdate: {value: ''},
81-
height: {value: ''},
82-
systolicbp: {value: ''},
83-
diastolicbp: {value: ''},
84-
ldl: {value: ''},
85-
hdl: {value: ''},
107+
lymph: {value: ''}
108+
109+
// Cerner SoF Tutorial Observations
110+
// height: {value: ''},
111+
// systolicbp: {value: ''},
112+
// diastolicbp: {value: ''},
113+
// ldl: {value: ''},
114+
// hdl: {value: ''},
86115
};
87116
}
88117

118+
// Helper Function
119+
89120
function getBloodPressureValue(BPObservations, typeOfPressure) {
90121
var formattedBPObservations = [];
91122
BPObservations.forEach(function(observation){
@@ -121,11 +152,15 @@
121152
$('#lname').html(p.lname);
122153
$('#gender').html(p.gender);
123154
$('#birthdate').html(p.birthdate);
124-
$('#height').html(p.height);
125-
$('#systolicbp').html(p.systolicbp);
126-
$('#diastolicbp').html(p.diastolicbp);
127-
$('#ldl').html(p.ldl);
128-
$('#hdl').html(p.hdl);
155+
$('#lymph').html(p.lymph);
156+
157+
// Cerner SoF Tutorial Observations
158+
159+
// $('#height').html(p.height);
160+
// $('#systolicbp').html(p.systolicbp);
161+
// $('#diastolicbp').html(p.diastolicbp);
162+
// $('#ldl').html(p.ldl);
163+
// $('#hdl').html(p.hdl);
129164
};
130165

131166
})(window);

images/smart-docs-ehr-launch.png

32.1 KB
Loading

0 commit comments

Comments
 (0)