@metriport/commonwell-cert-runner 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -3
- package/lib/document-consumption.d.ts +5 -0
- package/lib/document-consumption.js +61 -0
- package/lib/document-consumption.js.map +1 -0
- package/lib/document-contribution.d.ts +7 -0
- package/lib/document-contribution.js +97 -0
- package/lib/document-contribution.js.map +1 -0
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/link-management.js +5 -6
- package/lib/link-management.js.map +1 -1
- package/lib/org-management.js +10 -10
- package/lib/org-management.js.map +1 -1
- package/lib/patient-management.js +8 -8
- package/lib/patient-management.js.map +1 -1
- package/lib/payloads.d.ts +194 -27
- package/lib/payloads.js +116 -55
- package/lib/payloads.js.map +1 -1
- package/lib/person-management.js +1 -2
- package/lib/person-management.js.map +1 -1
- package/lib/shared-person.d.ts +21 -0
- package/lib/shared-person.js +75 -0
- package/lib/shared-person.js.map +1 -0
- package/lib/util.d.ts +3 -1
- package/lib/util.js +16 -3
- package/lib/util.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -18,21 +18,50 @@ After installation, create a `.env` file defining the following variables:
|
|
|
18
18
|
|
|
19
19
|
- `COMMONWELL_ORG_NAME`: the organization that will be making the requests.
|
|
20
20
|
- `COMMONWELL_OID`: the organization ID.
|
|
21
|
+
- `COMMONWELL_SANDBOX_ORG_NAME`: the organization on sandbox for patient management and document contribution
|
|
22
|
+
- should be configured with your FHIR server and OAuth 2 data on Commonwell management portal
|
|
23
|
+
- `COMMONWELL_SANDBOX_OID`: the ID of the organization above
|
|
24
|
+
- `COMMONWELL_MEMBER_OID`: the member ID for organization management
|
|
21
25
|
- `COMMONWELL_PRIVATE_KEY`: the RSA256 private key corresponding to the specified organization.
|
|
22
26
|
- `COMMONWELL_CERTIFICATE`: the public certificate/key corresponding to the private key.
|
|
27
|
+
- `DOCUMENT_PATIENT_FIRST_NAME`: the first name of a patient created along with the sandbox that has a document associated
|
|
28
|
+
- `DOCUMENT_PATIENT_LAST_NAME`: their last name
|
|
29
|
+
- `DOCUMENT_PATIENT_DATE_OF_BIRTH`: their date of birth on the format YYYY-MM-DD
|
|
30
|
+
- `DOCUMENT_PATIENT_GENDER`: their gender (M|F)
|
|
31
|
+
- `DOCUMENT_PATIENT_ZIP`: their address zip code
|
|
32
|
+
- `DOCUMENT_CONTRIBUTION_ORGANIZATION_ID`: organization suffix for the document contribution flow (usually in the format
|
|
33
|
+
"2.dddddd", with 'd' being a digit)
|
|
34
|
+
- `DOCUMENT_CONTRIBUTION_PATIENT_FIRST_NAME`: the first name of the patient to be created on the organization used for the
|
|
35
|
+
document contribution flow - same for the properties below [optional, defaults to the same name from the document patient
|
|
36
|
+
above]
|
|
37
|
+
- `DOCUMENT_CONTRIBUTION_PATIENT_LAST_NAME`
|
|
38
|
+
- `DOCUMENT_CONTRIBUTION_PATIENT_DATE_OF_BIRTH`
|
|
39
|
+
- `DOCUMENT_CONTRIBUTION_PATIENT_GENDER`
|
|
40
|
+
- `DOCUMENT_CONTRIBUTION_PATIENT_ZIP`
|
|
41
|
+
|
|
42
|
+
flow - must exist on the sandbox organization
|
|
23
43
|
|
|
24
44
|
Example file content looks like:
|
|
25
45
|
|
|
26
46
|
```
|
|
27
47
|
COMMONWELL_ORG_NAME=Metriport
|
|
28
48
|
COMMONWELL_OID=2.16.840.1.113883.3.9621
|
|
49
|
+
COMMONWELL_SANDBOX_ORG_NAME=Metriport-OrgA-1620
|
|
50
|
+
COMMONWELL_SANDBOX_OID=2.16.840.1.113883.3.3330.8889429.1620.1
|
|
51
|
+
COMMONWELL_MEMBER_OID=1.3.6.1.4.1.18.12.29.2022.945
|
|
29
52
|
COMMONWELL_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
|
|
30
53
|
fkadsjhfhdsakjfhdsakhfkdsahfadshfkhdsfhdsakfdhafkashdfkjhalsdkjf
|
|
31
|
-
-----END PRIVATE KEY-----
|
|
32
|
-
"
|
|
54
|
+
-----END PRIVATE KEY-----"
|
|
33
55
|
COMMONWELL_CERTIFICATE="-----BEGIN CERTIFICATE-----
|
|
34
56
|
asdlkfjladsjflkjdaslkfjdsafjadslfjasdlkfjdsaklfjdkalfjdslfjalkjs
|
|
35
|
-
-----END CERTIFICATE-----
|
|
57
|
+
-----END CERTIFICATE-----"
|
|
58
|
+
DOCUMENT_PATIENT_FIRST_NAME="Stephen"
|
|
59
|
+
DOCUMENT_PATIENT_LAST_NAME="Pujols1234"
|
|
60
|
+
DOCUMENT_PATIENT_DATE_OF_BIRTH="1955-10-23"
|
|
61
|
+
DOCUMENT_PATIENT_GENDER="M"
|
|
62
|
+
DOCUMENT_PATIENT_ZIP="62732"
|
|
63
|
+
# This is optional, if not set the runner will attempt to create the patient above on the sandbox org
|
|
64
|
+
DOCUMENT_CONTRIBUTION_PATIENT_ID=<patient-id>%5E%5E%5Eurn%3aoid%3a<org-id>
|
|
36
65
|
```
|
|
37
66
|
|
|
38
67
|
After the file is created, you can run execute following command on your terminal to run the program:
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { CommonWell, Document, RequestMetadata } from "@metriport/commonwell-sdk";
|
|
3
|
+
export declare function documentConsumption(commonWell: CommonWell, queryMeta: RequestMetadata): Promise<void>;
|
|
4
|
+
export declare function queryDocuments(commonWell: CommonWell, queryMeta: RequestMetadata): Promise<Document[]>;
|
|
5
|
+
export declare function retrieveDocument(commonWell: CommonWell, queryMeta: RequestMetadata, doc: Document): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.retrieveDocument = exports.queryDocuments = exports.documentConsumption = void 0;
|
|
14
|
+
const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const payloads_1 = require("./payloads");
|
|
17
|
+
const shared_person_1 = require("./shared-person");
|
|
18
|
+
function documentConsumption(commonWell, queryMeta) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const documents = yield queryDocuments(commonWell, queryMeta);
|
|
21
|
+
for (const doc of documents) {
|
|
22
|
+
yield retrieveDocument(commonWell, queryMeta, doc);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.documentConsumption = documentConsumption;
|
|
27
|
+
function queryDocuments(commonWell, queryMeta) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
console.log(`>>> E1c: Query for documents using FHIR (REST)`);
|
|
30
|
+
const { personId, patientId } = yield (0, shared_person_1.findOrCreatePerson)(commonWell, queryMeta, (0, payloads_1.makeDocPerson)());
|
|
31
|
+
if (!personId)
|
|
32
|
+
throw new Error(`[E1c] personId is undefined before calling getPatientsLinks()`);
|
|
33
|
+
const respLinks = yield commonWell.getPatientsLinks(queryMeta, patientId);
|
|
34
|
+
console.log(respLinks);
|
|
35
|
+
const allLinks = respLinks._embedded.networkLink;
|
|
36
|
+
const lola1Links = allLinks.filter(commonwell_sdk_1.isLOLA1);
|
|
37
|
+
console.log(`Found ${allLinks.length} network links, ${lola1Links.length} are LOLA 1`);
|
|
38
|
+
for (const link of lola1Links) {
|
|
39
|
+
const respUpgradeLink = yield commonWell.upgradeOrDowngradePatientLink(queryMeta, link._links.upgrade.href);
|
|
40
|
+
console.log(respUpgradeLink);
|
|
41
|
+
}
|
|
42
|
+
console.log(`>>> [E1c] Querying for docs...`);
|
|
43
|
+
const respDocQuery = yield commonWell.queryDocuments(queryMeta, patientId);
|
|
44
|
+
return respDocQuery.entry;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.queryDocuments = queryDocuments;
|
|
48
|
+
function retrieveDocument(commonWell, queryMeta, doc) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
console.log(`>>> E2c: Retrieve documents using FHIR (REST)`);
|
|
52
|
+
const queryFileName = `./commonwell_queried_${(_a = doc.id) !== null && _a !== void 0 ? _a : "ID"}_${(0, payloads_1.makeId)()}.query.file`;
|
|
53
|
+
fs.writeFileSync(queryFileName, JSON.stringify(doc));
|
|
54
|
+
const fileName = `./commonwell_queried_${(_b = doc.id) !== null && _b !== void 0 ? _b : "ID"}_${(0, payloads_1.makeId)()}.file`;
|
|
55
|
+
const outputStream = fs.createWriteStream(fileName, { encoding: null });
|
|
56
|
+
console.log(`File being created at ${process.cwd()}/${fileName}`);
|
|
57
|
+
const url = doc.content.location;
|
|
58
|
+
yield commonWell.retrieveDocument(queryMeta, url, outputStream);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.retrieveDocument = retrieveDocument;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-consumption.js","sourceRoot":"","sources":["../src/document-consumption.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA2F;AAC3F,yBAAyB;AACzB,yCAAmD;AACnD,mDAAqD;AAKrD,SAAsB,mBAAmB,CAAC,UAAsB,EAAE,SAA0B;;QAC1F,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,S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C5B,CAAC;CAAA;AA3BD,wCA2BC;AAED,SAAsB,gBAAgB,CACpC,UAAsB,EACtB,SAA0B,EAC1B,GAAa;;;QAGb,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QAG7D,MAAM,aAAa,GAAG,wBAAwB,MAAA,GAAG,CAAC,EAAE,mCAAI,IAAI,IAAI,IAAA,iBAAM,GAAE,aAAa,CAAC;QACtF,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAErD,MAAM,QAAQ,GAAG,wBAAwB,MAAA,GAAG,CAAC,EAAE,mCAAI,IAAI,IAAI,IAAA,iBAAM,GAAE,OAAO,CAAC;QAE3E,MAAM,YAAY,GAAG,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,yBAAyB,OAAO,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC,CAAC;QAClE,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;QACjC,MAAM,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;;CACjE;AAlBD,4CAkBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { CommonWell, RequestMetadata } from "@metriport/commonwell-sdk";
|
|
3
|
+
export declare function documentContribution({ memberManagementApi, api: apiDefaultOrg, queryMeta, }: {
|
|
4
|
+
memberManagementApi: CommonWell;
|
|
5
|
+
api: CommonWell;
|
|
6
|
+
queryMeta: RequestMetadata;
|
|
7
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.documentContribution = void 0;
|
|
14
|
+
const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const payloads_1 = require("./payloads");
|
|
18
|
+
const shared_person_1 = require("./shared-person");
|
|
19
|
+
const util_1 = require("./util");
|
|
20
|
+
const commonwellPrivateKey = (0, util_1.getEnvOrFail)("COMMONWELL_PRIVATE_KEY");
|
|
21
|
+
const commonwellCert = (0, util_1.getEnvOrFail)("COMMONWELL_CERTIFICATE");
|
|
22
|
+
const orgIdSuffix = (0, util_1.getEnvOrFail)("DOCUMENT_CONTRIBUTION_ORGANIZATION_ID");
|
|
23
|
+
const firstName = (0, util_1.getEnv)("DOCUMENT_CONTRIBUTION_PATIENT_FIRST_NAME");
|
|
24
|
+
const lastName = (0, util_1.getEnv)("DOCUMENT_CONTRIBUTION_PATIENT_LAST_NAME");
|
|
25
|
+
const dob = (0, util_1.getEnv)("DOCUMENT_CONTRIBUTION_PATIENT_DATE_OF_BIRTH");
|
|
26
|
+
const gender = (0, util_1.getEnv)("DOCUMENT_CONTRIBUTION_PATIENT_GENDER");
|
|
27
|
+
const zip = (0, util_1.getEnv)("DOCUMENT_CONTRIBUTION_PATIENT_ZIP");
|
|
28
|
+
function documentContribution({ memberManagementApi, api: apiDefaultOrg, queryMeta, }) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
console.log(`>>> E3: Query for documents served by Metriport's FHIR server`);
|
|
32
|
+
const { orgAPI: apiNewOrg, orgName } = yield getOrCreateOrg(memberManagementApi, queryMeta);
|
|
33
|
+
const person = (0, payloads_1.makeDocPerson)({
|
|
34
|
+
firstName,
|
|
35
|
+
lastName,
|
|
36
|
+
zip,
|
|
37
|
+
gender,
|
|
38
|
+
dob,
|
|
39
|
+
facilityId: apiDefaultOrg.oid,
|
|
40
|
+
});
|
|
41
|
+
console.log(`Find or create patient and person on main org`);
|
|
42
|
+
const { personId, patientId: patientIdMainOrg } = yield (0, shared_person_1.findOrCreatePerson)(apiDefaultOrg, queryMeta, person);
|
|
43
|
+
console.log(`personId: ${personId}`);
|
|
44
|
+
console.log(`patientId on main org: ${patientIdMainOrg}`);
|
|
45
|
+
const newPerson = (0, lodash_1.cloneDeep)(person);
|
|
46
|
+
newPerson.identifier = (0, payloads_1.makePatient)({ facilityId: apiNewOrg.oid }).identifier;
|
|
47
|
+
newPerson.identifier[0].assigner = orgName;
|
|
48
|
+
newPerson.identifier[0].label = orgName;
|
|
49
|
+
const { patientId: patientIdNewOrg } = yield (0, shared_person_1.findOrCreatePatient)(apiNewOrg, queryMeta, newPerson, personId);
|
|
50
|
+
console.log(`patientId: ${patientIdNewOrg}`);
|
|
51
|
+
console.log(`Get patients links`);
|
|
52
|
+
const respGetLinks = yield apiNewOrg.getPatientsLinks(queryMeta, patientIdNewOrg);
|
|
53
|
+
console.log(respGetLinks);
|
|
54
|
+
const allLinks = respGetLinks._embedded.networkLink;
|
|
55
|
+
const lola1Links = allLinks.filter(commonwell_sdk_1.isLOLA1);
|
|
56
|
+
console.log(`Found ${allLinks.length} network links, ${lola1Links.length} are LOLA 1`);
|
|
57
|
+
for (const link of lola1Links) {
|
|
58
|
+
const respUpgradeLink = yield apiNewOrg.upgradeOrDowngradePatientLink(queryMeta, link._links.upgrade.href);
|
|
59
|
+
console.log(respUpgradeLink);
|
|
60
|
+
}
|
|
61
|
+
console.log(`>>> [E3] Querying for docs from the main org...`);
|
|
62
|
+
const respDocQuery = yield apiDefaultOrg.queryDocuments(queryMeta, patientIdMainOrg);
|
|
63
|
+
console.log(respDocQuery);
|
|
64
|
+
const documents = (_a = respDocQuery.entry) !== null && _a !== void 0 ? _a : [];
|
|
65
|
+
for (const doc of documents) {
|
|
66
|
+
console.log(`DOCUMENT: ${JSON.stringify(doc, undefined, 2)}`);
|
|
67
|
+
const fileName = `./commonwell_contributed_${(_b = doc.id) !== null && _b !== void 0 ? _b : "ID"}_${(0, payloads_1.makeId)()}.file`;
|
|
68
|
+
const outputStream = fs.createWriteStream(fileName, { encoding: null });
|
|
69
|
+
console.log(`File being created at ${process.cwd()}/${fileName}`);
|
|
70
|
+
const url = (_c = doc.content) === null || _c === void 0 ? void 0 : _c.location;
|
|
71
|
+
if (url != null)
|
|
72
|
+
yield apiDefaultOrg.retrieveDocument(queryMeta, url, outputStream);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.documentContribution = documentContribution;
|
|
77
|
+
function getOrCreateOrg(memberManagementApi, queryMeta) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const orgPayload = (0, payloads_1.makeOrganization)(orgIdSuffix);
|
|
80
|
+
const orgId = orgPayload.organizationId;
|
|
81
|
+
const orgIdWithoutNamespace = orgId.slice("urn:oid:".length);
|
|
82
|
+
const orgName = orgPayload.name;
|
|
83
|
+
console.log(`Get the doc org - ID ${orgId}, name ${orgName}`);
|
|
84
|
+
const respGetOneOrg = yield memberManagementApi.getOneOrg(queryMeta, orgId);
|
|
85
|
+
console.log(respGetOneOrg);
|
|
86
|
+
if (!respGetOneOrg) {
|
|
87
|
+
console.log(`Doc org not found, create one`);
|
|
88
|
+
const respCreateOrg = yield memberManagementApi.createOrg(queryMeta, orgPayload);
|
|
89
|
+
console.log(respCreateOrg);
|
|
90
|
+
console.log(`Add certificate to doc org`);
|
|
91
|
+
const respAddCertificateToOrg = yield memberManagementApi.addCertificateToOrg(queryMeta, payloads_1.certificate, orgIdWithoutNamespace);
|
|
92
|
+
console.log(respAddCertificateToOrg);
|
|
93
|
+
}
|
|
94
|
+
const orgAPI = new commonwell_sdk_1.CommonWell(commonwellCert, commonwellPrivateKey, orgName, orgIdWithoutNamespace, commonwell_sdk_1.APIMode.integration);
|
|
95
|
+
return { orgAPI, orgName };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-contribution.js","sourceRoot":"","sources":["../src/document-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA0F;AAC1F,yBAAyB;AACzB,mCAAmC;AACnC,yCAA+F;AAC/F,mDAA0E;AAC1E,iCAA8C;AAK9C,MAAM,oBAAoB,GAAG,IAAA,mBAAY,EAAC,wBAAwB,CAAC,CAAC;AACpE,MAAM,cAAc,GAAG,IAAA,mBAAY,EAAC,wBAAwB,CAAC,CAAC;AAE9D,MAAM,WAAW,GAAG,IAAA,mBAAY,EAAC,uCAAuC,CAAC,CAAC;AAE1E,MAAM,SAAS,GAAG,IAAA,aAAM,EAAC,0CAA0C,CAAC,CAAC;AACrE,MAAM,QAAQ,GAAG,IAAA,aAAM,EAAC,yCAAyC,CAAC,CAAC;AACnE,MAAM,GAAG,GAAG,IAAA,aAAM,EAAC,6CAA6C,CAAC,CAAC;AAClE,MAAM,MAAM,GAAG,IAAA,aAAM,EAAC,sCAAsC,CAAC,CAAC;AAC9D,MAAM,GAAG,GAAG,IAAA,aAAM,EAAC,mCAAmC,CAAC,CAAC;AAExD,SAAsB,oBAAoB,CAAC,EACzC,mBAAmB,EACnB,GAAG,EAAE,aAAa,EAClB,SAAS,GAKV;;;QACC,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;QAE7E,MAAM,EAAE,MAAM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AAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC;CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -14,10 +14,12 @@ exports.program = void 0;
|
|
|
14
14
|
const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
15
15
|
const commander_1 = require("commander");
|
|
16
16
|
const dotenv = require("dotenv");
|
|
17
|
+
const document_consumption_1 = require("./document-consumption");
|
|
18
|
+
const document_contribution_1 = require("./document-contribution");
|
|
19
|
+
const link_management_1 = require("./link-management");
|
|
17
20
|
const org_management_1 = require("./org-management");
|
|
18
|
-
const person_management_1 = require("./person-management");
|
|
19
21
|
const patient_management_1 = require("./patient-management");
|
|
20
|
-
const
|
|
22
|
+
const person_management_1 = require("./person-management");
|
|
21
23
|
const util_1 = require("./util");
|
|
22
24
|
function metriportBanner() {
|
|
23
25
|
return `
|
|
@@ -87,7 +89,8 @@ function main() {
|
|
|
87
89
|
yield (0, person_management_1.personManagement)(commonWell, queryMeta);
|
|
88
90
|
yield (0, patient_management_1.patientManagement)(commonWell, commonWellSandbox, queryMeta);
|
|
89
91
|
yield (0, link_management_1.linkManagement)(commonWell, queryMeta);
|
|
92
|
+
yield (0, document_consumption_1.documentConsumption)(commonWell, queryMeta);
|
|
93
|
+
yield (0, document_contribution_1.documentContribution)({ memberManagementApi: commonWellMember, api: commonWell, queryMeta });
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
main();
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA+F;AAC/F,yCAAoC;AACpC,iCAAiC;AACjC,qDAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA+F;AAC/F,yCAAoC;AACpC,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AA6B,CAAC,CAAC;QAE7E,MAAM,iBAAiB,GAAG,IAAI,2BAAU,CACtC,cAAc,EACd,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAO,CAAC,WAAW,CACpB,CAAC;QAGF,MAAM,mBAAmB,GAAG,IAAA,mBAAY,EAAC,uBAAuB,CAAC,CAAC;QAElE,MAAM,gBAAgB,GAAG,IAAI,2BAAU,CACrC,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAO,CAAC,WAAW,CACpB,CAAC;QAEF,MAAM,SAAS,GAAoB;YACjC,YAAY,EAAE,6BAAY,CAAC,SAAS;YACpC,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,OAAO;SACnB,CAAC;QAIF,MAAM,IAAA,8BAAa,EAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;QACjD,MAAM,IAAA,oCAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC9C,MAAM,IAAA,sCAAiB,EAAC,UAAU,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;QAClE,MAAM,IAAA,gCAAc,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC5C,MAAM,IAAA,0CAAmB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACjD,MAAM,IAAA,4CAAoB,EAAC,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;IACpG,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
|
package/lib/link-management.js
CHANGED
|
@@ -15,25 +15,24 @@ const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
|
15
15
|
const payloads_1 = require("./payloads");
|
|
16
16
|
function linkManagement(commonWell, queryMeta) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
console.log(`>>>
|
|
18
|
+
console.log(`>>> C5a : Link a Patient to a Person upgrading from LOLA 1 to LOLA 2.`);
|
|
19
19
|
const person = yield commonWell.enrollPerson(queryMeta, payloads_1.personStrongId);
|
|
20
20
|
const personId = (0, commonwell_sdk_1.getId)(person);
|
|
21
|
-
const respPatient = yield commonWell.registerPatient(queryMeta, payloads_1.
|
|
21
|
+
const respPatient = yield commonWell.registerPatient(queryMeta, (0, payloads_1.makePatient)({ facilityId: commonWell.oid }));
|
|
22
22
|
const patientId = (0, commonwell_sdk_1.getIdTrailingSlash)(respPatient);
|
|
23
23
|
const referenceLink = respPatient._links.self.href;
|
|
24
24
|
const respC5a = yield commonWell.patientLink(queryMeta, personId, referenceLink);
|
|
25
25
|
console.log(respC5a);
|
|
26
|
-
console.log(`>>>
|
|
26
|
+
console.log(`>>> C5b : Upgrade Patient link from LOLA 2 to LOLA 3 (with Strong ID).`);
|
|
27
27
|
const respC5b = yield commonWell.updatePatientLink(queryMeta, respC5a._links.self.href, respPatient._links.self.href, payloads_1.identifier);
|
|
28
28
|
console.log(respC5b);
|
|
29
|
-
console.log(`>>>
|
|
29
|
+
console.log(`>>> C5c : Downgrade Patient link from LOLA 3 to LOLA 2 (without Strong ID).`);
|
|
30
30
|
const respC5c = yield commonWell.updatePatientLink(queryMeta, respC5a._links.self.href, respPatient._links.self.href, null);
|
|
31
31
|
console.log(respC5c);
|
|
32
|
-
console.log(`>>>
|
|
32
|
+
console.log(`>>> C5a : Delete Patient/Person link that exists as LOLA 2.`);
|
|
33
33
|
yield commonWell.deletePatientLink(queryMeta, respC5c._links.self.href);
|
|
34
34
|
yield commonWell.deletePerson(queryMeta, personId);
|
|
35
35
|
yield commonWell.deletePatient(queryMeta, patientId);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
exports.linkManagement = linkManagement;
|
|
39
|
-
//# sourceMappingURL=link-management.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-management.js","sourceRoot":"","sources":["../src/link-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAAmG;AAEnG,
|
|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,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAC5B,IAAI,CACL,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,MAAM,UAAU,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAGxE,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,UAAU,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;CAAA;AAvCD,wCAuCC"}
|
package/lib/org-management.js
CHANGED
|
@@ -16,12 +16,13 @@ const payloads_1 = require("./payloads");
|
|
|
16
16
|
function orgManagement(commonWell, queryMeta) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
console.log(`>>> Create an org`);
|
|
19
|
-
const
|
|
19
|
+
const org = (0, payloads_1.makeOrganization)();
|
|
20
|
+
const respCreateOrg = yield commonWell.createOrg(queryMeta, org);
|
|
20
21
|
console.log(respCreateOrg);
|
|
21
22
|
console.log(`>>> Update an org`);
|
|
22
|
-
|
|
23
|
+
org.locations[0].city = "Miami";
|
|
23
24
|
const orgId = (0, commonwell_sdk_1.getIdTrailingSlash)(respCreateOrg);
|
|
24
|
-
const respUpdateOrg = yield commonWell.updateOrg(queryMeta,
|
|
25
|
+
const respUpdateOrg = yield commonWell.updateOrg(queryMeta, org, orgId);
|
|
25
26
|
console.log(respUpdateOrg);
|
|
26
27
|
console.log(`>>> Get all orgs`);
|
|
27
28
|
const respGetAllOrgs = yield commonWell.getAllOrgs(queryMeta);
|
|
@@ -36,18 +37,17 @@ function orgManagement(commonWell, queryMeta) {
|
|
|
36
37
|
const respReplaceCertificateForOrg = yield commonWell.replaceCertificateForOrg(queryMeta, payloads_1.certificate, orgId);
|
|
37
38
|
console.log(respReplaceCertificateForOrg);
|
|
38
39
|
console.log(`>>> Get certificate from org`);
|
|
39
|
-
const
|
|
40
|
-
console.log(
|
|
40
|
+
const respGetCertificatesFromOrg = yield commonWell.getCertificatesFromOrg(queryMeta, orgId);
|
|
41
|
+
console.log(respGetCertificatesFromOrg);
|
|
41
42
|
console.log(`>>> Get certificate from org (by thumprint)`);
|
|
42
|
-
const
|
|
43
|
-
console.log(
|
|
43
|
+
const respGetCertificatesFromOrgByThumbprint = yield commonWell.getCertificatesFromOrgByThumbprint(queryMeta, orgId, payloads_1.thumbprint);
|
|
44
|
+
console.log(respGetCertificatesFromOrgByThumbprint);
|
|
44
45
|
console.log(`>>> Get certificate from org (by thumprint & purpose)`);
|
|
45
|
-
const
|
|
46
|
-
console.log(
|
|
46
|
+
const respGetCertificatesFromOrgByThumbprintAndPurpose = yield commonWell.getCertificatesFromOrgByThumbprintAndPurpose(queryMeta, orgId, payloads_1.thumbprint, payloads_1.certificate.Certificates[0].purpose);
|
|
47
|
+
console.log(respGetCertificatesFromOrgByThumbprintAndPurpose);
|
|
47
48
|
console.log(`>>> Delete certificate from org`);
|
|
48
49
|
yield commonWell.deleteCertificateFromOrg(queryMeta, orgId, payloads_1.thumbprint, payloads_1.certificate.Certificates[0].purpose);
|
|
49
50
|
console.log("Certificate deleted");
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
exports.orgManagement = orgManagement;
|
|
53
|
-
//# sourceMappingURL=org-management.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"org-management.js","sourceRoot":"","sources":["../src/org-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA4F;AAE5F,
|
|
1
|
+
{"version":3,"file":"org-management.js","sourceRoot":"","sources":["../src/org-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAA4F;AAE5F,yCAAuE;AAKvE,SAAsB,aAAa,CAAC,UAAsB,EAAE,SAA0B;;QACpF,OAAO,CAAC,GAAG,CA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,KAAK,CACN,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAE1C,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAC5C,MAAM,0BAA0B,GAAG,MAAM,UAAU,CAAC,sBAAsB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;QAC3D,MAAM,sCAAsC,GAC1C,MAAM,UAAU,CAAC,kCAAkC,CAAC,SAAS,EAAE,KAAK,EAAE,qBAAU,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;QAEpD,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;QACrE,MAAM,gDAAgD,GACpD,MAAM,UAAU,CAAC,4CAA4C,CAC3D,SAAS,EACT,KAAK,EACL,qBAAU,EACV,sBAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CACpC,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;QAE9D,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,UAAU,CAAC,wBAAwB,CACvC,SAAS,EACT,KAAK,EACL,qBAAU,EACV,sBAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CACpC,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACrC,CAAC;CAAA;AA/DD,sCA+DC"}
|
|
@@ -19,19 +19,20 @@ const commonwellSandboxOID = (0, util_1.getEnvOrFail)("COMMONWELL_SANDBOX_OID");
|
|
|
19
19
|
const commonwellSandboxOrgName = (0, util_1.getEnvOrFail)("COMMONWELL_SANDBOX_ORG_NAME");
|
|
20
20
|
function patientManagement(commonWell, commonwellSandbox, queryMeta) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const patient = (0, payloads_1.makePatient)({ facilityId: commonWell.oid });
|
|
22
23
|
console.log(`>>> D1b: Register a new Patient`);
|
|
23
|
-
const respD1b = yield commonWell.registerPatient(queryMeta,
|
|
24
|
+
const respD1b = yield commonWell.registerPatient(queryMeta, patient);
|
|
24
25
|
console.log(respD1b);
|
|
25
26
|
console.log(`>>> D2a: Update demographics for a local Patient `);
|
|
26
|
-
|
|
27
|
+
patient.details.name[0].family[0] = "Graham";
|
|
27
28
|
const patientId = (0, commonwell_sdk_1.getIdTrailingSlash)(respD1b);
|
|
28
|
-
const respD2a = yield commonWell.updatePatient(queryMeta,
|
|
29
|
+
const respD2a = yield commonWell.updatePatient(queryMeta, patient, patientId);
|
|
29
30
|
console.log(respD2a);
|
|
30
|
-
console.log(`>>> D3a:
|
|
31
|
-
const respD3a = yield commonWell.searchPatient(queryMeta,
|
|
31
|
+
console.log(`>>> D3a: Search for a Patient`);
|
|
32
|
+
const respD3a = yield commonWell.searchPatient(queryMeta, patient.details.name[0].given[0], patient.details.name[0].family[0], patient.details.birthDate, patient.details.gender.code, patient.details.address[0].zip);
|
|
32
33
|
console.log(respD3a);
|
|
33
34
|
console.log(`>>> D4a: Merge two Patient records`);
|
|
34
|
-
const respPatient2 = yield commonWell.registerPatient(queryMeta, payloads_1.
|
|
35
|
+
const respPatient2 = yield commonWell.registerPatient(queryMeta, (0, payloads_1.makeMergePatient)({ facilityId: commonWell.oid }));
|
|
35
36
|
const patientId2 = (0, commonwell_sdk_1.getIdTrailingSlash)(respPatient2);
|
|
36
37
|
const referenceLink = respD1b._links.self.href;
|
|
37
38
|
yield commonWell.mergePatients(queryMeta, patientId2, referenceLink);
|
|
@@ -40,7 +41,7 @@ function patientManagement(commonWell, commonwellSandbox, queryMeta) {
|
|
|
40
41
|
const person = yield commonWell.enrollPerson(queryMeta, payloads_1.personStrongId);
|
|
41
42
|
const personId = (0, commonwell_sdk_1.getId)(person);
|
|
42
43
|
yield commonWell.patientLink(queryMeta, personId, referenceLink);
|
|
43
|
-
|
|
44
|
+
const payloadSandboxPatient = (0, lodash_1.cloneDeep)(patient);
|
|
44
45
|
payloadSandboxPatient.identifier[0].system = `urn:oid:${commonwellSandboxOID}`;
|
|
45
46
|
payloadSandboxPatient.identifier[0].assigner = commonwellSandboxOrgName;
|
|
46
47
|
payloadSandboxPatient.identifier[0].label = commonwellSandboxOrgName;
|
|
@@ -65,4 +66,3 @@ function patientManagement(commonWell, commonwellSandbox, queryMeta) {
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
exports.patientManagement = patientManagement;
|
|
68
|
-
//# sourceMappingURL=patient-management.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patient-management.js","sourceRoot":"","sources":["../src/patient-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAMmC;AACnC,mCAAmC;AAEnC,
|
|
1
|
+
{"version":3,"file":"patient-management.js","sourceRoot":"","sources":["../src/patient-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAMmC;AACnC,mCAAmC;AAEnC,yCAA2E;AAE3E,iCAAsC;AAEtC,MAAM,oBAAoB,GAAG,IAAA,mBAAY,EAAC,wBAAwB,CAAC,CAAC;AACpE,MAAM,wBAAwB,GAAG,IAAA,mBAAY,EAAC,6BAA6B,CAAC,CAAC;AAK7E,SAAsB,iBAAiB,CACrC,UAAsB,EACtB,iBAA6B,EAC7B,SAA0B;;QAE1B,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC,EAAE,UAAU,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QAG5D,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,mDAAm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AAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CACrD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,KAAK,qBAAI,CAAC,OAAO,CAC7C,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,6BAA6B,CAC5D,SAAS,EACT,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CACjC,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,6BAA6B,CAC5D,SAAS,EACT,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAC9B,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAGrB,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAG5C,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,UAAU,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrD,MAAM,iBAAiB,CAAC,aAAa,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACrE,CAAC;CAAA;AAtFD,8CAsFC"}
|
package/lib/payloads.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { AddressUseCodes, IdentifierUseCodes, NameUseCodes, Person } from "@metriport/commonwell-sdk";
|
|
3
|
-
|
|
3
|
+
import { Demographics } from "@metriport/commonwell-sdk/lib/models/demographics";
|
|
4
|
+
export declare const CW_ID_PREFIX = "urn:oid:";
|
|
5
|
+
export declare function makeId(): string;
|
|
6
|
+
export declare function makeOrgId(orgId?: string): string;
|
|
7
|
+
export declare function makeFacilityId(orgId?: string): string;
|
|
8
|
+
export declare function makePatientId({ orgId, facilityId, }?: {
|
|
9
|
+
orgId?: string;
|
|
10
|
+
facilityId?: never;
|
|
11
|
+
} | {
|
|
12
|
+
orgId?: never;
|
|
13
|
+
facilityId?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
export declare const caDriversLicenseUri: string;
|
|
4
16
|
export declare const driversLicenseId: string;
|
|
5
17
|
export declare const identifier: {
|
|
6
18
|
use: IdentifierUseCodes;
|
|
@@ -10,9 +22,38 @@ export declare const identifier: {
|
|
|
10
22
|
start: string;
|
|
11
23
|
};
|
|
12
24
|
};
|
|
25
|
+
export declare const mainDetails: {
|
|
26
|
+
address: {
|
|
27
|
+
use: AddressUseCodes;
|
|
28
|
+
zip: string;
|
|
29
|
+
state: string;
|
|
30
|
+
line: string[];
|
|
31
|
+
city: string;
|
|
32
|
+
}[];
|
|
33
|
+
name: {
|
|
34
|
+
use: NameUseCodes;
|
|
35
|
+
given: string[];
|
|
36
|
+
family: string[];
|
|
37
|
+
}[];
|
|
38
|
+
gender: {
|
|
39
|
+
code: string;
|
|
40
|
+
};
|
|
41
|
+
birthDate: string;
|
|
42
|
+
identifier: {
|
|
43
|
+
use: IdentifierUseCodes;
|
|
44
|
+
key: string;
|
|
45
|
+
system: string;
|
|
46
|
+
period: {
|
|
47
|
+
start: string;
|
|
48
|
+
};
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
13
51
|
export declare const personStrongId: Person;
|
|
14
52
|
export declare const personNoStrongId: Person;
|
|
15
|
-
export declare const
|
|
53
|
+
export declare const makePatient: ({ facilityId, details, }?: {
|
|
54
|
+
facilityId?: string;
|
|
55
|
+
details?: Demographics;
|
|
56
|
+
}) => {
|
|
16
57
|
identifier: {
|
|
17
58
|
use: string;
|
|
18
59
|
label: string;
|
|
@@ -21,33 +62,134 @@ export declare const patient: {
|
|
|
21
62
|
assigner: string;
|
|
22
63
|
}[];
|
|
23
64
|
details: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
65
|
+
identifier?: {
|
|
66
|
+
system?: string;
|
|
67
|
+
key?: string;
|
|
68
|
+
use?: string;
|
|
69
|
+
label?: string;
|
|
70
|
+
period?: {
|
|
71
|
+
start?: string;
|
|
72
|
+
end?: string;
|
|
73
|
+
};
|
|
74
|
+
assigner?: string;
|
|
30
75
|
}[];
|
|
31
|
-
name
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
76
|
+
name?: {
|
|
77
|
+
text?: string;
|
|
78
|
+
use?: string;
|
|
79
|
+
period?: {
|
|
80
|
+
start?: string;
|
|
81
|
+
end?: string;
|
|
82
|
+
};
|
|
83
|
+
family?: string[];
|
|
84
|
+
given?: string[];
|
|
85
|
+
prefix?: string;
|
|
86
|
+
suffix?: string;
|
|
35
87
|
}[];
|
|
36
|
-
|
|
37
|
-
|
|
88
|
+
telecom?: {
|
|
89
|
+
value?: string;
|
|
90
|
+
system?: string;
|
|
91
|
+
use?: string;
|
|
92
|
+
period?: {
|
|
93
|
+
start?: string;
|
|
94
|
+
end?: string;
|
|
95
|
+
};
|
|
96
|
+
}[];
|
|
97
|
+
gender?: {
|
|
98
|
+
code?: string;
|
|
99
|
+
system?: string;
|
|
100
|
+
display?: string;
|
|
38
101
|
};
|
|
39
|
-
birthDate
|
|
40
|
-
|
|
41
|
-
use
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
start: string;
|
|
102
|
+
birthDate?: string;
|
|
103
|
+
address?: {
|
|
104
|
+
use?: string;
|
|
105
|
+
period?: {
|
|
106
|
+
start?: string;
|
|
107
|
+
end?: string;
|
|
46
108
|
};
|
|
109
|
+
line?: string[];
|
|
110
|
+
city?: string;
|
|
111
|
+
state?: string;
|
|
112
|
+
zip?: string;
|
|
113
|
+
country?: string;
|
|
47
114
|
}[];
|
|
115
|
+
picture?: any;
|
|
48
116
|
};
|
|
49
117
|
};
|
|
50
|
-
export declare const
|
|
118
|
+
export declare const makeMergePatient: ({ facilityId }?: {
|
|
119
|
+
facilityId?: string;
|
|
120
|
+
}) => {
|
|
121
|
+
identifier: {
|
|
122
|
+
use: string;
|
|
123
|
+
label: string;
|
|
124
|
+
system: string;
|
|
125
|
+
key: string;
|
|
126
|
+
assigner: string;
|
|
127
|
+
}[];
|
|
128
|
+
details: {
|
|
129
|
+
identifier?: {
|
|
130
|
+
system?: string;
|
|
131
|
+
key?: string;
|
|
132
|
+
use?: string;
|
|
133
|
+
label?: string;
|
|
134
|
+
period?: {
|
|
135
|
+
start?: string;
|
|
136
|
+
end?: string;
|
|
137
|
+
};
|
|
138
|
+
assigner?: string;
|
|
139
|
+
}[];
|
|
140
|
+
name?: {
|
|
141
|
+
text?: string;
|
|
142
|
+
use?: string;
|
|
143
|
+
period?: {
|
|
144
|
+
start?: string;
|
|
145
|
+
end?: string;
|
|
146
|
+
};
|
|
147
|
+
family?: string[];
|
|
148
|
+
given?: string[];
|
|
149
|
+
prefix?: string;
|
|
150
|
+
suffix?: string;
|
|
151
|
+
}[];
|
|
152
|
+
telecom?: {
|
|
153
|
+
value?: string;
|
|
154
|
+
system?: string;
|
|
155
|
+
use?: string;
|
|
156
|
+
period?: {
|
|
157
|
+
start?: string;
|
|
158
|
+
end?: string;
|
|
159
|
+
};
|
|
160
|
+
}[];
|
|
161
|
+
gender?: {
|
|
162
|
+
code?: string;
|
|
163
|
+
system?: string;
|
|
164
|
+
display?: string;
|
|
165
|
+
};
|
|
166
|
+
birthDate?: string;
|
|
167
|
+
address?: {
|
|
168
|
+
use?: string;
|
|
169
|
+
period?: {
|
|
170
|
+
start?: string;
|
|
171
|
+
end?: string;
|
|
172
|
+
};
|
|
173
|
+
line?: string[];
|
|
174
|
+
city?: string;
|
|
175
|
+
state?: string;
|
|
176
|
+
zip?: string;
|
|
177
|
+
country?: string;
|
|
178
|
+
}[];
|
|
179
|
+
picture?: any;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
export type PersonData = {
|
|
183
|
+
firstName?: string;
|
|
184
|
+
lastName?: string;
|
|
185
|
+
dob?: string;
|
|
186
|
+
gender?: string;
|
|
187
|
+
zip?: string;
|
|
188
|
+
};
|
|
189
|
+
type PersonDataOnOrg = PersonData & {
|
|
190
|
+
facilityId?: string;
|
|
191
|
+
};
|
|
192
|
+
export declare const makeDocPatient: ({ firstName, lastName, dob, gender, zip, facilityId, }?: PersonDataOnOrg) => {
|
|
51
193
|
identifier: {
|
|
52
194
|
use: string;
|
|
53
195
|
label: string;
|
|
@@ -57,24 +199,48 @@ export declare const mergePatient: {
|
|
|
57
199
|
}[];
|
|
58
200
|
details: {
|
|
59
201
|
address: {
|
|
60
|
-
use:
|
|
202
|
+
use: NameUseCodes;
|
|
61
203
|
zip: string;
|
|
62
|
-
|
|
63
|
-
line: string[];
|
|
64
|
-
city: string;
|
|
204
|
+
country: string;
|
|
65
205
|
}[];
|
|
66
206
|
name: {
|
|
67
207
|
use: NameUseCodes;
|
|
208
|
+
family: string[];
|
|
68
209
|
given: string[];
|
|
210
|
+
}[];
|
|
211
|
+
gender: {
|
|
212
|
+
code: string;
|
|
213
|
+
};
|
|
214
|
+
birthDate: string;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
export declare const makeDocPerson: (init?: PersonDataOnOrg) => {
|
|
218
|
+
details: {
|
|
219
|
+
identifier: any[];
|
|
220
|
+
address: {
|
|
221
|
+
use: NameUseCodes;
|
|
222
|
+
zip: string;
|
|
223
|
+
country: string;
|
|
224
|
+
}[];
|
|
225
|
+
name: {
|
|
226
|
+
use: NameUseCodes;
|
|
69
227
|
family: string[];
|
|
228
|
+
given: string[];
|
|
70
229
|
}[];
|
|
71
230
|
gender: {
|
|
72
231
|
code: string;
|
|
73
232
|
};
|
|
74
233
|
birthDate: string;
|
|
75
234
|
};
|
|
235
|
+
identifier: {
|
|
236
|
+
use: string;
|
|
237
|
+
label: string;
|
|
238
|
+
system: string;
|
|
239
|
+
key: string;
|
|
240
|
+
assigner: string;
|
|
241
|
+
}[];
|
|
76
242
|
};
|
|
77
|
-
export declare const
|
|
243
|
+
export declare const makeOrganization: (suffixId?: string) => {
|
|
78
244
|
organizationId: string;
|
|
79
245
|
homeCommunityId: string;
|
|
80
246
|
name: string;
|
|
@@ -113,3 +279,4 @@ export declare const certificate: {
|
|
|
113
279
|
purpose: string;
|
|
114
280
|
}[];
|
|
115
281
|
};
|
|
282
|
+
export {};
|
package/lib/payloads.js
CHANGED
|
@@ -1,17 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.certificate = exports.thumbprint = exports.
|
|
4
|
+
exports.certificate = exports.thumbprint = exports.makeOrganization = exports.makeDocPerson = exports.makeDocPatient = exports.makeMergePatient = exports.makePatient = exports.personNoStrongId = exports.personStrongId = exports.mainDetails = exports.identifier = exports.driversLicenseId = exports.caDriversLicenseUri = exports.makePatientId = exports.makeFacilityId = exports.makeOrgId = exports.makeId = exports.CW_ID_PREFIX = void 0;
|
|
5
5
|
const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
6
|
-
const nanoid = require("nanoid");
|
|
7
6
|
const crypto_1 = require("crypto");
|
|
7
|
+
const nanoid = require("nanoid");
|
|
8
8
|
const unique_names_generator_1 = require("unique-names-generator");
|
|
9
9
|
const util_1 = require("./util");
|
|
10
10
|
const commonwellOID = (0, util_1.getEnvOrFail)("COMMONWELL_OID");
|
|
11
|
-
const commonwellCertificateContent = (0, util_1.getEnvOrFail)("COMMONWELL_CERTIFICATE_CONTENT");
|
|
12
|
-
const commonwellCertificate = (0, util_1.getEnvOrFail)("COMMONWELL_CERTIFICATE");
|
|
13
11
|
const commonwellOrgName = (0, util_1.getEnvOrFail)("COMMONWELL_ORG_NAME");
|
|
14
|
-
|
|
12
|
+
const commonwellCertificate = (0, util_1.getEnvOrFail)("COMMONWELL_CERTIFICATE");
|
|
13
|
+
const commonwellCertificateContent = (0, util_1.getCertificateContent)(commonwellCertificate);
|
|
14
|
+
const docPatientFirstName = (0, util_1.getEnvOrFail)("DOCUMENT_PATIENT_FIRST_NAME");
|
|
15
|
+
const docPatientLastName = (0, util_1.getEnvOrFail)("DOCUMENT_PATIENT_LAST_NAME");
|
|
16
|
+
const docPatientDateOfBirth = (0, util_1.getEnvOrFail)("DOCUMENT_PATIENT_DATE_OF_BIRTH");
|
|
17
|
+
const docPatientGender = (0, util_1.getEnvOrFail)("DOCUMENT_PATIENT_GENDER");
|
|
18
|
+
const docPatientZip = (0, util_1.getEnvOrFail)("DOCUMENT_PATIENT_ZIP");
|
|
19
|
+
const ORGANIZATION = "5";
|
|
20
|
+
const LOCATION = "4";
|
|
21
|
+
const PATIENT = "2";
|
|
22
|
+
const idAlphabet = "123456789";
|
|
23
|
+
exports.CW_ID_PREFIX = "urn:oid:";
|
|
24
|
+
function makeId() {
|
|
25
|
+
return nanoid.customAlphabet(idAlphabet, 6)();
|
|
26
|
+
}
|
|
27
|
+
exports.makeId = makeId;
|
|
28
|
+
function makeOrgId(orgId) {
|
|
29
|
+
const org = orgId !== null && orgId !== void 0 ? orgId : makeId();
|
|
30
|
+
return `${commonwellOID}.${ORGANIZATION}.${org}`;
|
|
31
|
+
}
|
|
32
|
+
exports.makeOrgId = makeOrgId;
|
|
33
|
+
function makeFacilityId(orgId) {
|
|
34
|
+
const facility = makeId();
|
|
35
|
+
return orgId ? `${orgId}.${LOCATION}.${facility}` : `${makeOrgId()}.${LOCATION}.${facility}`;
|
|
36
|
+
}
|
|
37
|
+
exports.makeFacilityId = makeFacilityId;
|
|
38
|
+
function makePatientId({ orgId, facilityId, } = {}) {
|
|
39
|
+
const org = orgId !== null && orgId !== void 0 ? orgId : makeOrgId();
|
|
40
|
+
const facility = facilityId !== null && facilityId !== void 0 ? facilityId : makeFacilityId(org);
|
|
41
|
+
const patient = makeId();
|
|
42
|
+
return `${facility}.${PATIENT}.${patient}`;
|
|
43
|
+
}
|
|
44
|
+
exports.makePatientId = makePatientId;
|
|
45
|
+
exports.caDriversLicenseUri = `${exports.CW_ID_PREFIX}2.16.840.1.113883.4.3.6`;
|
|
15
46
|
exports.driversLicenseId = nanoid.nanoid();
|
|
16
47
|
exports.identifier = {
|
|
17
48
|
use: commonwell_sdk_1.IdentifierUseCodes.usual,
|
|
@@ -21,7 +52,7 @@ exports.identifier = {
|
|
|
21
52
|
start: "1996-04-20T00:00:00Z",
|
|
22
53
|
},
|
|
23
54
|
};
|
|
24
|
-
|
|
55
|
+
exports.mainDetails = {
|
|
25
56
|
address: [
|
|
26
57
|
{
|
|
27
58
|
use: commonwell_sdk_1.AddressUseCodes.home,
|
|
@@ -67,73 +98,96 @@ const secondaryDetails = {
|
|
|
67
98
|
birthDate: "2000-04-20T00:00:00Z",
|
|
68
99
|
};
|
|
69
100
|
exports.personStrongId = {
|
|
70
|
-
details: Object.assign(Object.assign({}, mainDetails), { identifier: [exports.identifier] }),
|
|
101
|
+
details: Object.assign(Object.assign({}, exports.mainDetails), { identifier: [exports.identifier] }),
|
|
71
102
|
};
|
|
72
103
|
exports.personNoStrongId = {
|
|
73
104
|
details: secondaryDetails,
|
|
74
105
|
};
|
|
75
|
-
exports.
|
|
106
|
+
const makePatient = ({ facilityId = makeFacilityId(), details = exports.mainDetails, } = {}) => ({
|
|
76
107
|
identifier: [
|
|
77
108
|
{
|
|
78
109
|
use: "unspecified",
|
|
79
110
|
label: commonwellOrgName,
|
|
80
|
-
system:
|
|
81
|
-
key:
|
|
111
|
+
system: `${exports.CW_ID_PREFIX}${facilityId}`,
|
|
112
|
+
key: makePatientId({ facilityId }),
|
|
82
113
|
assigner: commonwellOrgName,
|
|
83
114
|
},
|
|
84
115
|
],
|
|
85
|
-
details
|
|
86
|
-
};
|
|
87
|
-
exports.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
116
|
+
details,
|
|
117
|
+
});
|
|
118
|
+
exports.makePatient = makePatient;
|
|
119
|
+
const makeMergePatient = ({ facilityId = makeFacilityId() } = {}) => (0, exports.makePatient)({ facilityId, details: secondaryDetails });
|
|
120
|
+
exports.makeMergePatient = makeMergePatient;
|
|
121
|
+
const makeDocPatient = ({ firstName = docPatientFirstName, lastName = docPatientLastName, dob = docPatientDateOfBirth, gender = docPatientGender, zip = docPatientZip, facilityId = makeFacilityId(), } = {}) => ({
|
|
122
|
+
identifier: (0, exports.makePatient)({ facilityId }).identifier,
|
|
123
|
+
details: {
|
|
124
|
+
address: [
|
|
125
|
+
{
|
|
126
|
+
use: commonwell_sdk_1.NameUseCodes.usual,
|
|
127
|
+
zip,
|
|
128
|
+
country: "USA",
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
name: [
|
|
132
|
+
{
|
|
133
|
+
use: commonwell_sdk_1.NameUseCodes.usual,
|
|
134
|
+
family: [lastName],
|
|
135
|
+
given: [firstName],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
gender: {
|
|
139
|
+
code: gender,
|
|
95
140
|
},
|
|
96
|
-
|
|
97
|
-
|
|
141
|
+
birthDate: dob,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
exports.makeDocPatient = makeDocPatient;
|
|
145
|
+
const makeDocPerson = (init) => {
|
|
146
|
+
const docPatient = (0, exports.makeDocPatient)(init);
|
|
147
|
+
return Object.assign(Object.assign({}, docPatient), { details: Object.assign(Object.assign({}, docPatient.details), { identifier: [] }) });
|
|
98
148
|
};
|
|
99
|
-
|
|
149
|
+
exports.makeDocPerson = makeDocPerson;
|
|
100
150
|
const shortName = (0, unique_names_generator_1.uniqueNamesGenerator)({
|
|
101
151
|
dictionaries: [unique_names_generator_1.adjectives, unique_names_generator_1.colors, unique_names_generator_1.animals],
|
|
102
152
|
separator: "-",
|
|
103
153
|
length: 3,
|
|
104
154
|
});
|
|
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
|
-
|
|
155
|
+
const makeOrganization = (suffixId) => {
|
|
156
|
+
const orgId = makeOrgId(suffixId);
|
|
157
|
+
return {
|
|
158
|
+
organizationId: `${exports.CW_ID_PREFIX}${orgId}`,
|
|
159
|
+
homeCommunityId: `${exports.CW_ID_PREFIX}${orgId}`,
|
|
160
|
+
name: shortName,
|
|
161
|
+
displayName: shortName,
|
|
162
|
+
memberName: "Metriport",
|
|
163
|
+
type: "Hospital",
|
|
164
|
+
patientIdAssignAuthority: `${exports.CW_ID_PREFIX}${orgId}`,
|
|
165
|
+
securityTokenKeyType: "BearerKey",
|
|
166
|
+
isActive: true,
|
|
167
|
+
locations: [
|
|
168
|
+
{
|
|
169
|
+
address1: "1 Main Street",
|
|
170
|
+
address2: "PO Box 123",
|
|
171
|
+
city: "Denver",
|
|
172
|
+
state: "CO",
|
|
173
|
+
postalCode: "80001",
|
|
174
|
+
country: "USA",
|
|
175
|
+
phone: "303-555-1212",
|
|
176
|
+
fax: "303-555-1212",
|
|
177
|
+
email: "here@dummymail.com",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
technicalContacts: [
|
|
181
|
+
{
|
|
182
|
+
name: "Technician",
|
|
183
|
+
title: "TechnicalContact",
|
|
184
|
+
email: "technicalContact@dummymail.com",
|
|
185
|
+
phone: "303-555-1212",
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
};
|
|
136
189
|
};
|
|
190
|
+
exports.makeOrganization = makeOrganization;
|
|
137
191
|
const x509 = new crypto_1.X509Certificate(commonwellCertificate);
|
|
138
192
|
exports.thumbprint = x509.fingerprint;
|
|
139
193
|
exports.certificate = {
|
|
@@ -146,6 +200,13 @@ exports.certificate = {
|
|
|
146
200
|
content: commonwellCertificateContent,
|
|
147
201
|
purpose: "Authentication",
|
|
148
202
|
},
|
|
203
|
+
{
|
|
204
|
+
startDate: "2022-12-31T11:46:29Z",
|
|
205
|
+
endDate: "2023-03-31T12:46:28Z",
|
|
206
|
+
expirationDate: "2023-03-31T12:46:28Z",
|
|
207
|
+
thumbprint: exports.thumbprint,
|
|
208
|
+
content: commonwellCertificateContent,
|
|
209
|
+
purpose: "Signing",
|
|
210
|
+
},
|
|
149
211
|
],
|
|
150
212
|
};
|
|
151
|
-
//# sourceMappingURL=payloads.js.map
|
package/lib/payloads.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../src/payloads.ts"],"names":[],"mappings":";;;;AACA,8DAKmC;
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../src/payloads.ts"],"names":[],"mappings":";;;;AACA,8DAKmC;AAEnC,mCAAyC;AACzC,iCAAiC;AAEjC,mEAA2F;AAC3F,iCAA6D;AAE7D,MAAM,aAAa,GAAG,IAAA,mBAAY,EAAC,gBAAgB,CAAC,CAAC;AACrD,MAAM,iBAAiB,GAAG,IAAA,mBAAY,EAAC,qBAAqB,CAAC,CAAC;AAC9D,MAAM,qBAAqB,GAAG,IAAA,mBAAY,EAAC,wBAAwB,CAAC,CAAC;AACrE,MAAM,4BAA4B,GAAG,IAAA,4BAAqB,EAAC,qBAAqB,CAAC,CAAC;AAElF,MAAM,mBAAmB,GAAG,IAAA,mBAAY,EAAC,6BAA6B,CAAC,CAAC;AACxE,MAAM,kBAAkB,GAAG,IAAA,mBAAY,EAAC,4BAA4B,CAAC,CAAC;AACtE,MAAM,qBAAqB,GAAG,IAAA,mBAAY,EAAC,gCAAgC,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG,IAAA,mBAAY,EAAC,yBAAyB,CAAC,CAA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;YACjB;gBACE,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,kBAAkB;gBACzB,KAAK,EAAE,gCAAgC;gBACvC,KAAK,EAAE,cAAc;aACtB;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B;AAGF,MAAM,IAAI,GAAG,IAAI,wBAAe,CAAC,qBAAqB,CAAC,CAAC;AAE3C,QAAA,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;AAC9B,QAAA,WAAW,GAAG;IACzB,YAAY,EAAE;QACZ;YACE,SAAS,EAAE,sBAAsB;YACjC,OAAO,EAAE,sBAAsB;YAC/B,cAAc,EAAE,sBAAsB;YACtC,UAAU,EAAE,kBAAU;YACtB,OAAO,EAAE,4BAA4B;YACrC,OAAO,EAAE,gBAAgB;SAC1B;QACD;YACE,SAAS,EAAE,sBAAsB;YACjC,OAAO,EAAE,sBAAsB;YAC/B,cAAc,EAAE,sBAAsB;YACtC,UAAU,EAAE,kBAAU;YACtB,OAAO,EAAE,4BAA4B;YACrC,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC"}
|
package/lib/person-management.js
CHANGED
|
@@ -27,7 +27,7 @@ function personManagement(commonWell, queryMeta) {
|
|
|
27
27
|
console.log(respC2a);
|
|
28
28
|
console.log(`>>> C2b: Search for a Person using the local Patient demographics.`);
|
|
29
29
|
const personId = (0, commonwell_sdk_1.getId)(respC1a);
|
|
30
|
-
const newPatient = yield commonWell.registerPatient(queryMeta, payloads_1.
|
|
30
|
+
const newPatient = yield commonWell.registerPatient(queryMeta, (0, payloads_1.makePatient)({ facilityId: commonWell.oid }));
|
|
31
31
|
const patientId = (0, commonwell_sdk_1.getIdTrailingSlash)(newPatient);
|
|
32
32
|
const respC2b = yield commonWell.searchPersonByPatientDemo(queryMeta, patientId);
|
|
33
33
|
console.log(respC2b);
|
|
@@ -63,4 +63,3 @@ function personManagement(commonWell, queryMeta) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
exports.personManagement = personManagement;
|
|
66
|
-
//# sourceMappingURL=person-management.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"person-management.js","sourceRoot":"","sources":["../src/person-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAMmC;AACnC,iCAAiC;AAEjC,yCAMoB;AAKpB,SAAsB,gBAAgB,CAAC,UAAsB,EAAE,SAA0B;;QAEvF,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,yBAAc,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,2BAAgB,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAGrB,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,2BAAgB,EAAE,8BAAmB,CAAC,CAAC;QAChG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;QAClF,MAAM,QAAQ,GAAG,IAAA,sBAAK,EAAC,OAAO,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"person-management.js","sourceRoot":"","sources":["../src/person-management.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,8DAMmC;AACnC,iCAAiC;AAEjC,yCAMoB;AAKpB,SAAsB,gBAAgB,CAAC,UAAsB,EAAE,SAA0B;;QAEvF,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC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}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommonWell, RequestMetadata } from "@metriport/commonwell-sdk";
|
|
2
|
+
import { makeDocPerson, makePatient } from "./payloads";
|
|
3
|
+
export declare function findOrCreatePerson(commonWell: CommonWell, queryMeta: RequestMetadata, patientData: ReturnType<typeof makeDocPerson> | ReturnType<typeof makePatient>): Promise<{
|
|
4
|
+
patientId: string;
|
|
5
|
+
personId: string;
|
|
6
|
+
}>;
|
|
7
|
+
type FindOrCreatePatientResult = {
|
|
8
|
+
result: "existing";
|
|
9
|
+
patientId: string;
|
|
10
|
+
personId: string;
|
|
11
|
+
} | {
|
|
12
|
+
result: "new";
|
|
13
|
+
patientId: string;
|
|
14
|
+
patientLink: string;
|
|
15
|
+
patientStrongId?: {
|
|
16
|
+
key?: string;
|
|
17
|
+
system?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function findOrCreatePatient(commonWell: CommonWell, queryMeta: RequestMetadata, patientData: ReturnType<typeof makeDocPerson> | ReturnType<typeof makePatient>, personId?: string): Promise<FindOrCreatePatientResult>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.findOrCreatePatient = exports.findOrCreatePerson = void 0;
|
|
13
|
+
const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
|
|
14
|
+
const util_1 = require("@metriport/commonwell-sdk/lib/common/util");
|
|
15
|
+
const util_2 = require("./util");
|
|
16
|
+
const commonwellOID = (0, util_2.getEnvOrFail)("COMMONWELL_OID");
|
|
17
|
+
const prefixedCommonwellOID = `urn:oid:${commonwellOID}`;
|
|
18
|
+
function findOrCreatePerson(commonWell, queryMeta, patientData) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const res = yield findOrCreatePatient(commonWell, queryMeta, patientData);
|
|
21
|
+
if (res.result === "new") {
|
|
22
|
+
const { patientId, patientLink, patientStrongId } = res;
|
|
23
|
+
const respPerson = yield commonWell.enrollPerson(queryMeta, patientData);
|
|
24
|
+
console.log(respPerson);
|
|
25
|
+
const personId = (0, commonwell_sdk_1.getId)(respPerson);
|
|
26
|
+
const respLink = yield commonWell.patientLink(queryMeta, personId, patientLink, patientStrongId);
|
|
27
|
+
console.log(respLink);
|
|
28
|
+
return { patientId, personId };
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { patientId, personId } = res;
|
|
32
|
+
return { patientId, personId };
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.findOrCreatePerson = findOrCreatePerson;
|
|
37
|
+
function findOrCreatePatient(commonWell, queryMeta, patientData, personId) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const respPatient = yield commonWell.searchPatient(queryMeta, patientData.details.name[0].given[0], patientData.details.name[0].family[0], patientData.details.birthDate, patientData.details.gender.code, patientData.details.address[0].zip);
|
|
41
|
+
console.log(respPatient);
|
|
42
|
+
if (((_b = (_a = respPatient._embedded) === null || _a === void 0 ? void 0 : _a.patient) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
43
|
+
const embeddedPatients = respPatient._embedded.patient;
|
|
44
|
+
if (embeddedPatients.length > 1) {
|
|
45
|
+
console.log(`Found more than one patient, using the first one`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(`Found a patient, using it`);
|
|
49
|
+
}
|
|
50
|
+
const patient = embeddedPatients[0];
|
|
51
|
+
const patientId = (0, commonwell_sdk_1.getIdTrailingSlash)(patient);
|
|
52
|
+
const respPerson = yield commonWell.searchPersonByPatientDemo(queryMeta, patientId);
|
|
53
|
+
console.log(respPerson);
|
|
54
|
+
const personId = (0, commonwell_sdk_1.getPersonIdFromSearchByPatientDemo)(respPerson);
|
|
55
|
+
return { result: "existing", patientId, personId };
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(`Did not find a patient, creating one`);
|
|
59
|
+
const respPatientCreate = yield commonWell.registerPatient(queryMeta, patientData);
|
|
60
|
+
console.log(respPatientCreate);
|
|
61
|
+
const patientId = (0, commonwell_sdk_1.getIdTrailingSlash)(respPatientCreate);
|
|
62
|
+
const patientLink = respPatientCreate._links.self.href;
|
|
63
|
+
const patientStrongIds = (0, util_1.getPatientStrongIds)(respPatientCreate);
|
|
64
|
+
const patientStrongId = patientStrongIds
|
|
65
|
+
? patientStrongIds.find(id => id.system === prefixedCommonwellOID)
|
|
66
|
+
: undefined;
|
|
67
|
+
if (personId) {
|
|
68
|
+
const respLink = yield commonWell.patientLink(queryMeta, personId, patientLink, patientStrongId);
|
|
69
|
+
console.log(respLink);
|
|
70
|
+
}
|
|
71
|
+
return { result: "new", patientId, patientLink, patientStrongId };
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.findOrCreatePatient = findOrCreatePatient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-person.js","sourceRoot":"","sources":["../src/shared-person.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8DAMmC;AACnC,oEAAgF;AAEhF,iCAAsC;AAEtC,MAAM,aAAa,GAAG,IAAA,mBAAY,EAAC,gBAA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,IAAI,CAAC,IAAI,CAAC;YACvD,MAAM,gBAAgB,GAAG,IAAA,0BAAmB,EAAC,iBAAiB,CAAC,CAAC;YAChE,MAAM,eAAe,GAAG,gBAAgB;gBACtC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,qBAAqB,CAAC;gBAClE,CAAC,CAAC,SAAS,CAAC;YACd,IAAI,QAAQ,EAAE;gBAEZ,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,WAAW,CAC3C,SAAS,EACT,QAAQ,EACR,WAAW,EACX,eAAe,CAChB,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aACvB;YACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;SACnE;;CACF;AAxDD,kDAwDC"}
|
package/lib/util.d.ts
CHANGED
package/lib/util.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEnvOrFail = void 0;
|
|
3
|
+
exports.getCertificateContent = exports.getEnvOrFail = exports.getEnv = void 0;
|
|
4
4
|
const dotenv = require("dotenv");
|
|
5
5
|
dotenv.config();
|
|
6
|
+
function getEnv(name) {
|
|
7
|
+
return process.env[name];
|
|
8
|
+
}
|
|
9
|
+
exports.getEnv = getEnv;
|
|
6
10
|
function getEnvOrFail(name) {
|
|
7
|
-
const value =
|
|
11
|
+
const value = getEnv(name);
|
|
8
12
|
if (!value || value.trim().length < 1)
|
|
9
13
|
throw new Error(`Missing env var ${name}`);
|
|
10
14
|
return value;
|
|
11
15
|
}
|
|
12
16
|
exports.getEnvOrFail = getEnvOrFail;
|
|
13
|
-
|
|
17
|
+
function getCertificateContent(cert) {
|
|
18
|
+
const regex = /-+BEGIN CERTIFICATE-+([\s\S]+?)-+END CERTIFICATE-+/i;
|
|
19
|
+
const matches = cert.match(regex);
|
|
20
|
+
if (matches && matches.length > 1) {
|
|
21
|
+
const content = matches[1];
|
|
22
|
+
return content.replace(/\r\n|\n|\r/gm, "");
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
exports.getCertificateContent = getCertificateContent;
|
package/lib/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,SAAgB,
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,SAAgB,MAAM,CAAC,IAAY;IACjC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAFD,wBAEC;AACD,SAAgB,YAAY,CAAC,IAAY;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;IAClF,OAAO,KAAK,CAAC;AACf,CAAC;AAJD,oCAIC;AAED,SAAgB,qBAAqB,CAAC,IAAY;IAChD,MAAM,KAAK,GAAG,qDAAqD,CAAC;IACpE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;KAC5C;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AARD,sDAQC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metriport/commonwell-cert-runner",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Tool to run through Edge System CommonWell certification test cases - by Metriport Inc.",
|
|
5
5
|
"author": "Metriport Inc. <contact@metriport.com>",
|
|
6
6
|
"homepage": "https://metriport.com/",
|
|
@@ -24,10 +24,14 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"tsc": "tsc",
|
|
27
|
-
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
28
27
|
"build": "tsc -p .",
|
|
29
28
|
"install-local": "sudo npm i -g",
|
|
30
|
-
"start": "ts-node src/index.ts --env-file .env"
|
|
29
|
+
"start": "ts-node src/index.ts --env-file .env",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"lint": "npx eslint . --ext .ts",
|
|
32
|
+
"lint-fix": "npm run lint --fix",
|
|
33
|
+
"prettier-fix": "npx prettier '**/*.ts' --write",
|
|
34
|
+
"test": "echo \"No test specified yet\""
|
|
31
35
|
},
|
|
32
36
|
"bin": {
|
|
33
37
|
"cw-cert-runner": "lib/index.js"
|
|
@@ -42,12 +46,12 @@
|
|
|
42
46
|
"typescript": "^4.9.4"
|
|
43
47
|
},
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@metriport/commonwell-sdk": "^1.1.
|
|
49
|
+
"@metriport/commonwell-sdk": "^1.1.3",
|
|
46
50
|
"commander": "^9.5.0",
|
|
47
51
|
"dotenv": "^16.0.3",
|
|
48
52
|
"lodash": "^4.17.21",
|
|
49
53
|
"nanoid": "^3.3.4",
|
|
50
54
|
"unique-names-generator": "^4.7.1"
|
|
51
55
|
},
|
|
52
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1c16cbb9f40a7cb58b4c0d4b7943f5c430d9cfb4"
|
|
53
57
|
}
|