@oystehr/sdk 4.3.5 → 4.3.7
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/dist/cjs/client/client.cjs +4 -2
- package/dist/cjs/client/client.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.cjs +1 -1
- package/dist/cjs/resources/classes/erx.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.d.ts +1 -1
- package/dist/cjs/resources/classes/rcm-ext.cjs +23 -0
- package/dist/cjs/resources/classes/rcm-ext.cjs.map +1 -0
- package/dist/cjs/resources/classes/rcm-ext.d.ts +8 -0
- package/dist/cjs/resources/classes/rcm.cjs +3 -0
- package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
- package/dist/cjs/resources/classes/rcm.d.ts +3 -0
- package/dist/cjs/resources/types/RcmListPayersParams.d.ts +2 -2
- package/dist/esm/client/client.js +4 -2
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/erx.d.ts +1 -1
- package/dist/esm/resources/classes/erx.js +1 -1
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/classes/rcm-ext.d.ts +8 -0
- package/dist/esm/resources/classes/rcm-ext.js +20 -0
- package/dist/esm/resources/classes/rcm-ext.js.map +1 -0
- package/dist/esm/resources/classes/rcm.d.ts +3 -0
- package/dist/esm/resources/classes/rcm.js +3 -0
- package/dist/esm/resources/classes/rcm.js.map +1 -1
- package/dist/esm/resources/types/RcmListPayersParams.d.ts +2 -2
- package/package.json +1 -1
- package/src/client/client.ts +4 -2
- package/src/resources/classes/erx.ts +1 -1
- package/src/resources/classes/rcm-ext.ts +32 -0
- package/src/resources/classes/rcm.ts +3 -0
- package/src/resources/types/RcmListPayersParams.ts +2 -2
|
@@ -115,7 +115,7 @@ class Erx extends client.SDKResource {
|
|
|
115
115
|
return this.request('/practitioner/connect', 'get', this.#baseUrlThunk.bind(this))(params, request);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
* Check eRx enrollment for a practitioner.
|
|
118
|
+
* Check eRx enrollment and notifications for a practitioner.
|
|
119
119
|
* Action: `eRx:Read`
|
|
120
120
|
* Access Policy Resource: `eRx:Enrollment`
|
|
121
121
|
*/
|
|
@@ -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 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,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AC,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 and notifications 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,MA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ioner(request?: OystehrClientRequest): Promise<ErxConnectPractitionerResponse>;
|
|
103
103
|
/**
|
|
104
|
-
* Check eRx enrollment for a practitioner.
|
|
104
|
+
* Check eRx enrollment and notifications for a practitioner.
|
|
105
105
|
* Action: `eRx:Read`
|
|
106
106
|
* Access Policy Resource: `eRx:Enrollment`
|
|
107
107
|
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('../../errors/index.cjs');
|
|
4
|
+
|
|
5
|
+
function baseUrlThunk() {
|
|
6
|
+
return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';
|
|
7
|
+
}
|
|
8
|
+
function constructPayerUrl({ id, }) {
|
|
9
|
+
return `${baseUrlThunk.call(this)}/payer/${id}`;
|
|
10
|
+
}
|
|
11
|
+
async function getPayerByUrl({ url }, request) {
|
|
12
|
+
if (!url.startsWith(constructPayerUrl.call(this, { id: '' }))) {
|
|
13
|
+
throw new index.OystehrSdkError({ code: 400, message: 'Invalid payer URL.' });
|
|
14
|
+
}
|
|
15
|
+
const urlObj = new URL(url);
|
|
16
|
+
const pathParts = urlObj.pathname.split('/').filter(Boolean);
|
|
17
|
+
const id = pathParts[pathParts.length - 1];
|
|
18
|
+
return this.request('/payer/{id}', 'get', baseUrlThunk.bind(this))({ id }, request);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.constructPayerUrl = constructPayerUrl;
|
|
22
|
+
exports.getPayerByUrl = getPayerByUrl;
|
|
23
|
+
//# sourceMappingURL=rcm-ext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rcm-ext.cjs","sources":["../../../../src/resources/classes/rcm-ext.ts"],"sourcesContent":["import { OystehrClientRequest, SDKResource } from '../../client/client';\nimport { OystehrSdkError } from '../../errors';\nimport { RcmGetPayerResponse } from '../types';\n\nfunction baseUrlThunk(this: SDKResource): string {\n return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';\n}\n\nexport function constructPayerUrl(\n this: SDKResource,\n {\n id,\n }: {\n id: string;\n }\n): string {\n return `${baseUrlThunk.call(this)}/payer/${id}`;\n}\n\nexport async function getPayerByUrl(\n this: SDKResource,\n { url }: { url: string },\n request?: OystehrClientRequest\n): Promise<RcmGetPayerResponse> {\n if (!url.startsWith(constructPayerUrl.call(this, { id: '' }))) {\n throw new OystehrSdkError({ code: 400, message: 'Invalid payer URL.' });\n }\n const urlObj = new URL(url);\n const pathParts = urlObj.pathname.split('/').filter(Boolean);\n const id = pathParts[pathParts.length - 1];\n return this.request('/payer/{id}', 'get', baseUrlThunk.bind(this))({ id }, request);\n}\n"],"names":["OystehrSdkError"],"mappings":";;;;AAIA,SAAS,YAAY,GAAA;IACnB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,+BAA+B;AAC/E;AAEM,SAAU,iBAAiB,CAE/B,EACE,EAAE,GAGH,EAAA;IAED,OAAO,CAAA,EAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,OAAA,EAAU,EAAE,CAAA,CAAE;AACjD;AAEO,eAAe,aAAa,CAEjC,EAAE,GAAG,EAAmB,EACxB,OAA8B,EAAA;AAE9B,IAAA,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE;AAC7D,QAAA,MAAM,IAAIA,qBAAe,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IACzE;AACA,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;AAC3B,IAAA,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAC5D,MAAM,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC;AACrF;;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OystehrClientRequest, SDKResource } from '../../client/client';
|
|
2
|
+
import { RcmGetPayerResponse } from '../types';
|
|
3
|
+
export declare function constructPayerUrl(this: SDKResource, { id, }: {
|
|
4
|
+
id: string;
|
|
5
|
+
}): string;
|
|
6
|
+
export declare function getPayerByUrl(this: SDKResource, { url }: {
|
|
7
|
+
url: string;
|
|
8
|
+
}, request?: OystehrClientRequest): Promise<RcmGetPayerResponse>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var client = require('../../client/client.cjs');
|
|
4
|
+
var rcmExt = require('./rcm-ext.cjs');
|
|
4
5
|
|
|
5
6
|
// AUTOGENERATED -- DO NOT EDIT
|
|
6
7
|
class Rcm extends client.SDKResource {
|
|
@@ -10,6 +11,8 @@ class Rcm extends client.SDKResource {
|
|
|
10
11
|
#baseUrlThunk() {
|
|
11
12
|
return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';
|
|
12
13
|
}
|
|
14
|
+
constructPayerUrl = rcmExt.constructPayerUrl;
|
|
15
|
+
getPayerByUrl = rcmExt.getPayerByUrl;
|
|
13
16
|
/**
|
|
14
17
|
* Check [Insurance Eligibility](https://docs.oystehr.com/oystehr/services/rcm/eligibility/).
|
|
15
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rcm.cjs","sources":["../../../../src/resources/classes/rcm.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n RcmEligibilityCheckParams,\n RcmEligibilityCheckResponse,\n RcmGetPayerParams,\n RcmGetPayerResponse,\n RcmListPayersParams,\n RcmListPayersResponse,\n RcmSetClaimStatusParams,\n RcmSetClaimStatusResponse,\n RcmSubmitClaimParams,\n RcmSubmitClaimResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\n\nexport class Rcm extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';\n }\n /**\n * Check [Insurance Eligibility](https://docs.oystehr.com/oystehr/services/rcm/eligibility/).\n *\n * Access Policy Action: `RCM:CheckInsuranceEligibility`\n * Access Policy Resource: `RCM:InsuranceEligibility`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:CoverageEligibilityResponse`\n */\n eligibilityCheck(\n params: RcmEligibilityCheckParams,\n request?: OystehrClientRequest\n ): Promise<RcmEligibilityCheckResponse> {\n return this.request('/eligibility-check', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Submit a claim to a payer.\n *\n * Access Policy Action: `RCM:SubmitClaim`\n * Access Policy Resource: `RCM:Claim`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:ClaimResponse`\n */\n submitClaim(params: RcmSubmitClaimParams, request?: OystehrClientRequest): Promise<RcmSubmitClaimResponse> {\n return this.request('/claim/{claimId}/submit', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Emulate asynchronous claim responses by manually setting claim status.\n *\n * Access Policy Action: `RCM:SubmitClaim`\n * Access Policy Resource: `RCM:Claim`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:ClaimResponse`\n */\n setClaimStatus(params: RcmSetClaimStatusParams, request?: OystehrClientRequest): Promise<RcmSetClaimStatusResponse> {\n return this.request('/claim/{claimId}/status', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(params: RcmListPayersParams, request?: OystehrClientRequest): Promise<RcmListPayersResponse>;\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(request?: OystehrClientRequest): Promise<RcmListPayersResponse>;\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(\n params?: RcmListPayersParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<RcmListPayersResponse> {\n return this.request('/payer', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Retrieve a payer by its ID.\n *\n * Access Policy Action: `RCM:GetPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n getPayer(params: RcmGetPayerParams, request?: OystehrClientRequest): Promise<RcmGetPayerResponse> {\n return this.request('/payer/{id}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rcm.cjs","sources":["../../../../src/resources/classes/rcm.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n RcmEligibilityCheckParams,\n RcmEligibilityCheckResponse,\n RcmGetPayerParams,\n RcmGetPayerResponse,\n RcmListPayersParams,\n RcmListPayersResponse,\n RcmSetClaimStatusParams,\n RcmSetClaimStatusResponse,\n RcmSubmitClaimParams,\n RcmSubmitClaimResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './rcm-ext';\n\nexport class Rcm extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';\n }\n constructPayerUrl = ext.constructPayerUrl;\n getPayerByUrl = ext.getPayerByUrl;\n /**\n * Check [Insurance Eligibility](https://docs.oystehr.com/oystehr/services/rcm/eligibility/).\n *\n * Access Policy Action: `RCM:CheckInsuranceEligibility`\n * Access Policy Resource: `RCM:InsuranceEligibility`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:CoverageEligibilityResponse`\n */\n eligibilityCheck(\n params: RcmEligibilityCheckParams,\n request?: OystehrClientRequest\n ): Promise<RcmEligibilityCheckResponse> {\n return this.request('/eligibility-check', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Submit a claim to a payer.\n *\n * Access Policy Action: `RCM:SubmitClaim`\n * Access Policy Resource: `RCM:Claim`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:ClaimResponse`\n */\n submitClaim(params: RcmSubmitClaimParams, request?: OystehrClientRequest): Promise<RcmSubmitClaimResponse> {\n return this.request('/claim/{claimId}/submit', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Emulate asynchronous claim responses by manually setting claim status.\n *\n * Access Policy Action: `RCM:SubmitClaim`\n * Access Policy Resource: `RCM:Claim`\n *\n * Access Policy Action: `FHIR:Create`\n * Access Policy Resource: `FHIR:ClaimResponse`\n */\n setClaimStatus(params: RcmSetClaimStatusParams, request?: OystehrClientRequest): Promise<RcmSetClaimStatusResponse> {\n return this.request('/claim/{claimId}/status', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(params: RcmListPayersParams, request?: OystehrClientRequest): Promise<RcmListPayersResponse>;\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(request?: OystehrClientRequest): Promise<RcmListPayersResponse>;\n /**\n * Search for payers by name or identifier.\n *\n * Access Policy Action: `RCM:SearchPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n listPayers(\n params?: RcmListPayersParams | OystehrClientRequest,\n request?: OystehrClientRequest\n ): Promise<RcmListPayersResponse> {\n return this.request('/payer', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Retrieve a payer by its ID.\n *\n * Access Policy Action: `RCM:GetPayer`\n * Access Policy Resource: `RCM:Payer`\n */\n getPayer(params: RcmGetPayerParams, request?: OystehrClientRequest): Promise<RcmGetPayerResponse> {\n return this.request('/payer/{id}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource","ext.constructPayerUrl","ext.getPayerByUrl"],"mappings":";;;;;AAAA;AAmBM,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,IAAA,iBAAiB,GAAGC,wBAAqB;AACzC,IAAA,aAAa,GAAGC,oBAAiB;AACjC;;;;;;;;AAQG;IACH,gBAAgB,CACd,MAAiC,EACjC,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACnG;AACA;;;;;;;;AAQG;IACH,WAAW,CAAC,MAA4B,EAAE,OAA8B,EAAA;QACtE,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACxG;AACA;;;;;;;;AAQG;IACH,cAAc,CAAC,MAA+B,EAAE,OAA8B,EAAA;QAC5E,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACxG;AAeA;;;;;AAKG;IACH,UAAU,CACR,MAAmD,EACnD,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACtF;AACA;;;;;AAKG;IACH,QAAQ,CAAC,MAAyB,EAAE,OAA8B,EAAA;QAChE,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3F;AACD;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { OystehrClientRequest, RcmEligibilityCheckParams, RcmEligibilityCheckResponse, RcmGetPayerParams, RcmGetPayerResponse, RcmListPayersParams, RcmListPayersResponse, RcmSetClaimStatusParams, RcmSetClaimStatusResponse, RcmSubmitClaimParams, RcmSubmitClaimResponse } from '../..';
|
|
2
2
|
import { SDKResource } from '../../client/client';
|
|
3
3
|
import { OystehrConfig } from '../../config';
|
|
4
|
+
import * as ext from './rcm-ext';
|
|
4
5
|
export declare class Rcm extends SDKResource {
|
|
5
6
|
#private;
|
|
6
7
|
constructor(config: OystehrConfig);
|
|
8
|
+
constructPayerUrl: typeof ext.constructPayerUrl;
|
|
9
|
+
getPayerByUrl: typeof ext.getPayerByUrl;
|
|
7
10
|
/**
|
|
8
11
|
* Check [Insurance Eligibility](https://docs.oystehr.com/oystehr/services/rcm/eligibility/).
|
|
9
12
|
*
|
|
@@ -336,10 +336,12 @@ function subParamsInPath(path, params) {
|
|
|
336
336
|
function addParamsToSearch(params, search) {
|
|
337
337
|
for (const [key, value] of Object.entries(params)) {
|
|
338
338
|
if (Array.isArray(value)) {
|
|
339
|
-
value.forEach((v) => search.append(key, v));
|
|
339
|
+
value.forEach((v) => v !== null && v !== undefined && search.append(key, v));
|
|
340
340
|
continue;
|
|
341
341
|
}
|
|
342
|
-
|
|
342
|
+
if (value !== null && value !== undefined) {
|
|
343
|
+
search.append(key, value);
|
|
344
|
+
}
|
|
343
345
|
}
|
|
344
346
|
}
|
|
345
347
|
function extractParamsAndRequest(params, request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4, validate as uuidValidate } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { Logger } from '../logger';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nexport const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n protected readonly config: OystehrConfig;\n protected readonly logger: Logger;\n constructor(config: OystehrConfig) {\n this.config = config;\n this.logger = new Logger({\n level: this.config.logLevel,\n });\n }\n\n protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n try {\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number; cause?: unknown };\n this.logger.error(error.message, { code: error.code, cause: error.cause });\n throw new OystehrSdkError({ message: error.message, code: error.code, cause: error.cause });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.services?.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number; cause?: unknown };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n cause: fullError.cause,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return (\n 'accessToken' in request ||\n ('projectId' in request && uuidValidate(request.projectId)) ||\n ('contentType' in request && request.contentType?.split('/').length === 2) ||\n 'requestId' in request ||\n ('ifMatch' in request && request.ifMatch.startsWith('W/\"'))\n );\n}\n\n/**\n * Parse XML response in format <response><status>...</status><output>...</output></response>\n */\nfunction parseXmlResponse(xmlString: string): Record<string, unknown> | null {\n try {\n // Extract status\n const statusMatch = xmlString.match(/<status>(\\d+)<\\/status>/);\n const status = statusMatch ? parseInt(statusMatch[1], 10) : null;\n\n // Extract output - everything between <output> and </output>\n const outputMatch = xmlString.match(/<output>([\\s\\S]*?)<\\/output>/);\n const output = outputMatch ? outputMatch[1] : null;\n\n if (status === null || output === null) {\n return null;\n }\n\n return { status, output };\n } catch (_err) {\n return null;\n }\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n loggerThunk: () => Logger,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n // eslint-disable-next-line prefer-const\n let [providedParams, requestCtx] = extractParamsAndRequest(params, request);\n requestCtx ??= {};\n requestCtx.requestId ??= uuidv4();\n const config = configThunk();\n const logger = loggerThunk();\n const method = methodParam.toLowerCase() as HttpMethod;\n logger.debug('Beginning fetch', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? config.projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n logger.debug('Substituted parameters in path', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n logger.debug('Prepared request body', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n jitter: config.retry?.jitter ?? 20,\n delay: config.retry?.delay ?? 100,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async () => {\n logger.info('Request start', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const now = Date.now();\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n logger.info('Request end', {\n method,\n url,\n duration: Date.now() - now,\n requestId: requestCtx?.requestId,\n });\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n const contentType = response.headers.get('content-type');\n try {\n if (\n responseBody &&\n (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))\n ) {\n logger.time('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = JSON.parse(responseBody);\n logger.timeEnd('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {\n // Parse XML response into { status, output } structure\n logger.time('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = parseXmlResponse(responseBody);\n logger.timeEnd('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else {\n responseJson = null;\n }\n } catch (_err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n logger.debug('Deserialized response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n const errObj = {\n message:\n (typeof responseJson?.output === 'string'\n ? responseJson.output // XML error case - output is XML string\n : (responseJson?.output as Record<string, unknown>)?.message) ?? // official zambda output format (JSON)\n responseJson?.message ?? // normal endpoint output format\n responseJson ?? // parsable json\n responseBody ?? // raw response\n response.statusText, // fallback to status text\n code:\n (responseJson?.output as Record<string, unknown>)?.code ?? // official zambda output format\n responseJson?.code ?? // normal endpoint output format\n response.status, // fallback to status code\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n jitter: NonNullable<NonNullable<OystehrConfig['retry']>['jitter']>;\n delay: NonNullable<NonNullable<OystehrConfig['retry']>['delay']>;\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n const jitter = Math.floor(Math.random() * (config.jitter + 1));\n await new Promise((resolve) => setTimeout(resolve, config.delay + jitter));\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => search.append(key, v as string));\n continue;\n }\n search.append(key, value as string);\n }\n}\n\nexport function extractParamsAndRequest(\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n): [Record<string, unknown>, InternalClientRequest | undefined] {\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n return [providedParams, requestCtx];\n}\n"],"names":["uuidValidate","uuidv4"],"mappings":";;;;AAOO,MAAM,oBAAoB,GAAG;AACpC,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAM,oBAAoB,GAAG;IAC3B,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,gBAAgB;CACjB;MAiCY,WAAW,CAAA;AACH,IAAA,MAAM;AACN,IAAA,MAAM;AACzB,IAAA,WAAA,CAAY,MAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;AACvB,YAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;AAC5B,SAAA,CAAC;IACJ;AAEU,IAAA,OAAO,CAAC,IAAY,EAAE,MAAc,EAAE,YAA0B,EAAA;AACxE,QAAA,OAAO,OAAO,MAAW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AO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC;YACrD;QACF;AACA,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC;IACrC;AACF;AAEM,SAAU,uBAAuB,CACrC,MAAgE,EAChE,OAA+B,EAAA;IAE/B,MAAM,cAAc,GAClB,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAE;AACF,UAAG,MAAkC,IAAI,EAAE;IAC/C,MAAM,UAAU,GACd,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAG;UACD,OAAO;AACb,IAAA,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC;AACrC;;;;"}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4, validate as uuidValidate } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { Logger } from '../logger';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nexport const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n protected readonly config: OystehrConfig;\n protected readonly logger: Logger;\n constructor(config: OystehrConfig) {\n this.config = config;\n this.logger = new Logger({\n level: this.config.logLevel,\n });\n }\n\n protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n try {\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number; cause?: unknown };\n this.logger.error(error.message, { code: error.code, cause: error.cause });\n throw new OystehrSdkError({ message: error.message, code: error.code, cause: error.cause });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.services?.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number; cause?: unknown };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n cause: fullError.cause,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return (\n 'accessToken' in request ||\n ('projectId' in request && uuidValidate(request.projectId)) ||\n ('contentType' in request && request.contentType?.split('/').length === 2) ||\n 'requestId' in request ||\n ('ifMatch' in request && request.ifMatch.startsWith('W/\"'))\n );\n}\n\n/**\n * Parse XML response in format <response><status>...</status><output>...</output></response>\n */\nfunction parseXmlResponse(xmlString: string): Record<string, unknown> | null {\n try {\n // Extract status\n const statusMatch = xmlString.match(/<status>(\\d+)<\\/status>/);\n const status = statusMatch ? parseInt(statusMatch[1], 10) : null;\n\n // Extract output - everything between <output> and </output>\n const outputMatch = xmlString.match(/<output>([\\s\\S]*?)<\\/output>/);\n const output = outputMatch ? outputMatch[1] : null;\n\n if (status === null || output === null) {\n return null;\n }\n\n return { status, output };\n } catch (_err) {\n return null;\n }\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n loggerThunk: () => Logger,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n // eslint-disable-next-line prefer-const\n let [providedParams, requestCtx] = extractParamsAndRequest(params, request);\n requestCtx ??= {};\n requestCtx.requestId ??= uuidv4();\n const config = configThunk();\n const logger = loggerThunk();\n const method = methodParam.toLowerCase() as HttpMethod;\n logger.debug('Beginning fetch', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? config.projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n logger.debug('Substituted parameters in path', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n logger.debug('Prepared request body', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n jitter: config.retry?.jitter ?? 20,\n delay: config.retry?.delay ?? 100,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async () => {\n logger.info('Request start', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const now = Date.now();\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n logger.info('Request end', {\n method,\n url,\n duration: Date.now() - now,\n requestId: requestCtx?.requestId,\n });\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n const contentType = response.headers.get('content-type');\n try {\n if (\n responseBody &&\n (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))\n ) {\n logger.time('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = JSON.parse(responseBody);\n logger.timeEnd('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {\n // Parse XML response into { status, output } structure\n logger.time('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = parseXmlResponse(responseBody);\n logger.timeEnd('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else {\n responseJson = null;\n }\n } catch (_err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n logger.debug('Deserialized response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n const errObj = {\n message:\n (typeof responseJson?.output === 'string'\n ? responseJson.output // XML error case - output is XML string\n : (responseJson?.output as Record<string, unknown>)?.message) ?? // official zambda output format (JSON)\n responseJson?.message ?? // normal endpoint output format\n responseJson ?? // parsable json\n responseBody ?? // raw response\n response.statusText, // fallback to status text\n code:\n (responseJson?.output as Record<string, unknown>)?.code ?? // official zambda output format\n responseJson?.code ?? // normal endpoint output format\n response.status, // fallback to status code\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n jitter: NonNullable<NonNullable<OystehrConfig['retry']>['jitter']>;\n delay: NonNullable<NonNullable<OystehrConfig['retry']>['delay']>;\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n const jitter = Math.floor(Math.random() * (config.jitter + 1));\n await new Promise((resolve) => setTimeout(resolve, config.delay + jitter));\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => v !== null && v !== undefined && search.append(key, v as string));\n continue;\n }\n if (value !== null && value !== undefined) {\n search.append(key, value as string);\n }\n }\n}\n\nexport function extractParamsAndRequest(\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n): [Record<string, unknown>, InternalClientRequest | undefined] {\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n return [providedParams, requestCtx];\n}\n"],"names":["uuidValidate","uuidv4"],"mappings":";;;;AAOO,MAAM,oBAAoB,GAAG;AACpC,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAM,oBAAoB,GAAG;IAC3B,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,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G,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;UAC1E,EAAE;AACN,IAAA,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC;AACjC;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAAC,MAA+B,EAAE,MAAuB,EAAA;AACxF,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACxB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC;YACtF;QACF;QACA,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AACzC,YAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC;QACrC;IACF;AACF;AAEM,SAAU,uBAAuB,CACrC,MAAgE,EAChE,OAA+B,EAAA;IAE/B,MAAM,cAAc,GAClB,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAE;AACF,UAAG,MAAkC,IAAI,EAAE;IAC/C,MAAM,UAAU,GACd,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAG;UACD,OAAO;AACb,IAAA,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC;AACrC;;;;"}
|
package/dist/esm/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v4 as e,validate as t}from"uuid";class s extends Error{code;constructor({message:e,code:t,cause:r}){super(e,{cause:r}),Object.setPrototypeOf(this,s.prototype),this.code=t,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(e){const t=[];for(const s of e.issue??[])s.details&&s.details.text&&t.push(s.details.text);return t.length||t.push("Unknown FHIR error"),t.join(",")}class i extends s{cause;constructor({error:e,code:t}){super({message:r(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}class n{_level;constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify({message:e,...t}))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify({message:e,...t}))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify({message:e,...t}))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify({message:e,...t}))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify({message:e,...t}))}}const o=[408,429,500,502,503,504],a=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class u{config;logger;constructor(e){this.config=e,this.logger=new n({level:this.config.logLevel})}request(e,t,r){return async(i,n)=>{const o=()=>this.config,a=()=>this.logger;try{return await c(r,o,a,e,t)(i,n)}catch(e){const t=e;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new s({message:t.message,code:t.code,cause:t.cause})}}}fhirRequest(e,t){return async(r,n)=>{try{const s=()=>this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com",i=()=>this.config,o=()=>this.logger;return await c(s,i,o,e,t)(r,n)}catch(e){const t=e;if("string"==typeof t.message)throw new s({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}}}function h(e){return"accessToken"in e||"projectId"in e&&t(e.projectId)||"contentType"in e&&2===e.contentType?.split("/").length||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function c(t,r,i,n,u){return async(c,d)=>{let[p,b]=function(e,t){const s=e&&!t&&!Array.isArray(e)&&h(e)?{}:e??{},r=e&&!t&&!Array.isArray(e)&&h(e)?e:t;return[s,r]}(c,d);b??={},b.requestId??=e();const g=r(),m=i(),f=u.toLowerCase();m.debug("Beginning fetch",{method:f,path:n,requestId:b?.requestId});const T=g.fetch??fetch,U=b?.accessToken??g.accessToken,k=b?.projectId??g.projectId;let y=n,q=p;if(!Array.isArray(p)){const[e,t]=function(e,t){const r={...t},i=e.replace(/\{([^}]+)\}/g,((e,i)=>{if(delete r[i],i.match(/^.*\+$/))return t[i]+"";if(!t[i]||""===t[i])throw new s({message:`Required path parameter is an empty string: ${i}`,code:400});return t[i]?encodeURIComponent(t[i]+""):""})),n=Object.keys(r),o=n.length?n.reduce(((e,t)=>({...e,[t]:r[t]})),{}):{};return[i,o]}(n,p);y=e,q=t}m.debug("Substituted parameters in path",{method:f,path:n,requestId:b?.requestId}),y=y.replace(/^\//,"");const v=t(),w=v.endsWith("/")?v:v+"/",j=new URL(y,w);let I;if(Array.isArray(q))I=JSON.stringify(q);else if(Object.keys(q).length)if("get"===f)l(q,j.searchParams);else if("application/x-www-form-urlencoded"===b?.contentType){const e=new URLSearchParams;l(q,e),I=e.toString()}else I=JSON.stringify(q);else"application/x-www-form-urlencoded"!==b?.contentType&&"post"===f&&(I="{}");m.debug("Prepared request body",{method:f,path:n,requestId:b?.requestId});const z=Object.assign(k?{"x-zapehr-project-id":k,"x-oystehr-project-id":k}:{},{"content-type":b?.contentType??"application/json"},U?{Authorization:`Bearer ${U}`}:{},b?.ifMatch?{"If-Match":b.ifMatch}:{},{"x-oystehr-request-id":b?.requestId}),x={retries:g.retry?.retries??3,jitter:g.retry?.jitter??20,delay:g.retry?.delay??100,onRetry:g.retry?.onRetry,retryOn:[...g.retry?.retryOn??[],...o]};return x.retryOn.push(...o),async function(e,t){let s;for(const r of Array.from({length:(t.retries??0)+1},((e,t)=>t)))try{return await e(r)}catch(e){let i=!1;if("response"in e){const r=e;i=t.retryOn.includes(r.code),s={message:e.message,code:e.code}}else if(s=e,"code"in e&&"string"==typeof e.code){const t=e;i=a.includes(t.code)}if(!i)break;const n=Math.floor(Math.random()*(t.jitter+1));await new Promise((e=>setTimeout(e,t.delay+n))),t.onRetry&&r!==(t.retries??0)&&t.onRetry(r+1)}throw s}((async()=>{m.info("Request start",{method:f,url:j,requestId:b?.requestId});const e=Date.now(),t=await T(new Request(j,{method:f.toUpperCase(),body:I,headers:z}));m.info("Request end",{method:f,url:j,duration:Date.now()-e,requestId:b?.requestId});const s=t.body?await t.text():null;let r;const i=t.headers.get("content-type");try{s&&(i?.includes("application/json")||i?.includes("application/fhir+json"))?(m.time("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId}),r=JSON.parse(s),m.timeEnd("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId})):s&&(i?.includes("application/xml")||i?.includes("text/xml"))?(m.time("Deserialized XML response",{method:f,url:j,requestId:b?.requestId}),r=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),s=t?parseInt(t[1],10):null,r=e.match(/<output>([\s\S]*?)<\/output>/),i=r?r[1]:null;return null===s||null===i?null:{status:s,output:i}}catch(e){return null}}(s),m.timeEnd("Deserialized XML response",{method:f,url:j,requestId:b?.requestId})):r=null}catch(e){r=null}m.debug("Deserialized response",{method:f,url:j,requestId:b?.requestId});if(!t.ok||t.status>=400){throw{message:("string"==typeof r?.output?r.output:r?.output?.message)??r?.message??r??s??t.statusText,code:r?.output?.code??r?.code??t.status,response:t}}return r}),x)}}function l(e,t){for(const[s,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>t.append(s,e))):t.append(s,r)}class d extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/application","get",this.#e.bind(this))(e)}create(e,t){return this.request("/application","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",this.#e.bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",this.#e.bind(this))(e,t)}}class p extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}issue(e,t){return this.request("/payment/charge/issue","post",this.#e.bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",this.#e.bind(this))(e,t)}}const b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",g="addressString";function m(e){if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const t=e.virtualService?.find((e=>"https://fhir.zapehr.com/virtual-service-type"===e.channelType?.system));return t?.addressString}if(!e.extension)return;const t=e.extension.find((e=>e.url===b));if(!t?.extension)return;const s=t.extension?.find((e=>e.url===g))?.valueString;return s}class f extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}ENCOUNTER_VS_EXTENSION_URL=b;ENCOUNTER_VS_EXTENSION_RELATIVE_URL=g;getConversationIdFromEncounter=m;create(e,t){return this.request("/messaging/conversation","post",this.#e.bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",this.#e.bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",this.#e.bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",this.#e.bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",this.#e.bind(this))(e,t)}}class T extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e,t){return this.request("/developer/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/developer","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",this.#e.bind(this))(e,t)}}class U extends u{constructor(e){super(e)}#e(){return this.config.services?.erxApiUrl??"https://erx-api.zapehr.com/v3"}searchAllergens(e,t){return this.request("/allergen","get",this.#e.bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",this.#e.bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",this.#e.bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",this.#e.bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",this.#e.bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",this.#e.bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",this.#e.bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",this.#e.bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",this.#e.bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",this.#e.bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",this.#e.bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",this.#e.bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",this.#e.bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",this.#e.bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",this.#e.bind(this))(e,t)}}class k extends u{constructor(e){super(e)}#e(){return this.config.services?.faxApiUrl??"https://fax-api.zapehr.com/v1"}offboard(e){return this.request("/offboard","post",this.#e.bind(this))(e)}onboard(e){return this.request("/onboard","post",this.#e.bind(this))(e)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}send(e,t){return this.request("/send","post",this.#e.bind(this))(e,t)}}const y=65535;function q(e){const t=(new globalThis.TextEncoder).encode(e);let s="";for(let e=0;e<t.length;e+=y){const r=t.subarray(e,e+y);s+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return s}function v(e){return e.system?`${e.system}|${e.code??""}`:e.code??""}function w(e,t){return(e.system??"")===(t.system??"")&&(e.code??"")===(t.code??"")}function j(e,t){const r=t;if(e.ignoreTags?.length){const i=r.meta?.tag??[];for(const t of e.ignoreTags)if(i.some((e=>w(e,t))))throw new s({message:`Resource has an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be mutated in ignoreTags mode`,code:400});return t}if(e.workspaceTag){const s=e.workspaceTag,i=r.meta?.tag??[];if(!i.some((e=>w(e,s))))return{...t,meta:{...r.meta,tag:[...i,s]}}}return t}function I(e,t){if(e.ignoreTags?.length){for(const r of t)if("add"===r.op||"replace"===r.op||"test"===r.op){const t=r.value;if(null!=t&&"object"==typeof t){const r=t;if(void 0!==r.code)for(const t of e.ignoreTags)if(w(r,t))throw new s({message:`Patch operation contains an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be applied in ignoreTags mode`,code:400})}}return t}if(e.workspaceTag){const s=e.workspaceTag;return t.reduce(((e,t)=>{if("remove"===t.op&&"/meta/tag"===t.path)return e.push(t),e.push({op:"add",path:"/meta/tag",value:[s]}),e;if("remove"===t.op&&"/meta"===t.path)return e.push(t),e.push({op:"add",path:"/meta",value:{tag:[s]}}),e;if(("add"===t.op||"replace"===t.op)&&"/meta/tag"===t.path){const r=Array.isArray(t.value)?t.value:[];return r.some((e=>w(e,s)))?e.push(t):e.push({...t,value:[...r,s]}),e}if(("add"===t.op||"replace"===t.op)&&"/meta"===t.path){const r=null!=t.value&&"object"==typeof t.value?t.value:{},i=r.tag??[];return i.some((e=>w(e,s)))?e.push(t):e.push({...t,value:{...r,tag:[...i,s]}}),e}return e.push(t),e}),[])}return t}function z(e,t){const s=t,r=s.meta?.tag??[];if(e.workspaceTag){const t=e.workspaceTag;if(!r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(e.ignoreTags?.length)for(const t of e.ignoreTags)if(r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}async function x(e,t){const{resourceType:s}=e,r=function(e,t){const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:v(e.workspaceTag)});else if(e.ignoreTags?.length)for(const t of e.ignoreTags)s.push({name:"_tag:not",value:v(t)});return s}(this.config,e.params);let i;r.length&&(i=r.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=await this.fhirRequest(`/${s}/_search`,"POST")(i,{...t,contentType:"application/x-www-form-urlencoded"});return{...n,entry:n.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function E(e,t){const s=j(this.config,e),{resourceType:r}=s;return this.fhirRequest(`/${r}`,"POST")(s,t)}async function S({resourceType:e,id:t},s){const r=await this.fhirRequest(`/${e}/${t}`,"GET")({},s);return z(this.config,r),r}async function A(e,t){const s=j(this.config,e),{id:r,resourceType:i}=s;return this.fhirRequest(`/${i}/${r}`,"PUT")(s,{...t,ifMatch:t?.optimisticLockingVersionId?`W/"${t.optimisticLockingVersionId}"`:void 0})}async function O({resourceType:e,id:t,operations:s},r){const i=I(this.config,s);return this.fhirRequest(`/${e}/${t}`,"PATCH")(i,{...r,contentType:"application/json-patch+json",ifMatch:r?.optimisticLockingVersionId?`W/"${r.optimisticLockingVersionId}"`:void 0})}async function P({resourceType:e,id:t},s){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}async function N({resourceType:e,id:t,versionId:s,count:r,offset:i},n){return s?this.fhirRequest(`/${e}/${t}/_history/${s}`,"GET")({},n):r?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${r}\n ${i?`&_offset=${i}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}function R(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function _(e){return e.split("?")[0].endsWith("/_search")}function $(e,t){const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&R(r)||"POST"===s&&_(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${v(t.workspaceTag)}`),t.ignoreTags?.length))for(const e of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${v(e)}`;const i={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),s=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>t?(e[t]||(e[t]=[]),e[t].push(s),e):e),{}),n=new URLSearchParams;l(s,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return i;if("PUT"===s){const s=j(t,e.resource);return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}if("PATCH"===s){if("resource"in e){let s=e.resource;const r=s.data;if(r){const e=I(t,JSON.parse(function(e){const t=globalThis.atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return(new globalThis.TextDecoder).decode(s)}(r)));s={...s,data:q(JSON.stringify(e))}}return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}const s=I(t,e.operations),r=q(JSON.stringify(s));return{...i,resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:r}}}if("POST"===s&&_(r))return i;if("POST"===s&&"resource"in e){const s=j(t,e.resource),{fullUrl:r}=e;return{...i,resource:s,fullUrl:r}}throw new Error("Unrecognized method")}async function M(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>$(e,this.config)))},t),r=s.entry,n=this.config.workspaceTag||this.config.ignoreTags?.length?r?.map(((t,s)=>{const r=e.requests[s];if(!r||!t?.resource)return t;if(("GET"===r.method||"HEAD"===r.method)&&!R(r.url))try{z(this.config,t.resource)}catch(e){if(!(e instanceof i))throw e;return{request:t.request,response:{status:"404",outcome:e.cause}}}return t})):r;return{...s,entry:n,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]},errors:function(){return this.entry?.filter((e=>e.response?.status?.startsWith("4")||e.response?.status?.startsWith("5"))).map((e=>e.response?.outcome)).filter((e=>void 0!==e))}}}async function C(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>$(e,this.config)))},t);(this.config.workspaceTag||this.config.ignoreTags?.length)&&s.entry?.forEach(((t,s)=>{const r=e.requests[s];r&&t?.resource&&("GET"!==r.method&&"HEAD"!==r.method||R(r.url)||z(this.config,t.resource))}));return{...s,entry:s.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function D({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}function L(e,t){const s=[];if(e.line&&s.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),s.push(t.join(", "))}return e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(t?.lineSeparator||", ").trim()}function J(e,t){const s=[];return e.prefix&&!1!==t?.prefix&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==t?.suffix&&s.push(...e.suffix),e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(" ").trim()}class G extends u{constructor(e){super(e)}#e(){return this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com"}search=x;create=E;get=S;update=A;patch=O;delete=P;history=N;batch=M;transaction=C;generateFriendlyPatientId=D;formatAddress=L;formatHumanName=J}class H extends u{constructor(e){super(e)}#e(){return this.config.services?.labApiUrl??"https://labs-api.zapehr.com/v1"}routeList(e){return this.request("/route","get",this.#e.bind(this))(e)}routeCreate(e,t){return this.request("/route","post",this.#e.bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",this.#e.bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",this.#e.bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",this.#e.bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",this.#e.bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",this.#e.bind(this))(e,t)}}class F extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/m2m","get",this.#e.bind(this))(e)}create(e,t){return this.request("/m2m","post",this.#e.bind(this))(e,t)}me(e){return this.request("/m2m/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",this.#e.bind(this))(e,t)}}class V extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}getMessagingConfig(e){return this.request("/messaging/config","get",this.#e.bind(this))(e)}}class B extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}setUp(e,t){return this.request("/payment/payment-method/setup","post",this.#e.bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",this.#e.bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",this.#e.bind(this))(e,t)}}class W extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/project","get",this.#e.bind(this))(e)}update(e,t){return this.request("/project","patch",this.#e.bind(this))(e,t)}}class X extends u{constructor(e){super(e)}#e(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}eligibilityCheck(e,t){return this.request("/eligibility-check","post",this.#e.bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",this.#e.bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",this.#e.bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",this.#e.bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",this.#e.bind(this))(e,t)}}class Z extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/iam/role","get",this.#e.bind(this))(e)}create(e,t){return this.request("/iam/role","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",this.#e.bind(this))(e,t)}}class K extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/secret","get",this.#e.bind(this))(e)}set(e,t){return this.request("/secret","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",this.#e.bind(this))(e,t)}}class Q extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",this.#e.bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",this.#e.bind(this))(e,t)}}class Y extends u{constructor(e){super(e)}#e(){return this.config.services?.terminologyApiUrl??"https://terminology-api.zapehr.com/v1"}searchCpt(e,t){return this.request("/cpt/search","get",this.#e.bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",this.#e.bind(this))(e,t)}}class ee extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}send(e,t){return this.request("/messaging/transactional-sms/send","post",this.#e.bind(this))(e,t)}}class te extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}me(e){return this.request("/user/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/user/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",this.#e.bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",this.#e.bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",this.#e.bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/user","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",this.#e.bind(this))(e,t)}}class se extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/version","get",this.#e.bind(this))(e)}}function re(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function ie({bucketName:e,"objectPath+":t,file:s}){const r=await this.request("/z3/{bucketName}/{objectPath+}","post",re.bind(this))({action:"upload",bucketName:e,"objectPath+":t});await fetch(r.signedUrl,{method:"PUT",body:s})}async function ne({bucketName:e,"objectPath+":t}){const s=await this.request("/z3/{bucketName}/{objectPath+}","post",re.bind(this))({action:"download",bucketName:e,"objectPath+":t}),r=await fetch(s.signedUrl,{method:"GET"});if(!r.ok)throw new Error("Failed to download file");return r.arrayBuffer()}async function oe(e){let t,r;const i=new URL(e.url);if("z3:"===i.protocol){const e=i.pathname.split("/").slice(1);t=i.hostname,r=e.join("/")}else{if(!i.href.startsWith(this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"))throw new s({message:"Invalid Z3 URL",code:400});{const e=i.pathname.split("/").slice(3);t=e[0],r=e.slice(1).join("/")}}const n={action:"upload",bucketName:t,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",re.bind(this))(n)}class ae extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}uploadFile=ie;downloadFile=ne;getPresignedUrlForZ3Url=oe;listBuckets(e){return this.request("/z3","get",this.#e.bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",this.#e.bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",this.#e.bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",this.#e.bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",this.#e.bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",this.#e.bind(this))(e,t)}}function ue(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function he({id:e,file:t,filename:s}){const r=await this.request("/zambda/{id}/s3-upload","post",ue.bind(this))({id:e,filename:s});await fetch(r.signedUrl,{method:"PUT",body:t})}class ce extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}uploadFile=he;list(e){return this.request("/zambda","get",this.#e.bind(this))(e)}create(e,t){return this.request("/zambda","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",this.#e.bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",this.#e.bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",this.#e.bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",this.#e.bind(this))(e,t)}}class le extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}list(e,t){return this.request("/zambda/{id}/logStream","post",this.#e.bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",this.#e.bind(this))(e,t)}}let de=class{config;application;developer;m2m;messaging;conversation;transactionalSMS;paymentMethod;charge;project;role;secret;telemed;user;version;z3;fax;lab;erx;terminology;zambda;zambdaLogStream;rcm;fhir;constructor(e){if(e.workspaceTag&&e.ignoreTags)throw new s({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=e,this.config.services??={},this.config.services.projectApiUrl??=e.projectApiUrl,this.config.services.fhirApiUrl??=e.fhirApiUrl,this.application=new d(e),this.developer=new T(e),this.m2m=new F(e),this.messaging=new V(e),this.conversation=new f(e),this.transactionalSMS=new ee(e),this.paymentMethod=new B(e),this.charge=new p(e),this.project=new W(e),this.role=new Z(e),this.secret=new K(e),this.telemed=new Q(e),this.user=new te(e),this.version=new se(e),this.z3=new ae(e),this.fax=new k(e),this.lab=new H(e),this.erx=new U(e),this.terminology=new Y(e),this.zambda=new ce(e),this.zambdaLogStream=new le(e),this.rcm=new X(e),this.fhir=new G(e)}};class pe extends de{static OystehrFHIRError=i;static OystehrSdkError=s}export{pe as default};
|
|
1
|
+
import{v4 as e,validate as t}from"uuid";class s extends Error{code;constructor({message:e,code:t,cause:r}){super(e,{cause:r}),Object.setPrototypeOf(this,s.prototype),this.code=t,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(e){const t=[];for(const s of e.issue??[])s.details&&s.details.text&&t.push(s.details.text);return t.length||t.push("Unknown FHIR error"),t.join(",")}class i extends s{cause;constructor({error:e,code:t}){super({message:r(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}class n{_level;constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify({message:e,...t}))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify({message:e,...t}))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify({message:e,...t}))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify({message:e,...t}))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify({message:e,...t}))}}const o=[408,429,500,502,503,504],a=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class u{config;logger;constructor(e){this.config=e,this.logger=new n({level:this.config.logLevel})}request(e,t,r){return async(i,n)=>{const o=()=>this.config,a=()=>this.logger;try{return await c(r,o,a,e,t)(i,n)}catch(e){const t=e;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new s({message:t.message,code:t.code,cause:t.cause})}}}fhirRequest(e,t){return async(r,n)=>{try{const s=()=>this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com",i=()=>this.config,o=()=>this.logger;return await c(s,i,o,e,t)(r,n)}catch(e){const t=e;if("string"==typeof t.message)throw new s({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}}}function h(e){return"accessToken"in e||"projectId"in e&&t(e.projectId)||"contentType"in e&&2===e.contentType?.split("/").length||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function c(t,r,i,n,u){return async(c,d)=>{let[p,b]=function(e,t){const s=e&&!t&&!Array.isArray(e)&&h(e)?{}:e??{},r=e&&!t&&!Array.isArray(e)&&h(e)?e:t;return[s,r]}(c,d);b??={},b.requestId??=e();const g=r(),m=i(),f=u.toLowerCase();m.debug("Beginning fetch",{method:f,path:n,requestId:b?.requestId});const T=g.fetch??fetch,U=b?.accessToken??g.accessToken,k=b?.projectId??g.projectId;let y=n,q=p;if(!Array.isArray(p)){const[e,t]=function(e,t){const r={...t},i=e.replace(/\{([^}]+)\}/g,((e,i)=>{if(delete r[i],i.match(/^.*\+$/))return t[i]+"";if(!t[i]||""===t[i])throw new s({message:`Required path parameter is an empty string: ${i}`,code:400});return t[i]?encodeURIComponent(t[i]+""):""})),n=Object.keys(r),o=n.length?n.reduce(((e,t)=>({...e,[t]:r[t]})),{}):{};return[i,o]}(n,p);y=e,q=t}m.debug("Substituted parameters in path",{method:f,path:n,requestId:b?.requestId}),y=y.replace(/^\//,"");const v=t(),w=v.endsWith("/")?v:v+"/",j=new URL(y,w);let I;if(Array.isArray(q))I=JSON.stringify(q);else if(Object.keys(q).length)if("get"===f)l(q,j.searchParams);else if("application/x-www-form-urlencoded"===b?.contentType){const e=new URLSearchParams;l(q,e),I=e.toString()}else I=JSON.stringify(q);else"application/x-www-form-urlencoded"!==b?.contentType&&"post"===f&&(I="{}");m.debug("Prepared request body",{method:f,path:n,requestId:b?.requestId});const z=Object.assign(k?{"x-zapehr-project-id":k,"x-oystehr-project-id":k}:{},{"content-type":b?.contentType??"application/json"},U?{Authorization:`Bearer ${U}`}:{},b?.ifMatch?{"If-Match":b.ifMatch}:{},{"x-oystehr-request-id":b?.requestId}),x={retries:g.retry?.retries??3,jitter:g.retry?.jitter??20,delay:g.retry?.delay??100,onRetry:g.retry?.onRetry,retryOn:[...g.retry?.retryOn??[],...o]};return x.retryOn.push(...o),async function(e,t){let s;for(const r of Array.from({length:(t.retries??0)+1},((e,t)=>t)))try{return await e(r)}catch(e){let i=!1;if("response"in e){const r=e;i=t.retryOn.includes(r.code),s={message:e.message,code:e.code}}else if(s=e,"code"in e&&"string"==typeof e.code){const t=e;i=a.includes(t.code)}if(!i)break;const n=Math.floor(Math.random()*(t.jitter+1));await new Promise((e=>setTimeout(e,t.delay+n))),t.onRetry&&r!==(t.retries??0)&&t.onRetry(r+1)}throw s}((async()=>{m.info("Request start",{method:f,url:j,requestId:b?.requestId});const e=Date.now(),t=await T(new Request(j,{method:f.toUpperCase(),body:I,headers:z}));m.info("Request end",{method:f,url:j,duration:Date.now()-e,requestId:b?.requestId});const s=t.body?await t.text():null;let r;const i=t.headers.get("content-type");try{s&&(i?.includes("application/json")||i?.includes("application/fhir+json"))?(m.time("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId}),r=JSON.parse(s),m.timeEnd("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId})):s&&(i?.includes("application/xml")||i?.includes("text/xml"))?(m.time("Deserialized XML response",{method:f,url:j,requestId:b?.requestId}),r=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),s=t?parseInt(t[1],10):null,r=e.match(/<output>([\s\S]*?)<\/output>/),i=r?r[1]:null;return null===s||null===i?null:{status:s,output:i}}catch(e){return null}}(s),m.timeEnd("Deserialized XML response",{method:f,url:j,requestId:b?.requestId})):r=null}catch(e){r=null}m.debug("Deserialized response",{method:f,url:j,requestId:b?.requestId});if(!t.ok||t.status>=400){throw{message:("string"==typeof r?.output?r.output:r?.output?.message)??r?.message??r??s??t.statusText,code:r?.output?.code??r?.code??t.status,response:t}}return r}),x)}}function l(e,t){for(const[s,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>null!=e&&t.append(s,e))):null!=r&&t.append(s,r)}class d extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/application","get",this.#e.bind(this))(e)}create(e,t){return this.request("/application","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",this.#e.bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",this.#e.bind(this))(e,t)}}class p extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}issue(e,t){return this.request("/payment/charge/issue","post",this.#e.bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",this.#e.bind(this))(e,t)}}const b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",g="addressString";function m(e){if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const t=e.virtualService?.find((e=>"https://fhir.zapehr.com/virtual-service-type"===e.channelType?.system));return t?.addressString}if(!e.extension)return;const t=e.extension.find((e=>e.url===b));if(!t?.extension)return;const s=t.extension?.find((e=>e.url===g))?.valueString;return s}class f extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}ENCOUNTER_VS_EXTENSION_URL=b;ENCOUNTER_VS_EXTENSION_RELATIVE_URL=g;getConversationIdFromEncounter=m;create(e,t){return this.request("/messaging/conversation","post",this.#e.bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",this.#e.bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",this.#e.bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",this.#e.bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",this.#e.bind(this))(e,t)}}class T extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e,t){return this.request("/developer/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/developer","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",this.#e.bind(this))(e,t)}}class U extends u{constructor(e){super(e)}#e(){return this.config.services?.erxApiUrl??"https://erx-api.zapehr.com/v3"}searchAllergens(e,t){return this.request("/allergen","get",this.#e.bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",this.#e.bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",this.#e.bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",this.#e.bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",this.#e.bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",this.#e.bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",this.#e.bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",this.#e.bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",this.#e.bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",this.#e.bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",this.#e.bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",this.#e.bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",this.#e.bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",this.#e.bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",this.#e.bind(this))(e,t)}}class k extends u{constructor(e){super(e)}#e(){return this.config.services?.faxApiUrl??"https://fax-api.zapehr.com/v1"}offboard(e){return this.request("/offboard","post",this.#e.bind(this))(e)}onboard(e){return this.request("/onboard","post",this.#e.bind(this))(e)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}send(e,t){return this.request("/send","post",this.#e.bind(this))(e,t)}}const y=65535;function q(e){const t=(new globalThis.TextEncoder).encode(e);let s="";for(let e=0;e<t.length;e+=y){const r=t.subarray(e,e+y);s+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return s}function v(e){return e.system?`${e.system}|${e.code??""}`:e.code??""}function w(e,t){return(e.system??"")===(t.system??"")&&(e.code??"")===(t.code??"")}function j(e,t){const r=t;if(e.ignoreTags?.length){const i=r.meta?.tag??[];for(const t of e.ignoreTags)if(i.some((e=>w(e,t))))throw new s({message:`Resource has an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be mutated in ignoreTags mode`,code:400});return t}if(e.workspaceTag){const s=e.workspaceTag,i=r.meta?.tag??[];if(!i.some((e=>w(e,s))))return{...t,meta:{...r.meta,tag:[...i,s]}}}return t}function I(e,t){if(e.ignoreTags?.length){for(const r of t)if("add"===r.op||"replace"===r.op||"test"===r.op){const t=r.value;if(null!=t&&"object"==typeof t){const r=t;if(void 0!==r.code)for(const t of e.ignoreTags)if(w(r,t))throw new s({message:`Patch operation contains an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be applied in ignoreTags mode`,code:400})}}return t}if(e.workspaceTag){const s=e.workspaceTag;return t.reduce(((e,t)=>{if("remove"===t.op&&"/meta/tag"===t.path)return e.push(t),e.push({op:"add",path:"/meta/tag",value:[s]}),e;if("remove"===t.op&&"/meta"===t.path)return e.push(t),e.push({op:"add",path:"/meta",value:{tag:[s]}}),e;if(("add"===t.op||"replace"===t.op)&&"/meta/tag"===t.path){const r=Array.isArray(t.value)?t.value:[];return r.some((e=>w(e,s)))?e.push(t):e.push({...t,value:[...r,s]}),e}if(("add"===t.op||"replace"===t.op)&&"/meta"===t.path){const r=null!=t.value&&"object"==typeof t.value?t.value:{},i=r.tag??[];return i.some((e=>w(e,s)))?e.push(t):e.push({...t,value:{...r,tag:[...i,s]}}),e}return e.push(t),e}),[])}return t}function z(e,t){const s=t,r=s.meta?.tag??[];if(e.workspaceTag){const t=e.workspaceTag;if(!r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(e.ignoreTags?.length)for(const t of e.ignoreTags)if(r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}async function x(e,t){const{resourceType:s}=e,r=function(e,t){const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:v(e.workspaceTag)});else if(e.ignoreTags?.length)for(const t of e.ignoreTags)s.push({name:"_tag:not",value:v(t)});return s}(this.config,e.params);let i;r.length&&(i=r.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=await this.fhirRequest(`/${s}/_search`,"POST")(i,{...t,contentType:"application/x-www-form-urlencoded"});return{...n,entry:n.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function E(e,t){const s=j(this.config,e),{resourceType:r}=s;return this.fhirRequest(`/${r}`,"POST")(s,t)}async function S({resourceType:e,id:t},s){const r=await this.fhirRequest(`/${e}/${t}`,"GET")({},s);return z(this.config,r),r}async function A(e,t){const s=j(this.config,e),{id:r,resourceType:i}=s;return this.fhirRequest(`/${i}/${r}`,"PUT")(s,{...t,ifMatch:t?.optimisticLockingVersionId?`W/"${t.optimisticLockingVersionId}"`:void 0})}async function O({resourceType:e,id:t,operations:s},r){const i=I(this.config,s);return this.fhirRequest(`/${e}/${t}`,"PATCH")(i,{...r,contentType:"application/json-patch+json",ifMatch:r?.optimisticLockingVersionId?`W/"${r.optimisticLockingVersionId}"`:void 0})}async function P({resourceType:e,id:t},s){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}async function R({resourceType:e,id:t,versionId:s,count:r,offset:i},n){return s?this.fhirRequest(`/${e}/${t}/_history/${s}`,"GET")({},n):r?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${r}\n ${i?`&_offset=${i}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}function N(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function _(e){return e.split("?")[0].endsWith("/_search")}function $(e,t){const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&N(r)||"POST"===s&&_(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${v(t.workspaceTag)}`),t.ignoreTags?.length))for(const e of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${v(e)}`;const i={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),s=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>t?(e[t]||(e[t]=[]),e[t].push(s),e):e),{}),n=new URLSearchParams;l(s,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return i;if("PUT"===s){const s=j(t,e.resource);return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}if("PATCH"===s){if("resource"in e){let s=e.resource;const r=s.data;if(r){const e=I(t,JSON.parse(function(e){const t=globalThis.atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return(new globalThis.TextDecoder).decode(s)}(r)));s={...s,data:q(JSON.stringify(e))}}return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}const s=I(t,e.operations),r=q(JSON.stringify(s));return{...i,resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:r}}}if("POST"===s&&_(r))return i;if("POST"===s&&"resource"in e){const s=j(t,e.resource),{fullUrl:r}=e;return{...i,resource:s,fullUrl:r}}throw new Error("Unrecognized method")}async function M(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>$(e,this.config)))},t),r=s.entry,n=this.config.workspaceTag||this.config.ignoreTags?.length?r?.map(((t,s)=>{const r=e.requests[s];if(!r||!t?.resource)return t;if(("GET"===r.method||"HEAD"===r.method)&&!N(r.url))try{z(this.config,t.resource)}catch(e){if(!(e instanceof i))throw e;return{request:t.request,response:{status:"404",outcome:e.cause}}}return t})):r;return{...s,entry:n,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]},errors:function(){return this.entry?.filter((e=>e.response?.status?.startsWith("4")||e.response?.status?.startsWith("5"))).map((e=>e.response?.outcome)).filter((e=>void 0!==e))}}}async function C(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>$(e,this.config)))},t);(this.config.workspaceTag||this.config.ignoreTags?.length)&&s.entry?.forEach(((t,s)=>{const r=e.requests[s];r&&t?.resource&&("GET"!==r.method&&"HEAD"!==r.method||N(r.url)||z(this.config,t.resource))}));return{...s,entry:s.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function L({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}function D(e,t){const s=[];if(e.line&&s.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),s.push(t.join(", "))}return e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(t?.lineSeparator||", ").trim()}function J(e,t){const s=[];return e.prefix&&!1!==t?.prefix&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==t?.suffix&&s.push(...e.suffix),e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(" ").trim()}class G extends u{constructor(e){super(e)}#e(){return this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com"}search=x;create=E;get=S;update=A;patch=O;delete=P;history=R;batch=M;transaction=C;generateFriendlyPatientId=L;formatAddress=D;formatHumanName=J}class H extends u{constructor(e){super(e)}#e(){return this.config.services?.labApiUrl??"https://labs-api.zapehr.com/v1"}routeList(e){return this.request("/route","get",this.#e.bind(this))(e)}routeCreate(e,t){return this.request("/route","post",this.#e.bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",this.#e.bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",this.#e.bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",this.#e.bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",this.#e.bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",this.#e.bind(this))(e,t)}}class B extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/m2m","get",this.#e.bind(this))(e)}create(e,t){return this.request("/m2m","post",this.#e.bind(this))(e,t)}me(e){return this.request("/m2m/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",this.#e.bind(this))(e,t)}}class F extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}getMessagingConfig(e){return this.request("/messaging/config","get",this.#e.bind(this))(e)}}class V extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}setUp(e,t){return this.request("/payment/payment-method/setup","post",this.#e.bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",this.#e.bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",this.#e.bind(this))(e,t)}}class W extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/project","get",this.#e.bind(this))(e)}update(e,t){return this.request("/project","patch",this.#e.bind(this))(e,t)}}function X(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}function Z({id:e}){return`${X.call(this)}/payer/${e}`}async function K({url:e},t){if(!e.startsWith(Z.call(this,{id:""})))throw new s({code:400,message:"Invalid payer URL."});const r=new URL(e).pathname.split("/").filter(Boolean),i=r[r.length-1];return this.request("/payer/{id}","get",X.bind(this))({id:i},t)}class Q extends u{constructor(e){super(e)}#e(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}constructPayerUrl=Z;getPayerByUrl=K;eligibilityCheck(e,t){return this.request("/eligibility-check","post",this.#e.bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",this.#e.bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",this.#e.bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",this.#e.bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",this.#e.bind(this))(e,t)}}class Y extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/iam/role","get",this.#e.bind(this))(e)}create(e,t){return this.request("/iam/role","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",this.#e.bind(this))(e,t)}}class ee extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/secret","get",this.#e.bind(this))(e)}set(e,t){return this.request("/secret","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",this.#e.bind(this))(e,t)}}class te extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",this.#e.bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",this.#e.bind(this))(e,t)}}class se extends u{constructor(e){super(e)}#e(){return this.config.services?.terminologyApiUrl??"https://terminology-api.zapehr.com/v1"}searchCpt(e,t){return this.request("/cpt/search","get",this.#e.bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",this.#e.bind(this))(e,t)}}class re extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}send(e,t){return this.request("/messaging/transactional-sms/send","post",this.#e.bind(this))(e,t)}}class ie extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}me(e){return this.request("/user/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/user/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",this.#e.bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",this.#e.bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",this.#e.bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/user","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",this.#e.bind(this))(e,t)}}class ne extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/version","get",this.#e.bind(this))(e)}}function oe(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function ae({bucketName:e,"objectPath+":t,file:s}){const r=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"upload",bucketName:e,"objectPath+":t});await fetch(r.signedUrl,{method:"PUT",body:s})}async function ue({bucketName:e,"objectPath+":t}){const s=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"download",bucketName:e,"objectPath+":t}),r=await fetch(s.signedUrl,{method:"GET"});if(!r.ok)throw new Error("Failed to download file");return r.arrayBuffer()}async function he(e){let t,r;const i=new URL(e.url);if("z3:"===i.protocol){const e=i.pathname.split("/").slice(1);t=i.hostname,r=e.join("/")}else{if(!i.href.startsWith(this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"))throw new s({message:"Invalid Z3 URL",code:400});{const e=i.pathname.split("/").slice(3);t=e[0],r=e.slice(1).join("/")}}const n={action:"upload",bucketName:t,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))(n)}class ce extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}uploadFile=ae;downloadFile=ue;getPresignedUrlForZ3Url=he;listBuckets(e){return this.request("/z3","get",this.#e.bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",this.#e.bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",this.#e.bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",this.#e.bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",this.#e.bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",this.#e.bind(this))(e,t)}}function le(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function de({id:e,file:t,filename:s}){const r=await this.request("/zambda/{id}/s3-upload","post",le.bind(this))({id:e,filename:s});await fetch(r.signedUrl,{method:"PUT",body:t})}class pe extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}uploadFile=de;list(e){return this.request("/zambda","get",this.#e.bind(this))(e)}create(e,t){return this.request("/zambda","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",this.#e.bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",this.#e.bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",this.#e.bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",this.#e.bind(this))(e,t)}}class be extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}list(e,t){return this.request("/zambda/{id}/logStream","post",this.#e.bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",this.#e.bind(this))(e,t)}}let ge=class{config;application;developer;m2m;messaging;conversation;transactionalSMS;paymentMethod;charge;project;role;secret;telemed;user;version;z3;fax;lab;erx;terminology;zambda;zambdaLogStream;rcm;fhir;constructor(e){if(e.workspaceTag&&e.ignoreTags)throw new s({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=e,this.config.services??={},this.config.services.projectApiUrl??=e.projectApiUrl,this.config.services.fhirApiUrl??=e.fhirApiUrl,this.application=new d(e),this.developer=new T(e),this.m2m=new B(e),this.messaging=new F(e),this.conversation=new f(e),this.transactionalSMS=new re(e),this.paymentMethod=new V(e),this.charge=new p(e),this.project=new W(e),this.role=new Y(e),this.secret=new ee(e),this.telemed=new te(e),this.user=new ie(e),this.version=new ne(e),this.z3=new ce(e),this.fax=new k(e),this.lab=new H(e),this.erx=new U(e),this.terminology=new se(e),this.zambda=new pe(e),this.zambdaLogStream=new be(e),this.rcm=new Q(e),this.fhir=new G(e)}};class me extends ge{static OystehrFHIRError=i;static OystehrSdkError=s}export{me as default};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|