-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
45 lines (35 loc) · 1.25 KB
/
server.js
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
// Declare HMS instance object
const hmshealthapi = require('@hmsconnect/hmshealthapi');
require('dotenv').config();
let tokens = {
username: process.env.USERNAME,
password: process.env.PASSWORD,
client_id: process.env.CLIENT_ID
};
let hms = hmshealthapi();
hms.Initial(tokens, (error, response) => {
if(error) {
console.log('Initial error : ', error);
} else {
console.log('response :', response);
// Config data source
hms.SetConfig({
host: process.env.HOST_DATA_SRC,
endpoints: {
get_domain_resource : '/sandbox/api/v2',
get_version : '/sandbox/version'
}
});
try {
const headers = {
Authorization: `Bearer ${response.access_token ? response.access_token : ''}`
};
console.log('Header : ', headers)
hms.get('practitioner', headers, 'name.givenName:contain="Silas S9"&sort=-identifier.start')
.then((response) => { console.log('Searching with request URL:', JSON.stringify(response, null, 2)); })
.catch((err) => { console.log('Error :', err); });
} catch(err) {
console.log(err)
}
}
});