1 | /*
|
2 |
|
3 | ----------------------------------------------------------------------------
|
4 | | qewd-ripple: QEWD-based Middle Tier for Ripple OSI |
|
5 | | |
|
6 | | Copyright (c) 2016-17 Ripple Foundation Community Interest Company |
|
7 | | All rights reserved. |
|
8 | | |
|
9 | | http://rippleosi.org |
|
10 | | Email: code.custodian@rippleosi.org |
|
11 | | |
|
12 | | Author: Chris Johnson |
|
13 | | |
|
14 | | Licensed under the Apache License, Version 2.0 (the "License"); |
|
15 | | you may not use this file except in compliance with the License. |
|
16 | | You may obtain a copy of the License at |
|
17 | | |
|
18 | | http://www.apache.org/licenses/LICENSE-2.0 |
|
19 | | |
|
20 | | Unless required by applicable law or agreed to in writing, software |
|
21 | | distributed under the License is distributed on an "AS IS" BASIS, |
|
22 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
23 | | See the License for the specific language governing permissions and |
|
24 | | limitations under the License. |
|
25 | ----------------------------------------------------------------------------
|
26 |
|
27 | 26 January 2017
|
28 |
|
29 | */
|
30 |
|
31 | var headings = require('./../lib/headings/headings');
|
32 | var openEHR = require('./../lib/openEHR/openEHR');
|
33 | var template = require('qewd-template');
|
34 |
|
35 | Object.keys(openEHR.servers).forEach(function(server) {
|
36 | var session;
|
37 |
|
38 | // Create a session with the current openEHR server
|
39 | beforeEach(function(done) {
|
40 | openEHR.startSession(server, function(res) {
|
41 | session = res.id;
|
42 | done();
|
43 | });
|
44 | });
|
45 |
|
46 | afterEach(function(done) {
|
47 | openEHR.stopSession(server, session, done);
|
48 | });
|
49 |
|
50 | function request(url, data, done, process) {
|
51 | openEHR.request({
|
52 | url: url,
|
53 | queryString: data,
|
54 | host: server,
|
55 | session: session,
|
56 | processBody: process,
|
57 | callback: done
|
58 | });
|
59 | }
|
60 |
|
61 | describe("OpenEHR Server " + server, function() {
|
62 | var ivorCoxNhsId = 9999999000;
|
63 | var ivorCoxEhrId;
|
64 |
|
65 | beforeEach(function(done) {
|
66 | request('/rest/v1/ehr', {
|
67 | subjectId: ivorCoxNhsId,
|
68 | subjectNamespace: 'uk.nhs.nhs_number'
|
69 | }, done, function(res) { ivorCoxEhrId = res.ehrId;}
|
70 | );
|
71 | });
|
72 |
|
73 | // For each heading which has an aql defined
|
74 | Object.keys(headings.headings).forEach(function(headingName) {
|
75 | var heading = headings.headings[headingName];
|
76 | describe("using " + headingName, function() {
|
77 | if(heading.query && heading.query.aql) {
|
78 | it("can get Ivor Cox details using AQL", function(done) {
|
79 | var aql = template.replace(heading.query.aql,{
|
80 | patientId: ivorCoxNhsId, ehrId: ivorCoxEhrId
|
81 | });
|
82 |
|
83 | request('/rest/v1/query', {aql:aql}, done, function(res) {
|
84 | expect(res.resultSet).toBeTruthy();
|
85 | });
|
86 | });
|
87 | }
|
88 | });
|
89 | });
|
90 | });
|
91 | });
|