@fuego-systems/core 0.1.9 → 0.1.11

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.
@@ -31,8 +31,29 @@ export declare const HL7_IMPORT_TASK_SYSTEM = "http://example.org/CodeSystem/hl7
31
31
  export declare const HL7_IMPORT_APPOINTMENT_TASK_CODE = "import-orm-o01-appointment";
32
32
  export declare const HL7_IMPORT_TASK_INPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-inputs";
33
33
  export declare const HL7_IMPORT_TASK_OUTPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-outputs";
34
- /** Identifier system used to correlate multiple Appointments to the same ServiceRequest */
34
+ /**
35
+ * Identifier system used as `ServiceRequest.requisition.system` to correlate
36
+ * multiple ServiceRequests (one per Appointment) authored in the same
37
+ * appointments-portal wizard session. Maps to FHIR R4 `requisition` — "A
38
+ * shared identifier common to all service requests that were authorized more
39
+ * or less simultaneously by a single author, representing the composite or
40
+ * group identifier."
41
+ */
35
42
  export declare const SERVICE_REQUEST_GROUP_SYSTEM = "https://www.cdrossi.com/fhir/service-request-group";
43
+ /**
44
+ * Coding system for HealthcareService action (variant) selections recorded
45
+ * on `ServiceRequest.orderDetail[]`. The `code` is the PlanDefinition action
46
+ * id from the contained protocol on the HealthcareService, and `display` is
47
+ * the human-readable action label (e.g. "Frente y perfil").
48
+ */
49
+ export declare const HS_ACTION_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/hs-action";
50
+ /**
51
+ * Coding system for HealthcareService addon selections recorded on
52
+ * `ServiceRequest.orderDetail[]`. Same id/label shape as HS_ACTION_SYSTEM —
53
+ * the distinct URI lets readers filter action vs. addons without ordering
54
+ * assumptions on orderDetail.
55
+ */
56
+ export declare const HS_ADDON_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/hs-addon";
36
57
  /** Coding system for custom PlanDefinition types */
37
58
  export declare const PD_TYPE_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/plan-definition-type";
38
59
  /** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */
@@ -48,7 +69,7 @@ export declare const HS_PROTOCOL_EXTENSION_URL = "https://www.cdrossi.com/fhir/S
48
69
  /** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
49
70
  export declare const HS_BILLING_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-billing";
50
71
  /** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */
51
- export declare const PD_STUDY_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/pd-study";
72
+ export declare const PD_HEALTHCARE_SERVICE_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/pd-healthcare-service";
52
73
  /**
53
74
  * Extension URL for additional search aliases on HealthcareService.
54
75
  *
@@ -1 +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,oBAAoB,0CAAiC,CAAA;AAClE,eAAO,MAAM,qBAAqB,4CAAmC,CAAA;AACrE,eAAO,MAAM,oBAAoB,0CAAiC,CAAA;AAClE,eAAO,MAAM,kBAAkB,wCAA+B,CAAA;AAC9D,eAAO,MAAM,6BAA6B,mDAA0C,CAAA;AACpF,eAAO,MAAM,kBAAkB,wCAA+B,CAAA;AAC9D,eAAO,MAAM,iBAAiB,uCAA8B,CAAA;AAC5D,eAAO,MAAM,oBAAoB,0CAAiC,CAAA;AAClE,eAAO,MAAM,sBAAsB,4CAAmC,CAAA;AACtE,eAAO,MAAM,YAAY,kDAAkD,CAAA;AAC3E,eAAO,MAAM,yBAAyB,qEAAuC,CAAA;AAC7E,eAAO,MAAM,2BAA2B,uEAAyC,CAAA;AAEjF,eAAO,MAAM,mCAAmC,sEAAsE,CAAA;AACtH,eA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G,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,gIAAgI;AAChI,eAAO,MAAM,mCAAmC,2EAA2D,CAAA;AAE3G;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,uEAAuD,CAAA;AAEnG;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wCAAwC,gFAAgE,CAAA;AAIrH,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"}
package/dist/constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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_PROTOCOL_ALIASES_EXTENSION_URL = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.PD_STUDY_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.PD_TYPE_PROTOCOL_GROUP = exports.PD_TYPE_SYSTEM = exports.SERVICE_REQUEST_GROUP_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.REVIEW_APPOINTMENT_TASK_CODE = 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.MATRICULA_PROVINCIAL_SYSTEM = exports.MATRICULA_NACIONAL_SYSTEM = exports.RENAPER_BASE = exports.EGES_PRESTACION_SYSTEM = exports.EGES_PRACTICA_SYSTEM = exports.EGES_TURNO_SYSTEM = exports.EGES_EQUIPO_SYSTEM = exports.EGES_MEDICO_ASOCIACION_SYSTEM = exports.EGES_MEDICO_SYSTEM = exports.EGES_SUCURSAL_SYSTEM = exports.EGES_DOCUMENTO_SYSTEM = exports.EGES_PACIENTE_SYSTEM = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
4
- 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 = void 0;
3
+ exports.ORG_TYPE_PROV_CODE = exports.ORG_TYPE_PAY_CODE = exports.ORG_TYPE_SYSTEM = exports.INSURER_IDENTIFIER_SYSTEM = exports.HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.PD_HEALTHCARE_SERVICE_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.PD_TYPE_PROTOCOL_GROUP = exports.PD_TYPE_SYSTEM = exports.HS_ADDON_SYSTEM = exports.HS_ACTION_SYSTEM = exports.SERVICE_REQUEST_GROUP_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.REVIEW_APPOINTMENT_TASK_CODE = 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.MATRICULA_PROVINCIAL_SYSTEM = exports.MATRICULA_NACIONAL_SYSTEM = exports.RENAPER_BASE = exports.EGES_PRESTACION_SYSTEM = exports.EGES_PRACTICA_SYSTEM = exports.EGES_TURNO_SYSTEM = exports.EGES_EQUIPO_SYSTEM = exports.EGES_MEDICO_ASOCIACION_SYSTEM = exports.EGES_MEDICO_SYSTEM = exports.EGES_SUCURSAL_SYSTEM = exports.EGES_DOCUMENTO_SYSTEM = exports.EGES_PACIENTE_SYSTEM = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
4
+ 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 = void 0;
5
5
  exports.FHIR_BASE = 'https://www.cdrossi.com/fhir';
6
6
  exports.EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges';
7
7
  exports.EGES_PACIENTE_SYSTEM = `${exports.EGES_SYSTEM_BASE}/paciente`;
@@ -37,8 +37,29 @@ exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment';
37
37
  exports.HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs';
38
38
  exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs';
39
39
  // ─── ServiceRequest ──────────────────────────────────────────────────────────
40
- /** Identifier system used to correlate multiple Appointments to the same ServiceRequest */
40
+ /**
41
+ * Identifier system used as `ServiceRequest.requisition.system` to correlate
42
+ * multiple ServiceRequests (one per Appointment) authored in the same
43
+ * appointments-portal wizard session. Maps to FHIR R4 `requisition` — "A
44
+ * shared identifier common to all service requests that were authorized more
45
+ * or less simultaneously by a single author, representing the composite or
46
+ * group identifier."
47
+ */
41
48
  exports.SERVICE_REQUEST_GROUP_SYSTEM = `${exports.FHIR_BASE}/service-request-group`;
