-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (50 loc) · 2.06 KB
/
index.html
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
<!-- index.html -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- FHIR Library -->
<script src="https://combinatronics.com/smart-on-fhir/client-js/master/dist/build/fhir-client.js"></script>
<script src="https://combinatronics.com/smart-on-fhir/client-js/master/dist/build/fhir-client.min.js"></script>
<!-- Helper Scripts -->
<script src="./js/helper.js"></script>
<!-- JSON Viewer Scripts -->
<script src="json-viewer/jquery.json-viewer.js"></script>
<link href="json-viewer/jquery.json-viewer.css" type="text/css" rel="stylesheet">
<title>Smart-App</title>
</head>
<body>
<div class="cell full">
<h4>Patient Medications</h4>
<pre id="output">Loading...</pre>
</div>
<script type="text/javascript">
var render = createRenderer("output")
FHIR.oauth2.ready()
.then(function (client) {
client.request("MedicationStatement?patient=19", {
resolveReferences: ["medicationReference"],
graph: true
})
.then(function (data) {
if (!data.entry || !data.entry.length) {
throw new Error("No medications found for the selected patient");
}
return data.entry;
})
.then(function (entries) {
return entries.map(function (item) {
return getMedicationName(
client.getPath(item, "resource.medicationCodeableConcept.coding") ||
client.getPath(item, "resource.medicationReference.code.coding")
);
});
})
.then(render)
.then(console.log)
.catch(console.error)
})
</script>
</body>
</html>