@metriport/commonwell-cert-runner 1.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License Copyright (c) 2022 Metriport Inc.
2
+
3
+ Permission is hereby granted, free of
4
+ charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ (including the next paragraph) shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # `commonwell-cert-runner`
2
+
3
+ CommonWell Certification Runner by Metriport Inc.
4
+
5
+ Tool to run through Edge System CommonWell certification test cases.
6
+
7
+ ## Install
8
+
9
+ To install the program, execute the following command on your terminal:
10
+
11
+ `npm i -g @metriport/commonwell-cert-runner`
12
+
13
+ Note: you may have to run the command with `sudo`.
14
+
15
+ ## Usage
16
+
17
+ After installation, create a `.env` file defining the following variables:
18
+
19
+ - `COMMONWELL_ORG_NAME`: the organization that will be making the requests.
20
+ - `COMMONWELL_OID`: the organization ID.
21
+ - `COMMONWELL_PRIVATE_KEY`: the RSA256 private key corresponding to the specified organization.
22
+ - `COMMONWELL_CERTIFICATE`: the public certificate/key corresponding to the private key.
23
+
24
+ Example file content looks like:
25
+
26
+ ```
27
+ COMMONWELL_ORG_NAME=Metriport
28
+ COMMONWELL_OID=2.16.840.1.113883.3.9621
29
+ COMMONWELL_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
30
+ fkadsjhfhdsakjfhdsakhfkdsahfadshfkhdsfhdsakfdhafkashdfkjhalsdkjf
31
+ -----END PRIVATE KEY-----
32
+ "
33
+ COMMONWELL_CERTIFICATE="-----BEGIN CERTIFICATE-----
34
+ asdlkfjladsjflkjdaslkfjdsafjadslfjasdlkfjdsaklfjdkalfjdslfjalkjs
35
+ -----END CERTIFICATE-----
36
+ ```
37
+
38
+ After the file is created, you can run execute following command on your terminal to run the program:
39
+
40
+ `cw-cert-runner --env-file "/path/to/created/env/file/.env"`
41
+
42
+ ## Options
43
+
44
+ `--env-file <file-path>`
45
+
46
+ Absolute path to the .env file containing required config.
47
+
48
+ `-V, --version`
49
+
50
+ Output the version number.
51
+
52
+ `-h, --help`
53
+
54
+ Display help for command.
55
+
56
+ ## Development
57
+
58
+ `npm run build`: builds the package
59
+
60
+ `npm run local`: installs the package globally and runs it
61
+
62
+ ```
63
+ ,▄,
64
+ ▄▓███▌
65
+ ▄▀╙ ▀▓▀ ²▄
66
+ ▄└ ╙▌
67
+ ,▀ ╨▄
68
+ ▌ ║
69
+
70
+
71
+ ,▓██▄ ╔███▄
72
+ ╙███▌ ▀███▀
73
+ ▀▄
74
+ ▀╗▄ ,▄
75
+ '╙▀▀▀▀▀╙''
76
+
77
+
78
+ by Metriport Inc.
79
+
80
+ ```
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,165 @@
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
+ const commonwell_sdk_1 = require("@metriport/commonwell-sdk");
14
+ const nanoid = require("nanoid");
15
+ const dotenv = require("dotenv");
16
+ const commander_1 = require("commander");
17
+ function metriportBanner() {
18
+ return `
19
+ ,▄,
20
+ ▄▓███▌
21
+ ▄▀╙ ▀▓▀ ²▄
22
+ ▄└ ╙▌
23
+ ,▀ ╨▄
24
+ ▌ ║
25
+
26
+
27
+ ,▓██▄ ╔███▄
28
+ ╙███▌ ▀███▀
29
+ ▀▄
30
+ ▀╗▄ ,▄
31
+ '╙▀▀▀▀▀╙''
32
+
33
+ Metriport Inc.
34
+
35
+ CommonWell Cert Runner
36
+ `;
37
+ }
38
+ const program = new commander_1.Command();
39
+ program
40
+ .name("cw-cert-runner")
41
+ .description("Tool to run through Edge System CommonWell certification test cases.")
42
+ .requiredOption(`--env-file <file-path>`, `Absolute path to the .env file containing required config. Example required file contents:
43
+
44
+ COMMONWELL_ORG_NAME=Metriport
45
+ COMMONWELL_OID=2.16.840.1.113883.3.9621
46
+ COMMONWELL_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
47
+ fkadsjhfhdsakjfhdsakhfkdsahfadshfkhdsfhdsakfdhafkashdfkjhalsdkjf
48
+ -----END PRIVATE KEY-----
49
+ "
50
+ COMMONWELL_CERTIFICATE="-----BEGIN CERTIFICATE-----
51
+ asdlkfjladsjflkjdaslkfjdsafjadslfjasdlkfjdsaklfjdkalfjdslfjalkjs
52
+ -----END CERTIFICATE-----
53
+ "
54
+ `)
55
+ .addHelpText("before", metriportBanner())
56
+ .showHelpAfterError()
57
+ .version("1.0.0");
58
+ function main() {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ console.log(metriportBanner());
61
+ program.parse();
62
+ const options = program.opts();
63
+ dotenv.config({ path: options.envFile });
64
+ const commonwellPrivateKey = process.env.COMMONWELL_PRIVATE_KEY;
65
+ const commonwellCert = process.env.COMMONWELL_CERTIFICATE;
66
+ const commonwellOID = process.env.COMMONWELL_OID;
67
+ const commonwellOrgName = process.env.COMMONWELL_ORG_NAME;
68
+ const commonWell = new commonwell_sdk_1.CommonWell(commonwellCert, commonwellPrivateKey, commonwellOrgName, commonwellOID, commonwell_sdk_1.APIMode.integration);
69
+ const queryMeta = {
70
+ purposeOfUse: commonwell_sdk_1.PurposeOfUse.TREATMENT,
71
+ role: "ict",
72
+ subjectId: "admin",
73
+ };
74
+ const caDriversLicenseUri = "urn:oid:2.16.840.1.113883.4.3.6";
75
+ const driversLicenseId = nanoid.nanoid();
76
+ let personStrongId = {
77
+ details: {
78
+ address: [
79
+ {
80
+ use: commonwell_sdk_1.AddressUseCodes.home,
81
+ zip: "94041",
82
+ state: "CA",
83
+ line: ["335 Pioneer Way"],
84
+ city: "Mountain View",
85
+ },
86
+ ],
87
+ name: [
88
+ {
89
+ use: commonwell_sdk_1.NameUseCodes.usual,
90
+ given: ["Paul"],
91
+ family: ["Greyham"],
92
+ },
93
+ ],
94
+ gender: {
95
+ code: "M",
96
+ },
97
+ birthDate: "1980-04-20T00:00:00Z",
98
+ identifier: [
99
+ {
100
+ use: commonwell_sdk_1.IdentifierUseCodes.usual,
101
+ key: driversLicenseId,
102
+ system: caDriversLicenseUri,
103
+ period: {
104
+ start: "1996-04-20T00:00:00Z",
105
+ },
106
+ },
107
+ ],
108
+ },
109
+ };
110
+ const respC1a = yield commonWell.enrollPerson(queryMeta, personStrongId);
111
+ console.log(respC1a);
112
+ let person = {
113
+ details: {
114
+ address: [
115
+ {
116
+ use: commonwell_sdk_1.AddressUseCodes.home,
117
+ zip: "94111",
118
+ state: "CA",
119
+ line: ["755 Sansome Street"],
120
+ city: "San Francisco",
121
+ },
122
+ ],
123
+ name: [
124
+ {
125
+ use: commonwell_sdk_1.NameUseCodes.usual,
126
+ given: ["Mary"],
127
+ family: ["Jane"],
128
+ },
129
+ ],
130
+ gender: {
131
+ code: "F",
132
+ },
133
+ birthDate: "2000-04-20T00:00:00Z",
134
+ },
135
+ };
136
+ const respC1b = yield commonWell.enrollPerson(queryMeta, person);
137
+ console.log(respC1b);
138
+ const respC2a = yield commonWell.searchPerson(queryMeta, driversLicenseId, caDriversLicenseUri);
139
+ console.log(respC2a);
140
+ const personId = (0, commonwell_sdk_1.getId)(respC1a);
141
+ personStrongId.details.name[0].family[0] = "Graham";
142
+ const respC3a = yield commonWell.updatePerson(queryMeta, personStrongId, personId);
143
+ console.log(respC3a);
144
+ const personId2 = (0, commonwell_sdk_1.getId)(respC1b);
145
+ const driversLicenseId2 = nanoid.nanoid();
146
+ person.details.identifier = [
147
+ {
148
+ use: commonwell_sdk_1.IdentifierUseCodes.usual,
149
+ key: driversLicenseId2,
150
+ system: caDriversLicenseUri,
151
+ period: {
152
+ start: "2016-04-20T00:00:00Z",
153
+ },
154
+ },
155
+ ];
156
+ const respC3b = yield commonWell.updatePerson(queryMeta, person, personId2);
157
+ console.log(respC3b);
158
+ const respC6a = yield commonWell.unenrollPerson(queryMeta, personId2);
159
+ console.log(respC6a);
160
+ yield commonWell.deletePerson(queryMeta, personId);
161
+ yield commonWell.deletePerson(queryMeta, personId2);
162
+ });
163
+ }
164
+ main();
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,8DAUmC;AACnC,iCAAiC;AACjC,iCAAiC;AACjC,yCAAoC;AAEpC,SAAS,eAAe;IACtB,OAAO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EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;CAAA;AAED,IAAI,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@metriport/commonwell-cert-runner",
3
+ "version": "1.0.3",
4
+ "description": "Tool to run through Edge System CommonWell certification test cases - by Metriport Inc.",
5
+ "author": "Metriport Inc. <contact@metriport.com>",
6
+ "homepage": "https://metriport.com/",
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "typings": "lib/index.d.ts",
10
+ "directories": {
11
+ "lib": "lib",
12
+ "test": "__tests__"
13
+ },
14
+ "files": [
15
+ "lib"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "repository": {
21
+ "url": "https://github.com/metriport/metriport.git",
22
+ "type": "git",
23
+ "directory": "pkgs/packages/commonwell-cert-runner"
24
+ },
25
+ "scripts": {
26
+ "tsc": "tsc",
27
+ "test": "echo \"Error: run tests from root\" && exit 1",
28
+ "build": "tsc -p .",
29
+ "local": "sudo npm i -g && cw-cert-runner"
30
+ },
31
+ "bin": {
32
+ "cw-cert-runner": "lib/index.js"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/metriport/metriport/issues"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^18.11.18",
39
+ "nodemon": "^2.0.20",
40
+ "ts-node": "^10.9.1",
41
+ "typescript": "^4.9.4"
42
+ },
43
+ "dependencies": {
44
+ "@metriport/commonwell-sdk": "^1.0.3",
45
+ "commander": "^9.5.0",
46
+ "dotenv": "^16.0.3",
47
+ "nanoid": "^3.3.4"
48
+ },
49
+ "gitHead": "3f89c1e0d39ed55e180444335ff446e8c67bf8fa"
50
+ }