-
Notifications
You must be signed in to change notification settings - Fork 0
/
microepj_paste.html
192 lines (142 loc) · 7.46 KB
/
microepj_paste.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<html>
<head>
<title>Micro EPJ med SFM i iframe</title>
<link rel="icon" type="image/x-icon" href="./favicon.ico">
<style>
form { border-bottom : 1px solid ; }
.label { color : blue; }
.message { border : 1px solid; color : maroon; background :gold; }
.messagebox { margin-bottom : 8px ; }
.header { font-size: 30px; font-weight: bold;}
.info { font-style: italic; color: tomato;}
input[type=submit] { margin-bottom : 8px ; width : 80px; background : lightgreen; }
</style>
<script>
function displayMessage (evt) {
var message;
document.getElementById("svarmelding").innerHTML = JSON.stringify(evt.data);
};
function somethingPasted (event) {
let paste = (event.clipboardData || window.clipboardData).getData("text");
/* try parse as JSON and assume it is a session/create response */
var sessionData = JSON.parse(paste);
// document.getElementById("clipboard").innerText = sessionData;
document.getElementById("apiEndpoint").value = sessionData.apiAddress;
document.getElementById("code").value = sessionData.code;
document.getElementById("optPasientportal").value = sessionData.metadata.patientportal;
document.getElementById("optHelsepersonellportal").value = sessionData.metadata.healthcareportal;
document.getElementById("optDisplayportal").value = sessionData.metadata.displayportal;
document.getElementById("optVirksomhetsportal").value = sessionData.metadata.enterpriseportal;
/*
const select = document.querySelector('#portal');
while (select.options.length > 0) {
select.remove(0);
}
let displayOption = new Option('Displayportal', sessionData.metadata.displayportal);
let displayOption = new Option('Displayportal', sessionData.metadata.displayportal);
let displayOption = new Option('Displayportal', sessionData.metadata.displayportal);
let displayOption = new Option('Displayportal', sessionData.metadata.displayportal);
select.add(displayOption);
*/
};
/* this "hidden" function set the nonce from documentation, reuse of nonce shall not happen in production */
function setNonce() {
var nonceDefault= "qkhV08YwfJFk97VB3XP1t6WaZ2OaTMs8Y98HxGJgoHu9VGTrwN6R9te57JeOidhszqgOMpnCv5O6+X+F/8hWpA==";
document.getElementById("nonce").value = nonceDefault;
};
/*if(window.addEventListener) {
window.addEventListener("message", dispayMessage, false);
};
*/
window.onload = function () {
/* set intitial iframe src from select: */
document.getElementById("sfm_iframe").src = document.getElementById("portal").value;
document.getElementById("url").innerHTML = document.getElementById("portal").value;
var iframeWin = document.getElementById("sfm_iframe").contentWindow,
loginform = document.getElementById("loginform"),
myCode = document.getElementById("code"),
myNonce = document.getElementById("nonce"),
myApiEndpoint = document.getElementById("apiEndpoint"),
myPatientTicket =document.getElementById("patientTicket"),
myShowAllergies = document.getElementById("showAllergies"),
myShowLib = document.getElementById("showLib"),
myOnBehalfOf = document.getElementById("onBehalf"),
myPortal = document.getElementById("portal"),
myEncounter = document.getElementById("encounterId")
;
loginform.onsubmit = function () {
let sessionCode = myCode.value ;
let sessionNonce = myNonce.value ;
let apiEndpoint = myApiEndpoint.value;
let msg = {'action' : 'login', 'code' : sessionCode, 'nonce' : sessionNonce, 'apiEndpoint' : apiEndpoint };
document.getElementById("melding").innerHTML = JSON.stringify( msg );
iframeWin.postMessage(msg, "*");
return false;
};
patientform.onsubmit = function () {
let patientTicket = myPatientTicket.value ;
let showAllergies = myShowAllergies.checked ;
let showLib = myShowLib.checked;
let onBehalfOf = myOnBehalfOf.value;
let encounterId = myEncounter.value;
let msg = {'action' : 'setPatient', 'ticket' : patientTicket, 'showAllergies' : showAllergies,'showLib' : showLib, 'onBehalfOf' : onBehalfOf, 'encounterId' : encounterId };
document.getElementById("melding").innerHTML = JSON.stringify( msg );
iframeWin.postMessage(msg, "*");
return false;
};
portalform.onsubmit = function () {
let portal = myPortal.value ;
document.getElementById("melding").innerHTML = "...";
document.getElementById("svarmelding").innerHTML = "...";
document.getElementById("url").innerHTML = portal;
document.getElementById("sfm_iframe").src = portal;
return false;
};
};
if(window.addEventListener) {
window.addEventListener("message", displayMessage, false);
window.addEventListener("paste", somethingPasted, false);
};
</script>
</head>
<body>
<span class="header"> Micro EPJ med SFM i iframe </span><span class="info">(I denne versjonen kan http response fra Session/create pastes inn i vinduet)</span>
<div id="clipboard" >...</div>
<form id="portalform" action="/">
<table>
<tr><td>Velg portal:</td><td>
<!-- <input type="text" id="portal" value="https://client.test2.forskrivning.no/v30/" size='80'> -->
<select id="portal">
<option id="optPasientportal" selected value="https://client.test2.forskrivning.no/v35">Pasientportal</option>
<option id="optHelsepersonellportal" value="https://health-personnel-portal.test2.forskrivning.no/v35">Helsepersonellportal</option>
<option id="optVirksomhetsportal" value="https://enterprise-portal.test2.forskrivning.no/v35">Virksomhetsportal</option>
<option id="optDisplayportal" value="https://display-portal.test2.forskrivning.no/v35">Displayportal</option>
</select>
</table>
<input type="submit" value="Velg portal">
</form>
<form id="loginform" action="/">
<table>
<tr><td>Code from create session:</td><td><input type="text" id="code" value="Code" size='120'></td></tr>
<tr><td>Nonce[b64]:</td><td><input type="text" id="nonce" value="Nonce" size='120' ondblclick="setNonce()"><span class="info"> <-- dblclick for default verdi fra dokumentasjonssidene</span></td></tr>
<tr><td>Api endpoint:</td><td><input type="text" id="apiEndpoint" value="https://server.test2.forskrivning.no/v35" size='40'></td></tr>
</table>
<input type="submit" value="Login">
</form>
<form id="patientform" action="/">
<table>
<tr><td>PatientTicket:</td><td><input type="text" id="patientTicket" value="PatientTicket" size='50'></td></tr>
<tr><td>Show allergies</td><td><input type="checkbox" id="showAllergies" checked="true" ></td></tr>
<tr><td>Show Lib</td><td><input type="checkbox" id="showLib" checked="true" ></td></tr>
<tr><td>On behalf [HRR]</td><td><input type="text" id="onBehalf" value="" size='20'></td></tr>
<tr><td>Encounter id</td><td><input type="text" id="encounterId" value="" size='50'></td></tr>
</table>
<input type="submit" value="SetPatient">
</form>
<div class="messagebox"><span class="label">iframe.src:</span><span class="message" id="url" > </span></div>
<div class="messagebox"><span class="label">Til iframe:</span><span class="message" id="melding" > </span></div>
<div class="messagebox"><span class="label">Fra iframe:</span><span class="message" id="svarmelding" > </span></div>
<iframe id="sfm_iframe" src="" width="99%" height="800px">
</iframe>
</body>
<html>