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: Rob Tweed, M/Gateway Developments Ltd |
|
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 | 17 May 2017
|
28 |
|
29 | */
|
30 |
|
31 | function getTransferOfCareDetail(args, callback) {
|
32 |
|
33 | var patientId = args.patientId;
|
34 |
|
35 | if (typeof patientId === 'undefined' || patientId === '') {
|
36 | return callback({error: 'patientId not defined or invalid'});
|
37 | }
|
38 |
|
39 | var sourceId = args.sourceId;
|
40 |
|
41 | if (typeof sourceId === 'undefined' || sourceId === '') {
|
42 | return callback({error: 'sourceId not defined or invalid'});
|
43 | }
|
44 |
|
45 | var docName = this.userDefined.tocDocumentName;
|
46 | var tocDoc = new this.documentStore.DocumentNode(docName, ['byPatient', patientId, sourceId]);
|
47 | if (!tocDoc.exists) return callback({error: 'No record exists for ' + patientId + ' with sourceId: ' + sourceId});
|
48 |
|
49 | var results = tocDoc.getDocument(true);
|
50 | if (typeof results.source === 'undefined') results.source = 'qewdDB';
|
51 | callback(results);
|
52 | }
|
53 |
|
54 | module.exports = getTransferOfCareDetail;
|