@oystehr/sdk 4.3.2 → 4.3.4
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 +1 -1
- package/dist/cjs/client/client.cjs +87 -13
- package/dist/cjs/client/client.cjs.map +1 -1
- package/dist/cjs/client/client.d.ts +3 -0
- package/dist/cjs/config.d.ts +19 -0
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/logger.cjs +36 -0
- package/dist/cjs/logger.cjs.map +1 -0
- package/dist/cjs/logger.d.ts +11 -0
- package/dist/cjs/resources/classes/erx.cjs +8 -0
- package/dist/cjs/resources/classes/erx.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.d.ts +7 -1
- package/dist/cjs/resources/classes/fhir-ext.cjs +290 -19
- package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/index.cjs +9 -2
- package/dist/cjs/resources/classes/index.cjs.map +1 -1
- package/dist/cjs/resources/classes/index.d.ts +1 -1
- package/dist/cjs/resources/classes/rcm.cjs +18 -0
- package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
- package/dist/cjs/resources/classes/rcm.d.ts +22 -1
- package/dist/cjs/resources/classes/user.cjs +9 -0
- package/dist/cjs/resources/classes/user.cjs.map +1 -1
- package/dist/cjs/resources/classes/user.d.ts +8 -1
- package/dist/cjs/resources/types/ErxGetMedicationHistoryParams.d.ts +3 -0
- package/dist/cjs/resources/types/ErxGetMedicationHistoryResponse.d.ts +43 -0
- package/dist/cjs/resources/types/ErxGetMedicationResponse.d.ts +1 -1
- package/dist/cjs/resources/types/RcmGetPayerParams.d.ts +3 -0
- package/dist/cjs/resources/types/RcmGetPayerResponse.d.ts +5 -0
- package/dist/cjs/resources/types/RcmListPayersParams.d.ts +9 -0
- package/dist/cjs/resources/types/RcmListPayersResponse.d.ts +13 -0
- package/dist/cjs/resources/types/UserChangePasswordParams.d.ts +7 -0
- package/dist/cjs/resources/types/fhir.d.ts +13 -3
- package/dist/cjs/resources/types/index.d.ts +13 -6
- package/dist/esm/client/client.d.ts +3 -0
- package/dist/esm/client/client.js +88 -15
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/config.d.ts +19 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/logger.d.ts +11 -0
- package/dist/esm/logger.js +34 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/resources/classes/erx.d.ts +7 -1
- package/dist/esm/resources/classes/erx.js +8 -0
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.js +290 -19
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/index.d.ts +1 -1
- package/dist/esm/resources/classes/index.js +9 -2
- package/dist/esm/resources/classes/index.js.map +1 -1
- package/dist/esm/resources/classes/rcm.d.ts +22 -1
- package/dist/esm/resources/classes/rcm.js +18 -0
- package/dist/esm/resources/classes/rcm.js.map +1 -1
- package/dist/esm/resources/classes/user.d.ts +8 -1
- package/dist/esm/resources/classes/user.js +9 -0
- package/dist/esm/resources/classes/user.js.map +1 -1
- package/dist/esm/resources/types/ErxGetMedicationHistoryParams.d.ts +3 -0
- package/dist/esm/resources/types/ErxGetMedicationHistoryResponse.d.ts +43 -0
- package/dist/esm/resources/types/ErxGetMedicationResponse.d.ts +1 -1
- package/dist/esm/resources/types/RcmGetPayerParams.d.ts +3 -0
- package/dist/esm/resources/types/RcmGetPayerResponse.d.ts +5 -0
- package/dist/esm/resources/types/RcmListPayersParams.d.ts +9 -0
- package/dist/esm/resources/types/RcmListPayersResponse.d.ts +13 -0
- package/dist/esm/resources/types/UserChangePasswordParams.d.ts +7 -0
- package/dist/esm/resources/types/fhir.d.ts +13 -3
- package/dist/esm/resources/types/index.d.ts +13 -6
- package/package.json +1 -1
- package/src/client/client.ts +95 -15
- package/src/config.ts +20 -0
- package/src/logger.ts +36 -0
- package/src/resources/classes/erx.ts +17 -0
- package/src/resources/classes/fhir-ext.ts +322 -19
- package/src/resources/classes/index.ts +9 -2
- package/src/resources/classes/rcm.ts +39 -0
- package/src/resources/classes/user.ts +10 -0
- package/src/resources/types/ErxGetMedicationHistoryParams.ts +5 -0
- package/src/resources/types/ErxGetMedicationHistoryResponse.ts +45 -0
- package/src/resources/types/ErxGetMedicationResponse.ts +1 -1
- package/src/resources/types/RcmGetPayerParams.ts +5 -0
- package/src/resources/types/RcmGetPayerResponse.ts +7 -0
- package/src/resources/types/RcmListPayersParams.ts +11 -0
- package/src/resources/types/RcmListPayersResponse.ts +15 -0
- package/src/resources/types/UserChangePasswordParams.ts +9 -0
- package/src/resources/types/fhir.ts +16 -0
- package/src/resources/types/index.ts +13 -6
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class Logger {
|
|
4
|
+
_level;
|
|
5
|
+
constructor({ level }) {
|
|
6
|
+
this._level = level;
|
|
7
|
+
}
|
|
8
|
+
error(message, extra = {}) {
|
|
9
|
+
if (this._level && ['error', 'info', 'debug'].includes(this._level)) {
|
|
10
|
+
console.error(JSON.stringify({ message, ...extra }));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
info(message, extra = {}) {
|
|
14
|
+
if (this._level && ['info', 'debug'].includes(this._level)) {
|
|
15
|
+
console.info(JSON.stringify({ message, ...extra }));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
debug(message, extra = {}) {
|
|
19
|
+
if (this._level && ['debug'].includes(this._level)) {
|
|
20
|
+
console.debug(JSON.stringify({ message, ...extra }));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
time(message, extra = {}) {
|
|
24
|
+
if (this._level && ['debug'].includes(this._level)) {
|
|
25
|
+
console.time(JSON.stringify({ message, ...extra }));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
timeEnd(message, extra = {}) {
|
|
29
|
+
if (this._level && ['debug'].includes(this._level)) {
|
|
30
|
+
console.timeEnd(JSON.stringify({ message, ...extra }));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.Logger = Logger;
|
|
36
|
+
//# sourceMappingURL=logger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.cjs","sources":["../../src/logger.ts"],"sourcesContent":["export class Logger {\n _level?: 'error' | 'info' | 'debug';\n constructor({ level }: { level?: 'error' | 'info' | 'debug' }) {\n this._level = level;\n }\n\n error(message: string, extra: Record<string, any> = {}): void {\n if (this._level && ['error', 'info', 'debug'].includes(this._level)) {\n console.error(JSON.stringify({ message, ...extra }));\n }\n }\n\n info(message: string, extra: Record<string, any> = {}): void {\n if (this._level && ['info', 'debug'].includes(this._level)) {\n console.info(JSON.stringify({ message, ...extra }));\n }\n }\n\n debug(message: string, extra: Record<string, any> = {}): void {\n if (this._level && ['debug'].includes(this._level)) {\n console.debug(JSON.stringify({ message, ...extra }));\n }\n }\n\n time(message: string, extra: Record<string, any> = {}): void {\n if (this._level && ['debug'].includes(this._level)) {\n console.time(JSON.stringify({ message, ...extra }));\n }\n }\n\n timeEnd(message: string, extra: Record<string, any> = {}): void {\n if (this._level && ['debug'].includes(this._level)) {\n console.timeEnd(JSON.stringify({ message, ...extra }));\n }\n }\n}\n"],"names":[],"mappings":";;MAAa,MAAM,CAAA;AACjB,IAAA,MAAM;IACN,WAAA,CAAY,EAAE,KAAK,EAA0C,EAAA;AAC3D,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;IACrB;AAEA,IAAA,KAAK,CAAC,OAAe,EAAE,KAAA,GAA6B,EAAE,EAAA;AACpD,QAAA,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;AACnE,YAAA,OAAO,CAAC,KAAK,CA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AAE,CAAC,CAAC;QACxD;IACF;AACD;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
_level?: 'error' | 'info' | 'debug';
|
|
3
|
+
constructor({ level }: {
|
|
4
|
+
level?: 'error' | 'info' | 'debug';
|
|
5
|
+
});
|
|
6
|
+
error(message: string, extra?: Record<string, any>): void;
|
|
7
|
+
info(message: string, extra?: Record<string, any>): void;
|
|
8
|
+
debug(message: string, extra?: Record<string, any>): void;
|
|
9
|
+
time(message: string, extra?: Record<string, any>): void;
|
|
10
|
+
timeEnd(message: string, extra?: Record<string, any>): void;
|
|
11
|
+
}
|
|
@@ -66,6 +66,14 @@ class Erx extends client.SDKResource {
|
|
|
66
66
|
checkPrecheckInteractions(params, request) {
|
|
67
67
|
return this.request('/patient/{patientId}/interactions/precheck/{drugId}', 'get', this.#baseUrlThunk.bind(this))(params, request);
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve claims-based medication history for a patient. This endpoint requires the patient to be synced with the upstream eRx provider.
|
|
71
|
+
* Action: `eRx:GetMedicationHistory`
|
|
72
|
+
* Access Policy Resource: `eRx:Patient`
|
|
73
|
+
*/
|
|
74
|
+
getMedicationHistory(params, request) {
|
|
75
|
+
return this.request('/patient/{patientId}/medication-history', 'get', this.#baseUrlThunk.bind(this))(params, request);
|
|
76
|
+
}
|
|
69
77
|
/**
|
|
70
78
|
* Adds pharmacy for a patient with the upstream eRx provider, setting it as primary if specified.
|
|
71
79
|
* Action: `eRx:AddPatientPharmacy`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erx.cjs","sources":["../../../../src/resources/classes/erx.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n ErxAddPatientPharmacyParams,\n ErxCancelPrescriptionParams,\n ErxCheckAllergyInteractionsParams,\n ErxCheckAllergyInteractionsResponse,\n ErxCheckMedicationInteractionsParams,\n ErxCheckMedicationInteractionsResponse,\n ErxCheckPractitionerEnrollmentParams,\n ErxCheckPractitionerEnrollmentResponse,\n ErxCheckPrecheckInteractionsParams,\n ErxCheckPrecheckInteractionsResponse,\n ErxConnectPractitionerParams,\n ErxConnectPractitionerResponse,\n ErxEnrollPractitionerParams,\n ErxGetConfigurationResponse,\n ErxGetMedicationParams,\n ErxGetMedicationResponse,\n ErxSearchAllergensParams,\n ErxSearchAllergensResponse,\n ErxSearchMedicationsParams,\n ErxSearchMedicationsResponse,\n ErxSearchPharmaciesParams,\n ErxSearchPharmaciesResponse,\n ErxSyncPatientParams,\n ErxUnenrollPractitionerParams,\n OystehrClientRequest,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\n\nexport class Erx extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['erxApiUrl'] ?? 'https://erx-api.zapehr.com/v3';\n }\n /**\n * Search for allergens.\n * Action: `eRx:SearchAllergen`\n * Access Policy Resource: `eRx:Allergen`\n */\n searchAllergens(\n params: ErxSearchAllergensParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchAllergensResponse> {\n return this.request('/allergen', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for medications.\n * Action: `eRx:SearchMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n searchMedications(\n params: ErxSearchMedicationsParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchMedicationsResponse> {\n return this.request('/medication', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(params: ErxGetMedicationParams, request?: OystehrClientRequest): Promise<ErxGetMedicationResponse>;\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(request?: OystehrClientRequest): Promise<ErxGetMedicationResponse>;\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(\n params?: ErxGetMedicationParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxGetMedicationResponse> {\n return this.request('/medication/details', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get eRx configuration for project.\n * Action: `eRx:GetConfiguration`\n * Access Policy Resource: `eRx:Configuration`\n */\n getConfiguration(request?: OystehrClientRequest): Promise<ErxGetConfigurationResponse> {\n return this.request('/config', 'get', this.#baseUrlThunk.bind(this))(request);\n }\n /**\n * Check for drug-allergy interactions for a patient. This endpoint requires the patient's allergies to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkAllergyInteractions(\n params: ErxCheckAllergyInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckAllergyInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/allergy',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Check for drug-drug interactions for a patient. This endpoint requires the patient's medications to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkMedicationInteractions(\n params: ErxCheckMedicationInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckMedicationInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/medication',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Check for drug-allergy and drug-drug interactions with a specific drug for a patient. This endpoint requires the patient's allergies and medications to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkPrecheckInteractions(\n params: ErxCheckPrecheckInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckPrecheckInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/precheck/{drugId}',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Adds pharmacy for a patient with the upstream eRx provider, setting it as primary if specified.\n * Action: `eRx:AddPatientPharmacy`\n * Access Policy Resource: `eRx:Patient`\n */\n addPatientPharmacy(params: ErxAddPatientPharmacyParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/patient/{patientId}/pharmacies', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Cancel prescription for patient.\n * Action: `eRx:CancelPrescription`\n * Access Policy Resource: `eRx:Prescription`\n */\n cancelPrescription(params: ErxCancelPrescriptionParams, request?: OystehrClientRequest): Promise<void> {\n return this.request(\n '/patient/{patientId}/prescriptions/{medicationRequestId}',\n 'delete',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Syncs demographic, allergy, and medication data for a patient with the upstream eRx provider.\n * Action: `eRx:SyncPatient`\n * Access Policy Resource: `eRx:Patient`\n */\n syncPatient(params: ErxSyncPatientParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/patient/{patientId}/sync', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(\n params: ErxSearchPharmaciesParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchPharmaciesResponse>;\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(request?: OystehrClientRequest): Promise<ErxSearchPharmaciesResponse>;\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(\n params?: ErxSearchPharmaciesParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxSearchPharmaciesResponse> {\n return this.request('/pharmacy', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(\n params: ErxConnectPractitionerParams,\n request?: OystehrClientRequest\n ): Promise<ErxConnectPractitionerResponse>;\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(request?: OystehrClientRequest): Promise<ErxConnectPractitionerResponse>;\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(\n params?: ErxConnectPractitionerParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxConnectPractitionerResponse> {\n return this.request('/practitioner/connect', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Check eRx enrollment for a practitioner.\n * Action: `eRx:Read`\n * Access Policy Resource: `eRx:Enrollment`\n */\n checkPractitionerEnrollment(\n params: ErxCheckPractitionerEnrollmentParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckPractitionerEnrollmentResponse> {\n return this.request('/practitioner/{practitionerId}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Enroll a practitioner in the eRx service.\n * Action: `eRx:Create`\n * Access Policy Resource: `eRx:Enrollment`\n */\n enrollPractitioner(params: ErxEnrollPractitionerParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/practitioner/{practitionerId}', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Unenroll a practitioner from the eRx service.\n * Action: `eRx:Delete`\n * Access Policy Resource: `eRx:Enrollment`\n */\n unenrollPractitioner(params: ErxUnenrollPractitionerParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/practitioner/{practitionerId}', 'delete', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource"],"mappings":";;;;AAAA;AAgCM,MAAO,GAAI,SAAQA,kBAAW,CAAA;AAClC,IAAA,WAAA,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AO,CAAC;IACzF;AAgBA;;;;AAIG;IACH,mBAAmB,CACjB,MAA4D,EAC5D,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACrG;AACA;;;;AAIG;IACH,2BAA2B,CACzB,MAA4C,EAC5C,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9G;AACA;;;;AAIG;IACH,kBAAkB,CAAC,MAAmC,EAAE,OAA8B,EAAA;QACpF,OAAO,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/G;AACA;;;;AAIG;IACH,oBAAoB,CAAC,MAAqC,EAAE,OAA8B,EAAA;QACxF,OAAO,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACjH;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"erx.cjs","sources":["../../../../src/resources/classes/erx.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n ErxAddPatientPharmacyParams,\n ErxCancelPrescriptionParams,\n ErxCheckAllergyInteractionsParams,\n ErxCheckAllergyInteractionsResponse,\n ErxCheckMedicationInteractionsParams,\n ErxCheckMedicationInteractionsResponse,\n ErxCheckPractitionerEnrollmentParams,\n ErxCheckPractitionerEnrollmentResponse,\n ErxCheckPrecheckInteractionsParams,\n ErxCheckPrecheckInteractionsResponse,\n ErxConnectPractitionerParams,\n ErxConnectPractitionerResponse,\n ErxEnrollPractitionerParams,\n ErxGetConfigurationResponse,\n ErxGetMedicationHistoryParams,\n ErxGetMedicationHistoryResponse,\n ErxGetMedicationParams,\n ErxGetMedicationResponse,\n ErxSearchAllergensParams,\n ErxSearchAllergensResponse,\n ErxSearchMedicationsParams,\n ErxSearchMedicationsResponse,\n ErxSearchPharmaciesParams,\n ErxSearchPharmaciesResponse,\n ErxSyncPatientParams,\n ErxUnenrollPractitionerParams,\n OystehrClientRequest,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\n\nexport class Erx extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['erxApiUrl'] ?? 'https://erx-api.zapehr.com/v3';\n }\n /**\n * Search for allergens.\n * Action: `eRx:SearchAllergen`\n * Access Policy Resource: `eRx:Allergen`\n */\n searchAllergens(\n params: ErxSearchAllergensParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchAllergensResponse> {\n return this.request('/allergen', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for medications.\n * Action: `eRx:SearchMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n searchMedications(\n params: ErxSearchMedicationsParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchMedicationsResponse> {\n return this.request('/medication', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(params: ErxGetMedicationParams, request?: OystehrClientRequest): Promise<ErxGetMedicationResponse>;\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(request?: OystehrClientRequest): Promise<ErxGetMedicationResponse>;\n /**\n * Get full medication details.\n * Action: `eRx:GetMedication`\n * Access Policy Resource: `eRx:Medication`\n */\n getMedication(\n params?: ErxGetMedicationParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxGetMedicationResponse> {\n return this.request('/medication/details', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get eRx configuration for project.\n * Action: `eRx:GetConfiguration`\n * Access Policy Resource: `eRx:Configuration`\n */\n getConfiguration(request?: OystehrClientRequest): Promise<ErxGetConfigurationResponse> {\n return this.request('/config', 'get', this.#baseUrlThunk.bind(this))(request);\n }\n /**\n * Check for drug-allergy interactions for a patient. This endpoint requires the patient's allergies to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkAllergyInteractions(\n params: ErxCheckAllergyInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckAllergyInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/allergy',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Check for drug-drug interactions for a patient. This endpoint requires the patient's medications to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkMedicationInteractions(\n params: ErxCheckMedicationInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckMedicationInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/medication',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Check for drug-allergy and drug-drug interactions with a specific drug for a patient. This endpoint requires the patient's allergies and medications to be synced with the upstream eRx provider.\n * Action: `eRx:Check`\n * Access Policy Resource: `eRx:Interaction`\n */\n checkPrecheckInteractions(\n params: ErxCheckPrecheckInteractionsParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckPrecheckInteractionsResponse> {\n return this.request(\n '/patient/{patientId}/interactions/precheck/{drugId}',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Retrieve claims-based medication history for a patient. This endpoint requires the patient to be synced with the upstream eRx provider.\n * Action: `eRx:GetMedicationHistory`\n * Access Policy Resource: `eRx:Patient`\n */\n getMedicationHistory(\n params: ErxGetMedicationHistoryParams,\n request?: OystehrClientRequest\n ): Promise<ErxGetMedicationHistoryResponse> {\n return this.request(\n '/patient/{patientId}/medication-history',\n 'get',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Adds pharmacy for a patient with the upstream eRx provider, setting it as primary if specified.\n * Action: `eRx:AddPatientPharmacy`\n * Access Policy Resource: `eRx:Patient`\n */\n addPatientPharmacy(params: ErxAddPatientPharmacyParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/patient/{patientId}/pharmacies', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Cancel prescription for patient.\n * Action: `eRx:CancelPrescription`\n * Access Policy Resource: `eRx:Prescription`\n */\n cancelPrescription(params: ErxCancelPrescriptionParams, request?: OystehrClientRequest): Promise<void> {\n return this.request(\n '/patient/{patientId}/prescriptions/{medicationRequestId}',\n 'delete',\n this.#baseUrlThunk.bind(this)\n )(params, request);\n }\n /**\n * Syncs demographic, allergy, and medication data for a patient with the upstream eRx provider.\n * Action: `eRx:SyncPatient`\n * Access Policy Resource: `eRx:Patient`\n */\n syncPatient(params: ErxSyncPatientParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/patient/{patientId}/sync', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(\n params: ErxSearchPharmaciesParams,\n request?: OystehrClientRequest\n ): Promise<ErxSearchPharmaciesResponse>;\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(request?: OystehrClientRequest): Promise<ErxSearchPharmaciesResponse>;\n /**\n * Search for pharmacies by a variety of criteria.\n * Action: `eRx:SearchPharmacy`\n * Access Policy Resource: `eRx:Pharmacy`\n */\n searchPharmacies(\n params?: ErxSearchPharmaciesParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxSearchPharmaciesResponse> {\n return this.request('/pharmacy', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(\n params: ErxConnectPractitionerParams,\n request?: OystehrClientRequest\n ): Promise<ErxConnectPractitionerResponse>;\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(request?: OystehrClientRequest): Promise<ErxConnectPractitionerResponse>;\n /**\n * Create an SSO link for a practitioner. This link can be used to log in to the eRx service as the specified practitioner.\n * Action: `eRx:Connect`\n * Access Policy Resource: `eRx:SSO`\n */\n connectPractitioner(\n params?: ErxConnectPractitionerParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<ErxConnectPractitionerResponse> {\n return this.request('/practitioner/connect', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Check eRx enrollment for a practitioner.\n * Action: `eRx:Read`\n * Access Policy Resource: `eRx:Enrollment`\n */\n checkPractitionerEnrollment(\n params: ErxCheckPractitionerEnrollmentParams,\n request?: OystehrClientRequest\n ): Promise<ErxCheckPractitionerEnrollmentResponse> {\n return this.request('/practitioner/{practitionerId}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Enroll a practitioner in the eRx service.\n * Action: `eRx:Create`\n * Access Policy Resource: `eRx:Enrollment`\n */\n enrollPractitioner(params: ErxEnrollPractitionerParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/practitioner/{practitionerId}', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Unenroll a practitioner from the eRx service.\n * Action: `eRx:Delete`\n * Access Policy Resource: `eRx:Enrollment`\n */\n unenrollPractitioner(params: ErxUnenrollPractitionerParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/practitioner/{practitionerId}', 'delete', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource"],"mappings":";;;;AAAA;AAkCM,MAAO,GAAI,SAAQA,kBAAW,CAAA;AAClC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC;IACf;IACA,aAAa,GAAA;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,+BAA+B;IAC/E;AACA;;;;AAIG;IACH,eAAe,CACb,MAAgC,EAChC,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACzF;AACA;;;;AAIG;IACH,iBAAiB,CACf,MAAkC,EAClC,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3F;AAaA;;;;AAIG;IACH,aAAa,CACX,MAAsD,EACtD,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACnG;AACA;;;;AAIG;AACH,IAAA,gBAAgB,CAAC,OAA8B,EAAA;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/E;AACA;;;;AAIG;IACH,wBAAwB,CACtB,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,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACjH;AACD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErxAddPatientPharmacyParams, ErxCancelPrescriptionParams, ErxCheckAllergyInteractionsParams, ErxCheckAllergyInteractionsResponse, ErxCheckMedicationInteractionsParams, ErxCheckMedicationInteractionsResponse, ErxCheckPractitionerEnrollmentParams, ErxCheckPractitionerEnrollmentResponse, ErxCheckPrecheckInteractionsParams, ErxCheckPrecheckInteractionsResponse, ErxConnectPractitionerParams, ErxConnectPractitionerResponse, ErxEnrollPractitionerParams, ErxGetConfigurationResponse, ErxGetMedicationParams, ErxGetMedicationResponse, ErxSearchAllergensParams, ErxSearchAllergensResponse, ErxSearchMedicationsParams, ErxSearchMedicationsResponse, ErxSearchPharmaciesParams, ErxSearchPharmaciesResponse, ErxSyncPatientParams, ErxUnenrollPractitionerParams, OystehrClientRequest } from '../..';
|
|
1
|
+
import { ErxAddPatientPharmacyParams, ErxCancelPrescriptionParams, ErxCheckAllergyInteractionsParams, ErxCheckAllergyInteractionsResponse, ErxCheckMedicationInteractionsParams, ErxCheckMedicationInteractionsResponse, ErxCheckPractitionerEnrollmentParams, ErxCheckPractitionerEnrollmentResponse, ErxCheckPrecheckInteractionsParams, ErxCheckPrecheckInteractionsResponse, ErxConnectPractitionerParams, ErxConnectPractitionerResponse, ErxEnrollPractitionerParams, ErxGetConfigurationResponse, ErxGetMedicationHistoryParams, ErxGetMedicationHistoryResponse, ErxGetMedicationParams, ErxGetMedicationResponse, ErxSearchAllergensParams, ErxSearchAllergensResponse, ErxSearchMedicationsParams, ErxSearchMedicationsResponse, ErxSearchPharmaciesParams, ErxSearchPharmaciesResponse, ErxSyncPatientParams, ErxUnenrollPractitionerParams, OystehrClientRequest } from '../..';
|
|
2
2
|
import { SDKResource } from '../../client/client';
|
|
3
3
|
import { OystehrConfig } from '../../config';
|
|
4
4
|
export declare class Erx extends SDKResource {
|
|
@@ -52,6 +52,12 @@ export declare class Erx extends SDKResource {
|
|
|
52
52
|
* Access Policy Resource: `eRx:Interaction`
|
|
53
53
|
*/
|
|
54
54
|
checkPrecheckInteractions(params: ErxCheckPrecheckInteractionsParams, request?: OystehrClientRequest): Promise<ErxCheckPrecheckInteractionsResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve claims-based medication history for a patient. This endpoint requires the patient to be synced with the upstream eRx provider.
|
|
57
|
+
* Action: `eRx:GetMedicationHistory`
|
|
58
|
+
* Access Policy Resource: `eRx:Patient`
|
|
59
|
+
*/
|
|
60
|
+
getMedicationHistory(params: ErxGetMedicationHistoryParams, request?: OystehrClientRequest): Promise<ErxGetMedicationHistoryResponse>;
|
|
55
61
|
/**
|
|
56
62
|
* Adds pharmacy for a patient with the upstream eRx provider, setting it as primary if specified.
|
|
57
63
|
* Action: `eRx:AddPatientPharmacy`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var client = require('../../client/client.cjs');
|
|
4
|
+
var index = require('../../errors/index.cjs');
|
|
4
5
|
|
|
5
6
|
// Code adapted from https://github.com/sindresorhus/uint8array-extras
|
|
6
7
|
const MAX_BLOCK_SIZE = 65_535;
|
|
@@ -14,6 +15,186 @@ function stringToBase64(input) {
|
|
|
14
15
|
}
|
|
15
16
|
return base64;
|
|
16
17
|
}
|
|
18
|
+
function base64ToString(input) {
|
|
19
|
+
const binaryString = globalThis.atob(input);
|
|
20
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
21
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
22
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
23
|
+
}
|
|
24
|
+
return new globalThis.TextDecoder().decode(bytes);
|
|
25
|
+
}
|
|
26
|
+
// ─── Tag-mode helpers ────────────────────────────────────────────────────────
|
|
27
|
+
/** Converts a Coding to the FHIR _tag parameter value format "system|code". */
|
|
28
|
+
function codingToTagValue(coding) {
|
|
29
|
+
return coding.system ? `${coding.system}|${coding.code ?? ''}` : coding.code ?? '';
|
|
30
|
+
}
|
|
31
|
+
/** Returns true if two Codings match on system (treating absent as empty string) and code. */
|
|
32
|
+
function codingMatches(a, b) {
|
|
33
|
+
return (a.system ?? '') === (b.system ?? '') && (a.code ?? '') === (b.code ?? '');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Appends _tag (tag-workspace mode) or _tag:not (ignore-tags mode) search
|
|
37
|
+
* params to an existing SearchParam array and returns the new array.
|
|
38
|
+
*/
|
|
39
|
+
function applyTagSearchParams(config, params) {
|
|
40
|
+
const out = params ? [...params] : [];
|
|
41
|
+
if (config.workspaceTag) {
|
|
42
|
+
out.push({ name: '_tag', value: codingToTagValue(config.workspaceTag) });
|
|
43
|
+
}
|
|
44
|
+
else if (config.ignoreTags?.length) {
|
|
45
|
+
for (const tag of config.ignoreTags) {
|
|
46
|
+
out.push({ name: '_tag:not', value: codingToTagValue(tag) });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* In ignore-tags mode: throws OystehrSdkError if the resource carries any ignored tag.
|
|
53
|
+
* In tag-workspace mode: injects the workspace tag into resource.meta.tag if not already present.
|
|
54
|
+
* Returns the (possibly cloned) resource.
|
|
55
|
+
*/
|
|
56
|
+
function applyTagToResource(config, resource) {
|
|
57
|
+
const resourceLike = resource;
|
|
58
|
+
if (config.ignoreTags?.length) {
|
|
59
|
+
const resourceTags = (resourceLike.meta?.tag ?? []);
|
|
60
|
+
for (const ignored of config.ignoreTags) {
|
|
61
|
+
if (resourceTags.some((t) => codingMatches(t, ignored))) {
|
|
62
|
+
throw new index.OystehrSdkError({
|
|
63
|
+
message: `Resource has an ignored tag (system: "${ignored.system ?? ''}", code: "${ignored.code ?? ''}") and cannot be mutated in ignoreTags mode`,
|
|
64
|
+
code: 400,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return resource;
|
|
69
|
+
}
|
|
70
|
+
if (config.workspaceTag) {
|
|
71
|
+
const tag = config.workspaceTag;
|
|
72
|
+
const existingTags = (resourceLike.meta?.tag ?? []);
|
|
73
|
+
if (!existingTags.some((t) => codingMatches(t, tag))) {
|
|
74
|
+
return {
|
|
75
|
+
...resource,
|
|
76
|
+
meta: {
|
|
77
|
+
...resourceLike.meta,
|
|
78
|
+
tag: [...existingTags, tag],
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return resource;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* In ignore-tags mode: throws OystehrSdkError if any operation value resembles an ignored tag.
|
|
87
|
+
* In tag-workspace mode: guards against removal or loss of the workspace tag:
|
|
88
|
+
* - add/replace of the tag array: ensures workspace tag is present in the value
|
|
89
|
+
* - add/replace of meta: ensures workspace tag is present in meta.tag
|
|
90
|
+
* - remove of /meta/tag or /meta: keeps the remove and appends an operation to restore the workspace tag
|
|
91
|
+
* - add of a single tag (path ends in /-): left unchanged (workspace tag already on the resource)
|
|
92
|
+
*/
|
|
93
|
+
function applyTagToPatchOperations(config, operations) {
|
|
94
|
+
if (config.ignoreTags?.length) {
|
|
95
|
+
for (const op of operations) {
|
|
96
|
+
if (op.op === 'add' || op.op === 'replace' || op.op === 'test') {
|
|
97
|
+
const opValue = op.value;
|
|
98
|
+
if (opValue !== null && opValue !== undefined && typeof opValue === 'object') {
|
|
99
|
+
const v = opValue;
|
|
100
|
+
if (v.code !== undefined) {
|
|
101
|
+
for (const ignored of config.ignoreTags) {
|
|
102
|
+
if (codingMatches(v, ignored)) {
|
|
103
|
+
throw new index.OystehrSdkError({
|
|
104
|
+
message: `Patch operation contains an ignored tag (system: "${ignored.system ?? ''}", code: "${ignored.code ?? ''}") and cannot be applied in ignoreTags mode`,
|
|
105
|
+
code: 400,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return operations;
|
|
114
|
+
}
|
|
115
|
+
if (config.workspaceTag) {
|
|
116
|
+
const tag = config.workspaceTag;
|
|
117
|
+
return operations.reduce((result, op) => {
|
|
118
|
+
// remove /meta/tag — restore workspace tag afterwards
|
|
119
|
+
if (op.op === 'remove' && op.path === '/meta/tag') {
|
|
120
|
+
result.push(op);
|
|
121
|
+
result.push({ op: 'add', path: '/meta/tag', value: [tag] });
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
// remove /meta — restore workspace tag afterwards
|
|
125
|
+
if (op.op === 'remove' && op.path === '/meta') {
|
|
126
|
+
result.push(op);
|
|
127
|
+
result.push({ op: 'add', path: '/meta', value: { tag: [tag] } });
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
// add/replace the entire tag array — ensure workspace tag is present
|
|
131
|
+
if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta/tag') {
|
|
132
|
+
const tags = Array.isArray(op.value) ? op.value : [];
|
|
133
|
+
if (!tags.some((t) => codingMatches(t, tag))) {
|
|
134
|
+
result.push({ ...op, value: [...tags, tag] });
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
result.push(op);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
// add/replace the entire meta object — ensure workspace tag is present in meta.tag
|
|
142
|
+
if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta') {
|
|
143
|
+
const metaValue = op.value != null && typeof op.value === 'object' ? op.value : {};
|
|
144
|
+
const tags = metaValue.tag ?? [];
|
|
145
|
+
if (!tags.some((t) => codingMatches(t, tag))) {
|
|
146
|
+
result.push({ ...op, value: { ...metaValue, tag: [...tags, tag] } });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
result.push(op);
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
// All other operations (including add /meta/tag/- for individual tags) pass through unchanged.
|
|
154
|
+
// Workspace tag is assumed already present on the resource from create/update.
|
|
155
|
+
result.push(op);
|
|
156
|
+
return result;
|
|
157
|
+
}, []);
|
|
158
|
+
}
|
|
159
|
+
return operations;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Throws OystehrFHIRError (404) if the retrieved resource violates the tag configuration:
|
|
163
|
+
* - workspaceTag mode: resource must carry the workspace tag
|
|
164
|
+
* - ignoreTags mode: resource must not carry any ignored tag
|
|
165
|
+
*/
|
|
166
|
+
function assertRetrievedResource(config, resource) {
|
|
167
|
+
const resourceLike = resource;
|
|
168
|
+
const resourceTags = (resourceLike.meta?.tag ?? []);
|
|
169
|
+
if (config.workspaceTag) {
|
|
170
|
+
const tag = config.workspaceTag;
|
|
171
|
+
if (!resourceTags.some((t) => codingMatches(t, tag))) {
|
|
172
|
+
throw new index.OystehrFHIRError({
|
|
173
|
+
error: {
|
|
174
|
+
resourceType: 'OperationOutcome',
|
|
175
|
+
id: 'not-found',
|
|
176
|
+
issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],
|
|
177
|
+
},
|
|
178
|
+
code: 404,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (config.ignoreTags?.length) {
|
|
184
|
+
for (const ignored of config.ignoreTags) {
|
|
185
|
+
if (resourceTags.some((t) => codingMatches(t, ignored))) {
|
|
186
|
+
throw new index.OystehrFHIRError({
|
|
187
|
+
error: {
|
|
188
|
+
resourceType: 'OperationOutcome',
|
|
189
|
+
id: 'not-found',
|
|
190
|
+
issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],
|
|
191
|
+
},
|
|
192
|
+
code: 404,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
17
198
|
/**
|
|
18
199
|
* Performs a FHIR search and returns the results as a Bundle resource
|
|
19
200
|
*
|
|
@@ -22,10 +203,11 @@ function stringToBase64(input) {
|
|
|
22
203
|
* @returns FHIR Bundle resource
|
|
23
204
|
*/
|
|
24
205
|
async function search(params, request) {
|
|
25
|
-
const { resourceType
|
|
206
|
+
const { resourceType } = params;
|
|
207
|
+
const taggedParams = applyTagSearchParams(this.config, params.params);
|
|
26
208
|
let paramMap;
|
|
27
|
-
if (
|
|
28
|
-
paramMap =
|
|
209
|
+
if (taggedParams.length) {
|
|
210
|
+
paramMap = taggedParams.reduce((acc, param) => {
|
|
29
211
|
if (!acc[param.name]) {
|
|
30
212
|
acc[param.name] = [];
|
|
31
213
|
}
|
|
@@ -47,21 +229,26 @@ async function search(params, request) {
|
|
|
47
229
|
return bundle;
|
|
48
230
|
}
|
|
49
231
|
async function create(params, request) {
|
|
50
|
-
const
|
|
51
|
-
|
|
232
|
+
const tagged = applyTagToResource(this.config, params);
|
|
233
|
+
const { resourceType } = tagged;
|
|
234
|
+
return this.fhirRequest(`/${resourceType}`, 'POST')(tagged, request);
|
|
52
235
|
}
|
|
53
236
|
async function get({ resourceType, id }, request) {
|
|
54
|
-
|
|
237
|
+
const result = await this.fhirRequest(`/${resourceType}/${id}`, 'GET')({}, request);
|
|
238
|
+
assertRetrievedResource(this.config, result);
|
|
239
|
+
return result;
|
|
55
240
|
}
|
|
56
241
|
async function update(params, request) {
|
|
57
|
-
const
|
|
58
|
-
|
|
242
|
+
const tagged = applyTagToResource(this.config, params);
|
|
243
|
+
const { id, resourceType } = tagged;
|
|
244
|
+
return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged, {
|
|
59
245
|
...request,
|
|
60
246
|
ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
|
|
61
247
|
});
|
|
62
248
|
}
|
|
63
249
|
async function patch({ resourceType, id, operations }, request) {
|
|
64
|
-
|
|
250
|
+
const taggedOperations = applyTagToPatchOperations(this.config, operations);
|
|
251
|
+
return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {
|
|
65
252
|
...request,
|
|
66
253
|
contentType: 'application/json-patch+json',
|
|
67
254
|
ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
|
|
@@ -80,8 +267,42 @@ async function history({ resourceType, id, versionId, count, offset, }, request)
|
|
|
80
267
|
}
|
|
81
268
|
return this.fhirRequest(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);
|
|
82
269
|
}
|
|
83
|
-
|
|
84
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Returns true when a batch GET/HEAD URL is a search (e.g. "Patient" or "Patient?name=foo")
|
|
272
|
+
* rather than a direct retrieval (e.g. "Patient/abc-123").
|
|
273
|
+
* A retrieval URL has a path segment after the resource type that is not a FHIR operation
|
|
274
|
+
* (operations start with "_", e.g. "_search" or "_history").
|
|
275
|
+
*/
|
|
276
|
+
function isBatchSearchUrl(url) {
|
|
277
|
+
const path = url.split('?')[0];
|
|
278
|
+
const segments = path.split('/').filter(Boolean);
|
|
279
|
+
// Only one segment → bare resource type, always a search
|
|
280
|
+
if (segments.length <= 1)
|
|
281
|
+
return true;
|
|
282
|
+
// Two or more segments: second segment is an ID if it doesn't start with '_'
|
|
283
|
+
return segments[1].startsWith('_');
|
|
284
|
+
}
|
|
285
|
+
/** Returns true when a batch POST URL targets a `_search` endpoint (e.g. "Patient/_search"). */
|
|
286
|
+
function isBatchSearchPostUrl(url) {
|
|
287
|
+
return url.split('?')[0].endsWith('/_search');
|
|
288
|
+
}
|
|
289
|
+
function batchInputRequestToBundleEntryItem(request, config) {
|
|
290
|
+
const { method } = request;
|
|
291
|
+
let url = request.url;
|
|
292
|
+
// Inject tag search params into search request URLs before URL encoding.
|
|
293
|
+
// GET/HEAD: only for search URLs (not retrievals like Patient/<id>).
|
|
294
|
+
// POST: only for _search endpoints (not creates).
|
|
295
|
+
if (((method === 'GET' || method === 'HEAD') && isBatchSearchUrl(url)) ||
|
|
296
|
+
(method === 'POST' && isBatchSearchPostUrl(url))) {
|
|
297
|
+
if (config.workspaceTag) {
|
|
298
|
+
url += (url.includes('?') ? '&' : '?') + `_tag=${codingToTagValue(config.workspaceTag)}`;
|
|
299
|
+
}
|
|
300
|
+
if (config.ignoreTags?.length) {
|
|
301
|
+
for (const tag of config.ignoreTags) {
|
|
302
|
+
url += (url.includes('?') ? '&' : '?') + `_tag:not=${codingToTagValue(tag)}`;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
85
306
|
const baseRequest = {
|
|
86
307
|
request: {
|
|
87
308
|
method,
|
|
@@ -117,7 +338,7 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
117
338
|
}
|
|
118
339
|
// PUT updates require a full resource
|
|
119
340
|
if (method === 'PUT') {
|
|
120
|
-
const
|
|
341
|
+
const resource = applyTagToResource(config, request.resource);
|
|
121
342
|
return {
|
|
122
343
|
request: {
|
|
123
344
|
...baseRequest.request,
|
|
@@ -129,15 +350,24 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
129
350
|
// PATCH can be Binary resource or JSON patch
|
|
130
351
|
if (method === 'PATCH') {
|
|
131
352
|
if ('resource' in request) {
|
|
353
|
+
// Binary patch — decode operations, apply tag transforms, re-encode
|
|
354
|
+
let patchResource = request.resource;
|
|
355
|
+
const binaryData = patchResource.data;
|
|
356
|
+
if (binaryData) {
|
|
357
|
+
const operations = JSON.parse(base64ToString(binaryData));
|
|
358
|
+
const taggedOperations = applyTagToPatchOperations(config, operations);
|
|
359
|
+
patchResource = { ...patchResource, data: stringToBase64(JSON.stringify(taggedOperations)) };
|
|
360
|
+
}
|
|
132
361
|
return {
|
|
133
362
|
request: {
|
|
134
363
|
...baseRequest.request,
|
|
135
364
|
ifMatch: request.ifMatch,
|
|
136
365
|
},
|
|
137
|
-
resource:
|
|
366
|
+
resource: patchResource,
|
|
138
367
|
};
|
|
139
368
|
}
|
|
140
|
-
const
|
|
369
|
+
const operations = applyTagToPatchOperations(config, request.operations);
|
|
370
|
+
const data = stringToBase64(JSON.stringify(operations));
|
|
141
371
|
return {
|
|
142
372
|
...baseRequest,
|
|
143
373
|
resource: {
|
|
@@ -147,9 +377,14 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
147
377
|
},
|
|
148
378
|
};
|
|
149
379
|
}
|
|
380
|
+
// POST _search — no resource body; tag params were already injected into the URL above
|
|
381
|
+
if (method === 'POST' && isBatchSearchPostUrl(url)) {
|
|
382
|
+
return baseRequest;
|
|
383
|
+
}
|
|
150
384
|
// POST creates require a full resource
|
|
151
|
-
if (method === 'POST') {
|
|
152
|
-
const
|
|
385
|
+
if (method === 'POST' && 'resource' in request) {
|
|
386
|
+
const resource = applyTagToResource(config, request.resource);
|
|
387
|
+
const { fullUrl } = request;
|
|
153
388
|
return {
|
|
154
389
|
...baseRequest,
|
|
155
390
|
resource: resource,
|
|
@@ -169,11 +404,35 @@ async function batch(input, request) {
|
|
|
169
404
|
const resp = await this.fhirRequest('/', 'POST')({
|
|
170
405
|
resourceType: 'Bundle',
|
|
171
406
|
type: 'batch',
|
|
172
|
-
entry: input.requests.map(batchInputRequestToBundleEntryItem),
|
|
407
|
+
entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
|
|
173
408
|
}, request);
|
|
409
|
+
// Validate each GET/HEAD retrieval entry against the tag config.
|
|
410
|
+
// Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.
|
|
411
|
+
const rawEntries = resp.entry;
|
|
412
|
+
const processedEntries = this.config.workspaceTag || this.config.ignoreTags?.length
|
|
413
|
+
? rawEntries?.map((entry, i) => {
|
|
414
|
+
const req = input.requests[i];
|
|
415
|
+
if (!req || !entry?.resource)
|
|
416
|
+
return entry;
|
|
417
|
+
if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {
|
|
418
|
+
try {
|
|
419
|
+
assertRetrievedResource(this.config, entry.resource);
|
|
420
|
+
}
|
|
421
|
+
catch (err) {
|
|
422
|
+
if (!(err instanceof index.OystehrFHIRError))
|
|
423
|
+
throw err;
|
|
424
|
+
return {
|
|
425
|
+
request: entry.request,
|
|
426
|
+
response: { status: '404', outcome: err.cause },
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return entry;
|
|
431
|
+
})
|
|
432
|
+
: rawEntries;
|
|
174
433
|
const bundle = {
|
|
175
434
|
...resp,
|
|
176
|
-
entry:
|
|
435
|
+
entry: processedEntries,
|
|
177
436
|
unbundle: function () {
|
|
178
437
|
return (this.entry
|
|
179
438
|
?.map((entry) => entry.resource)
|
|
@@ -192,8 +451,20 @@ async function transaction(input, request) {
|
|
|
192
451
|
const resp = await this.fhirRequest('/', 'POST')({
|
|
193
452
|
resourceType: 'Bundle',
|
|
194
453
|
type: 'transaction',
|
|
195
|
-
entry: input.requests.map(batchInputRequestToBundleEntryItem),
|
|
454
|
+
entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
|
|
196
455
|
}, request);
|
|
456
|
+
// Validate each GET/HEAD retrieval entry against the tag config.
|
|
457
|
+
// A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.
|
|
458
|
+
if (this.config.workspaceTag || this.config.ignoreTags?.length) {
|
|
459
|
+
resp.entry?.forEach((entry, i) => {
|
|
460
|
+
const req = input.requests[i];
|
|
461
|
+
if (!req || !entry?.resource)
|
|
462
|
+
return;
|
|
463
|
+
if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {
|
|
464
|
+
assertRetrievedResource(this.config, entry.resource);
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
197
468
|
const bundle = {
|
|
198
469
|
...resp,
|
|
199
470
|
entry: resp.entry,
|