@fuego-systems/core 0.1.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 (54) hide show
  1. package/dist/constants.d.ts +89 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +97 -0
  4. package/dist/constants.js.map +1 -0
  5. package/dist/db/types.d.ts +49 -0
  6. package/dist/db/types.d.ts.map +1 -0
  7. package/dist/db/types.js +7 -0
  8. package/dist/db/types.js.map +1 -0
  9. package/dist/fhir/helpers.d.ts +4 -0
  10. package/dist/fhir/helpers.d.ts.map +1 -0
  11. package/dist/fhir/helpers.js +7 -0
  12. package/dist/fhir/helpers.js.map +1 -0
  13. package/dist/fhir/index.d.ts +3 -0
  14. package/dist/fhir/index.d.ts.map +1 -0
  15. package/dist/fhir/index.js +19 -0
  16. package/dist/fhir/index.js.map +1 -0
  17. package/dist/fhir/transaction-utils.d.ts +22 -0
  18. package/dist/fhir/transaction-utils.d.ts.map +1 -0
  19. package/dist/fhir/transaction-utils.js +156 -0
  20. package/dist/fhir/transaction-utils.js.map +1 -0
  21. package/dist/index.d.ts +9 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +23 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/scheduling/appointment.d.ts +15 -0
  26. package/dist/scheduling/appointment.d.ts.map +1 -0
  27. package/dist/scheduling/appointment.js +338 -0
  28. package/dist/scheduling/appointment.js.map +1 -0
  29. package/dist/scheduling/extension.d.ts +58 -0
  30. package/dist/scheduling/extension.d.ts.map +1 -0
  31. package/dist/scheduling/extension.js +3 -0
  32. package/dist/scheduling/extension.js.map +1 -0
  33. package/dist/scheduling/slot.d.ts +15 -0
  34. package/dist/scheduling/slot.d.ts.map +1 -0
  35. package/dist/scheduling/slot.js +291 -0
  36. package/dist/scheduling/slot.js.map +1 -0
  37. package/dist/scheduling/time-span.d.ts +26 -0
  38. package/dist/scheduling/time-span.d.ts.map +1 -0
  39. package/dist/scheduling/time-span.js +143 -0
  40. package/dist/scheduling/time-span.js.map +1 -0
  41. package/dist/search/alias-builder.d.ts +23 -0
  42. package/dist/search/alias-builder.d.ts.map +1 -0
  43. package/dist/search/alias-builder.js +126 -0
  44. package/dist/search/alias-builder.js.map +1 -0
  45. package/dist/search/normalizer.d.ts +25 -0
  46. package/dist/search/normalizer.d.ts.map +1 -0
  47. package/dist/search/normalizer.js +81 -0
  48. package/dist/search/normalizer.js.map +1 -0
  49. package/dist/test/factories.d.ts +10 -0
  50. package/dist/test/factories.d.ts.map +1 -0
  51. package/dist/test/factories.js +68 -0
  52. package/dist/test/factories.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -0
  54. package/package.json +33 -0