49
+ /**
50
+ * Coding system for HealthcareService action (variant) selections recorded
51
+ * on `ServiceRequest.orderDetail[]`. The `code` is the PlanDefinition action
52
+ * id from the contained protocol on the HealthcareService, and `display` is
53
+ * the human-readable action label (e.g. "Frente y perfil").
54
+ */
55
+ exports.HS_ACTION_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/hs-action`;
56
+ /**
57
+ * Coding system for HealthcareService addon selections recorded on
58
+ * `ServiceRequest.orderDetail[]`. Same id/label shape as HS_ACTION_SYSTEM —
59
+ * the distinct URI lets readers filter action vs. addons without ordering
60
+ * assumptions on orderDetail.
61
+ */
62
+ exports.HS_ADDON_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/hs-addon`;
42
63
  // ─── PlanDefinition type ─────────────────────────────────────────────────────
43
64
  /** Coding system for custom PlanDefinition types */
44
65
  exports.PD_TYPE_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/plan-definition-type`;
@@ -56,7 +77,7 @@ exports.HS_PROTOCOL_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs
56
77
  /** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
57
78
  exports.HS_BILLING_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-billing`;
58
79
  /** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */
59
- exports.PD_STUDY_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/pd-study`;
80
+ exports.PD_HEALTHCARE_SERVICE_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/pd-healthcare-service`;
60
81
  /**
61
82
  * Extension URL for additional search aliases on HealthcareService.
62
83
  *
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceR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;;;;;;;;;;;GAWG;AACU,QAAA,wCAAwC,GAAG,GAAG,iBAAS,iDAAiD,CAAA;AAErH,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 EGES_PACIENTE_SYSTEM = `${EGES_SYSTEM_BASE}/paciente`\nexport const EGES_DOCUMENTO_SYSTEM = `${EGES_SYSTEM_BASE}/documentos`\nexport const EGES_SUCURSAL_SYSTEM = `${EGES_SYSTEM_BASE}/sucursal`\nexport const EGES_MEDICO_SYSTEM = `${EGES_SYSTEM_BASE}/medico`\nexport const EGES_MEDICO_ASOCIACION_SYSTEM = `${EGES_SYSTEM_BASE}/medico-asociacion`\nexport const EGES_EQUIPO_SYSTEM = `${EGES_SYSTEM_BASE}/equipo`\nexport const EGES_TURNO_SYSTEM = `${EGES_SYSTEM_BASE}/turno`\nexport const EGES_PRACTICA_SYSTEM = `${EGES_SYSTEM_BASE}/practica`\nexport const EGES_PRESTACION_SYSTEM = `${EGES_SYSTEM_BASE}/prestacion`\nexport const RENAPER_BASE = 'https://www.argentina.gob.ar/interior/renaper'\nexport const MATRICULA_NACIONAL_SYSTEM = `${RENAPER_BASE}/matricula-nacional`\nexport const MATRICULA_PROVINCIAL_SYSTEM = `${RENAPER_BASE}/matricula-provincial`\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`\nexport const REVIEW_APPOINTMENT_TASK_CODE = 'review-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// ─── ServiceRequest ──────────────────────────────────────────────────────────\n\n/** Identifier system used to correlate multiple Appointments to the same ServiceRequest */\nexport const SERVICE_REQUEST_GROUP_SYSTEM = `${FHIR_BASE}/service-request-group`\n\n// ─── PlanDefinition type ─────────────────────────────────────────────────────\n\n/** Coding system for custom PlanDefinition types */\nexport const PD_TYPE_SYSTEM = `${FHIR_BASE}/CodeSystem/plan-definition-type`\n\n/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */\nexport const PD_TYPE_PROTOCOL_GROUP = 'protocol-group'\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/** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */\nexport const PD_STUDY_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/pd-study`\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/**\n * @example\n * {\n * url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,\n * extension: [\n * { url: \"alias\", valueString: \"placa de tórax\" },\n * { url: \"protocol\", valueString: \"9a9056df-0e54-4c2a-a3ce-eb58405f1ec9\" },\n * { url: \"addon\", valueString: \"a7101b76-6f1a-4562-8689-edaee07d6b95\" },\n * { url: \"addon\", valueString: \"97b7c2ce-6f1a-4562-8689-f21a8673e009\" }\n * ]\n * }\n */\nexport const HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-protocol-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"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;;AAAa,QAAA,SAAS,GAAG,8BAA8B,CAAA;AAC1C,QAAA,gBAAgB,GAAG,8BAA8B,CAAA;AAEjD,QAAA,oBAAoB,GAAG,GAAG,wBAAgB,WAAW,CAAA;AACrD,QAAA,qBAAqB,GAAG,GAAG,wBAAgB,aAAa,CAAA;AACxD,QAAA,oBAAoB,GAAG,GAAG,wBAAgB,WAAW,CAAA;AACrD,QAAA,kBAAkB,G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3E,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 EGES_PACIENTE_SYSTEM = `${EGES_SYSTEM_BASE}/paciente`\nexport const EGES_DOCUMENTO_SYSTEM = `${EGES_SYSTEM_BASE}/documentos`\nexport const EGES_SUCURSAL_SYSTEM = `${EGES_SYSTEM_BASE}/sucursal`\nexport const EGES_MEDICO_SYSTEM = `${EGES_SYSTEM_BASE}/medico`\nexport const EGES_MEDICO_ASOCIACION_SYSTEM = `${EGES_SYSTEM_BASE}/medico-asociacion`\nexport const EGES_EQUIPO_SYSTEM = `${EGES_SYSTEM_BASE}/equipo`\nexport const EGES_TURNO_SYSTEM = `${EGES_SYSTEM_BASE}/turno`\nexport const EGES_PRACTICA_SYSTEM = `${EGES_SYSTEM_BASE}/practica`\nexport const EGES_PRESTACION_SYSTEM = `${EGES_SYSTEM_BASE}/prestacion`\nexport const RENAPER_BASE = 'https://www.argentina.gob.ar/interior/renaper'\nexport const MATRICULA_NACIONAL_SYSTEM = `${RENAPER_BASE}/matricula-nacional`\nexport const MATRICULA_PROVINCIAL_SYSTEM = `${RENAPER_BASE}/matricula-provincial`\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`\nexport const REVIEW_APPOINTMENT_TASK_CODE = 'review-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// ─── ServiceRequest ──────────────────────────────────────────────────────────\n\n/**\n * Identifier system used as `ServiceRequest.requisition.system` to correlate\n * multiple ServiceRequests (one per Appointment) authored in the same\n * appointments-portal wizard session. Maps to FHIR R4 `requisition` — \"A\n * shared identifier common to all service requests that were authorized more\n * or less simultaneously by a single author, representing the composite or\n * group identifier.\"\n */\nexport const SERVICE_REQUEST_GROUP_SYSTEM = `${FHIR_BASE}/service-request-group`\n\n/**\n * Coding system for HealthcareService action (variant) selections recorded\n * on `ServiceRequest.orderDetail[]`. The `code` is the PlanDefinition action\n * id from the contained protocol on the HealthcareService, and `display` is\n * the human-readable action label (e.g. \"Frente y perfil\").\n */\nexport const HS_ACTION_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-action`\n\n/**\n * Coding system for HealthcareService addon selections recorded on\n * `ServiceRequest.orderDetail[]`. Same id/label shape as HS_ACTION_SYSTEM —\n * the distinct URI lets readers filter action vs. addons without ordering\n * assumptions on orderDetail.\n */\nexport const HS_ADDON_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-addon`\n\n// ─── PlanDefinition type ─────────────────────────────────────────────────────\n\n/** Coding system for custom PlanDefinition types */\nexport const PD_TYPE_SYSTEM = `${FHIR_BASE}/CodeSystem/plan-definition-type`\n\n/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */\nexport const PD_TYPE_PROTOCOL_GROUP = 'protocol-group'\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/** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */\nexport const PD_HEALTHCARE_SERVICE_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/pd-healthcare-service`\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/**\n * @example\n * {\n * url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,\n * extension: [\n * { url: \"alias\", valueString: \"placa de tórax\" },\n * { url: \"protocol\", valueString: \"9a9056df-0e54-4c2a-a3ce-eb58405f1ec9\" },\n * { url: \"addon\", valueString: \"a7101b76-6f1a-4562-8689-edaee07d6b95\" },\n * { url: \"addon\", valueString: \"97b7c2ce-6f1a-4562-8689-f21a8673e009\" }\n * ]\n * }\n */\nexport const HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-protocol-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"]}
@@ -76,17 +76,17 @@ export declare function getProtocolVariants(pd: PlanDefinition): ProtocolActionI
76
76
  * @param pd - the PlanDefinition to inspect
