-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.html
More file actions
191 lines (163 loc) · 5.77 KB
/
create.html
File metadata and controls
191 lines (163 loc) · 5.77 KB
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
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Create a FHIR Patient</title>
<link rel="icon" href="static/styles/common/favicon.ico" />
<script src="static/styles/common/jquery/jquery.min.js"></script>
<script src="static/styles/common/bootstrap/bootstrap.min.js"></script>
<link rel="stylesheet" href="static/styles/common/main.min.css" />
<link rel="stylesheet" href="static/styles/common/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="static/styles/common/rendering/rendering.min.css" />
<script src="static/styles/common/rendering/stu3TreeTable.min.js"></script>
<script src="static/styles/common/rendering/baseTreetable.min.js"></script>
<link rel="stylesheet" href="static/styles/twolevelmenu/style.css?v=1da42fd98e2a000" />
<script src="https://cdn.jsdelivr.net/npm/fhirclient/build/fhir-client.js"></script>
</head>
<body>
<div id="ig-viewer">
<div class="ig-view-content">
<div id="ig-view-twolevelmenu">
<div class="header" role="banner" aria-label="Header">
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">
Training exercises
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Select <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="retrieve.html">
Retrieve a Patient
</a>
</li>
<li>
<a href="create.html">
Create a Patient
</a>
</li>
<li>
<a href="obs.html">
Add an Observation
</a>
</li>
<li>
<a href="search.html">
Search for Patients
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</div>
<div class="content container" role="main" aria-label="Main content">
<div class="row">
<div class="col-md-24">
<div id="preview-content">
<h1 id="page-title">Create a FHIR Patient</h1>
Please input some Patient details and click on 'Create':<br><br>
<label for="given">Given name </label>
<input type="text" id="given" name="given"><br>
<label for="family">Family name </label>
<input type="text" id="family" name="family"><br>
<label for="identifier">Identifier value </label>
<input type="text" id="identifier" name="identifier"><br>
<label for="birthdate">Date of birth </label>
<input type="date" id="birthdate" name="birthdate"><br><br>
<input type="button" id="create" value="Create"/>
<br><br>
<div id="patient"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ig-view-footer" role="contentinfo" aria-label="Footer">
<div class="container">
<div class="row">
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript">
var resource = null;
function displayPatient(data) {
const output = document.getElementById("patient");
output.innerHTML =
"<i>The Patient was successfully created</i><br><br>The server has created the Patient with technical id: " +
getPatientId(data);
resource = data;
}
function displayError(data) {
const output = document.getElementById("patient");
if (data.name == "HttpError")
output.innerText = "Error: Patient could not be created";
}
function getPatientId (pt) {
if (pt.id) {
return pt.id;
} else {
return "something went wrong: no id present";
}
}
function makePatient() {
const given = document.getElementById("given").value;
const family = document.getElementById("family").value;
const birthdate = document.getElementById("birthdate").value;
const identifier = {
system: "http://www.miniaf.alp/citreg",
value: document.getElementById("identifier").value
};
const patientResource = {
resourceType: 'Patient',
meta: {
tag: [
{
system: "http://www.alpha.alp/use-case",
code: "EX25HSE"
},
],
},
text: {
status: "generated",
div: "<div xmlns=\"http://www.w3.org/1999/xhtml\"><b>Patient:</b> "+ family + ", " + given + ", " + birthdate + ", Cit.id " + identifier.value +"</div>"
},
name: [
{
given: [given],
family: family,
},
],
birthDate: birthdate,
identifier: [ identifier ]
};
return patientResource;
}
const createBtn = document.getElementById("create");
//const client = FHIR.client("https://hapi.fhir.org/baseR4");
const client = FHIR.client("https://server.fire.ly/R4");
createBtn.onclick = () => {
var pat = makePatient();
client.create(pat)
.then(displayPatient)
.catch(displayError);
}
</script>
</html>