-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcerner-patient-index.html
119 lines (83 loc) · 3.84 KB
/
cerner-patient-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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Cerner Patient App</title>
<!-- import fhir-client library-->
<script src="./fhir-client.js"></script>
<link rel="stylesheet" type="text/css" href="./app.css" />
</head>
<body>
<div class="wrapper">
<div class="header-section1">
<h1>Cerner Patient App</h1>
</div>
<div class="header-section2">
<h2 id="patient_header"> Patient Details</h2>
<div class="row">
<div class="col3">
<div>Patient: <span id="patientS"></span></div>
<div>Ethnicity: <span id="ethnicityS"></span></div>
</div>
<div class="col3">
<div>CID: <span id="cidS"></span></div>
<div>Race: <span id="raceS"></span></div>
</div>
<div class="col3">
<div>DOB: <span id="dobS"></span></div>
<div>Address: <span id="addressS"></span></div>
</div>
<div class="col3">
<div>Gender: <span id="genderS"></span></div>
<div>Phone: <span id="phoneS"></span></div>
</div>
</div>
</div>
<div class="header-section3">
<h4>Patient Information:</h4>
<pre id="info">Loading...</pre>
</div>
</div>
<script type="text/javascript">
function getExtensionValue(pt, reqVal) {
for (var i = 0; i < pt.extension.length; i++) {
console.log(pt.extension[i].url);
if (pt.extension[i].url !=null && pt.extension[i].url == reqVal) {
if (pt.extension[i].extension[0].valueCoding!=null){
return pt.extension[i].extension[0].valueCoding.display;
}else {
return pt.extension[i].extension[0].valueString;
}
}
}
return 'N/A'
}
// Request current logged in Patient Data using fhir-client library and updates DOM on successful response
FHIR.oauth2.ready().then(async (client) => {
console.log('loading data....');
console.log(client);
console.log(client.state.tokenResponse.access_token);
return client.patient.read()
}).then(
function (pt) {
console.log('pt is::');
console.log(pt);
document.getElementById('patient_header').innerText = (pt.name[0].prefix || '') + pt.name[0].given.join(' ') + ' ' + pt.name[0].family;
document.getElementById('patientS').innerText = (pt.name[0].text || pt.name[0].given);
document.getElementById('ethnicityS').innerText = getExtensionValue(pt,'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity');
document.getElementById('cidS').innerText = pt.identifier[0].id;
document.getElementById('raceS').innerText = getExtensionValue(pt,'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race');
document.getElementById('dobS').innerText = pt.birthDate;
document.getElementById('addressS').innerText = pt.address[0].line[0];
document.getElementById('genderS').innerText = pt.gender;
document.getElementById('phoneS').innerText = pt.telecom[0].value || 'N/A';
document.getElementById('info').innerText = JSON.stringify(pt, null, '\t')
},
function (error) {
document.getElementById('patient_header').innerText = 'Error Occurred'
document.getElementById('info').innerText = error.stack
},
).catch(console.error)
</script>
</body>
</html>