77
77
  * @returns the referenced HealthcareService, if present
78
78
  */
79
- export declare function getProtocolGroupStudyReference(pd: PlanDefinition): string | undefined;
79
+ export declare function getProtocolGroupHealthcareServiceReference(pd: PlanDefinition): string | undefined;
80
80
  /**
81
81
  * Builds a protocol-group PlanDefinition resource.
82
82
  *
83
83
  * @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
84
84
  * @param entries - protocol action entries (at least one should have `isDefault: true`)
85
85
  * @param existingId - optional ID to reuse when updating an existing group PD
86
- * @param studyReference - optional HealthcareService reference stored on the group PD
86
+ * @param hsReference - optional HealthcareService reference stored on the group PD
87
87
  * @returns the constructed protocol-group PlanDefinition
88
88
  */
89
- export declare function buildProtocolGroup(title: string, entries: readonly ProtocolGroupActionEntry[], existingId?: string, studyReference?: string): PlanDefinition;
89
+ export declare function buildProtocolGroup(title: string, entries: readonly ProtocolGroupActionEntry[], existingId?: string, hsReference?: string): PlanDefinition;
90
90
  /**
91
91
  * A user's selection within a protocol-group PlanDefinition.
92
92
  *
@@ -1 +1 @@
1
- {"version":3,"file":"plan-definition-group.d.ts","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAwB,MAAM,oBAAoB,CAAA;AAKxF,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC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gE;AAChE,MAAM,WAAW,sBAAsB;IACrC,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAC7B;AAED,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAA;CACnD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,iBAAiB,GAC3B,cAAc,CAyBhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,iBAAiB,GAC3B,gBAAgB,CA0BlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAE,EAAE,EAAE,cAAc,GAAG,iBAAiB,CAiB5E"}
@@ -4,7 +4,7 @@ exports.isProtocolGroup = isProtocolGroup;
4
4
  exports.getProtocolActions = getProtocolActions;
5
5
  exports.getDefaultProtocol = getDefaultProtocol;
6
6
  exports.getProtocolVariants = getProtocolVariants;
7
- exports.getProtocolGroupStudyReference = getProtocolGroupStudyReference;
7
+ exports.getProtocolGroupHealthcareServiceReference = getProtocolGroupHealthcareServiceReference;
8
8
  exports.buildProtocolGroup = buildProtocolGroup;
9
9
  exports.configureProtocolGroup = configureProtocolGroup;
10
10
  exports.resolveProtocolSelection = resolveProtocolSelection;
@@ -68,9 +68,9 @@ function getProtocolVariants(pd) {
68
68
  * @param pd - the PlanDefinition to inspect
69
69
  * @returns the referenced HealthcareService, if present
70
70
  */