@@ -0,0 +1,89 @@
1
+ export declare const FHIR_BASE = "https://www.cdrossi.com/fhir";
2
+ export declare const EGES_SYSTEM_BASE = "https://www.cdrossi.com/eges";
3
+ export declare const SCHEDULING_PARAMETERS_EXTENSION_URL = "http://medplum.com/fhir/StructureDefinition/scheduling-parameters";
4
+ export declare const REQUIRES_PRACTITIONER_EXTENSION_URL = "https://www.cdrossi.com/fhir/requires-practitioner";
5
+ export declare const SERVICE_TYPE_SYSTEM = "https://www.cdrossi.com/fhir/service-type";
6
+ export declare const PRACTITIONER_ROLE_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/practitioner-role";
7
+ export declare const PRACTITIONER_ROLE_REFERRING_CODE = "referring";
8
+ export declare const MIGRATE_TASK_SYSTEM = "https://www.cdrossi.com/fhir/tasks";
9
+ export declare const MIGRATE_TASK_INPUT_SYSTEM = "https://www.cdrossi.com/fhir/task-inputs";
10
+ export declare const MIGRATE_TASK_OUTPUT_SYSTEM = "https://www.cdrossi.com/fhir/task-outputs";
11
+ export declare const MIGRATE_PRACTITIONER_TASK_CODE = "eges-migrate-practitioner";
12
+ export declare const MIGRATE_PATIENT_TASK_CODE = "eges-migrate-patient";
13
+ export declare const MIGRATE_DEVICE_TASK_CODE = "eges-migrate-device";
14
+ export declare const MIGRATE_SITE_TASK_CODE = "eges-migrate-site";
15
+ export declare const MIGRATE_SERVICE_TASK_CODE = "eges-migrate-service";
16
+ export declare const MIGRATE_APPOINTMENT_TASK_CODE = "eges-migrate-appointment";
17
+ export declare const HL7_IMPORT_TASK_SYSTEM = "http://example.org/CodeSystem/hl7-import-tasks";
18
+ export declare const HL7_IMPORT_APPOINTMENT_TASK_CODE = "import-orm-o01-appointment";
19
+ export declare const HL7_IMPORT_TASK_INPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-inputs";
20
+ export declare const HL7_IMPORT_TASK_OUTPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-outputs";
21
+ /** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */
22
+ export declare const SERVICE_CODES_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/service-codes";
23
+ /** Coding system for service categories on HealthcareService.category */
24
+ export declare const SERVICE_CATEGORY_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/service-category";
25
+ /** Coding system for specialities on HealthcareService.specialty */
26
+ export declare const SPECIALITY_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/speciality";
27
+ /** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */
28
+ export declare const HS_PROTOCOL_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-protocol";
29
+ /** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
30
+ export declare const HS_BILLING_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-billing";
31
+ /**
32
+ * Extension URL for additional search aliases on HealthcareService.
33
+ *
34
+ * Stored as multiple same-URL extensions, each with a `valueString`.
35
+ * These are indexed at weight 1.2 by the search indexer.
36
+ * Using an extension instead of HealthcareService.alias[] because the local
37
+ * FHIR profile does not permit the standard alias field.
38
+ *
39
+ * @example
40
+ * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: "placa de tórax" }
41
+ */
42
+ export declare const HS_SEARCH_ALIASES_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-search-aliases";
43
+ /** Identifier system for insurance company (payer) Organization resources */
44
+ export declare const INSURER_IDENTIFIER_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/insurers";
45
+ /** HL7 organization-type code system */
46
+ export declare const ORG_TYPE_SYSTEM = "http://terminology.hl7.org/CodeSystem/organization-type";
47
+ /** organization-type code for payer/insurance */
48
+ export declare const ORG_TYPE_PAY_CODE = "pay";
49
+ /** organization-type code for healthcare provider (the main clinic) */
50
+ export declare const ORG_TYPE_PROV_CODE = "prov";
51
+ /** Identifier system for InsurancePlan resources (specific plan products) */
52
+ export declare const INSURANCE_PLAN_IDENTIFIER_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/insurance-plans";
53
+ /**
54
+ * Tag system applied to every billing-codes CodeSystem resource,
55
+ * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.
56
+ */
57
+ export declare const BILLING_CODES_TAG_SYSTEM = "https://www.cdrossi.com/fhir/tags";
58
+ /**
59
+ * Tag code that marks a CodeSystem as a billing codes system.
60
+ * Every billing CodeSystem must carry:
61
+ * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]
62
+ */
63
+ export declare const BILLING_CODES_TAG_CODE = "billing-codes";
64
+ /**
65
+ * Extension URL stored on a billing CodeSystem to record which billing
66
+ * Organization (obra social) owns / uses this billing code system.
67
+ *
68
+ * Value type: Reference (Organization)
69
+ *
70
+ * Example:
71
+ * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]
72
+ */
73
+ export declare const BILLING_CODES_ORG_EXTENSION = "https://www.cdrossi.com/fhir/extensions/billing-code-system-organization";
74
+ /**
75
+ * Identifier system used to tag every billing ChargeItemDefinition with the ID
76
+ * of the PlanDefinition it belongs to, enabling reliable search via
77
+ * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.
78
+ * (The FHIR R4 `instance` search parameter is not supported by Medplum.)
79
+ */
80
+ export declare const BILLING_CID_PD_IDENTIFIER_SYSTEM = "https://www.cdrossi.com/fhir/billing/plan-definition";
81
+ /**
82
+ * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.
83
+ * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM
84
+ * useContext.code.code = BILLING_CID_CONTEXT_CODE
85
+ * useContext.valueReference → InsurancePlan
86
+ */
87
+ export declare const BILLING_CID_CONTEXT_SYSTEM = "http://terminology.hl7.org/CodeSystem/usage-context-type";
88
+ export declare const BILLING_CID_CONTEXT_CODE = "user";
89
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,iCAAiC,CAAA;AACvD,eAAO,MAAM,gBAAgB,iCAAiC,CAAA;AAE9D,eAAO,MAAM,mCAAmC,sEAAsE,CAAA;AACtH,eAAO,MAAM,mCAAmC,uDAAuC,CAAA;AACvF,eAAO,MAAM,mBAAmB,8CAA8B,CAAA;AAE9D,eAAO,MAAM,wBAAwB,8DAA8C,CAAA;AACnF,eAAO,MAAM,gCAAgC,cAAc,CAAA;AAG3D,eAAO,MAAM,mBAAmB,uCAAuB,CAAA;AACvD,eAAO,MAAM,yBAAyB,6CAA6B,CAAA;AACnE,eAAO,MAAM,0BAA0B,8CAA8B,CAAA;AACrE,eAAO,MAAM,8BAA8B,8BAAsC,CAAA;AACjF,eAAO,MAAM,yBAAyB,yBAAiC,CAAA;AACvE,eAAO,MAAM,wBAAwB,wBAAgC,CAAA;AACrE,eAAO,MAAM,sBAAsB,sBAA8B,CAAA;AACjE,eAAO,MAAM,yBAAyB,yBAAiC,CAAA;AACvE,eAAO,MAAM,6BAA6B,6BAAqC,CAAA;AAE/E,eAAO,MAAM,sBAAsB,mDAAmD,CAAA;AACtF,eAAO,MAAM,gCAAgC,+BAA+B,CAAA;AAC5E,eAAO,MAAM,4BAA4B,yDAAyD,CAAA;AAClG,eAAO,MAAM,6BAA6B,0DAA0D,CAAA;AAIpG,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,0DAA0C,CAAA;AAE3E,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,6DAA6C,CAAA;AAEjF,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,uDAAuC,CAAA;AAErE,wGAAwG;AACxG,eAAO,MAAM,yBAAyB,iEAAiD,CAAA;AAEvF,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,gEAAgD,CAAA;AAErF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,uEAAuD,CAAA;AAInG,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,qDAAqC,CAAA;AAE3E,wCAAwC;AACxC,eAAO,MAAM,eAAe,4DAA4D,CAAA;AAExF,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,QAAQ,CAAA;AAEtC,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,SAAS,CAAA;AAIxC,6EAA6E;AAC7E,eAAO,MAAM,gCAAgC,4DAA4C,CAAA;AAIzF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sCAAsB,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kBAAkB,CAAA;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,6EAA6D,CAAA;AAErG;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,yDAAyC,CAAA;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6DAA6D,CAAA;AACpG,eAAO,MAAM,wBAAwB,SAAS,CAAA"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = exports.BILLING_CODES_ORG_EXTENSION = exports.BILLING_CODES_TAG_CODE = exports.BILLING_CODES_TAG_SYSTEM = exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = exports.ORG_TYPE_PROV_CODE = exports.ORG_TYPE_PAY_CODE = exports.ORG_TYPE_SYSTEM = exports.INSURER_IDENTIFIER_SYSTEM = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = exports.HL7_IMPORT_TASK_INPUT_SYSTEM = exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = exports.HL7_IMPORT_TASK_SYSTEM = exports.MIGRATE_APPOINTMENT_TASK_CODE = exports.MIGRATE_SERVICE_TASK_CODE = exports.MIGRATE_SITE_TASK_CODE = exports.MIGRATE_DEVICE_TASK_CODE = exports.MIGRATE_PATIENT_TASK_CODE = exports.MIGRATE_PRACTITIONER_TASK_CODE = exports.MIGRATE_TASK_OUTPUT_SYSTEM = exports.MIGRATE_TASK_INPUT_SYSTEM = exports.MIGRATE_TASK_SYSTEM = exports.PRACTITIONER_ROLE_REFERRING_CODE = exports.PRACTITIONER_ROLE_SYSTEM = exports.SERVICE_TYPE_SYSTEM = exports.REQUIRES_PRACTITIONER_EXTENSION_URL = exports.SCHEDULING_PARAMETERS_EXTENSION_URL = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
4
+ exports.FHIR_BASE = 'https://www.cdrossi.com/fhir';
5
+ exports.EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges';
6
+ exports.SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters';
7
+ exports.REQUIRES_PRACTITIONER_EXTENSION_URL = `${exports.FHIR_BASE}/requires-practitioner`;
8
+ exports.SERVICE_TYPE_SYSTEM = `${exports.FHIR_BASE}/service-type`;
9
+ exports.PRACTITIONER_ROLE_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/practitioner-role`;
10
+ exports.PRACTITIONER_ROLE_REFERRING_CODE = 'referring';
11
+ const MIGRATE_TASK_BASE = 'eges-migrate';
12
+ exports.MIGRATE_TASK_SYSTEM = `${exports.FHIR_BASE}/tasks`;
13
+ exports.MIGRATE_TASK_INPUT_SYSTEM = `${exports.FHIR_BASE}/task-inputs`;
14
+ exports.MIGRATE_TASK_OUTPUT_SYSTEM = `${exports.FHIR_BASE}/task-outputs`;
15
+ exports.MIGRATE_PRACTITIONER_TASK_CODE = `${MIGRATE_TASK_BASE}-practitioner`;
16
+ exports.MIGRATE_PATIENT_TASK_CODE = `${MIGRATE_TASK_BASE}-patient`;
17
+ exports.MIGRATE_DEVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-device`;
18
+ exports.MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`;
19
+ exports.MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`;
20
+ exports.MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`;
21
+ exports.HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks';
22
+ exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment';
23
+ exports.HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs';
24
+ exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs';
25
+ // ─── HealthcareService model ──────────────────────────────────────────────────
26
+ /** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */
27
+ exports.SERVICE_CODES_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/service-codes`;
28
+ /** Coding system for service categories on HealthcareService.category */
29
+ exports.SERVICE_CATEGORY_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/service-category`;
30
+ /** Coding system for specialities on HealthcareService.specialty */
31
+ exports.SPECIALITY_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/speciality`;
32
+ /** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */
33
+ exports.HS_PROTOCOL_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-protocol`;
34
+ /** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
35
+ exports.HS_BILLING_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-billing`;
36
+ /**
37
+ * Extension URL for additional search aliases on HealthcareService.
38
+ *
39
+ * Stored as multiple same-URL extensions, each with a `valueString`.
40
+ * These are indexed at weight 1.2 by the search indexer.
41
+ * Using an extension instead of HealthcareService.alias[] because the local
42
+ * FHIR profile does not permit the standard alias field.
43
+ *
44
+ * @example
45
+ * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: "placa de tórax" }
46
+ */
47
+ exports.HS_SEARCH_ALIASES_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-search-aliases`;
48
+ // ─── Organization (payer / insurance company) ─────────────────────────────────
49
+ /** Identifier system for insurance company (payer) Organization resources */
50
+ exports.INSURER_IDENTIFIER_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/insurers`;
51
+ /** HL7 organization-type code system */
52
+ exports.ORG_TYPE_SYSTEM = 'http://terminology.hl7.org/CodeSystem/organization-type';
53
+ /** organization-type code for payer/insurance */
54
+ exports.ORG_TYPE_PAY_CODE = 'pay';
55
+ /** organization-type code for healthcare provider (the main clinic) */
56
+ exports.ORG_TYPE_PROV_CODE = 'prov';
57
+ // ─── InsurancePlan ────────────────────────────────────────────────────────────
58
+ /** Identifier system for InsurancePlan resources (specific plan products) */
59
+ exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/insurance-plans`;
60
+ // ─── Billing CodeSystem discovery tag ────────────────────────────────────────
61
+ /**
62
+ * Tag system applied to every billing-codes CodeSystem resource,
63
+ * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.
64
+ */
65
+ exports.BILLING_CODES_TAG_SYSTEM = `${exports.FHIR_BASE}/tags`;
66
+ /**
67
+ * Tag code that marks a CodeSystem as a billing codes system.
68
+ * Every billing CodeSystem must carry:
69
+ * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]
70
+ */
71
+ exports.BILLING_CODES_TAG_CODE = 'billing-codes';
72
+ /**
73
+ * Extension URL stored on a billing CodeSystem to record which billing
74
+ * Organization (obra social) owns / uses this billing code system.
75
+ *
76
+ * Value type: Reference (Organization)
77
+ *
78
+ * Example:
79
+ * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]
80
+ */
81
+ exports.BILLING_CODES_ORG_EXTENSION = `${exports.FHIR_BASE}/extensions/billing-code-system-organization`;
82
+ /**
83
+ * Identifier system used to tag every billing ChargeItemDefinition with the ID
84
+ * of the PlanDefinition it belongs to, enabling reliable search via
85
+ * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.
86
+ * (The FHIR R4 `instance` search parameter is not supported by Medplum.)
87
+ */
88
+ exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = `${exports.FHIR_BASE}/billing/plan-definition`;
89
+ /**
90
+ * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.
91
+ * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM
92
+ * useContext.code.code = BILLING_CID_CONTEXT_CODE
93
+ * useContext.valueReference → InsurancePlan
94
+ */
95
+ exports.BILLING_CID_CONTEXT_SYSTEM = 'http://terminology.hl7.org/CodeSystem/usage-context-type';
96
+ exports.BILLING_CID_CONTEXT_CODE = 'user';
97
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names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,wBAAwB,CAAA;AAErE,wGAAwG;AAC3F,QAAA,yBAAyB,GAAG,GAAG,iBAAS,kCAAkC,CAAA;AAEvF,mGAAmG;AACtF,QAAA,wBAAwB,GAAG,GAAG,iBAAS,iCAAiC,CAAA;AAErF;;;;;;;;;;GAUG;AACU,QAAA,+BAA+B,GAAG,GAAG,iBAAS,wCAAwC,CAAA;AAEnG,iFAAiF;AAEjF,6EAA6E;AAChE,QAAA,yBAAyB,GAAG,GAAG,iBAAS,sBAAsB,CAAA;AAE3E,wCAAwC;AAC3B,QAAA,eAAe,GAAG,yDAAyD,CAAA;AAExF,iDAAiD;AACpC,QAAA,iBAAiB,GAAG,KAAK,CAAA;AAEtC,uEAAuE;AAC1D,QAAA,kBAAkB,GAAG,MAAM,CAAA;AAExC,iFAAiF;AAEjF,6EAA6E;AAChE,QAAA,gCAAgC,GAAG,GAAG,iBAAS,6BAA6B,CAAA;AAEzF,gFAAgF;AAEhF;;;GAGG;AACU,QAAA,wBAAwB,GAAG,GAAG,iBAAS,OAAO,CAAA;AAE3D;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,eAAe,CAAA;AAErD;;;;;;;;GAQG;AACU,QAAA,2BAA2B,GAAG,GAAG,iBAAS,8CAA8C,CAAA;AAErG;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,GAAG,iBAAS,0BAA0B,CAAA;AAEtF;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,0DAA0D,CAAA;AACvF,QAAA,wBAAwB,GAAG,MAAM,CAAA","sourcesContent":["export const FHIR_BASE = 'https://www.cdrossi.com/fhir'\nexport const EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges'\n\nexport const SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters'\nexport const REQUIRES_PRACTITIONER_EXTENSION_URL = `${FHIR_BASE}/requires-practitioner`\nexport const SERVICE_TYPE_SYSTEM = `${FHIR_BASE}/service-type`\n\nexport const PRACTITIONER_ROLE_SYSTEM = `${FHIR_BASE}/CodeSystem/practitioner-role`\nexport const PRACTITIONER_ROLE_REFERRING_CODE = 'referring'\n\nconst MIGRATE_TASK_BASE = 'eges-migrate'\nexport const MIGRATE_TASK_SYSTEM = `${FHIR_BASE}/tasks`\nexport const MIGRATE_TASK_INPUT_SYSTEM = `${FHIR_BASE}/task-inputs`\nexport const MIGRATE_TASK_OUTPUT_SYSTEM = `${FHIR_BASE}/task-outputs`\nexport const MIGRATE_PRACTITIONER_TASK_CODE = `${MIGRATE_TASK_BASE}-practitioner`\nexport const MIGRATE_PATIENT_TASK_CODE = `${MIGRATE_TASK_BASE}-patient`\nexport const MIGRATE_DEVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-device`\nexport const MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`\nexport const MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`\nexport const MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`\n\nexport const HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks'\nexport const HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment'\nexport const HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs'\nexport const HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs'\n\n// ─── HealthcareService model ──────────────────────────────────────────────────\n\n/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */\nexport const SERVICE_CODES_SYSTEM = `${FHIR_BASE}/CodeSystem/service-codes`\n\n/** Coding system for service categories on HealthcareService.category */\nexport const SERVICE_CATEGORY_SYSTEM = `${FHIR_BASE}/CodeSystem/service-category`\n\n/** Coding system for specialities on HealthcareService.specialty */\nexport const SPECIALITY_SYSTEM = `${FHIR_BASE}/CodeSystem/speciality`\n\n/** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */\nexport const HS_PROTOCOL_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-protocol`\n\n/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */\nexport const HS_BILLING_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-billing`\n\n/**\n * Extension URL for additional search aliases on HealthcareService.\n *\n * Stored as multiple same-URL extensions, each with a `valueString`.\n * These are indexed at weight 1.2 by the search indexer.\n * Using an extension instead of HealthcareService.alias[] because the local\n * FHIR profile does not permit the standard alias field.\n *\n * @example\n * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: \"placa de tórax\" }\n */\nexport const HS_SEARCH_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-aliases`\n\n// ─── Organization (payer / insurance company) ─────────────────────────────────\n\n/** Identifier system for insurance company (payer) Organization resources */\nexport const INSURER_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurers`\n\n/** HL7 organization-type code system */\nexport const ORG_TYPE_SYSTEM = 'http://terminology.hl7.org/CodeSystem/organization-type'\n\n/** organization-type code for payer/insurance */\nexport const ORG_TYPE_PAY_CODE = 'pay'\n\n/** organization-type code for healthcare provider (the main clinic) */\nexport const ORG_TYPE_PROV_CODE = 'prov'\n\n// ─── InsurancePlan ────────────────────────────────────────────────────────────\n\n/** Identifier system for InsurancePlan resources (specific plan products) */\nexport const INSURANCE_PLAN_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurance-plans`\n\n// ─── Billing CodeSystem discovery tag ────────────────────────────────────────\n\n/**\n * Tag system applied to every billing-codes CodeSystem resource,\n * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.\n */\nexport const BILLING_CODES_TAG_SYSTEM = `${FHIR_BASE}/tags`\n\n/**\n * Tag code that marks a CodeSystem as a billing codes system.\n * Every billing CodeSystem must carry:\n * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]\n */\nexport const BILLING_CODES_TAG_CODE = 'billing-codes'\n\n/**\n * Extension URL stored on a billing CodeSystem to record which billing\n * Organization (obra social) owns / uses this billing code system.\n *\n * Value type: Reference (Organization)\n *\n * Example:\n * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]\n */\nexport const BILLING_CODES_ORG_EXTENSION = `${FHIR_BASE}/extensions/billing-code-system-organization`\n\n/**\n * Identifier system used to tag every billing ChargeItemDefinition with the ID\n * of the PlanDefinition it belongs to, enabling reliable search via\n * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.\n * (The FHIR R4 `instance` search parameter is not supported by Medplum.)\n */\nexport const BILLING_CID_PD_IDENTIFIER_SYSTEM = `${FHIR_BASE}/billing/plan-definition`\n\n/**\n * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.\n * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM\n * useContext.code.code = BILLING_CID_CONTEXT_CODE\n * useContext.valueReference → InsurancePlan\n */\nexport const BILLING_CID_CONTEXT_SYSTEM = 'http://terminology.hl7.org/CodeSystem/usage-context-type'\nexport const BILLING_CID_CONTEXT_CODE = 'user'\n"]}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Shared POJO types for the HealthcareService search index.
3
+ * These are plain objects — no TypeORM or framework dependencies.
4
+ */
5
+ /** A single alias row to be indexed. */
6
+ export interface AliasRow {
7
+ /** Human-readable alias text (original casing). */
8
+ readonly alias: string;
9
+ /** Pre-normalised alias (lowercase, unaccented, expanded). */
10
+ readonly normalizedAlias: string;
11
+ /**
12
+ * Alias category:
13
+ * - canonical – primary display name
14
+ * - alias – alternative label, informal name, or short name
15
+ * - code – service code identifier
16
+ * - code-name – code concatenated with the service name
17
+ */
18
+ readonly kind: 'canonical' | 'alias' | 'code' | 'code-name';
19
+ /** Relevance multiplier applied to the trigram score. */
20
+ readonly weight: number;
21
+ /** Optional ISO 639-1 language tag (e.g. 'es', 'en'). */
22
+ readonly language?: string;
23
+ }
24
+ /** Payload sent to the index endpoint to (re)index a single service. */
25
+ export interface ReindexPayload {
26
+ readonly healthcareServiceId: string;
27
+ readonly serviceName: string;
28
+ /** Service code value from the SERVICE_CODES_SYSTEM identifier. */
29
+ readonly code: string;
30
+ readonly aliases: AliasRow[];
31
+ }
32
+ /** Payload sent to the rebuild endpoint to reindex all services atomically. */
33
+ export interface RebuildPayload {
34
+ readonly services: ReindexPayload[];
35
+ }
36
+ /** A ranked search result returned by the query endpoint. */
37
+ export interface ServiceSearchResult {
38
+ readonly healthcareServiceId: string;
39
+ readonly serviceName: string;
40
+ readonly code: string;
41
+ /** Trigram similarity score (0–1 range, weighted). */
42
+ readonly score: number;
43
+ }
44
+ /** Query parameters for the search endpoint. */
45
+ export interface ServiceSearchQuery {
46
+ readonly q: string;
47
+ readonly limit?: number;
48
+ }
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,CAAA;IAC3D,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAA;CAC7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CACpC;AAED,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Shared POJO types for the HealthcareService search index.
4
+ * These are plain objects — no TypeORM or framework dependencies.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * Shared POJO types for the HealthcareService search index.\n * These are plain objects — no TypeORM or framework dependencies.\n */\n\n/** A single alias row to be indexed. */\nexport interface AliasRow {\n /** Human-readable alias text (original casing). */\n readonly alias: string\n /** Pre-normalised alias (lowercase, unaccented, expanded). */\n readonly normalizedAlias: string\n /**\n * Alias category:\n * - canonical – primary display name\n * - alias – alternative label, informal name, or short name\n * - code – service code identifier\n * - code-name – code concatenated with the service name\n */\n readonly kind: 'canonical' | 'alias' | 'code' | 'code-name'\n /** Relevance multiplier applied to the trigram score. */\n readonly weight: number\n /** Optional ISO 639-1 language tag (e.g. 'es', 'en'). */\n readonly language?: string\n}\n\n/** Payload sent to the index endpoint to (re)index a single service. */\nexport interface ReindexPayload {\n readonly healthcareServiceId: string\n readonly serviceName: string\n /** Service code value from the SERVICE_CODES_SYSTEM identifier. */\n readonly code: string\n readonly aliases: AliasRow[]\n}\n\n/** Payload sent to the rebuild endpoint to reindex all services atomically. */\nexport interface RebuildPayload {\n readonly services: ReindexPayload[]\n}\n\n/** A ranked search result returned by the query endpoint. */\nexport interface ServiceSearchResult {\n readonly healthcareServiceId: string\n readonly serviceName: string\n readonly code: string\n /** Trigram similarity score (0–1 range, weighted). */\n readonly score: number\n}\n\n/** Query parameters for the search endpoint. */\nexport interface ServiceSearchQuery {\n readonly q: string\n readonly limit?: number\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { ExtractResource, ResourceType } from '@medplum/fhirtypes';
2
+ import { MedplumClient, MedplumRequestOptions, ReadablePromise, WithId } from '@medplum/core';
3
+ export declare function readCanonical<RT extends ResourceType>(medplum: MedplumClient, resourceType: RT, url: string, options?: MedplumRequestOptions): ReadablePromise<WithId<ExtractResource<RT>> | undefined>;
4
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/fhir/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7F,wBAAgB,aAAa,CAAC,EAAE,SAAS,YAAY,EACnD,OAAO,EAAE,aAAa,EACtB,YAAY,EAAE,EAAE,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAC9B,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAE1D"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCanonical = readCanonical;
4
+ function readCanonical(medplum, resourceType, url, options) {
5
+ return medplum.searchOne(resourceType, 'url=' + url, options);
6
+ }
7
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/fhir/helpers.ts"],"names":[],"mappings":";;AAGA,sCAOC;AAPD,SAAgB,aAAa,CAC3B,OAAsB,EACtB,YAAgB,EAChB,GAAW,EACX,OAA+B;IAE/B,OAAO,OAAO,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["import { ExtractResource, ResourceType } from '@medplum/fhirtypes'\nimport { MedplumClient, MedplumRequestOptions, ReadablePromise, WithId } from '@medplum/core'\n\nexport function readCanonical<RT extends ResourceType> (\n medplum: MedplumClient,\n resourceType: RT,\n url: string,\n options?: MedplumRequestOptions\n): ReadablePromise<WithId<ExtractResource<RT>> | undefined> {\n return medplum.searchOne(resourceType, 'url=' + url, options)\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './helpers';
2
+ export * from './transaction-utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fhir/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./helpers"), exports);
18
+ __exportStar(require("./transaction-utils"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fhir/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,sDAAmC","sourcesContent":["export * from './helpers'\nexport * from './transaction-utils'\n"]}
@@ -0,0 +1,22 @@
1
+ import type { Bundle, BundleEntry, OperationOutcome, ResourceType } from '@medplum/fhirtypes';
2
+ export interface TransactionSummary {
3
+ total: number;
4
+ parts: string[];
5
+ }
6
+ export type TransactionBundleSplitter = (entries: BundleEntry[]) => BundleEntry[][];
7
+ export declare function summarizeResourceCounts(bundle: Bundle): TransactionSummary;
8
+ export declare function logTransactionBundleSummary(bundle: Bundle): void;
9
+ export declare function logTransactionResponseSummary(bundle: Bundle, failures: string[], requestBundle?: Bundle): void;
10
+ export declare function combineTransactionBundles(bundles: Bundle[]): Bundle;
11
+ export declare function splitTransactionBundle(bundle: Bundle, splitter: TransactionBundleSplitter): Bundle[];
12
+ export declare function indexBundleReferences(bundle: Bundle): Map<string, string>;
13
+ export declare function deriveReferenceFromEntry(entry: any): string | undefined;
14
+ export declare function parseResourceUrl(url: string): {
15
+ resourceType: ResourceType;
16
+ id: string;
17
+ } | undefined;
18
+ export declare function mapStatusToAction(status: string): string;
19
+ export declare function getTransactionFailures(bundle: Bundle): string[];
20
+ export declare function readOutcomeDetail(outcome: OperationOutcome | undefined): string | undefined;
21
+ export declare function isSuccessfulStatus(status: string | undefined): boolean;
22
+ //# sourceMappingURL=transaction-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-utils.d.ts","sourceRoot":"","sources":["../../src/fhir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AAgB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM5F;AAED,wBAAgB,kBAAkB,CAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAMvE"}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.summarizeResourceCounts = summarizeResourceCounts;
4
+ exports.logTransactionBundleSummary = logTransactionBundleSummary;
5
+ exports.logTransactionResponseSummary = logTransactionResponseSummary;
6
+ exports.combineTransactionBundles = combineTransactionBundles;
7
+ exports.splitTransactionBundle = splitTransactionBundle;
8
+ exports.indexBundleReferences = indexBundleReferences;
9
+ exports.deriveReferenceFromEntry = deriveReferenceFromEntry;
10
+ exports.parseResourceUrl = parseResourceUrl;
11
+ exports.mapStatusToAction = mapStatusToAction;
12
+ exports.getTransactionFailures = getTransactionFailures;
13
+ exports.readOutcomeDetail = readOutcomeDetail;
14
+ exports.isSuccessfulStatus = isSuccessfulStatus;
15
+ function summarizeResourceCounts(bundle) {
16
+ var _a;
17
+ const counts = new Map();
18
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.forEach((entry) => {
19
+ var _a, _b;
20
+ const type = (_a = entry.resource) === null || _a === void 0 ? void 0 : _a.resourceType;
21
+ if (type) {
22
+ counts.set(type, ((_b = counts.get(type)) !== null && _b !== void 0 ? _b : 0) + 1);
23
+ }
24
+ });
25
+ const parts = Array.from(counts.entries()).map(([type, count]) => `${count} ${type}${count === 1 ? '' : 's'}`);
26
+ const total = Array.from(counts.values()).reduce((sum, count) => sum + count, 0);
27
+ return { total, parts };
28
+ }
29
+ function logTransactionBundleSummary(bundle) {
30
+ const counts = summarizeResourceCounts(bundle);
31
+ const summary = counts.parts.length > 0 ? counts.parts.join(', ') : '0 resources';
32
+ console.log(`Got ${counts.total} resources in transaction Bundle: ${summary}`);
33
+ }
34
+ function logTransactionResponseSummary(bundle, failures, requestBundle) {
35
+ var _a;
36
+ if (failures.length > 0) {
37
+ console.log('Transaction executed with errors');
38
+ }
39
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.forEach((entry, index) => {
40
+ var _a, _b, _c, _d;
41
+ const requestEntry = (_a = requestBundle === null || requestBundle === void 0 ? void 0 : requestBundle.entry) === null || _a === void 0 ? void 0 : _a[index];
42
+ const status = (_b = entry.response) === null || _b === void 0 ? void 0 : _b.status;
43
+ const detail = readOutcomeDetail((_c = entry.response) === null || _c === void 0 ? void 0 : _c.outcome);
44
+ const action = mapStatusToAction(status !== null && status !== void 0 ? status : 'unknown');
45
+ const label = deriveEntryLabel(entry, requestEntry, index);
46
+ const suffix = !isSuccessfulStatus(status) && detail ? ` - ${detail}` : '';
47
+ console.log(`[${index}] ${label} ${action}${suffix}`);
48
+ if (!isSuccessfulStatus(status)) {
49
+ const resource = (_d = requestEntry === null || requestEntry === void 0 ? void 0 : requestEntry.resource) !== null && _d !== void 0 ? _d : entry.resource;
50
+ if (resource) {
51
+ console.log(JSON.stringify(resource, null, 2));
52
+ }
53
+ }
54
+ });
55
+ }
56
+ function combineTransactionBundles(bundles) {
57
+ var _a;
58
+ const entries = bundles.flatMap((bundle) => { var _a; return (_a = bundle === null || bundle === void 0 ? void 0 : bundle.entry) !== null && _a !== void 0 ? _a : []; });
59
+ const base = (_a = bundles.find((bundle) => (bundle === null || bundle === void 0 ? void 0 : bundle.resourceType) === 'Bundle')) !== null && _a !== void 0 ? _a : {
60
+ resourceType: 'Bundle',
61
+ type: 'transaction'
62
+ };
63
+ return { ...base, entry: entries };
64
+ }
65
+ function splitTransactionBundle(bundle, splitter) {
66
+ var _a, _b;
67
+ const groups = (_b = splitter((_a = bundle.entry) !== null && _a !== void 0 ? _a : [])) !== null && _b !== void 0 ? _b : [];
68
+ const base = { ...bundle, entry: undefined };
69
+ return groups
70
+ .filter((group) => Array.isArray(group) && group.length > 0)
71
+ .map((group) => ({ ...base, entry: group }));
72
+ }
73
+ function indexBundleReferences(bundle) {
74
+ var _a;
75
+ const map = new Map();
76
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.forEach((entry) => {
77
+ const ref = deriveReferenceFromEntry(entry);
78
+ if (entry.fullUrl && ref) {
79
+ map.set(entry.fullUrl, ref);
80
+ }
81
+ });
82
+ return map;
83
+ }
84
+ function deriveReferenceFromEntry(entry) {
85
+ var _a, _b, _c;
86
+ const resourceType = (_a = entry.resource) === null || _a === void 0 ? void 0 : _a.resourceType;
87
+ const resourceId = (_b = entry.resource) === null || _b === void 0 ? void 0 : _b.id;
88
+ if (resourceType && resourceId) {
89
+ return `${resourceType}/${resourceId}`;
90
+ }
91
+ const requestUrl = (_c = entry.request) === null || _c === void 0 ? void 0 : _c.url;
92
+ const parsed = requestUrl ? parseResourceUrl(requestUrl) : undefined;
93
+ if (parsed) {
94
+ return `${parsed.resourceType}/${parsed.id}`;
95
+ }
96
+ return undefined;
97
+ }
98
+ function parseResourceUrl(url) {
99
+ const match = /^([A-Za-z]+)\/([^/?]+)$/.exec(url);
100
+ if (!match) {
101
+ return undefined;
102
+ }
103
+ return { resourceType: match[1], id: match[2] };
104
+ }
105
+ function mapStatusToAction(status) {
106
+ if (status.startsWith('200')) {
107
+ return 'UPDATED';
108
+ }
109
+ if (status.startsWith('201')) {
110
+ return 'CREATED';
111
+ }
112
+ if (status.startsWith('204')) {
113
+ return 'NOOP';
114
+ }
115
+ return status;
116
+ }
117
+ function getTransactionFailures(bundle) {
118
+ var _a;
119
+ const failures = [];
120
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.forEach((entry) => {
121
+ var _a, _b, _c;
122
+ const status = (_b = (_a = entry.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : '';
123
+ if (!isSuccessfulStatus(status)) {
124
+ const detail = readOutcomeDetail((_c = entry.response) === null || _c === void 0 ? void 0 : _c.outcome);
125
+ failures.push(detail !== null && detail !== void 0 ? detail : status);
126
+ }
127
+ });
128
+ return failures;
129
+ }
130
+ function readOutcomeDetail(outcome) {
131
+ const issues = outcome === null || outcome === void 0 ? void 0 : outcome.issue;
132
+ if (!Array.isArray(issues) || issues.length === 0) {
133
+ return undefined;
134
+ }
135
+ return issues.map((issue) => { var _a, _b; return (_b = (_a = issue.details) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : issue.diagnostics; }).filter(Boolean).join('; ');
136
+ }
137
+ function isSuccessfulStatus(status) {
138
+ if (!status) {
139
+ return false;
140
+ }
141
+ const code = Number(status.split(' ')[0]);
142
+ return code >= 200 && code < 300;
143
+ }
144
+ function deriveEntryLabel(entry, requestEntry, index) {
145
+ var _a, _b, _c, _d, _e;
146
+ if ((_a = entry === null || entry === void 0 ? void 0 : entry.response) === null || _a === void 0 ? void 0 : _a.location) {
147
+ return entry.response.location;
148
+ }
149
+ const requestUrl = (_c = (_b = requestEntry === null || requestEntry === void 0 ? void 0 : requestEntry.request) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : (_d = entry === null || entry === void 0 ? void 0 : entry.request) === null || _d === void 0 ? void 0 : _d.url;
150
+ const parsed = requestUrl ? parseResourceUrl(requestUrl) : undefined;
151
+ if (parsed) {
152
+ return `${parsed.resourceType}/${(_e = parsed.id) !== null && _e !== void 0 ? _e : 'new'}`;
153
+ }
154
+ return `entry-${index}`;
155
+ }
156
+ //# sourceMappingURL=transaction-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-utils.js","sourceRoot":"","sources":["../../src/fhir/transaction-utils.ts"],"names":[],"mappings":";;AASA,0DAWC;AAED,kEAIC;AAED,sEAmBC;AAED,8DAQC;AAED,wDAMC;AAED,sDASC;AAED,4DAYC;AAED,4CAMC;AAED,8CAWC;AAED,wDAUC;AAED,8CAMC;AAED,gDAMC;AAlID,SAAgB,uBAAuB,CAAE,MAAc;;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,MAAA,MAAM,CAAC,KAAK,0CAAE,OAAO,CAAC,CAAC,KAAK,EAAE,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I,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzC,OAAO,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,CAAA;AAClC,CAAC;AAED,SAAS,gBAAgB,CAAE,KAA8B,EAAE,YAAqC,EAAE,KAAa;;IAC7G,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAA;IAChC,CAAC;IACD,MAAM,UAAU,GAAG,MAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,0CAAE,GAAG,mCAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,GAAG,CAAA;IACpE,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACpE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,GAAG,MAAM,CAAC,YAAY,IAAI,MAAA,MAAM,CAAC,EAAE,mCAAI,KAAK,EAAE,CAAA;IACvD,CAAC;IACD,OAAO,SAAS,KAAK,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import type { Bundle, BundleEntry, OperationOutcome, ResourceType } from '@medplum/fhirtypes'\n\nexport interface TransactionSummary {\n total: number\n parts: string[]\n}\n\nexport type TransactionBundleSplitter = (entries: BundleEntry[]) => BundleEntry[][]\n\nexport function summarizeResourceCounts (bundle: Bundle): TransactionSummary {\n const counts = new Map<string, number>()\n bundle.entry?.forEach((entry) => {\n const type = entry.resource?.resourceType\n if (type) {\n counts.set(type, (counts.get(type) ?? 0) + 1)\n }\n })\n const parts = Array.from(counts.entries()).map(([type, count]) => `${count} ${type}${count === 1 ? '' : 's'}`)\n const total = Array.from(counts.values()).reduce((sum, count) => sum + count, 0)\n return { total, parts }\n}\n\nexport function logTransactionBundleSummary (bundle: Bundle): void {\n const counts = summarizeResourceCounts(bundle)\n const summary = counts.parts.length > 0 ? counts.parts.join(', ') : '0 resources'\n console.log(`Got ${counts.total} resources in transaction Bundle: ${summary}`)\n}\n\nexport function logTransactionResponseSummary (bundle: Bundle, failures: string[], requestBundle?: Bundle): void {\n if (failures.length > 0) {\n console.log('Transaction executed with errors')\n }\n bundle.entry?.forEach((entry, index) => {\n const requestEntry = requestBundle?.entry?.[index]\n const status = entry.response?.status\n const detail = readOutcomeDetail(entry.response?.outcome)\n const action = mapStatusToAction(status ?? 'unknown')\n const label = deriveEntryLabel(entry, requestEntry, index)\n const suffix = !isSuccessfulStatus(status) && detail ? ` - ${detail}` : ''\n console.log(`[${index}] ${label} ${action}${suffix}`)\n if (!isSuccessfulStatus(status)) {\n const resource = requestEntry?.resource ?? entry.resource\n if (resource) {\n console.log(JSON.stringify(resource, null, 2))\n }\n }\n })\n}\n\nexport function combineTransactionBundles (bundles: Bundle[]): Bundle {\n const entries = bundles.flatMap((bundle) => bundle?.entry ?? [])\n const base =\n bundles.find((bundle) => bundle?.resourceType === 'Bundle') ?? ({\n resourceType: 'Bundle',\n type: 'transaction'\n } as Bundle)\n return { ...base, entry: entries }\n}\n\nexport function splitTransactionBundle (bundle: Bundle, splitter: TransactionBundleSplitter): Bundle[] {\n const groups = splitter(bundle.entry ?? []) ?? []\n const base: Bundle = { ...bundle, entry: undefined }\n return groups\n .filter((group) => Array.isArray(group) && group.length > 0)\n .map((group) => ({ ...base, entry: group }))\n}\n\nexport function indexBundleReferences (bundle: Bundle): Map<string, string> {\n const map = new Map<string, string>()\n bundle.entry?.forEach((entry) => {\n const ref = deriveReferenceFromEntry(entry)\n if (entry.fullUrl && ref) {\n map.set(entry.fullUrl, ref)\n }\n })\n return map\n}\n\nexport function deriveReferenceFromEntry (entry: any): string | undefined {\n const resourceType = entry.resource?.resourceType as ResourceType | undefined\n const resourceId = entry.resource?.id as string | undefined\n if (resourceType && resourceId) {\n return `${resourceType}/${resourceId}`\n }\n const requestUrl = entry.request?.url as string | undefined\n const parsed = requestUrl ? parseResourceUrl(requestUrl) : undefined\n if (parsed) {\n return `${parsed.resourceType}/${parsed.id}`\n }\n return undefined\n}\n\nexport function parseResourceUrl (url: string): { resourceType: ResourceType; id: string } | undefined {\n const match = /^([A-Za-z]+)\\/([^/?]+)$/.exec(url)\n if (!match) {\n return undefined\n }\n return { resourceType: match[1] as ResourceType, id: match[2] }\n}\n\nexport function mapStatusToAction (status: string): string {\n if (status.startsWith('200')) {\n return 'UPDATED'\n }\n if (status.startsWith('201')) {\n return 'CREATED'\n }\n if (status.startsWith('204')) {\n return 'NOOP'\n }\n return status\n}\n\nexport function getTransactionFailures (bundle: Bundle): string[] {\n const failures: string[] = []\n bundle.entry?.forEach((entry) => {\n const status = entry.response?.status ?? ''\n if (!isSuccessfulStatus(status)) {\n const detail = readOutcomeDetail(entry.response?.outcome)\n failures.push(detail ?? status)\n }\n })\n return failures\n}\n\nexport function readOutcomeDetail (outcome: OperationOutcome | undefined): string | undefined {\n const issues = outcome?.issue\n if (!Array.isArray(issues) || issues.length === 0) {\n return undefined\n }\n return issues.map((issue: any) => issue.details?.text ?? issue.diagnostics).filter(Boolean).join('; ')\n}\n\nexport function isSuccessfulStatus (status: string | undefined): boolean {\n if (!status) {\n return false\n }\n const code = Number(status.split(' ')[0])\n return code >= 200 && code < 300\n}\n\nfunction deriveEntryLabel (entry: BundleEntry | undefined, requestEntry: BundleEntry | undefined, index: number): string {\n if (entry?.response?.location) {\n return entry.response.location\n }\n const requestUrl = requestEntry?.request?.url ?? entry?.request?.url\n const parsed = requestUrl ? parseResourceUrl(requestUrl) : undefined\n if (parsed) {\n return `${parsed.resourceType}/${parsed.id ?? 'new'}`\n }\n return `entry-${index}`\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export * from './scheduling/slot';
2
+ export * from './scheduling/appointment';
3
+ export type * from './scheduling/extension';
4
+ export * from './constants';
5
+ export * from './fhir';
6
+ export type * from './db/types';
7
+ export * from './search/normalizer';
8
+ export * from './search/alias-builder';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,mBAAmB,wBAAwB,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./scheduling/slot"), exports);
18
+ __exportStar(require("./scheduling/appointment"), exports);
19
+ __exportStar(require("./constants"), exports);
20
+ __exportStar(require("./fhir"), exports);
21
+ __exportStar(require("./search/normalizer"), exports);
22
+ __exportStar(require("./search/alias-builder"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AAExC,8CAA2B;AAC3B,yCAAsB;AAEtB,sDAAmC;AACnC,yDAAsC","sourcesContent":["export * from './scheduling/slot'\nexport * from './scheduling/appointment'\nexport type * from './scheduling/extension'\nexport * from './constants'\nexport * from './fhir'\nexport type * from './db/types'\nexport * from './search/normalizer'\nexport * from './search/alias-builder'\n"]}
@@ -0,0 +1,15 @@
1
+ import { MedplumClient } from '@medplum/core';
2
+ import { Appointment, Bundle, Patient, Reference, Slot } from '@medplum/fhirtypes';
3
+ export interface HoldAppointmentArguments {
4
+ slots: Slot[];
5
+ patientReference?: Reference<Patient>;
6
+ }
7
+ export declare function holdAppointment(medplum: MedplumClient, options: HoldAppointmentArguments): Promise<Bundle<Appointment>>;
8
+ export interface BookAppointmentArguments {
9
+ appointmentReference?: Reference<Appointment>;
10
+ slots?: Slot[];
11
+ patientReference?: Reference<Patient>;
12
+ }
13
+ export declare function bookAppointment(medplum: MedplumClient, options: BookAppointmentArguments): Promise<Bundle<Appointment>>;
14
+ export declare function cancelAppointment(medplum: MedplumClient, appointmentReference: Reference<Appointment>): Promise<Bundle<Appointment>>;
15
+ //# sourceMappingURL=appointment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appointment.d.ts","sourceRoot":"","sources":["../../src/scheduling/appointment.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,aAAa,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EACL,WAAW,EAEX,MAAM,EAIN,OAAO,EACP,SAAS,EAET,IAAI,EACL,MAAM,oBAAoB,CAAA;AAI3B,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,gBAAgB,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,wBAAsB,eAAe,CAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAO9H;AAED,MAAM,WAAW,wBAAwB;IACvC,oBAAoB,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAA;IAC7C,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IACd,gBAAgB,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,wBAAsB,eAAe,CAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAsI9H;AAED,wBAAsB,iBAAiB,CAAE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,SAAS,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAiE3I"}