@oystehr/sdk 4.3.2 → 4.3.4

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