ndhm-hrp 2.2.37 → 3.0.0
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/lib/classes/discovery.d.ts +45 -12
- package/lib/classes/discovery.d.ts.map +1 -1
- package/lib/classes/discovery.js +46 -22
- package/lib/classes/discovery.js.map +1 -1
- package/lib/classes/link.d.ts +182 -62
- package/lib/classes/link.d.ts.map +1 -1
- package/lib/classes/link.js +211 -82
- package/lib/classes/link.js.map +1 -1
- package/lib/classes/patients.d.ts +20 -12
- package/lib/classes/patients.d.ts.map +1 -1
- package/lib/classes/patients.js +46 -39
- package/lib/classes/patients.js.map +1 -1
- package/lib/classes/userAuth.d.ts.map +1 -1
- package/lib/classes/userAuth.js +3 -6
- package/lib/classes/userAuth.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,57 @@
|
|
|
1
1
|
import Header from "./header";
|
|
2
|
+
declare type HI_TYPES = "OPConsultation" | "DiagnosticReport" | "Prescription" | "ImmunizationRecord" | "DischargeSummary" | "HealthDocumentRecord" | "WellnessRecord" | "InitialAssessment" | "DietaryRecord";
|
|
2
3
|
export default class Discovery extends Header {
|
|
3
4
|
constructor(_baseUrl: string, _accessToken: string);
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* HMIS/LMIS response to the HIE-CM discovery callback (User Initiated Linking v3).
|
|
7
|
+
*
|
|
8
|
+
* Called by the HIP after receiving the discovery callback at
|
|
9
|
+
* `{callback_url}/api/v3/hip/patient/care-context/discover` (section 5.3.2).
|
|
10
|
+
* The HIP searches its records and returns matching patients with their
|
|
11
|
+
* associated care contexts, HI type, and count. If no match is found, an
|
|
12
|
+
* error is returned instead.
|
|
13
|
+
*
|
|
14
|
+
* Uses the v3 endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.3):
|
|
15
|
+
* `POST /api/hiecm/user-initiated-linking/v3/patient/care-context/on-discover`
|
|
16
|
+
*
|
|
17
|
+
* @param config - Configuration object
|
|
18
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
19
|
+
* @param config.transactionId - Transaction ID from the HIE-CM discovery callback, used for correlation
|
|
20
|
+
* @param config.patients - Array of matched patient entries, each with:
|
|
21
|
+
* - referenceNumber - Patient reference in HIP system
|
|
22
|
+
* - display - Display name for the patient
|
|
23
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
24
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
25
|
+
* - count - Number of care contexts
|
|
26
|
+
* @param config.matchedBy - Array of matching criteria used (e.g. ["MR", "NAME", "DOB"])
|
|
27
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM discovery callback, sent in `response.requestId`
|
|
28
|
+
* @param config.error - Optional error object if no matching patient was found (code, message)
|
|
29
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
30
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
31
|
+
* @returns The request body that was sent (for logging/reference)
|
|
8
32
|
*/
|
|
9
33
|
onDiscovery: (config: {
|
|
34
|
+
healthId: string;
|
|
10
35
|
transactionId: string;
|
|
11
|
-
|
|
12
|
-
patientDisplay: string;
|
|
13
|
-
careContexts: {
|
|
36
|
+
patients?: Array<{
|
|
14
37
|
referenceNumber: string;
|
|
15
38
|
display: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
careContexts: Array<{
|
|
40
|
+
referenceNumber: string;
|
|
41
|
+
display: string;
|
|
42
|
+
}>;
|
|
43
|
+
hiType: HI_TYPES;
|
|
44
|
+
count: number;
|
|
45
|
+
}>;
|
|
46
|
+
matchedBy?: string[];
|
|
47
|
+
callbackRequestId: string;
|
|
48
|
+
error?: {
|
|
49
|
+
code: string;
|
|
50
|
+
message: string;
|
|
51
|
+
};
|
|
52
|
+
requestId?: string;
|
|
53
|
+
timestamp?: string;
|
|
22
54
|
}) => Promise<any>;
|
|
23
55
|
}
|
|
56
|
+
export {};
|
|
24
57
|
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/classes/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAI9B,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,MAAM;gBAC/B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/classes/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAI9B,aAAK,QAAQ,GACT,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,CAAC;AAEpB,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,MAAM;gBAC/B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIlD;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,WAAW,WAAkB;QAC3B,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM;YACf,eAAe,EAAE,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,MAAM;gBAClB,eAAe,EAAE,MAAM,CAAC;gBACxB,OAAO,EAAE,MAAM,CAAC;aACjB,CAAC,CAAC;YACH,MAAM,EAAE,QAAQ,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;SACf,CAAC,CAAC;QACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,KAAK,CAAC,EAAE;YACN,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,kBAiCC;CACH"}
|
package/lib/classes/discovery.js
CHANGED
|
@@ -19,38 +19,62 @@ class Discovery extends header_1.default {
|
|
|
19
19
|
constructor(_baseUrl, _accessToken) {
|
|
20
20
|
super(_baseUrl, _accessToken);
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* HMIS/LMIS response to the HIE-CM discovery callback (User Initiated Linking v3).
|
|
23
|
+
*
|
|
24
|
+
* Called by the HIP after receiving the discovery callback at
|
|
25
|
+
* `{callback_url}/api/v3/hip/patient/care-context/discover` (section 5.3.2).
|
|
26
|
+
* The HIP searches its records and returns matching patients with their
|
|
27
|
+
* associated care contexts, HI type, and count. If no match is found, an
|
|
28
|
+
* error is returned instead.
|
|
29
|
+
*
|
|
30
|
+
* Uses the v3 endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.3):
|
|
31
|
+
* `POST /api/hiecm/user-initiated-linking/v3/patient/care-context/on-discover`
|
|
32
|
+
*
|
|
33
|
+
* @param config - Configuration object
|
|
34
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
35
|
+
* @param config.transactionId - Transaction ID from the HIE-CM discovery callback, used for correlation
|
|
36
|
+
* @param config.patients - Array of matched patient entries, each with:
|
|
37
|
+
* - referenceNumber - Patient reference in HIP system
|
|
38
|
+
* - display - Display name for the patient
|
|
39
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
40
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
41
|
+
* - count - Number of care contexts
|
|
42
|
+
* @param config.matchedBy - Array of matching criteria used (e.g. ["MR", "NAME", "DOB"])
|
|
43
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM discovery callback, sent in `response.requestId`
|
|
44
|
+
* @param config.error - Optional error object if no matching patient was found (code, message)
|
|
45
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
46
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
47
|
+
* @returns The request body that was sent (for logging/reference)
|
|
25
48
|
*/
|
|
26
49
|
this.onDiscovery = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
var _a, _b;
|
|
51
|
+
this.setXCmId(config.healthId);
|
|
52
|
+
const headers = {
|
|
53
|
+
"REQUEST-ID": (_a = config.requestId) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)(),
|
|
54
|
+
TIMESTAMP: (_b = config.timestamp) !== null && _b !== void 0 ? _b : new Date().toISOString(),
|
|
55
|
+
"X-CM-ID": this.xCmId,
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
58
|
+
};
|
|
59
|
+
const url = `${this.baseUrl}api/hiecm/user-initiated-linking/v3/patient/care-context/on-discover`;
|
|
29
60
|
const body = {
|
|
30
|
-
requestId: (0, uuid_1.v4)(),
|
|
31
|
-
timestamp: new Date().toISOString(),
|
|
32
61
|
transactionId: config.transactionId,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
display: config.patientDisplay,
|
|
36
|
-
careContexts: config.careContexts,
|
|
37
|
-
matchedBy: config.matchedBy,
|
|
38
|
-
},
|
|
39
|
-
resp: {
|
|
40
|
-
requestId: config.requestId,
|
|
62
|
+
response: {
|
|
63
|
+
requestId: config.callbackRequestId,
|
|
41
64
|
},
|
|
42
65
|
};
|
|
43
|
-
if (config.
|
|
44
|
-
body.error =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
if (config.error) {
|
|
67
|
+
body.error = config.error;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
body.patient = config.patients;
|
|
71
|
+
body.matchedBy = config.matchedBy;
|
|
48
72
|
}
|
|
49
73
|
yield new request_1.default().request({
|
|
50
|
-
headers
|
|
74
|
+
headers,
|
|
51
75
|
method: "POST",
|
|
52
76
|
requestBody: body,
|
|
53
|
-
url
|
|
77
|
+
url,
|
|
54
78
|
});
|
|
55
79
|
return body;
|
|
56
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/classes/discovery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,+BAAoC;AACpC,wDAAgC;
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/classes/discovery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,+BAAoC;AACpC,wDAAgC;AAahC,MAAqB,SAAU,SAAQ,gBAAM;IAC3C,YAAY,QAAgB,EAAE,YAAoB;QAChD,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2BG;QACH,gBAAW,GAAG,CAAO,MAqBpB,EAAE,EAAE;;YACH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG;gBACd,YAAY,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAA,SAAM,GAAE;gBAC1C,SAAS,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACvD,SAAS,EAAE,IAAI,CAAC,KAAK;gBACrB,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,IAAI,CAAC,WAAW,EAAE;aAC5C,CAAC;YACF,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,sEAAsE,CAAC;YAElG,MAAM,IAAI,GAAQ;gBAChB,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,QAAQ,EAAE;oBACR,SAAS,EAAE,MAAM,CAAC,iBAAiB;iBACpC;aACF,CAAC;YAEF,IAAI,MAAM,CAAC,KAAK,EAAE;gBAChB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;aAC3B;iBAAM;gBACL,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC;gBAC/B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;aACnC;YAED,MAAM,IAAI,iBAAO,EAAE,CAAC,OAAO,CAAC;gBAC1B,OAAO;gBACP,MAAM,EAAE,MAAM;gBACd,WAAW,EAAE,IAAI;gBACjB,GAAG;aACJ,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QACd,CAAC,CAAA,CAAC;IApFF,CAAC;CAqFF;AAxFD,4BAwFC"}
|
package/lib/classes/link.d.ts
CHANGED
|
@@ -3,105 +3,195 @@ declare type HI_TYPES = "OPConsultation" | "DiagnosticReport" | "Prescription" |
|
|
|
3
3
|
export default class Link extends Header {
|
|
4
4
|
constructor(_baseUrl: string, _accessToken: string);
|
|
5
5
|
/**
|
|
6
|
+
* Adds care contexts to a patient's ABHA account using the v3 HIE-CM endpoint.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* This replaces the deprecated v0.5 `AddContext` method. It requires a
|
|
9
|
+
* `linkToken` (obtained via `generateToken`) and sends patient care-context
|
|
10
|
+
* data with `hiType` and `count` fields.
|
|
11
|
+
*
|
|
12
|
+
* Headers are built inline following the existing `generateToken` v3 pattern.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Configuration object
|
|
15
|
+
* @param config.healthId - Patient's health ID used to derive X-CM-ID header
|
|
16
|
+
* @param config.hipId - HIP ID sent as X-HIP-ID header
|
|
17
|
+
* @param config.linkToken - Link token obtained from HIE-CM token generation
|
|
18
|
+
* @param config.abhaNumber - Patient's ABHA number
|
|
19
|
+
* @param config.abhaAddress - Patient's ABHA address
|
|
20
|
+
* @param config.patients - Array of patient care-context entries, each with:
|
|
21
|
+
* - referenceNumber - Patient reference (encounter ID) in HIP system
|
|
22
|
+
* - display - Display name for the patient
|
|
23
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
24
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
25
|
+
* - count - Number of care contexts
|
|
26
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
27
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
28
|
+
* @returns The parsed API response
|
|
9
29
|
*/
|
|
10
|
-
|
|
30
|
+
addCareContext: (config: {
|
|
11
31
|
healthId: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
link: {
|
|
21
|
-
accessToken: string;
|
|
22
|
-
patient: {
|
|
32
|
+
hipId: string;
|
|
33
|
+
linkToken: string;
|
|
34
|
+
abhaNumber: string;
|
|
35
|
+
abhaAddress: string;
|
|
36
|
+
patients: Array<{
|
|
37
|
+
referenceNumber: string;
|
|
38
|
+
display: string;
|
|
39
|
+
careContexts: Array<{
|
|
23
40
|
referenceNumber: string;
|
|
24
41
|
display: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}>;
|
|
42
|
+
}>;
|
|
43
|
+
hiType: HI_TYPES;
|
|
44
|
+
count: number;
|
|
45
|
+
}>;
|
|
46
|
+
requestId?: string;
|
|
47
|
+
timestamp?: string;
|
|
48
|
+
}) => Promise<any>;
|
|
32
49
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
* HMIS/LMIS response to the HIE-CM callback for user-initiated linking (v3).
|
|
51
|
+
*
|
|
52
|
+
* This is called by the HIP in response to the discovery callback (section 5.3.2).
|
|
53
|
+
* The HIP validates the transactionId against a previous discovery, sends an
|
|
54
|
+
* authentication request to the patient (e.g. OTP), and returns the link
|
|
55
|
+
* reference number with authentication metadata. The patient subsequently passes
|
|
56
|
+
* the token via `/link/care-context/confirm` against the `link.referenceNumber`.
|
|
57
|
+
*
|
|
58
|
+
* Uses the v3 HIE-CM endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.7):
|
|
59
|
+
* `POST /api/hiecm/user-initiated-linking/v3/link/care-context/on-init`
|
|
60
|
+
*
|
|
61
|
+
* Possible errors returned:
|
|
62
|
+
* - Patient reference number is invalid
|
|
63
|
+
* - Care context reference numbers are invalid
|
|
64
|
+
*
|
|
65
|
+
* @param config - Configuration object
|
|
66
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
67
|
+
* @param config.transactionId - Transaction ID from the discovery callback, used for correlation
|
|
68
|
+
* @param config.referenceNumber - Link reference number generated by the HIP for this linking attempt
|
|
69
|
+
* @param config.authenticationType - Authentication type: "DIRECT" or "MEDIATE"
|
|
70
|
+
* @param config.communicationMedium - Medium for patient communication (e.g. "MOBILE")
|
|
71
|
+
* @param config.communicationHint - Hint for the communication (e.g. "OTP")
|
|
72
|
+
* @param config.communicationExpiry - ISO timestamp for communication expiry (defaults to 10 min from now)
|
|
73
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
74
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
75
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM discovery callback, sent in `response.requestId`
|
|
76
|
+
* @param config.error - Optional error object if the HIP cannot process the link request
|
|
77
|
+
* @returns The request body that was sent (for logging/reference)
|
|
44
78
|
*/
|
|
45
79
|
onInit: (config: {
|
|
46
80
|
healthId: string;
|
|
47
81
|
transactionId: string;
|
|
48
82
|
referenceNumber: string;
|
|
83
|
+
authenticationType: "DIRECT" | "MEDIATE";
|
|
84
|
+
communicationMedium: string;
|
|
49
85
|
communicationHint: string;
|
|
50
86
|
communicationExpiry?: string;
|
|
51
|
-
requestId
|
|
87
|
+
requestId?: string;
|
|
88
|
+
timestamp?: string;
|
|
89
|
+
callbackRequestId: string;
|
|
52
90
|
error?: {
|
|
53
91
|
code: number;
|
|
54
92
|
message: string;
|
|
55
93
|
};
|
|
56
94
|
}) => Promise<any>;
|
|
57
|
-
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
/**
|
|
96
|
+
* HMIS/LMIS response on confirm — called by HIP after the patient confirms
|
|
97
|
+
* the link via OTP/token (User Initiated Linking v3).
|
|
98
|
+
*
|
|
99
|
+
* This is the HIP's response to the HIE-CM callback at
|
|
100
|
+
* `{callback_url}/api/v3/hip/link/care-context/confirm` (section 5.3.10).
|
|
101
|
+
* The HIP returns the confirmed care contexts that have been linked to the
|
|
102
|
+
* patient's ABHA account.
|
|
103
|
+
*
|
|
104
|
+
* Uses the v3 endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.11):
|
|
105
|
+
* `POST /api/hiecm/user-initiated-linking/v3/link/care-context/on-confirm`
|
|
106
|
+
*
|
|
107
|
+
* @param config - Configuration object
|
|
108
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
109
|
+
* @param config.patients - Array of patient care-context entries that were confirmed, each with:
|
|
110
|
+
* - referenceNumber - Patient reference in HIP system
|
|
111
|
+
* - display - Display name for the patient
|
|
112
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
113
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
114
|
+
* - count - Number of care contexts
|
|
115
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM confirm callback, sent in `response.requestId`
|
|
116
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
117
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
118
|
+
* @returns The request body that was sent (for logging/reference)
|
|
63
119
|
*/
|
|
64
120
|
onConfirm: (config: {
|
|
65
121
|
healthId: string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
122
|
+
patients: Array<{
|
|
123
|
+
referenceNumber: string;
|
|
124
|
+
display: string;
|
|
125
|
+
careContexts: Array<{
|
|
126
|
+
referenceNumber: string;
|
|
127
|
+
display: string;
|
|
128
|
+
}>;
|
|
129
|
+
hiType: HI_TYPES;
|
|
130
|
+
count: number;
|
|
131
|
+
}>;
|
|
132
|
+
callbackRequestId: string;
|
|
133
|
+
requestId?: string;
|
|
134
|
+
timestamp?: string;
|
|
135
|
+
}) => Promise<{
|
|
136
|
+
patient: {
|
|
71
137
|
referenceNumber: string;
|
|
72
138
|
display: string;
|
|
139
|
+
careContexts: Array<{
|
|
140
|
+
referenceNumber: string;
|
|
141
|
+
display: string;
|
|
142
|
+
}>;
|
|
143
|
+
hiType: HI_TYPES;
|
|
144
|
+
count: number;
|
|
73
145
|
}[];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
message: string;
|
|
146
|
+
response: {
|
|
147
|
+
requestId: string;
|
|
77
148
|
};
|
|
78
|
-
}
|
|
149
|
+
}>;
|
|
79
150
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
151
|
+
* Notifies the ABDM Consent Manager about new health data added/created for a patient
|
|
152
|
+
* under an already-linked care context (HIP Initiated Linking v3).
|
|
153
|
+
*
|
|
154
|
+
* Called by HIP when new health information is added under a care context that
|
|
155
|
+
* is already linked with the patient's ABHA account. This API should NOT be called
|
|
156
|
+
* if the new health data is added under a new (unlinked) care context.
|
|
157
|
+
*
|
|
158
|
+
* Uses the v3 HIE-CM endpoint `/api/hiecm/hip/v3/link/context/notify` per the
|
|
159
|
+
* ABDM M2 Sandbox Documentation v2.8 (section 4.3.6).
|
|
160
|
+
*
|
|
161
|
+
* Headers are built inline following the v3 pattern used by `generateToken` and
|
|
162
|
+
* `addCareContext`, including `X-HIP-ID`, `X-LINK-TOKEN`, `REQUEST-ID`, and
|
|
163
|
+
* `TIMESTAMP` as required by the v3 API.
|
|
164
|
+
*
|
|
165
|
+
* @param config - Configuration object
|
|
166
|
+
* @param config.healthId - Patient's identifier (ABHA address, e.g. "user@sbx") used to derive X-CM-ID
|
|
167
|
+
* @param config.hipId - HIP facility ID sent as X-HIP-ID header (e.g. "IN2910000004")
|
|
168
|
+
* @param config.linkToken - Link token (JWT) obtained from token generation, sent as X-LINK-TOKEN header
|
|
169
|
+
* @param config.patientReference - Patient's reference number in the HIP system (e.g. ABHA number)
|
|
170
|
+
* @param config.careContextReference - Care context reference under which new health data was added
|
|
171
|
+
* @param config.hiTypes - Array of HI types for the new health data (e.g. ["Prescription", "DischargeSummary"])
|
|
172
|
+
* @param config.date - ISO 8601 UTC date when the health information was created/added on the HIP
|
|
173
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
174
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
175
|
+
* @returns The request body that was sent (for logging/reference)
|
|
87
176
|
*/
|
|
88
177
|
notify: (config: {
|
|
89
178
|
healthId: string;
|
|
90
|
-
|
|
91
|
-
|
|
179
|
+
hipId: string;
|
|
180
|
+
linkToken: string;
|
|
181
|
+
patientReference: string;
|
|
182
|
+
careContextReference: string;
|
|
92
183
|
hiTypes: HI_TYPES[];
|
|
93
184
|
date: string;
|
|
94
|
-
|
|
185
|
+
requestId?: string;
|
|
186
|
+
timestamp?: string;
|
|
95
187
|
}) => Promise<{
|
|
96
|
-
requestId: string;
|
|
97
|
-
timestamp: string;
|
|
98
188
|
notification: {
|
|
99
189
|
patient: {
|
|
100
190
|
id: string;
|
|
101
191
|
};
|
|
102
192
|
careContext: {
|
|
103
|
-
patientReference:
|
|
104
|
-
careContextReference:
|
|
193
|
+
patientReference: string;
|
|
194
|
+
careContextReference: string;
|
|
105
195
|
};
|
|
106
196
|
hiTypes: HI_TYPES[];
|
|
107
197
|
date: string;
|
|
@@ -110,6 +200,36 @@ export default class Link extends Header {
|
|
|
110
200
|
};
|
|
111
201
|
};
|
|
112
202
|
}>;
|
|
203
|
+
/**
|
|
204
|
+
* Generates a patient token (ABDM HIE-CM v3 endpoint) required for HIE (Health Information Exchange) operations.
|
|
205
|
+
*
|
|
206
|
+
* This token is needed to authorize subsequent HIE transactions such as data push and data pull requests.
|
|
207
|
+
* The API uses the v3 endpoint `/api/hiecm/v3/token/generate-token` which requires custom headers
|
|
208
|
+
* (REQUEST-ID, TIMESTAMP, X-HIP-ID) not present in the standard v0.5 header set.
|
|
209
|
+
*
|
|
210
|
+
* @param config - Configuration object for token generation
|
|
211
|
+
* @param config.healthId - Patient's health ID used to derive the X-CM-ID header (e.g., "user@abdm")
|
|
212
|
+
* @param config.hipId - Health Information Provider ID sent as X-HIP-ID header
|
|
213
|
+
* @param config.abhaNumber - Patient's ABHA number (can be numeric or string)
|
|
214
|
+
* @param config.abhaAddress - Patient's ABHA address (e.g., "user@sbx")
|
|
215
|
+
* @param config.name - Patient's full name
|
|
216
|
+
* @param config.gender - Patient's gender
|
|
217
|
+
* @param config.yearOfBirth - Patient's year of birth
|
|
218
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
219
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
220
|
+
* @returns The parsed API response containing the generated patient token
|
|
221
|
+
*/
|
|
222
|
+
generateToken: (config: {
|
|
223
|
+
healthId: string;
|
|
224
|
+
hipId: string;
|
|
225
|
+
abhaNumber: number | string;
|
|
226
|
+
abhaAddress: string;
|
|
227
|
+
name: string;
|
|
228
|
+
gender: string;
|
|
229
|
+
yearOfBirth: number;
|
|
230
|
+
requestId?: string;
|
|
231
|
+
timestamp?: string;
|
|
232
|
+
}) => Promise<any>;
|
|
113
233
|
}
|
|
114
234
|
export {};
|
|
115
235
|
//# sourceMappingURL=link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/classes/link.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,aAAK,QAAQ,GACT,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,CAAA;AAGnB,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,MAAM;gBAC1B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIlD
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/classes/link.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,aAAK,QAAQ,GACT,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,CAAA;AAGnB,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,MAAM;gBAC1B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIlD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,cAAc,WAAkB;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM;YACd,eAAe,EAAE,MAAM,CAAC;YACxB,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,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KACpB;;6BAZoB,MAAM;qBACd,MAAM;0BACD,MAAM;gBAClB,eAAe,EAAE,MAAM,CAAC;gBACxB,OAAO,EAAE,MAAM,CAAC;aACjB,CAAC;oBACM,QAAQ;mBACT,MAAM;;;;;OA8Bf;IAEF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,WAAkB;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,OAAO,EAAE,QAAQ,EAAE,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;;;;;;;;;;;;;;;OAsCC;IAEF;;;;;;;;;;;;;;;;;;OAkBG;IACH,aAAa,WAAkB;QAC7B,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;QAC5B,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,kBA2BC;CACH"}
|
package/lib/classes/link.js
CHANGED
|
@@ -19,131 +19,214 @@ class Link extends header_1.default {
|
|
|
19
19
|
constructor(_baseUrl, _accessToken) {
|
|
20
20
|
super(_baseUrl, _accessToken);
|
|
21
21
|
/**
|
|
22
|
+
* Adds care contexts to a patient's ABHA account using the v3 HIE-CM endpoint.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* This replaces the deprecated v0.5 `AddContext` method. It requires a
|
|
25
|
+
* `linkToken` (obtained via `generateToken`) and sends patient care-context
|
|
26
|
+
* data with `hiType` and `count` fields.
|
|
27
|
+
*
|
|
28
|
+
* Headers are built inline following the existing `generateToken` v3 pattern.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Configuration object
|
|
31
|
+
* @param config.healthId - Patient's health ID used to derive X-CM-ID header
|
|
32
|
+
* @param config.hipId - HIP ID sent as X-HIP-ID header
|
|
33
|
+
* @param config.linkToken - Link token obtained from HIE-CM token generation
|
|
34
|
+
* @param config.abhaNumber - Patient's ABHA number
|
|
35
|
+
* @param config.abhaAddress - Patient's ABHA address
|
|
36
|
+
* @param config.patients - Array of patient care-context entries, each with:
|
|
37
|
+
* - referenceNumber - Patient reference (encounter ID) in HIP system
|
|
38
|
+
* - display - Display name for the patient
|
|
39
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
40
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
41
|
+
* - count - Number of care contexts
|
|
42
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
43
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
44
|
+
* @returns The parsed API response
|
|
25
45
|
*/
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
this.addCareContext = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
this.setXCmId(config.healthId);
|
|
49
|
+
const headers = {
|
|
50
|
+
"REQUEST-ID": (_a = config.requestId) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)(),
|
|
51
|
+
TIMESTAMP: (_b = config.timestamp) !== null && _b !== void 0 ? _b : new Date().toISOString(),
|
|
52
|
+
"X-HIP-ID": config.hipId,
|
|
53
|
+
"X-LINK-TOKEN": config.linkToken,
|
|
54
|
+
"X-CM-ID": this.xCmId,
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
57
|
+
};
|
|
58
|
+
const url = `${this.baseUrl}api/hiecm/hip/v3/link/carecontext`;
|
|
29
59
|
const body = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
accessToken: config.careContextAccessToken,
|
|
34
|
-
patient: {
|
|
35
|
-
referenceNumber: config.patientId,
|
|
36
|
-
display: config.patinetDisplay,
|
|
37
|
-
careContexts: [
|
|
38
|
-
{
|
|
39
|
-
referenceNumber: config.careContextId,
|
|
40
|
-
display: config.careContextDisplay,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
},
|
|
60
|
+
abhaNumber: config.abhaNumber,
|
|
61
|
+
abhaAddress: config.abhaAddress,
|
|
62
|
+
patient: config.patients,
|
|
45
63
|
};
|
|
46
|
-
yield new request_1.default().request({
|
|
47
|
-
headers
|
|
64
|
+
const response = yield new request_1.default().request({
|
|
65
|
+
headers,
|
|
48
66
|
method: "POST",
|
|
49
67
|
requestBody: body,
|
|
50
|
-
url
|
|
68
|
+
url,
|
|
51
69
|
});
|
|
52
|
-
return body;
|
|
70
|
+
return JSON.parse(response.body);
|
|
53
71
|
});
|
|
54
72
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
* HMIS/LMIS response to the HIE-CM callback for user-initiated linking (v3).
|
|
74
|
+
*
|
|
75
|
+
* This is called by the HIP in response to the discovery callback (section 5.3.2).
|
|
76
|
+
* The HIP validates the transactionId against a previous discovery, sends an
|
|
77
|
+
* authentication request to the patient (e.g. OTP), and returns the link
|
|
78
|
+
* reference number with authentication metadata. The patient subsequently passes
|
|
79
|
+
* the token via `/link/care-context/confirm` against the `link.referenceNumber`.
|
|
80
|
+
*
|
|
81
|
+
* Uses the v3 HIE-CM endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.7):
|
|
82
|
+
* `POST /api/hiecm/user-initiated-linking/v3/link/care-context/on-init`
|
|
83
|
+
*
|
|
84
|
+
* Possible errors returned:
|
|
85
|
+
* - Patient reference number is invalid
|
|
86
|
+
* - Care context reference numbers are invalid
|
|
87
|
+
*
|
|
88
|
+
* @param config - Configuration object
|
|
89
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
90
|
+
* @param config.transactionId - Transaction ID from the discovery callback, used for correlation
|
|
91
|
+
* @param config.referenceNumber - Link reference number generated by the HIP for this linking attempt
|
|
92
|
+
* @param config.authenticationType - Authentication type: "DIRECT" or "MEDIATE"
|
|
93
|
+
* @param config.communicationMedium - Medium for patient communication (e.g. "MOBILE")
|
|
94
|
+
* @param config.communicationHint - Hint for the communication (e.g. "OTP")
|
|
95
|
+
* @param config.communicationExpiry - ISO timestamp for communication expiry (defaults to 10 min from now)
|
|
96
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
97
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
98
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM discovery callback, sent in `response.requestId`
|
|
99
|
+
* @param config.error - Optional error object if the HIP cannot process the link request
|
|
100
|
+
* @returns The request body that was sent (for logging/reference)
|
|
66
101
|
*/
|
|
67
102
|
this.onInit = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
var _c, _d, _e;
|
|
104
|
+
this.setXCmId(config.healthId);
|
|
105
|
+
const headers = {
|
|
106
|
+
"REQUEST-ID": (_c = config.requestId) !== null && _c !== void 0 ? _c : (0, uuid_1.v4)(),
|
|
107
|
+
TIMESTAMP: (_d = config.timestamp) !== null && _d !== void 0 ? _d : new Date().toISOString(),
|
|
108
|
+
"X-CM-ID": this.xCmId,
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
111
|
+
};
|
|
112
|
+
const url = `${this.baseUrl}api/hiecm/user-initiated-linking/v3/link/care-context/on-init`;
|
|
70
113
|
const body = {
|
|
71
|
-
requestId: (0, uuid_1.v4)(),
|
|
72
|
-
timestamp: new Date().toISOString(),
|
|
73
114
|
transactionId: config.transactionId,
|
|
74
115
|
link: {
|
|
75
116
|
referenceNumber: config.referenceNumber,
|
|
76
|
-
authenticationType:
|
|
117
|
+
authenticationType: config.authenticationType,
|
|
77
118
|
meta: {
|
|
78
|
-
communicationMedium:
|
|
119
|
+
communicationMedium: config.communicationMedium,
|
|
79
120
|
communicationHint: config.communicationHint,
|
|
80
|
-
communicationExpiry: config.communicationExpiry
|
|
81
|
-
new Date(new Date().getTime() + 10 * 60000).toISOString(),
|
|
121
|
+
communicationExpiry: (_e = config.communicationExpiry) !== null && _e !== void 0 ? _e : new Date(new Date().getTime() + 10 * 60000).toISOString(),
|
|
82
122
|
},
|
|
83
123
|
},
|
|
84
|
-
|
|
85
|
-
requestId: config.
|
|
124
|
+
response: {
|
|
125
|
+
requestId: config.callbackRequestId,
|
|
86
126
|
},
|
|
87
127
|
};
|
|
88
128
|
if (config.error) {
|
|
89
129
|
body.error = config.error;
|
|
90
130
|
}
|
|
91
131
|
yield new request_1.default().request({
|
|
92
|
-
headers
|
|
132
|
+
headers,
|
|
93
133
|
method: "POST",
|
|
94
134
|
requestBody: body,
|
|
95
|
-
url
|
|
135
|
+
url,
|
|
96
136
|
});
|
|
97
137
|
return body;
|
|
98
138
|
});
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
139
|
+
/**
|
|
140
|
+
* HMIS/LMIS response on confirm — called by HIP after the patient confirms
|
|
141
|
+
* the link via OTP/token (User Initiated Linking v3).
|
|
142
|
+
*
|
|
143
|
+
* This is the HIP's response to the HIE-CM callback at
|
|
144
|
+
* `{callback_url}/api/v3/hip/link/care-context/confirm` (section 5.3.10).
|
|
145
|
+
* The HIP returns the confirmed care contexts that have been linked to the
|
|
146
|
+
* patient's ABHA account.
|
|
147
|
+
*
|
|
148
|
+
* Uses the v3 endpoint per ABDM M2 Sandbox Documentation v2.8 (section 5.3.11):
|
|
149
|
+
* `POST /api/hiecm/user-initiated-linking/v3/link/care-context/on-confirm`
|
|
150
|
+
*
|
|
151
|
+
* @param config - Configuration object
|
|
152
|
+
* @param config.healthId - Patient's ABHA address (e.g. "user@sbx") used to derive X-CM-ID
|
|
153
|
+
* @param config.patients - Array of patient care-context entries that were confirmed, each with:
|
|
154
|
+
* - referenceNumber - Patient reference in HIP system
|
|
155
|
+
* - display - Display name for the patient
|
|
156
|
+
* - careContexts - Array of { referenceNumber, display }
|
|
157
|
+
* - hiType - Type of health information (HI_TYPES)
|
|
158
|
+
* - count - Number of care contexts
|
|
159
|
+
* @param config.callbackRequestId - The `requestId` from the HIE-CM confirm callback, sent in `response.requestId`
|
|
160
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
161
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
162
|
+
* @returns The request body that was sent (for logging/reference)
|
|
105
163
|
*/
|
|
106
164
|
this.onConfirm = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
|
|
108
|
-
|
|
165
|
+
var _f, _g;
|
|
166
|
+
this.setXCmId(config.healthId);
|
|
167
|
+
const headers = {
|
|
168
|
+
"REQUEST-ID": (_f = config.requestId) !== null && _f !== void 0 ? _f : (0, uuid_1.v4)(),
|
|
169
|
+
TIMESTAMP: (_g = config.timestamp) !== null && _g !== void 0 ? _g : new Date().toISOString(),
|
|
170
|
+
"X-CM-ID": this.xCmId,
|
|
171
|
+
"Content-Type": "application/json",
|
|
172
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
173
|
+
};
|
|
174
|
+
const url = `${this.baseUrl}api/hiecm/user-initiated-linking/v3/link/care-context/on-confirm`;
|
|
109
175
|
const body = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
referenceNumber: config.patientReferenceNumber,
|
|
114
|
-
display: config.patinetDisplay,
|
|
115
|
-
careContexts: config.careContexts,
|
|
116
|
-
},
|
|
117
|
-
resp: {
|
|
118
|
-
requestId: config.requestId,
|
|
176
|
+
patient: config.patients,
|
|
177
|
+
response: {
|
|
178
|
+
requestId: config.callbackRequestId,
|
|
119
179
|
},
|
|
120
180
|
};
|
|
121
|
-
if (config.error) {
|
|
122
|
-
body.error = config.error;
|
|
123
|
-
}
|
|
124
181
|
yield new request_1.default().request({
|
|
125
|
-
headers
|
|
182
|
+
headers,
|
|
126
183
|
method: "POST",
|
|
127
184
|
requestBody: body,
|
|
128
|
-
url
|
|
185
|
+
url,
|
|
129
186
|
});
|
|
130
187
|
return body;
|
|
131
188
|
});
|
|
132
189
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
190
|
+
* Notifies the ABDM Consent Manager about new health data added/created for a patient
|
|
191
|
+
* under an already-linked care context (HIP Initiated Linking v3).
|
|
192
|
+
*
|
|
193
|
+
* Called by HIP when new health information is added under a care context that
|
|
194
|
+
* is already linked with the patient's ABHA account. This API should NOT be called
|
|
195
|
+
* if the new health data is added under a new (unlinked) care context.
|
|
196
|
+
*
|
|
197
|
+
* Uses the v3 HIE-CM endpoint `/api/hiecm/hip/v3/link/context/notify` per the
|
|
198
|
+
* ABDM M2 Sandbox Documentation v2.8 (section 4.3.6).
|
|
199
|
+
*
|
|
200
|
+
* Headers are built inline following the v3 pattern used by `generateToken` and
|
|
201
|
+
* `addCareContext`, including `X-HIP-ID`, `X-LINK-TOKEN`, `REQUEST-ID`, and
|
|
202
|
+
* `TIMESTAMP` as required by the v3 API.
|
|
203
|
+
*
|
|
204
|
+
* @param config - Configuration object
|
|
205
|
+
* @param config.healthId - Patient's identifier (ABHA address, e.g. "user@sbx") used to derive X-CM-ID
|
|
206
|
+
* @param config.hipId - HIP facility ID sent as X-HIP-ID header (e.g. "IN2910000004")
|
|
207
|
+
* @param config.linkToken - Link token (JWT) obtained from token generation, sent as X-LINK-TOKEN header
|
|
208
|
+
* @param config.patientReference - Patient's reference number in the HIP system (e.g. ABHA number)
|
|
209
|
+
* @param config.careContextReference - Care context reference under which new health data was added
|
|
210
|
+
* @param config.hiTypes - Array of HI types for the new health data (e.g. ["Prescription", "DischargeSummary"])
|
|
211
|
+
* @param config.date - ISO 8601 UTC date when the health information was created/added on the HIP
|
|
212
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
213
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
214
|
+
* @returns The request body that was sent (for logging/reference)
|
|
140
215
|
*/
|
|
141
216
|
this.notify = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
|
|
143
|
-
|
|
217
|
+
var _h, _j;
|
|
218
|
+
this.setXCmId(config.healthId);
|
|
219
|
+
const headers = {
|
|
220
|
+
"REQUEST-ID": (_h = config.requestId) !== null && _h !== void 0 ? _h : (0, uuid_1.v4)(),
|
|
221
|
+
TIMESTAMP: (_j = config.timestamp) !== null && _j !== void 0 ? _j : new Date().toISOString(),
|
|
222
|
+
"X-HIP-ID": config.hipId,
|
|
223
|
+
"X-LINK-TOKEN": config.linkToken,
|
|
224
|
+
"X-CM-ID": this.xCmId,
|
|
225
|
+
"Content-Type": "application/json",
|
|
226
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
227
|
+
};
|
|
228
|
+
const url = `${this.baseUrl}api/hiecm/hip/v3/link/context/notify`;
|
|
144
229
|
const body = {
|
|
145
|
-
requestId: (0, uuid_1.v4)(),
|
|
146
|
-
timestamp: new Date().toISOString(),
|
|
147
230
|
notification: {
|
|
148
231
|
patient: {
|
|
149
232
|
id: config.healthId,
|
|
@@ -160,13 +243,59 @@ class Link extends header_1.default {
|
|
|
160
243
|
},
|
|
161
244
|
};
|
|
162
245
|
yield new request_1.default().request({
|
|
163
|
-
headers
|
|
246
|
+
headers,
|
|
164
247
|
method: "POST",
|
|
165
248
|
requestBody: body,
|
|
166
|
-
url
|
|
249
|
+
url,
|
|
167
250
|
});
|
|
168
251
|
return body;
|
|
169
252
|
});
|
|
253
|
+
/**
|
|
254
|
+
* Generates a patient token (ABDM HIE-CM v3 endpoint) required for HIE (Health Information Exchange) operations.
|
|
255
|
+
*
|
|
256
|
+
* This token is needed to authorize subsequent HIE transactions such as data push and data pull requests.
|
|
257
|
+
* The API uses the v3 endpoint `/api/hiecm/v3/token/generate-token` which requires custom headers
|
|
258
|
+
* (REQUEST-ID, TIMESTAMP, X-HIP-ID) not present in the standard v0.5 header set.
|
|
259
|
+
*
|
|
260
|
+
* @param config - Configuration object for token generation
|
|
261
|
+
* @param config.healthId - Patient's health ID used to derive the X-CM-ID header (e.g., "user@abdm")
|
|
262
|
+
* @param config.hipId - Health Information Provider ID sent as X-HIP-ID header
|
|
263
|
+
* @param config.abhaNumber - Patient's ABHA number (can be numeric or string)
|
|
264
|
+
* @param config.abhaAddress - Patient's ABHA address (e.g., "user@sbx")
|
|
265
|
+
* @param config.name - Patient's full name
|
|
266
|
+
* @param config.gender - Patient's gender
|
|
267
|
+
* @param config.yearOfBirth - Patient's year of birth
|
|
268
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header (auto-generated if omitted)
|
|
269
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header (auto-generated if omitted)
|
|
270
|
+
* @returns The parsed API response containing the generated patient token
|
|
271
|
+
*/
|
|
272
|
+
this.generateToken = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
var _k, _l;
|
|
274
|
+
this.setXCmId(config.healthId);
|
|
275
|
+
const headers = {
|
|
276
|
+
"REQUEST-ID": (_k = config.requestId) !== null && _k !== void 0 ? _k : (0, uuid_1.v4)(),
|
|
277
|
+
TIMESTAMP: (_l = config.timestamp) !== null && _l !== void 0 ? _l : new Date().toISOString(),
|
|
278
|
+
"X-HIP-ID": config.hipId,
|
|
279
|
+
"X-CM-ID": this.xCmId,
|
|
280
|
+
"Content-Type": "application/json",
|
|
281
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
282
|
+
};
|
|
283
|
+
const url = `${this.baseUrl}api/hiecm/v3/token/generate-token`;
|
|
284
|
+
const body = {
|
|
285
|
+
abhaNumber: config.abhaNumber,
|
|
286
|
+
abhaAddress: config.abhaAddress,
|
|
287
|
+
name: config.name,
|
|
288
|
+
gender: config.gender,
|
|
289
|
+
yearOfBirth: config.yearOfBirth,
|
|
290
|
+
};
|
|
291
|
+
const response = yield new request_1.default().request({
|
|
292
|
+
headers,
|
|
293
|
+
method: "POST",
|
|
294
|
+
requestBody: body,
|
|
295
|
+
url,
|
|
296
|
+
});
|
|
297
|
+
return JSON.parse(response.body);
|
|
298
|
+
});
|
|
170
299
|
}
|
|
171
300
|
}
|
|
172
301
|
exports.default = Link;
|
package/lib/classes/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/classes/link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAAoC;AACpC,wDAAgC;AAChC,sDAA8B;AAc9B,MAAqB,IAAK,SAAQ,gBAAM;IACtC,YAAY,QAAgB,EAAE,YAAoB;QAChD,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAGhC
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/classes/link.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAAoC;AACpC,wDAAgC;AAChC,sDAA8B;AAc9B,MAAqB,IAAK,SAAQ,gBAAM;IACtC,YAAY,QAAgB,EAAE,YAAoB;QAChD,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAGhC;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;QACH,mBAAc,GAAG,CAAO,MAkBvB,EAAE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AAM,EAAE,MAAM,CAAC,MAAM;gBACrB,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,iBAAO,EAAE,CAAC,OAAO,CAAC;gBAC3C,OAAO;gBACP,MAAM,EAAE,MAAM;gBACd,WAAW,EAAE,IAAI;gBACjB,GAAG;aACJ,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CAAA,CAAC;IAzWF,CAAC;CA0WF;AA7WD,uBA6WC"}
|
|
@@ -16,22 +16,30 @@ export interface PATIENT_FIND {
|
|
|
16
16
|
export default class Patients extends Header {
|
|
17
17
|
constructor(_baseUrl: string, _accessToken: string);
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* Sends an SMS notification to a patient about linked care contexts using the v3 HIE-CM endpoint.
|
|
20
|
+
*
|
|
21
|
+
* This replaces the deprecated v0.5 `smsNotify2` endpoint. It requires the v3 inline header
|
|
22
|
+
* pattern (REQUEST-ID, TIMESTAMP, X-CM-ID) and sends a simplified notification payload
|
|
23
|
+
* containing the patient's phone number and HIP details.
|
|
24
|
+
*
|
|
25
|
+
* Headers are built inline following the existing v3 pattern used by `generateToken` and `addCareContext`.
|
|
26
|
+
*
|
|
27
|
+
* @param config - Configuration object
|
|
28
|
+
* @param config.healthId - Patient's health ID used to derive X-CM-ID header (e.g., "unknown@sbx" or "unknown@abdm")
|
|
29
|
+
* @param config.phoneNo - Patient's phone number for SMS notification
|
|
30
|
+
* @param config.hipName - Display name of the Health Information Provider (HIP)
|
|
31
|
+
* @param config.hipId - HIP identifier (e.g., "IN2910000004")
|
|
32
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header and body (auto-generated if omitted)
|
|
33
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header and body (auto-generated if omitted)
|
|
34
|
+
* @returns The parsed API response
|
|
24
35
|
*/
|
|
25
36
|
smsNotify2: (config: {
|
|
26
37
|
healthId: "unknown@sbx" | "unknown@abdm";
|
|
27
38
|
phoneNo: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
hipid: string;
|
|
33
|
-
errCode?: string;
|
|
34
|
-
errMessage?: string;
|
|
39
|
+
hipName: string;
|
|
40
|
+
hipId: string;
|
|
41
|
+
requestId?: string;
|
|
42
|
+
timestamp?: string;
|
|
35
43
|
}) => Promise<any>;
|
|
36
44
|
/**
|
|
37
45
|
* This API is meant for identify to patient given her consent-manager-user-id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patients.d.ts","sourceRoot":"","sources":["../../src/classes/patients.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAI9B,aAAK,aAAa,GAAG,KAAK,GAAE,KAAK,CAAA;AACjC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACL,OAAO,EAAG;YACR,EAAE,EAAE,MAAM,CAAA;SACX,CAAA;QAED,SAAS,EAAE;YACT,IAAI,EAAG,aAAa,CAAA;YACpB,EAAE,EAAE,MAAM,CAAA;SACX,CAAA;KACF,CAAA;CACF;AAID,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,MAAM;gBAC9B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAGlD
|
|
1
|
+
{"version":3,"file":"patients.d.ts","sourceRoot":"","sources":["../../src/classes/patients.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAI9B,aAAK,aAAa,GAAG,KAAK,GAAE,KAAK,CAAA;AACjC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACL,OAAO,EAAG;YACR,EAAE,EAAE,MAAM,CAAA;SACX,CAAA;QAED,SAAS,EAAE;YACT,IAAI,EAAG,aAAa,CAAA;YACpB,EAAE,EAAE,MAAM,CAAA;SACX,CAAA;KACF,CAAA;CACF;AAID,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,MAAM;gBAC9B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAGlD;;;;;;;;;;;;;;;;;OAiBG;IACH,UAAU,WAAkB;QAC1B,QAAQ,EAAE,aAAa,GAAG,cAAc,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,kBAgCC;IAEF;;;;;OAKG;IACH,IAAI,WACM,YAAY,YACV,MAAM,uCAsBhB;CAMH"}
|
package/lib/classes/patients.js
CHANGED
|
@@ -19,47 +19,54 @@ class Patients extends header_1.default {
|
|
|
19
19
|
constructor(_baseUrl, _accessToken) {
|
|
20
20
|
super(_baseUrl, _accessToken);
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* Sends an SMS notification to a patient about linked care contexts using the v3 HIE-CM endpoint.
|
|
23
|
+
*
|
|
24
|
+
* This replaces the deprecated v0.5 `smsNotify2` endpoint. It requires the v3 inline header
|
|
25
|
+
* pattern (REQUEST-ID, TIMESTAMP, X-CM-ID) and sends a simplified notification payload
|
|
26
|
+
* containing the patient's phone number and HIP details.
|
|
27
|
+
*
|
|
28
|
+
* Headers are built inline following the existing v3 pattern used by `generateToken` and `addCareContext`.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Configuration object
|
|
31
|
+
* @param config.healthId - Patient's health ID used to derive X-CM-ID header (e.g., "unknown@sbx" or "unknown@abdm")
|
|
32
|
+
* @param config.phoneNo - Patient's phone number for SMS notification
|
|
33
|
+
* @param config.hipName - Display name of the Health Information Provider (HIP)
|
|
34
|
+
* @param config.hipId - HIP identifier (e.g., "IN2910000004")
|
|
35
|
+
* @param config.requestId - Optional UUID for REQUEST-ID header and body (auto-generated if omitted)
|
|
36
|
+
* @param config.timestamp - Optional ISO timestamp for TIMESTAMP header and body (auto-generated if omitted)
|
|
37
|
+
* @returns The parsed API response
|
|
27
38
|
*/
|
|
28
39
|
this.smsNotify2 = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
console.log(error);
|
|
62
|
-
}
|
|
40
|
+
var _a, _b;
|
|
41
|
+
this.setXCmId(config.healthId);
|
|
42
|
+
const requestId = (_a = config.requestId) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
43
|
+
const timestamp = (_b = config.timestamp) !== null && _b !== void 0 ? _b : new Date().toISOString();
|
|
44
|
+
const headers = {
|
|
45
|
+
"REQUEST-ID": requestId,
|
|
46
|
+
TIMESTAMP: timestamp,
|
|
47
|
+
"X-CM-ID": this.xCmId,
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
Authorization: `Bearer ${this.accessToken}`,
|
|
50
|
+
};
|
|
51
|
+
const url = `${this.baseUrl}api/hiecm/hip/v3/link/patient/links/sms/notify2`;
|
|
52
|
+
const body = {
|
|
53
|
+
requestId,
|
|
54
|
+
timestamp,
|
|
55
|
+
notification: {
|
|
56
|
+
phoneNo: config.phoneNo,
|
|
57
|
+
hip: {
|
|
58
|
+
name: config.hipName,
|
|
59
|
+
id: config.hipId,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const response = yield new request_1.default().request({
|
|
64
|
+
headers,
|
|
65
|
+
method: "POST",
|
|
66
|
+
requestBody: body,
|
|
67
|
+
url,
|
|
68
|
+
});
|
|
69
|
+
return JSON.parse(response.body);
|
|
63
70
|
});
|
|
64
71
|
/**
|
|
65
72
|
* This API is meant for identify to patient given her consent-manager-user-id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patients.js","sourceRoot":"","sources":["../../src/classes/patients.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,+BAAoC;AACpC,wDAAgC;AAoBhC,MAAqB,QAAS,SAAQ,gBAAM;IAC1C,YAAY,QAAgB,EAAE,YAAoB;QAChD,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEhC
|
|
1
|
+
{"version":3,"file":"patients.js","sourceRoot":"","sources":["../../src/classes/patients.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,+BAAoC;AACpC,wDAAgC;AAoBhC,MAAqB,QAAS,SAAQ,gBAAM;IAC1C,YAAY,QAAgB,EAAE,YAAoB;QAChD,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEhC;;;;;;;;;;;;;;;;;WAiBG;QACH,eAAU,GAAG,CAAO,MAOnB,EAAE,EAAE;;YACH,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC/B,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAA,SAAM,GAAE,CAAC;YAC/C,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,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B,MAAM,EAAE,MAAM;oBACd,WAAW,EAAE,IAAI;oBACjB,GAAG,EAAE,GAAG;iBACT,CAAC,CAAC;gBAEH,OAAO,IAAI,CAAC;aACb;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;aACpB;QACH,CAAC,CAAA,CAAC;IA1FF,CAAC;CAgGF;AAnGD,2BAmGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAuth.d.ts","sourceRoot":"","sources":["../../src/classes/userAuth.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,aAAK,OAAO,GAAG,cAAc,GAAG,KAAK,GAAG,MAAM,CAAA;AAG9C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,MAAM;gBAC5B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIlD,UAAU,WAAiB;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"userAuth.d.ts","sourceRoot":"","sources":["../../src/classes/userAuth.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,aAAK,OAAO,GAAG,cAAc,GAAG,KAAK,GAAG,MAAM,CAAA;AAG9C,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,MAAM;gBAC5B,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAIlD,UAAU,WAAiB;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,KAAG,QAAQ,GAAG,CAAC,CAsB/G;IAGD,IAAI,WAAkB;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,YAAY,GAAG,cAAc,GAAG,aAAa,CAAA;KAAE,KAAG,QAAQ,GAAG,CAAC,CAuBnK;IAGD,OAAO,WAAkB;QAAE,QAAQ,EAAC,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAE;QAAC,WAAW,CAAC,EAAE;YACjG,MAAM,EAAE,MAAM,CAAC;YACf,QAAQ,EAAE,MAAM,CAAC;YACjB,aAAa,EAAE,MAAM,CAAC;YACtB,YAAY,EAAE;gBACZ,MAAM,EAAE,QAAQ,CAAC;gBACjB,OAAO,EAAE,MAAM,CAAA;aAChB,CAAA;SACJ,CAAA;KAAE;;;;;;;;;;;;;;;;OA4BF;CAIJ"}
|
package/lib/classes/userAuth.js
CHANGED
|
@@ -20,8 +20,7 @@ class UserAuth extends header_1.default {
|
|
|
20
20
|
super(_baseUrl, _accessToken);
|
|
21
21
|
this.fetchModes = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
const headers = this.headers(config.healthId);
|
|
23
|
-
|
|
24
|
-
const url = `${this.baseUrl}api/v3/identity/authentication`;
|
|
23
|
+
const url = `${this.baseUrl}v0.5/users/auth/fetch-modes`;
|
|
25
24
|
const body = {
|
|
26
25
|
"requestId": (0, uuid_1.v4)(),
|
|
27
26
|
"timestamp": new Date().toISOString(),
|
|
@@ -41,8 +40,7 @@ class UserAuth extends header_1.default {
|
|
|
41
40
|
});
|
|
42
41
|
this.init = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
43
42
|
const headers = this.headers(config.healthId);
|
|
44
|
-
|
|
45
|
-
const url = `${this.baseUrl}api/v3/identity/authentication`;
|
|
43
|
+
const url = `${this.baseUrl}v0.5/users/auth/init`;
|
|
46
44
|
const body = {
|
|
47
45
|
"requestId": (0, uuid_1.v4)(),
|
|
48
46
|
"timestamp": new Date().toISOString(),
|
|
@@ -64,8 +62,7 @@ class UserAuth extends header_1.default {
|
|
|
64
62
|
this.confirm = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
65
63
|
var _a, _b, _c, _d, _e;
|
|
66
64
|
const headers = this.headers(config.healthId);
|
|
67
|
-
|
|
68
|
-
const url = `${this.baseUrl}api/v3/identity/authentication`;
|
|
65
|
+
const url = `${this.baseUrl}v0.5/users/auth/confirm`;
|
|
69
66
|
const body = {
|
|
70
67
|
"requestId": (0, uuid_1.v4)(),
|
|
71
68
|
"timestamp": new Date().toISOString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userAuth.js","sourceRoot":"","sources":["../../src/classes/userAuth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,+BAAoC;AACpC,wDAAgC;AAChC,sDAA8B;AAK9B,MAAqB,QAAS,SAAQ,gBAAM;IACxC,YAAY,QAAgB,EAAE,YAAoB;QAC9C,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAGjC,eAAU,GAAE,CAAO,MAA8E,EAAgB,EAAE;YAC/G,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC7C,
|
|
1
|
+
{"version":3,"file":"userAuth.js","sourceRoot":"","sources":["../../src/classes/userAuth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,+BAAoC;AACpC,wDAAgC;AAChC,sDAA8B;AAK9B,MAAqB,QAAS,SAAQ,gBAAM;IACxC,YAAY,QAAgB,EAAE,YAAoB;QAC9C,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;QAGjC,eAAU,GAAE,CAAO,MAA8E,EAAgB,EAAE;YAC/G,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YAC7C,MAAM,GAAG,GAAG,GAAG,I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