-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.htm
170 lines (149 loc) · 5.38 KB
/
index.htm
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
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="ehrserver_ajax_client.js"></script>
<!--<script src="ehrserver_jsonp_client.js"></script>-->
<script type="text/javascript">
$(document).ready(function() {
// The functions will return true if the request was done, false if not and log the reason in the console.
var ehrserver = ehrserver_ajax_client;
ehrserver.init('http://localhost:8090/ehr');
//ehrserver.init('http://127.0.0.1:8090/ehr');
//ehrserver.init('https://ehrserver-cabolabs2.rhcloud.com/');
var show_status = function(status, statusText) {
$("input[name='status']").val(status +" "+ statusText);
};
$('#login').on('click', function (){
ehrserver.login(
$('input[name=username]').val(),
$('input[name=password]').val(),
$('input[name=organization]').val(),
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
if (ehrserver.is_authenticated())
{
$('#login_status').removeClass('not_auth');
$('#login_status').addClass('auth');
}
}
);
});
$('#user').on('click', function (){
ehrserver.user(
$('input[name=username2]').val(),
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
$('#ehrs').on('click', function (){
ehrserver.ehrs(
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
$('#ehr').on('click', function (){
ehrserver.ehr(
$('input[name=ehr_uid]').val(),
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
$('#ehr_for_patient').on('click', function (){
ehrserver.ehr_for_patient(
$('input[name=ehr_patient_uid]').val(),
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
$('#contributions').on('click', function (){
ehrserver.contributions(
$('input[name=contributions_ehr_uid]').val(),
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
$('#queries').on('click', function (){
ehrserver.queries(
function(data, status, statusText) {
$('#out').text( JSON.stringify(data, null, " ") );
show_status(status, statusText);
}
);
});
//var url = 'http://localhost:8090/ehr/rest/patientList?format=json&callback=?';
//$.getJSON(url, null, function(data) {
// console.log( data );
//});
});
</script>
<style>
fieldset {
display: inline;
margin: 1em;
border: 1px solid #aaa;
}
textarea, input[name=status] {
width: 100%;
}
#login_status {
display: inline-block;
width: 20px;
height: 20px;
background-size: 20px 20px;
background-repeat: no-repeat;
}
#login_status.not_auth {
background-image: url("http://www.clipartkid.com/images/485/not-allowed-sign-clipart-download-j2CTjB-clipart.png");
}
#login_status.auth {
background-image: url("http://cliparts.co/cliparts/pio/da5/pioda5AbT.png");
}
</style>
</head>
<body>
<div id="buttons">
<fieldset>
<input type="text" name="username" placeholder="username" />
<input type="text" name="password" placeholder="password" />
<input type="text" name="organization" placeholder="organization" />
<button id="login">login</button>
<span id="login_status" class="not_auth"></span>
</fieldset>
<fieldset>
<input type="text" name="username2" placeholder="username" />
<button id="user">user profile</button>
</fieldset>
<button id="ehrs">ehrs</button>
<fieldset>
<input type="text" name="ehr_uid" placeholder="ehr uid" />
<button id="ehr">ehr</button>
</fieldset>
<fieldset>
<input type="text" name="ehr_patient_uid" placeholder="patient uid" />
<button id="ehr_for_patient">ehr for patient</button>
</fieldset>
<fieldset>
<input type="text" name="contributions_ehr_uid" placeholder="ehr uid" />
<button id="contributions">contributions for ehr</button>
</fieldset>
<button id="queries">queries</button>
</div>
<div id="status">
<input type="text" name="status" value="" />
</div>
<div id="output">
<textarea id="out" rows="40"></textarea>
</div>
</body>
</html>