71
- function getProtocolGroupStudyReference(pd) {
71
+ function getProtocolGroupHealthcareServiceReference(pd) {
72
72
  var _a, _b, _c;
73
- return (_c = (_b = (_a = pd.extension) === null || _a === void 0 ? void 0 : _a.find((e) => e.url === constants_1.PD_STUDY_EXTENSION_URL)) === null || _b === void 0 ? void 0 : _b.valueReference) === null || _c === void 0 ? void 0 : _c.reference;
73
+ return (_c = (_b = (_a = pd.extension) === null || _a === void 0 ? void 0 : _a.find((e) => e.url === constants_1.PD_HEALTHCARE_SERVICE_EXTENSION_URL)) === null || _b === void 0 ? void 0 : _b.valueReference) === null || _c === void 0 ? void 0 : _c.reference;
74
74
  }
75
75
  // ─── Construction ────────────────────────────────────────────────────────────
76
76
  /**
@@ -79,10 +79,10 @@ function getProtocolGroupStudyReference(pd) {
79
79
  * @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
80
80
  * @param entries - protocol action entries (at least one should have `isDefault: true`)
81
81
  * @param existingId - optional ID to reuse when updating an existing group PD
82
- * @param studyReference - optional HealthcareService reference stored on the group PD
82
+ * @param hsReference - optional HealthcareService reference stored on the group PD
83
83
  * @returns the constructed protocol-group PlanDefinition
84
84
  */
85
- function buildProtocolGroup(title, entries, existingId, studyReference) {
85
+ function buildProtocolGroup(title, entries, existingId, hsReference) {
86
86
  const actions = entries.map((e) => {
87
87
  var _a;
88
88
  const subActions = ((_a = e.addons) !== null && _a !== void 0 ? _a : []).map((addon) => buildAction(addon.id, addon.display, addon.ref, addon.code, addon.duration, addon.question, addon.label));
@@ -105,11 +105,11 @@ function buildProtocolGroup(title, entries, existingId, studyReference) {
105
105
  },
106
106
  action: actions
107
107
  };
108
- if (studyReference) {
108
+ if (hsReference) {
109
109
  pd.extension = [
110
110
  {
111
- url: constants_1.PD_STUDY_EXTENSION_URL,
112
- valueReference: { reference: studyReference }
111
+ url: constants_1.PD_HEALTHCARE_SERVICE_EXTENSION_URL,
112
+ valueReference: { reference: hsReference }
113
113
  }
114
114
  ];
115
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plan-definition-group.js","sourceRoot":"","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AE,+BAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;IACrE,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,cAAc,GAAG,QAAQ,CAAA;IAClC,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA;IAC/B,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,cAAc,GAAG,aAAa,CAAA;IACvC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import type { Duration, PlanDefinition, PlanDefinitionAction } from '@medplum/fhirtypes'\nimport { PD_STUDY_EXTENSION_URL, PD_TYPE_PROTOCOL_GROUP, PD_TYPE_SYSTEM, SERVICE_TYPE_SYSTEM } from './constants'\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Information about a single action inside a protocol-group PD. */\nexport interface ProtocolActionInfo {\n readonly actionId: string\n readonly isDefault: boolean\n /** Short label for the variant (e.g. \"Helicoidal\") */\n readonly label: string\n /** User-facing question to select this variant */\n readonly question: string\n readonly protocolRef: string\n readonly protocolDisplay: string\n readonly protocolCode: string\n readonly duration?: Duration\n /**\n * Whether this action is pre-selected in a **configured** protocol-group.\n * Set by {@link configureProtocolGroup} via FHIR `precheckBehavior`.\n * `undefined` means the PD has not been configured (use `isDefault` as fallback).\n */\n readonly prechecked?: boolean\n /** Optional sub-actions (addons) with `any` selection behavior. */\n readonly addons: readonly ProtocolActionInfo[]\n}\n\n/** Entry used to build a protocol-group PD action. */\nexport interface ProtocolGroupActionEntry {\n readonly id: string\n readonly isDefault: boolean\n readonly label: string\n readonly question: string\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n /** Optional sub-action entries (addons). */\n readonly addons?: readonly ProtocolGroupActionEntry[]\n}\n\n// ─── Backward-compat aliases ────────────────────────────────────────────────\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport type ProtocolVariantInfo = ProtocolActionInfo\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport interface ProtocolDefaultInfo {\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n}\n\n// ─── Detection ───────────────────────────────────────────────────────────────\n\n/**\n * Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).\n *\n * @param pd - the PlanDefinition to check\n * @returns whether the PlanDefinition is a protocol-group\n */\nexport function isProtocolGroup (pd: PlanDefinition): boolean {\n return (pd.type?.coding ?? []).some(\n (c) => c.system === PD_TYPE_SYSTEM && c.code === PD_TYPE_PROTOCOL_GROUP\n )\n}\n\n// ─── Extraction ──────────────────────────────────────────────────────────────\n\n/**\n * Extracts all protocol actions from a protocol-group PD (preserving order).\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of action info objects (the one with `isDefault === true` is the default)\n */\nexport function getProtocolActions (pd: PlanDefinition): ProtocolActionInfo[] {\n return (pd.action ?? [])\n .filter((a): a is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(a.definitionCanonical)\n )\n .map((a) => extractActionInfo(a, a.id === 'default'))\n}\n\n/**\n * Extracts the default protocol action from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns the default protocol info, or undefined if not found\n */\nexport function getDefaultProtocol (pd: PlanDefinition): ProtocolDefaultInfo | undefined {\n const action = (pd.action ?? []).find((a) => a.id === 'default')\n if (!action?.definitionCanonical) { return undefined }\n return {\n ref: action.definitionCanonical,\n display: action.title ?? '',\n code: getActionServiceCode(action),\n duration: action.timingDuration\n }\n}\n\n/**\n * Extracts the non-default variant actions from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of variant info objects\n */\nexport function getProtocolVariants (pd: PlanDefinition): ProtocolActionInfo[] {\n return getProtocolActions(pd).filter((a) => !a.isDefault)\n}\n\n/**\n * Extracts the HealthcareService reference linked to a protocol-group PD.\n *\n * @param pd - the PlanDefinition to inspect\n * @returns the referenced HealthcareService, if present\n */\nexport function getProtocolGroupStudyReference (pd: PlanDefinition): string | undefined {\n return pd.extension?.find((e) => e.url === PD_STUDY_EXTENSION_URL)?.valueReference?.reference\n}\n\n// ─── Construction ────────────────────────────────────────────────────────────\n\n/**\n * Builds a protocol-group PlanDefinition resource.\n *\n * @param title - human-readable title for the group (e.g. \"TAC de hombro — Protocolos\")\n * @param entries - protocol action entries (at least one should have `isDefault: true`)\n * @param existingId - optional ID to reuse when updating an existing group PD\n * @param studyReference - optional HealthcareService reference stored on the group PD\n * @returns the constructed protocol-group PlanDefinition\n */\nexport function buildProtocolGroup (\n title: string,\n entries: readonly ProtocolGroupActionEntry[],\n existingId?: string,\n studyReference?: string\n): PlanDefinition {\n const actions: PlanDefinitionAction[] = entries.map((e) => {\n const subActions = (e.addons ?? []).map((addon) =>\n buildAction(\n addon.id,\n addon.display,\n addon.ref,\n addon.code,\n addon.duration,\n addon.question,\n addon.label\n )\n )\n\n const action = buildAction(\n e.isDefault ? 'default' : e.id,\n e.display,\n e.ref,\n e.code,\n e.duration,\n e.question,\n e.label\n )\n\n // Top-level actions use exactly-one selection behavior\n action.selectionBehavior = 'exactly-one'\n\n if (subActions.length > 0) {\n action.action = subActions\n // When an action has sub-actions (addons), they use `any` grouping\n action.groupingBehavior = 'logical-group'\n }\n\n return action\n })\n\n const pd: PlanDefinition = {\n resourceType: 'PlanDefinition',\n status: 'active',\n title,\n type: {\n coding: [{ system: PD_TYPE_SYSTEM, code: PD_TYPE_PROTOCOL_GROUP }]\n },\n action: actions\n }\n\n if (studyReference) {\n pd.extension = [\n {\n url: PD_STUDY_EXTENSION_URL,\n valueReference: { reference: studyReference }\n }\n ]\n }\n\n if (existingId) {\n pd.id = existingId\n }\n\n return pd\n}\n\n// ─── Selection / Configuration ──────────────────────────────────────────────\n\n/**\n * A user's selection within a protocol-group PlanDefinition.\n *\n * Represents the patient's choices when configuring a HealthcareService:\n * one main action (from the `exactly-one` selection) plus zero or more\n * addon sub-actions.\n */\nexport interface ProtocolSelection {\n /** The `action.id` of the chosen top-level action. */\n readonly actionId: string\n /** The `action.id`s of toggled-on addon sub-actions within the selected action. */\n readonly addonIds: readonly string[]\n}\n\n/** Resolved booking parameters for a single protocol action. */\nexport interface ResolvedProtocolAction {\n /** The `definitionCanonical` reference to the order-set PlanDefinition. */\n readonly protocolRef: string\n /** The service-type code for slot searching / billing. */\n readonly serviceType: string\n /** Estimated duration for this action. */\n readonly duration?: Duration\n}\n\n/** Fully resolved booking parameters produced by {@link resolveProtocolSelection}. */\nexport interface ResolvedProtocol {\n /** Resolved main action. */\n readonly main: ResolvedProtocolAction\n /** Resolved addon actions (empty when none selected). */\n readonly addons: readonly ResolvedProtocolAction[]\n}\n\n/**\n * Returns a **configured** copy of a protocol-group PlanDefinition by stamping\n * `precheckBehavior` on every action according to the given selection.\n *\n * - The selected top-level action gets `precheckBehavior: \"yes\"`, all others `\"no\"`.\n * - Within the selected action, each addon sub-action is stamped according to\n * whether its id appears in `selection.addonIds`.\n * - Unselected top-level actions have all their sub-actions stamped as `\"no\"`.\n *\n * The returned PD is a shallow copy — the original is never mutated.\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns a new PlanDefinition with `precheckBehavior` set on every action\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function configureProtocolGroup (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): PlanDefinition {\n const actions = pd.action ?? []\n const found = actions.some((a) => a.id === selection.actionId)\n if (!found) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n\n return {\n ...pd,\n action: actions.map((a) => {\n const isSelected = a.id === selection.actionId\n const subActions = (a.action ?? []).map((sub) => ({\n ...sub,\n precheckBehavior: (isSelected && addonSet.has(sub.id ?? '')) ? 'yes' as const : 'no' as const\n }))\n\n return {\n ...a,\n precheckBehavior: isSelected ? 'yes' as const : 'no' as const,\n ...(a.action ? { action: subActions } : {})\n }\n })\n }\n}\n\n/**\n * Resolves a protocol-group PlanDefinition + selection into concrete booking\n * parameters (service-type codes, definitionCanonical references, durations).\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns the resolved main + addon protocol references and codes\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function resolveProtocolSelection (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): ResolvedProtocol {\n const actions = pd.action ?? []\n const selected = actions.find((a) => a.id === selection.actionId)\n if (!selected?.definitionCanonical) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n const resolvedAddons: ResolvedProtocolAction[] = (selected.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string; id: string } =>\n Boolean(sub.id) && addonSet.has(sub.id ?? '') && Boolean(sub.definitionCanonical)\n )\n .map((sub) => ({\n protocolRef: sub.definitionCanonical,\n serviceType: getActionServiceCode(sub),\n duration: sub.timingDuration\n }))\n\n return {\n main: {\n protocolRef: selected.definitionCanonical,\n serviceType: getActionServiceCode(selected),\n duration: selected.timingDuration\n },\n addons: resolvedAddons\n }\n}\n\n/**\n * Reads the current selection from a **configured** protocol-group PlanDefinition\n * (one whose actions have been stamped with `precheckBehavior` via\n * {@link configureProtocolGroup}).\n *\n * Falls back to `id === \"default\"` with no addons if no action has\n * `precheckBehavior: \"yes\"`.\n *\n * @param pd - a (possibly configured) protocol-group PlanDefinition\n * @returns the selection encoded in the PD, or the default selection\n */\nexport function readProtocolSelection (pd: PlanDefinition): ProtocolSelection {\n const actions = pd.action ?? []\n\n // Look for an action explicitly marked as prechecked\n const prechecked = actions.find((a) => a.precheckBehavior === 'yes')\n if (prechecked?.id) {\n const addonIds = (prechecked.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { id: string } =>\n sub.precheckBehavior === 'yes' && Boolean(sub.id)\n )\n .map((sub) => sub.id)\n return { actionId: prechecked.id, addonIds }\n }\n\n // Fallback: default action, no addons\n const defaultAction = actions.find((a) => a.id === 'default') ?? actions[0]\n return { actionId: defaultAction?.id ?? '', addonIds: [] }\n}\n\n// ─── Internal helpers ───────────────────────────────────────────────────────\n\nfunction getActionServiceCode (action: PlanDefinitionAction): string {\n const coding = (action.code ?? [])\n .flatMap((cc) => cc.coding ?? [])\n .find((c) => c.system === SERVICE_TYPE_SYSTEM)\n return coding?.code ?? ''\n}\n\nfunction precheckToBool (value: string | undefined): boolean | undefined {\n if (value === 'yes') { return true }\n if (value === 'no') { return false }\n return undefined\n}\n\nfunction extractActionInfo (a: PlanDefinitionAction & { definitionCanonical: string }, isDefault: boolean): ProtocolActionInfo {\n const subActions = (a.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(sub.definitionCanonical)\n )\n .map((sub) => extractActionInfo(sub, false))\n\n return {\n actionId: a.id ?? '',\n isDefault,\n label: a.textEquivalent ?? a.title ?? '',\n question: a.description ?? '',\n protocolRef: a.definitionCanonical,\n protocolDisplay: a.title ?? '',\n protocolCode: getActionServiceCode(a),\n duration: a.timingDuration,\n prechecked: precheckToBool(a.precheckBehavior),\n addons: subActions\n }\n}\n\nfunction buildAction (\n id: string,\n title: string,\n ref: string,\n code: string,\n duration?: Duration,\n question?: string,\n labelOverride?: string\n): PlanDefinitionAction {\n const action: PlanDefinitionAction = {\n id,\n title,\n definitionCanonical: ref\n }\n if (code) {\n action.code = [{ coding: [{ system: SERVICE_TYPE_SYSTEM, code }] }]\n }\n if (duration) {\n action.timingDuration = duration\n }\n if (question) {\n action.description = question\n }\n if (labelOverride) {\n action.textEquivalent = labelOverride\n }\n return action\n}\n"]}
1
+ {"version":3,"file":"plan-definition-group.js","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":";;AA8DA,0CAIC;AAUD,gDAMC;AAQD,gDASC;AAQD,kDAEC;AAQD,gGAEC;AAaD,gDAiEC;AAoDD,wDA4BC;AAWD,4DA6BC;AAaD,sD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AAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA;IAC/B,CAAC;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,cAAc,GAAG,aAAa,CAAA;IACvC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import type { Duration, PlanDefinition, PlanDefinitionAction } from '@medplum/fhirtypes'\nimport { PD_HEALTHCARE_SERVICE_EXTENSION_URL, PD_TYPE_PROTOCOL_GROUP, PD_TYPE_SYSTEM, SERVICE_TYPE_SYSTEM } from './constants'\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Information about a single action inside a protocol-group PD. */\nexport interface ProtocolActionInfo {\n readonly actionId: string\n readonly isDefault: boolean\n /** Short label for the variant (e.g. \"Helicoidal\") */\n readonly label: string\n /** User-facing question to select this variant */\n readonly question: string\n readonly protocolRef: string\n readonly protocolDisplay: string\n readonly protocolCode: string\n readonly duration?: Duration\n /**\n * Whether this action is pre-selected in a **configured** protocol-group.\n * Set by {@link configureProtocolGroup} via FHIR `precheckBehavior`.\n * `undefined` means the PD has not been configured (use `isDefault` as fallback).\n */\n readonly prechecked?: boolean\n /** Optional sub-actions (addons) with `any` selection behavior. */\n readonly addons: readonly ProtocolActionInfo[]\n}\n\n/** Entry used to build a protocol-group PD action. */\nexport interface ProtocolGroupActionEntry {\n readonly id: string\n readonly isDefault: boolean\n readonly label: string\n readonly question: string\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n /** Optional sub-action entries (addons). */\n readonly addons?: readonly ProtocolGroupActionEntry[]\n}\n\n// ─── Backward-compat aliases ────────────────────────────────────────────────\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport type ProtocolVariantInfo = ProtocolActionInfo\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport interface ProtocolDefaultInfo {\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n}\n\n// ─── Detection ───────────────────────────────────────────────────────────────\n\n/**\n * Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).\n *\n * @param pd - the PlanDefinition to check\n * @returns whether the PlanDefinition is a protocol-group\n */\nexport function isProtocolGroup (pd: PlanDefinition): boolean {\n return (pd.type?.coding ?? []).some(\n (c) => c.system === PD_TYPE_SYSTEM && c.code === PD_TYPE_PROTOCOL_GROUP\n )\n}\n\n// ─── Extraction ──────────────────────────────────────────────────────────────\n\n/**\n * Extracts all protocol actions from a protocol-group PD (preserving order).\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of action info objects (the one with `isDefault === true` is the default)\n */\nexport function getProtocolActions (pd: PlanDefinition): ProtocolActionInfo[] {\n return (pd.action ?? [])\n .filter((a): a is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(a.definitionCanonical)\n )\n .map((a) => extractActionInfo(a, a.id === 'default'))\n}\n\n/**\n * Extracts the default protocol action from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns the default protocol info, or undefined if not found\n */\nexport function getDefaultProtocol (pd: PlanDefinition): ProtocolDefaultInfo | undefined {\n const action = (pd.action ?? []).find((a) => a.id === 'default')\n if (!action?.definitionCanonical) { return undefined }\n return {\n ref: action.definitionCanonical,\n display: action.title ?? '',\n code: getActionServiceCode(action),\n duration: action.timingDuration\n }\n}\n\n/**\n * Extracts the non-default variant actions from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of variant info objects\n */\nexport function getProtocolVariants (pd: PlanDefinition): ProtocolActionInfo[] {\n return getProtocolActions(pd).filter((a) => !a.isDefault)\n}\n\n/**\n * Extracts the HealthcareService reference linked to a protocol-group PD.\n *\n * @param pd - the PlanDefinition to inspect\n * @returns the referenced HealthcareService, if present\n */\nexport function getProtocolGroupHealthcareServiceReference (pd: PlanDefinition): string | undefined {\n return pd.extension?.find((e) => e.url === PD_HEALTHCARE_SERVICE_EXTENSION_URL)?.valueReference?.reference\n}\n\n// ─── Construction ────────────────────────────────────────────────────────────\n\n/**\n * Builds a protocol-group PlanDefinition resource.\n *\n * @param title - human-readable title for the group (e.g. \"TAC de hombro — Protocolos\")\n * @param entries - protocol action entries (at least one should have `isDefault: true`)\n * @param existingId - optional ID to reuse when updating an existing group PD\n * @param hsReference - optional HealthcareService reference stored on the group PD\n * @returns the constructed protocol-group PlanDefinition\n */\nexport function buildProtocolGroup (\n title: string,\n entries: readonly ProtocolGroupActionEntry[],\n existingId?: string,\n hsReference?: string\n): PlanDefinition {\n const actions: PlanDefinitionAction[] = entries.map((e) => {\n const subActions = (e.addons ?? []).map((addon) =>\n buildAction(\n addon.id,\n addon.display,\n addon.ref,\n addon.code,\n addon.duration,\n addon.question,\n addon.label\n )\n )\n\n const action = buildAction(\n e.isDefault ? 'default' : e.id,\n e.display,\n e.ref,\n e.code,\n e.duration,\n e.question,\n e.label\n )\n\n // Top-level actions use exactly-one selection behavior\n action.selectionBehavior = 'exactly-one'\n\n if (subActions.length > 0) {\n action.action = subActions\n // When an action has sub-actions (addons), they use `any` grouping\n action.groupingBehavior = 'logical-group'\n }\n\n return action\n })\n\n const pd: PlanDefinition = {\n resourceType: 'PlanDefinition',\n status: 'active',\n title,\n type: {\n coding: [{ system: PD_TYPE_SYSTEM, code: PD_TYPE_PROTOCOL_GROUP }]\n },\n action: actions\n }\n\n if (hsReference) {\n pd.extension = [\n {\n url: PD_HEALTHCARE_SERVICE_EXTENSION_URL,\n valueReference: { reference: hsReference }\n }\n ]\n }\n\n if (existingId) {\n pd.id = existingId\n }\n\n return pd\n}\n\n// ─── Selection / Configuration ──────────────────────────────────────────────\n\n/**\n * A user's selection within a protocol-group PlanDefinition.\n *\n * Represents the patient's choices when configuring a HealthcareService:\n * one main action (from the `exactly-one` selection) plus zero or more\n * addon sub-actions.\n */\nexport interface ProtocolSelection {\n /** The `action.id` of the chosen top-level action. */\n readonly actionId: string\n /** The `action.id`s of toggled-on addon sub-actions within the selected action. */\n readonly addonIds: readonly string[]\n}\n\n/** Resolved booking parameters for a single protocol action. */\nexport interface ResolvedProtocolAction {\n /** The `definitionCanonical` reference to the order-set PlanDefinition. */\n readonly protocolRef: string\n /** The service-type code for slot searching / billing. */\n readonly serviceType: string\n /** Estimated duration for this action. */\n readonly duration?: Duration\n}\n\n/** Fully resolved booking parameters produced by {@link resolveProtocolSelection}. */\nexport interface ResolvedProtocol {\n /** Resolved main action. */\n readonly main: ResolvedProtocolAction\n /** Resolved addon actions (empty when none selected). */\n readonly addons: readonly ResolvedProtocolAction[]\n}\n\n/**\n * Returns a **configured** copy of a protocol-group PlanDefinition by stamping\n * `precheckBehavior` on every action according to the given selection.\n *\n * - The selected top-level action gets `precheckBehavior: \"yes\"`, all others `\"no\"`.\n * - Within the selected action, each addon sub-action is stamped according to\n * whether its id appears in `selection.addonIds`.\n * - Unselected top-level actions have all their sub-actions stamped as `\"no\"`.\n *\n * The returned PD is a shallow copy — the original is never mutated.\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns a new PlanDefinition with `precheckBehavior` set on every action\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function configureProtocolGroup (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): PlanDefinition {\n const actions = pd.action ?? []\n const found = actions.some((a) => a.id === selection.actionId)\n if (!found) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n\n return {\n ...pd,\n action: actions.map((a) => {\n const isSelected = a.id === selection.actionId\n const subActions = (a.action ?? []).map((sub) => ({\n ...sub,\n precheckBehavior: (isSelected && addonSet.has(sub.id ?? '')) ? 'yes' as const : 'no' as const\n }))\n\n return {\n ...a,\n precheckBehavior: isSelected ? 'yes' as const : 'no' as const,\n ...(a.action ? { action: subActions } : {})\n }\n })\n }\n}\n\n/**\n * Resolves a protocol-group PlanDefinition + selection into concrete booking\n * parameters (service-type codes, definitionCanonical references, durations).\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns the resolved main + addon protocol references and codes\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function resolveProtocolSelection (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): ResolvedProtocol {\n const actions = pd.action ?? []\n const selected = actions.find((a) => a.id === selection.actionId)\n if (!selected?.definitionCanonical) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n const resolvedAddons: ResolvedProtocolAction[] = (selected.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string; id: string } =>\n Boolean(sub.id) && addonSet.has(sub.id ?? '') && Boolean(sub.definitionCanonical)\n )\n .map((sub) => ({\n protocolRef: sub.definitionCanonical,\n serviceType: getActionServiceCode(sub),\n duration: sub.timingDuration\n }))\n\n return {\n main: {\n protocolRef: selected.definitionCanonical,\n serviceType: getActionServiceCode(selected),\n duration: selected.timingDuration\n },\n addons: resolvedAddons\n }\n}\n\n/**\n * Reads the current selection from a **configured** protocol-group PlanDefinition\n * (one whose actions have been stamped with `precheckBehavior` via\n * {@link configureProtocolGroup}).\n *\n * Falls back to `id === \"default\"` with no addons if no action has\n * `precheckBehavior: \"yes\"`.\n *\n * @param pd - a (possibly configured) protocol-group PlanDefinition\n * @returns the selection encoded in the PD, or the default selection\n */\nexport function readProtocolSelection (pd: PlanDefinition): ProtocolSelection {\n const actions = pd.action ?? []\n\n // Look for an action explicitly marked as prechecked\n const prechecked = actions.find((a) => a.precheckBehavior === 'yes')\n if (prechecked?.id) {\n const addonIds = (prechecked.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { id: string } =>\n sub.precheckBehavior === 'yes' && Boolean(sub.id)\n )\n .map((sub) => sub.id)\n return { actionId: prechecked.id, addonIds }\n }\n\n // Fallback: default action, no addons\n const defaultAction = actions.find((a) => a.id === 'default') ?? actions[0]\n return { actionId: defaultAction?.id ?? '', addonIds: [] }\n}\n\n// ─── Internal helpers ───────────────────────────────────────────────────────\n\nfunction getActionServiceCode (action: PlanDefinitionAction): string {\n const coding = (action.code ?? [])\n .flatMap((cc) => cc.coding ?? [])\n .find((c) => c.system === SERVICE_TYPE_SYSTEM)\n return coding?.code ?? ''\n}\n\nfunction precheckToBool (value: string | undefined): boolean | undefined {\n if (value === 'yes') { return true }\n if (value === 'no') { return false }\n return undefined\n}\n\nfunction extractActionInfo (a: PlanDefinitionAction & { definitionCanonical: string }, isDefault: boolean): ProtocolActionInfo {\n const subActions = (a.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(sub.definitionCanonical)\n )\n .map((sub) => extractActionInfo(sub, false))\n\n return {\n actionId: a.id ?? '',\n isDefault,\n label: a.textEquivalent ?? a.title ?? '',\n question: a.description ?? '',\n protocolRef: a.definitionCanonical,\n protocolDisplay: a.title ?? '',\n protocolCode: getActionServiceCode(a),\n duration: a.timingDuration,\n prechecked: precheckToBool(a.precheckBehavior),\n addons: subActions\n }\n}\n\nfunction buildAction (\n id: string,\n title: string,\n ref: string,\n code: string,\n duration?: Duration,\n question?: string,\n labelOverride?: string\n): PlanDefinitionAction {\n const action: PlanDefinitionAction = {\n id,\n title,\n definitionCanonical: ref\n }\n if (code) {\n action.code = [{ coding: [{ system: SERVICE_TYPE_SYSTEM, code }] }]\n }\n if (duration) {\n action.timingDuration = duration\n }\n if (question) {\n action.description = question\n }\n if (labelOverride) {\n action.textEquivalent = labelOverride\n }\n return action\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsCH;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAuBlE"}
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAwCH;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAuBlE"}
@@ -15,9 +15,11 @@ exports.normalize = normalize;
15
15
  /** Expanded abbreviations map (Spanish medical/radiological context). */
16
16
  const ABBREVIATIONS = [
17
17
  [/\brm\b/g, 'resonancia magnetica'],
18
+ [/\brmn\b/g, 'resonancia magnetica'],
19
+ [/\brnm\b/g, 'resonancia magnetica'],
18
20
  [/\brx\b/g, 'radiografia'],
19
- [/\btac\b/g, 'tomografia computada'],
20
- [/\btc\b/g, 'tomografia computada'],
21
+ [/\btac\b/g, 'tomografia'],
22
+ [/\btc\b/g, 'tomografia'],
21
23
  [/\beco\b/g, 'ecografia'],
22
24
  [/\bus\b/g, 'ecografia'],
23
25
  [/\bder\b/g, 'derecha'],
@@ -1 +1 @@
1
- {"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAkDH,8BAuBC;AAvED,yEAAyE;AACzE,MAAM,aAAa,GAAuB;IACxC,CAAC,SAAS,EAAE,sBAAsB,CAAC;IACnC,CAAC,SAAS,EAAE,aAAa,CAAC;IAC1B,CAAC,UAAU,EAAE,sBAAsB,CAAC;IACpC,CAAC,SAAS,EAAE,sBAAsB,CAAC;IACnC,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,SAAS,EAAE,WAAW,CAAC;IACxB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,UAAU,EAAE,UAAU,CAAC;IACxB,CAAC,UAAU,EAAE,UAAU,CAAC;IACxB,CAAC,UAAU,EAAE,UAAU,CAAC;IACxB,CAAC,WAAW,EAAE,WAAW,CAAC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E,GAAG,CAAC,CAAA;IAE5C,uCAAuC;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * Text normaliser for the HealthcareService search index.\n *\n * Produces a lower-cased, accent-stripped, abbreviation-expanded string\n * suitable for trigram similarity matching via pg_trgm.\n *\n * The normalisation here must mirror what the Postgres migration achieves with\n * `unaccent()` for query-time comparisons. By pre-normalising at index time we\n * avoid calling `unaccent()` on every row during search, which would prevent\n * the GIN index from being used.\n */\n\n/** Expanded abbreviations map (Spanish medical/radiological context). */\nconst ABBREVIATIONS: [RegExp, string][] = [\n [/\\brm\\b/g, 'resonancia magnetica'],\n [/\\brx\\b/g, 'radiografia'],\n [/\\btac\\b/g, 'tomografia computada'],\n [/\\btc\\b/g, 'tomografia computada'],\n [/\\beco\\b/g, 'ecografia'],\n [/\\bus\\b/g, 'ecografia'],\n [/\\bder\\b/g, 'derecha'],\n [/\\bizq\\b/g, 'izquierda'],\n [/\\bint\\b/g, 'interno'],\n [/\\bext\\b/g, 'externo'],\n [/\\bsup\\b/g, 'superior'],\n [/\\binf\\b/g, 'inferior'],\n [/\\bant\\b/g, 'anterior'],\n [/\\bpost\\b/g, 'posterior'],\n [/\\bmed\\b/g, 'medico'],\n [/\\bped\\b/g, 'pediatrico'],\n [/\\bgine\\b/g, 'ginecologia'],\n [/\\boftal\\b/g, 'oftalmologia'],\n [/\\btraumat\\b/g, 'traumatologia'],\n [/\\bneurol\\b/g, 'neurologia'],\n [/\\bcardio\\b/g, 'cardiologia'],\n [/\\bderma\\b/g, 'dermatologia'],\n [/\\boncol\\b/g, 'oncologia'],\n [/\\burgen\\b/g, 'urgencias'],\n [/\\bcir\\b/g, 'cirugia'],\n [/\\bfisio\\b/g, 'fisioterapia'],\n [/\\bpsico\\b/g, 'psicologia'],\n [/\\bodont\\b/g, 'odontologia'],\n [/\\bnutri\\b/g, 'nutricion'],\n [/\\blab\\b/g, 'laboratorio'],\n [/\\bpat\\b/g, 'patologia'],\n [/\\brad\\b/g, 'radiologia']\n]\n\n/**\n * Normalise a text string for storage or query comparison.\n *\n * Steps:\n * 1. NFD decompose + strip combining diacritical marks (accent removal)\n * 2. Lower-case\n * 3. Expand known medical abbreviations\n * 4. Remove non-alphanumeric characters (keep spaces)\n * 5. Collapse whitespace and trim\n * @param text - Input text to normalize.\n * @returns Normalized text suitable for trigram index lookup.\n */\nexport function normalize (text: string | null | undefined): string {\n if (!text) {\n return ''\n }\n\n // Step 1: Remove diacritics (accent stripping via NFD decomposition)\n let result = text\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n\n // Step 2: Lower-case\n result = result.toLowerCase()\n\n // Step 3: Expand abbreviations\n for (const [pattern, expansion] of ABBREVIATIONS) {\n result = result.replace(pattern, expansion)\n }\n\n // Step 4: Remove non-alphanumeric characters (keep spaces)\n result = result.replace(/[^a-z0-9\\s]/g, ' ')\n\n // Step 5: Collapse whitespace and trim\n return result.replace(/\\s+/g, ' ').trim()\n}\n"]}
1
+ {"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAoDH,8BAuBC;AAzED,yEAAyE;AACzE,MAAM,aAAa,GAAuB;IACxC,CAAC,SAAS,EAAE,sBAAsB,CAAC;IACnC,CAAC,UAAU,EAAE,sBAAsB,CAAC;IACpC,CAAC,UAAU,EAAE,sBAAsB,CAAC;IACpC,CAAC,SAAS,EAAE,aAAa,CAAC;IAC1B,CAAC,UAAU,EAAE,YAAY,CAAC;IAC1B,CAAC,SAAS,EAAE,YAAY,CAAC;IACzB,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,SAAS,EAAE,WAAW,CAAC;IACxB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,UAAU,EAAE,WAAW,CAAC;IACzB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,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AI,aAAa,EAAE,CAAC;QACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC7C,CAAC;IAED,2DAA2D;IAC3D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;IAE5C,uCAAuC;IACvC,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * Text normaliser for the HealthcareService search index.\n *\n * Produces a lower-cased, accent-stripped, abbreviation-expanded string\n * suitable for trigram similarity matching via pg_trgm.\n *\n * The normalisation here must mirror what the Postgres migration achieves with\n * `unaccent()` for query-time comparisons. By pre-normalising at index time we\n * avoid calling `unaccent()` on every row during search, which would prevent\n * the GIN index from being used.\n */\n\n/** Expanded abbreviations map (Spanish medical/radiological context). */\nconst ABBREVIATIONS: [RegExp, string][] = [\n [/\\brm\\b/g, 'resonancia magnetica'],\n [/\\brmn\\b/g, 'resonancia magnetica'],\n [/\\brnm\\b/g, 'resonancia magnetica'],\n [/\\brx\\b/g, 'radiografia'],\n [/\\btac\\b/g, 'tomografia'],\n [/\\btc\\b/g, 'tomografia'],\n [/\\beco\\b/g, 'ecografia'],\n [/\\bus\\b/g, 'ecografia'],\n [/\\bder\\b/g, 'derecha'],\n [/\\bizq\\b/g, 'izquierda'],\n [/\\bint\\b/g, 'interno'],\n [/\\bext\\b/g, 'externo'],\n [/\\bsup\\b/g, 'superior'],\n [/\\binf\\b/g, 'inferior'],\n [/\\bant\\b/g, 'anterior'],\n [/\\bpost\\b/g, 'posterior'],\n [/\\bmed\\b/g, 'medico'],\n [/\\bped\\b/g, 'pediatrico'],\n [/\\bgine\\b/g, 'ginecologia'],\n [/\\boftal\\b/g, 'oftalmologia'],\n [/\\btraumat\\b/g, 'traumatologia'],\n [/\\bneurol\\b/g, 'neurologia'],\n [/\\bcardio\\b/g, 'cardiologia'],\n [/\\bderma\\b/g, 'dermatologia'],\n [/\\boncol\\b/g, 'oncologia'],\n [/\\burgen\\b/g, 'urgencias'],\n [/\\bcir\\b/g, 'cirugia'],\n [/\\bfisio\\b/g, 'fisioterapia'],\n [/\\bpsico\\b/g, 'psicologia'],\n [/\\bodont\\b/g, 'odontologia'],\n [/\\bnutri\\b/g, 'nutricion'],\n [/\\blab\\b/g, 'laboratorio'],\n [/\\bpat\\b/g, 'patologia'],\n [/\\brad\\b/g, 'radiologia']\n]\n\n/**\n * Normalise a text string for storage or query comparison.\n *\n * Steps:\n * 1. NFD decompose + strip combining diacritical marks (accent removal)\n * 2. Lower-case\n * 3. Expand known medical abbreviations\n * 4. Remove non-alphanumeric characters (keep spaces)\n * 5. Collapse whitespace and trim\n * @param text - Input text to normalize.\n * @returns Normalized text suitable for trigram index lookup.\n */\nexport function normalize (text: string | null | undefined): string {\n if (!text) {\n return ''\n }\n\n // Step 1: Remove diacritics (accent stripping via NFD decomposition)\n let result = text\n .normalize('NFD')\n .replace(/[\\u0300-\\u036f]/g, '')\n\n // Step 2: Lower-case\n result = result.toLowerCase()\n\n // Step 3: Expand abbreviations\n for (const [pattern, expansion] of ABBREVIATIONS) {\n result = result.replace(pattern, expansion)\n }\n\n // Step 4: Remove non-alphanumeric characters (keep spaces)\n result = result.replace(/[^a-z0-9\\s]/g, ' ')\n\n // Step 5: Collapse whitespace and trim\n return result.replace(/\\s+/g, ' ').trim()\n}\n"]}