@fuego-systems/core 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +17 -2
- package/dist/constants.js.map +1 -1
- package/dist/db/types.d.ts +9 -5
- package/dist/db/types.d.ts.map +1 -1
- package/dist/db/types.js.map +1 -1
- package/dist/plan-definition-group.d.ts +10 -1
- package/dist/plan-definition-group.d.ts.map +1 -1
- package/dist/plan-definition-group.js +23 -3
- package/dist/plan-definition-group.js.map +1 -1
- package/dist/search/alias-builder.d.ts +8 -0
- package/dist/search/alias-builder.d.ts.map +1 -1
- package/dist/search/alias-builder.js +49 -5
- package/dist/search/alias-builder.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare const SPECIALITY_SYSTEM = "https://www.cdrossi.com/fhir/CodeSyste
|
|
|
47
47
|
export declare const HS_PROTOCOL_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-protocol";
|
|
48
48
|
/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
|
|
49
49
|
export declare const HS_BILLING_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-billing";
|
|
50
|
+
/** 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";
|
|
50
52
|
/**
|
|
51
53
|
* Extension URL for additional search aliases on HealthcareService.
|
|
52
54
|
*
|
|
@@ -59,6 +61,19 @@ export declare const HS_BILLING_EXTENSION_URL = "https://www.cdrossi.com/fhir/St
|
|
|
59
61
|
* { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: "placa de tórax" }
|
|
60
62
|
*/
|
|
61
63
|
export declare const HS_SEARCH_ALIASES_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-search-aliases";
|
|
64
|
+
/**
|
|
65
|
+
* @example
|
|
66
|
+
* {
|
|
67
|
+
* url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,
|
|
68
|
+
* extension: [
|
|
69
|
+
* { url: "alias", valueString: "placa de tórax" },
|
|
70
|
+
* { url: "protocol", valueString: "9a9056df-0e54-4c2a-a3ce-eb58405f1ec9" },
|
|
71
|
+
* { url: "addon", valueString: "a7101b76-6f1a-4562-8689-edaee07d6b95" },
|
|
72
|
+
* { url: "addon", valueString: "97b7c2ce-6f1a-4562-8689-f21a8673e009" }
|
|
73
|
+
* ]
|
|
74
|
+
* }
|
|
75
|
+
*/
|
|
76
|
+
export declare const HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/hs-search-protocol-aliases";
|
|
62
77
|
/** Identifier system for insurance company (payer) Organization resources */
|
|
63
78
|
export declare const INSURER_IDENTIFIER_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/insurers";
|
|
64
79
|
/** HL7 organization-type code system */
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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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,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.
|
|
4
|
-
exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = void 0;
|
|
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;
|
|
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`;
|
|
@@ -55,6 +55,8 @@ exports.SPECIALITY_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/speciality`;
|
|
|
55
55
|
exports.HS_PROTOCOL_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-protocol`;
|
|
56
56
|
/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */
|
|
57
57
|
exports.HS_BILLING_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-billing`;
|
|
58
|
+
/** 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`;
|
|
58
60
|
/**
|
|
59
61
|
* Extension URL for additional search aliases on HealthcareService.
|
|
60
62
|
*
|
|
@@ -67,6 +69,19 @@ exports.HS_BILLING_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-
|
|
|
67
69
|
* { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: "placa de tórax" }
|
|
68
70
|
*/
|
|
69
71
|
exports.HS_SEARCH_ALIASES_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-search-aliases`;
|
|
72
|
+
/**
|
|
73
|
+
* @example
|
|
74
|
+
* {
|
|
75
|
+
* url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,
|
|
76
|
+
* extension: [
|
|
77
|
+
* { url: "alias", valueString: "placa de tórax" },
|
|
78
|
+
* { url: "protocol", valueString: "9a9056df-0e54-4c2a-a3ce-eb58405f1ec9" },
|
|
79
|
+
* { url: "addon", valueString: "a7101b76-6f1a-4562-8689-edaee07d6b95" },
|
|
80
|
+
* { url: "addon", valueString: "97b7c2ce-6f1a-4562-8689-f21a8673e009" }
|
|
81
|
+
* ]
|
|
82
|
+
* }
|
|
83
|
+
*/
|
|
84
|
+
exports.HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/hs-search-protocol-aliases`;
|
|
70
85
|
// ─── Organization (payer / insurance company) ─────────────────────────────────
|
|
71
86
|
/** Identifier system for insurance company (payer) Organization resources */
|
|
72
87
|
exports.INSURER_IDENTIFIER_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/insurers`;
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,GAAG,GAAG,wBAAgB,SAAS,CAAA;AACjD,QAAA,6BAA6B,GAAG,GAAG,wBAAgB,oBAAoB,CAAA;AACvE,QAAA,kBAAkB,GAAG,GAAG,wBAAgB,SAAS,CAAA;AACjD,QAAA,iBAAiB,GAAG,GAAG,wBAAgB,QAAQ,CAAA;AAC/C,QAAA,oBAAoB,GAAG,GAAG,wBAAgB,WAAW,CAAA;AACrD,QAAA,sBAAsB,GAAG,GAAG,wBAAgB,aAAa,CAAA;AACzD,QAAA,YAAY,GAAG,+CAA+C,CAAA;AAC9D,QAAA,yBAAyB,GAAG,GAAG,oBAAY,qBAAqB,CAAA;AAChE,QAAA,2BAA2B,GAAG,GAAG,oBAAY,uBAAuB,CAAA;AAEpE,QAAA,mCAAmC,GAAG,mEAAmE,CAAA;AACzG,QAAA,mCAAmC,GAAG,GAAG,iBAAS,wBAAwB,CAAA;AAC1E,QAAA,mBAAmB,GAAG,GAAG,iBAAS,eAAe,CAAA;AAEjD,QAAA,wBAAwB,GAAG,GAAG,iBAAS,+BAA+B,CAAA;AACtE,QAAA,gCAAg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yB,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 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/**\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"]}
|
|
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,GAAG,GAAG,wBAAgB,SAAS,CAAA;AACjD,QAAA,6BAA6B,GAAG,GAAG,wBAAgB,oBAAoB,CAAA;AACvE,QAAA,kBAAkB,GAAG,GAAG,wBAAgB,SAAS,CAAA;AACjD,QAAA,iBAAiB,GAAG,GAAG,wBAAgB,QAAQ,CAAA;AAC/C,QAAA,oBAAoB,GAAG,GAAG,wBAAgB,WAAW,CAAA;AACrD,QAAA,sBAAsB,GAAG,GAAG,wBAAgB,aAAa,CAAA;AACzD,QAAA,YAAY,GAAG,+CAA+C,CAAA;AAC9D,QAAA,yBAAyB,GAAG,GAA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A0B,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"]}
|
package/dist/db/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Shared POJO types for the HealthcareService search index.
|
|
3
3
|
* These are plain objects — no TypeORM or framework dependencies.
|
|
4
4
|
*/
|
|
5
|
+
import { ProtocolSelection } from '../plan-definition-group';
|
|
5
6
|
/** A single alias row to be indexed. */
|
|
6
7
|
export interface AliasRow {
|
|
7
8
|
/** Human-readable alias text (original casing). */
|
|
@@ -10,16 +11,18 @@ export interface AliasRow {
|
|
|
10
11
|
readonly normalizedAlias: string;
|
|
11
12
|
/**
|
|
12
13
|
* Alias category:
|
|
13
|
-
* - canonical
|
|
14
|
-
* - alias
|
|
15
|
-
* - code
|
|
16
|
-
* - code-name
|
|
14
|
+
* - canonical – primary display name
|
|
15
|
+
* - alias – alternative label, informal name, or short name
|
|
16
|
+
* - code – service code identifier
|
|
17
|
+
* - code-name – code concatenated with the service name
|
|
18
|
+
* - protocol-alias - name of specific protocol configuration
|
|
17
19
|
*/
|
|
18
|
-
readonly kind: 'canonical' | 'alias' | 'code' | 'code-name';
|
|
20
|
+
readonly kind: 'canonical' | 'alias' | 'code' | 'code-name' | 'protocol-alias';
|
|
19
21
|
/** Relevance multiplier applied to the trigram score. */
|
|
20
22
|
readonly weight: number;
|
|
21
23
|
/** Optional ISO 639-1 language tag (e.g. 'es', 'en'). */
|
|
22
24
|
readonly language?: string;
|
|
25
|
+
readonly protocolSelection?: ProtocolSelection;
|
|
23
26
|
}
|
|
24
27
|
/** Payload sent to the index endpoint to (re)index a single service. */
|
|
25
28
|
export interface ReindexPayload {
|
|
@@ -40,6 +43,7 @@ export interface ServiceSearchResult {
|
|
|
40
43
|
readonly code: string;
|
|
41
44
|
/** Trigram similarity score (0–1 range, weighted). */
|
|
42
45
|
readonly score: number;
|
|
46
|
+
readonly protocolSelection?: ProtocolSelection;
|
|
43
47
|
}
|
|
44
48
|
/** Query parameters for the search endpoint. */
|
|
45
49
|
export interface ServiceSearchQuery {
|
package/dist/db/types.d.ts.map
CHANGED
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/db/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,wCAAwC;AACxC,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,WAAW,GAAG,gBAAgB,CAAA;IAC9E,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAC/C;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;IACtB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAC/C;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
package/dist/db/types.js.map
CHANGED
|
@@ -1 +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
|
|
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\nimport { ProtocolSelection } from '../plan-definition-group'\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 * - protocol-alias - name of specific protocol configuration\n */\n readonly kind: 'canonical' | 'alias' | 'code' | 'code-name' | 'protocol-alias'\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 readonly protocolSelection?: ProtocolSelection\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 readonly protocolSelection?: ProtocolSelection\n}\n\n/** Query parameters for the search endpoint. */\nexport interface ServiceSearchQuery {\n readonly q: string\n readonly limit?: number\n}\n"]}
|
|
@@ -22,6 +22,7 @@ export interface ProtocolActionInfo {
|
|
|
22
22
|
}
|
|
23
23
|
/** Entry used to build a protocol-group PD action. */
|
|
24
24
|
export interface ProtocolGroupActionEntry {
|
|
25
|
+
readonly id: string;
|
|
25
26
|
readonly isDefault: boolean;
|
|
26
27
|
readonly label: string;
|
|
27
28
|
readonly question: string;
|
|
@@ -69,15 +70,23 @@ export declare function getDefaultProtocol(pd: PlanDefinition): ProtocolDefaultI
|
|
|
69
70
|
* @returns array of variant info objects
|
|
70
71
|
*/
|
|
71
72
|
export declare function getProtocolVariants(pd: PlanDefinition): ProtocolActionInfo[];
|
|
73
|
+
/**
|
|
74
|
+
* Extracts the HealthcareService reference linked to a protocol-group PD.
|
|
75
|
+
*
|
|
76
|
+
* @param pd - the PlanDefinition to inspect
|
|
77
|
+
* @returns the referenced HealthcareService, if present
|
|
78
|
+
*/
|
|
79
|
+
export declare function getProtocolGroupStudyReference(pd: PlanDefinition): string | undefined;
|
|
72
80
|
/**
|
|
73
81
|
* Builds a protocol-group PlanDefinition resource.
|
|
74
82
|
*
|
|
75
83
|
* @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
|
|
76
84
|
* @param entries - protocol action entries (at least one should have `isDefault: true`)
|
|
77
85
|
* @param existingId - optional ID to reuse when updating an existing group PD
|
|
86
|
+
* @param studyReference - optional HealthcareService reference stored on the group PD
|
|
78
87
|
* @returns the constructed protocol-group PlanDefinition
|
|
79
88
|
*/
|
|
80
|
-
export declare function buildProtocolGroup(title: string, entries: readonly ProtocolGroupActionEntry[], existingId?: string): PlanDefinition;
|
|
89
|
+
export declare function buildProtocolGroup(title: string, entries: readonly ProtocolGroupActionEntry[], existingId?: string, studyReference?: string): PlanDefinition;
|
|
81
90
|
/**
|
|
82
91
|
* A user's selection within a protocol-group PlanDefinition.
|
|
83
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;IAC5B,QAAQ,CAAC,eAAe,E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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,6 +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
8
|
exports.buildProtocolGroup = buildProtocolGroup;
|
|
8
9
|
exports.configureProtocolGroup = configureProtocolGroup;
|
|
9
10
|
exports.resolveProtocolSelection = resolveProtocolSelection;
|
|
@@ -61,6 +62,16 @@ function getDefaultProtocol(pd) {
|
|
|
61
62
|
function getProtocolVariants(pd) {
|
|
62
63
|
return getProtocolActions(pd).filter((a) => !a.isDefault);
|
|
63
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Extracts the HealthcareService reference linked to a protocol-group PD.
|
|
67
|
+
*
|
|
68
|
+
* @param pd - the PlanDefinition to inspect
|
|
69
|
+
* @returns the referenced HealthcareService, if present
|
|
70
|
+
*/
|
|
71
|
+
function getProtocolGroupStudyReference(pd) {
|
|
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;
|
|
74
|
+
}
|
|
64
75
|
// ─── Construction ────────────────────────────────────────────────────────────
|
|
65
76
|
/**
|
|
66
77
|
* Builds a protocol-group PlanDefinition resource.
|
|
@@ -68,13 +79,14 @@ function getProtocolVariants(pd) {
|
|
|
68
79
|
* @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
|
|
69
80
|
* @param entries - protocol action entries (at least one should have `isDefault: true`)
|
|
70
81
|
* @param existingId - optional ID to reuse when updating an existing group PD
|
|
82
|
+
* @param studyReference - optional HealthcareService reference stored on the group PD
|
|
71
83
|
* @returns the constructed protocol-group PlanDefinition
|
|
72
84
|
*/
|
|
73
|
-
function buildProtocolGroup(title, entries, existingId) {
|
|
85
|
+
function buildProtocolGroup(title, entries, existingId, studyReference) {
|
|
74
86
|
const actions = entries.map((e) => {
|
|
75
87
|
var _a;
|
|
76
|
-
const subActions = ((_a = e.addons) !== null && _a !== void 0 ? _a : []).map((addon) => buildAction(
|
|
77
|
-
const action = buildAction(e.isDefault ? 'default' :
|
|
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));
|
|
89
|
+
const action = buildAction(e.isDefault ? 'default' : e.id, e.display, e.ref, e.code, e.duration, e.question, e.label);
|
|
78
90
|
// Top-level actions use exactly-one selection behavior
|
|
79
91
|
action.selectionBehavior = 'exactly-one';
|
|
80
92
|
if (subActions.length > 0) {
|
|
@@ -93,6 +105,14 @@ function buildProtocolGroup(title, entries, existingId) {
|
|
|
93
105
|
},
|
|
94
106
|
action: actions
|
|
95
107
|
};
|
|
108
|
+
if (studyReference) {
|
|
109
|
+
pd.extension = [
|
|
110
|
+
{
|
|
111
|
+
url: constants_1.PD_STUDY_EXTENSION_URL,
|
|
112
|
+
valueReference: { reference: studyReference }
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
}
|
|
96
116
|
if (existingId) {
|
|
97
117
|
pd.id = existingId;
|
|
98
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-definition-group.js","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":";;AA6DA,0CAIC;AAUD,gDAMC;AAQD,gDASC;AAQD,kDAEC;AAYD,gDAuDC;AAoDD,wDA4BC;AAWD,4DA6BC;AAaD,sDAiBC;AApUD,2CAAyF;AAoDzF,gFAAgF;AAEhF;;;;;GAKG;AACH,SAAgB,eAAe,CAAE,EAAkB;;IACjD,OAAO,CAAC,MAAA,MAAA,EAAE,CAAC,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,IAAI,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,0BAAc,IAAI,CAAC,CAAC,IAAI,KAAK,kCAAsB,CACxE,CAAA;AACH,CAAC;AAED,gFAAgF;AAEhF;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAE,EAAkB;;IACpD,OAAO,CAAC,MAAA,EAAE,CAAC,MAAM,mCAAI,EAAE,CAAC;SACrB,MAAM,CAAC,CAAC,CAAC,EAA+D,EAAE,CACzE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAC/B;SACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAA;AACzD,CAAC;AAED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EAAE,+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_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 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// ─── 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 * @returns the constructed protocol-group PlanDefinition\n */\nexport function buildProtocolGroup (\n title: string,\n entries: readonly ProtocolGroupActionEntry[],\n existingId?: string\n): PlanDefinition {\n const actions: PlanDefinitionAction[] = entries.map((e) => {\n const subActions = (e.addons ?? []).map((addon) =>\n buildAction(\n crypto.randomUUID(),\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' : crypto.randomUUID(),\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 (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,wEAEC;AAaD,gDAiEC;AAoDD,wDA4BC;AAWD,4DA6BC;AAaD,sDAiBC;AA1VD,2CAAiH;AAqDjH,gFAAgF;AAEhF;;;;;GAKG;AACH,SAAgB,eAAe,CAAE,EAAkB;;IACjD,OAAO,CAAC,MAAA,MAAA,EAAE,CAAC,IAAI,0CAAE,MAAM,mCAAI,EAAE,CAAC,CAAC,IAAI,CACjC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,0BAAc,IAAI,CAAC,CAAC,IAAI,KAAK,kCAAsB,CACxE,CAAA;AACH,CAAC;AAED,gFAAgF;AAEhF;;;;;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CAAI,EAAE;QACpB,SAAS;QACT,KAAK,EAAE,MAAA,MAAA,CAAC,CAAC,cAAc,mCAAI,CAAC,CAAC,KAAK,mCAAI,EAAE;QACxC,QAAQ,EAAE,MAAA,CAAC,CAAC,WAAW,mCAAI,EAAE;QAC7B,WAAW,EAAE,CAAC,CAAC,mBAAmB;QAClC,eAAe,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,EAAE;QAC9B,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC;QACrC,QAAQ,EAAE,CAAC,CAAC,cAAc;QAC1B,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC9C,MAAM,EAAE,UAAU;KACnB,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAClB,EAAU,EACV,KAAa,EACb,GAAW,EACX,IAAY,EACZ,QAAmB,EACnB,QAAiB,EACjB,aAAsB;IAEtB,MAAM,MAAM,GAAyB;QACnC,EAAE;QACF,KAAK;QACL,mBAAmB,EAAE,GAAG;KACzB,CAAA;IACD,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,+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,5 +1,6 @@
|
|
|
1
1
|
import type { HealthcareService } from '@medplum/fhirtypes';
|
|
2
2
|
import type { AliasRow } from '../db/types';
|
|
3
|
+
import { ProtocolSelection } from '../plan-definition-group';
|
|
3
4
|
/**
|
|
4
5
|
* FHIR identifier system used by the search index to store and extract service codes.
|
|
5
6
|
*
|
|
@@ -14,6 +15,13 @@ export declare const SEARCH_SERVICE_CODES_SYSTEM = "http://fuego.health/fhir/ser
|
|
|
14
15
|
* @returns Non-empty extension alias strings.
|
|
15
16
|
*/
|
|
16
17
|
export declare function extractSearchAliases(hs: HealthcareService): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Extract custom search aliases from the HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL extension.
|
|
20
|
+
* Returns an empty array when none are present.
|
|
21
|
+
* @param hs - HealthcareService resource to read.
|
|
22
|
+
* @returns Non-empty extension alias strings.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractSearchProtocolAliases(hs: HealthcareService): [string, ProtocolSelection][];
|
|
17
25
|
/**
|
|
18
26
|
* Build all alias rows for a single HealthcareService resource.
|
|
19
27
|
* @param hs - Source HealthcareService resource.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias-builder.d.ts","sourceRoot":"","sources":["../../src/search/alias-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"alias-builder.d.ts","sourceRoot":"","sources":["../../src/search/alias-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,2CAA2C,CAAA;AA0BnF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAE,EAAE,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAOrE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAE,EAAE,EAAE,iBAAiB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAAE,CAclG;AAkCD;;;;GAIG;AACH,wBAAgB,YAAY,CAAE,EAAE,EAAE,iBAAiB,GAAG,QAAQ,EAAE,CA0E/D"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SEARCH_SERVICE_CODES_SYSTEM = void 0;
|
|
4
4
|
exports.extractSearchAliases = extractSearchAliases;
|
|
5
|
+
exports.extractSearchProtocolAliases = extractSearchProtocolAliases;
|
|
5
6
|
exports.buildAliases = buildAliases;
|
|
6
7
|
const constants_1 = require("../constants");
|
|
7
8
|
const normalizer_1 = require("./normalizer");
|
|
@@ -45,6 +46,33 @@ function extractSearchAliases(hs) {
|
|
|
45
46
|
var _a, _b, _c, _d;
|
|
46
47
|
return ((_d = (_c = (_b = (_a = hs.extension) === null || _a === void 0 ? void 0 : _a.filter((e) => e.url === constants_1.HS_SEARCH_ALIASES_EXTENSION_URL)) === null || _b === void 0 ? void 0 : _b.map((e) => { var _a; return (_a = e.valueString) !== null && _a !== void 0 ? _a : ''; })) === null || _c === void 0 ? void 0 : _c.filter(Boolean)) !== null && _d !== void 0 ? _d : []);
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Extract custom search aliases from the HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL extension.
|
|
51
|
+
* Returns an empty array when none are present.
|
|
52
|
+
* @param hs - HealthcareService resource to read.
|
|
53
|
+
* @returns Non-empty extension alias strings.
|
|
54
|
+
*/
|
|
55
|
+
function extractSearchProtocolAliases(hs) {
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
return ((_c = (_b = (_a = hs.extension) === null || _a === void 0 ? void 0 : _a.filter((e) => e.url === constants_1.HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL && e.extension !== undefined)) === null || _b === void 0 ? void 0 : _b.map((e) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
return [
|
|
60
|
+
getExtensionStringValue(e.extension, 'alias'),
|
|
61
|
+
{
|
|
62
|
+
actionId: getExtensionStringValue(e.extension, 'protocol'),
|
|
63
|
+
addonIds: (_b = (_a = e.extension) === null || _a === void 0 ? void 0 : _a.filter((a) => a.url === 'addon' && a.valueString !== undefined).map((a) => a.valueString)) !== null && _b !== void 0 ? _b : []
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
})) !== null && _c !== void 0 ? _c : []);
|
|
67
|
+
}
|
|
68
|
+
function getExtensionStringValue(extension, url) {
|
|
69
|
+
var _a;
|
|
70
|
+
const result = (_a = extension === null || extension === void 0 ? void 0 : extension.find((e) => e.url === url)) === null || _a === void 0 ? void 0 : _a.valueString;
|
|
71
|
+
if (result === undefined) {
|
|
72
|
+
throw new Error(`No string value for extension url ${url}`);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
48
76
|
/**
|
|
49
77
|
* Deduplicate alias rows by normalizedAlias, keeping the one with the highest
|
|
50
78
|
* weight when multiple rows resolve to the same normalised form.
|
|
@@ -54,9 +82,13 @@ function extractSearchAliases(hs) {
|
|
|
54
82
|
function dedup(rows) {
|
|
55
83
|
const seen = new Map();
|
|
56
84
|
for (const row of rows) {
|
|
57
|
-
|
|
85
|
+
let key = row.normalizedAlias;
|
|
86
|
+
if (row.protocolSelection) {
|
|
87
|
+
key += `:${row.protocolSelection.actionId}:${row.protocolSelection.addonIds.slice().sort().join(',')}`;
|
|
88
|
+
}
|
|
89
|
+
const existing = seen.get(key);
|
|
58
90
|
if (!existing || row.weight > existing.weight) {
|
|
59
|
-
seen.set(
|
|
91
|
+
seen.set(key, row);
|
|
60
92
|
}
|
|
61
93
|
}
|
|
62
94
|
return Array.from(seen.values());
|
|
@@ -91,7 +123,19 @@ function buildAliases(hs) {
|
|
|
91
123
|
});
|
|
92
124
|
}
|
|
93
125
|
}
|
|
94
|
-
// 3.
|
|
126
|
+
// 3. Custom search aliases from HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL extension
|
|
127
|
+
for (const [alt, protocolSelection] of extractSearchProtocolAliases(hs)) {
|
|
128
|
+
if (alt !== name) {
|
|
129
|
+
rows.push({
|
|
130
|
+
alias: alt,
|
|
131
|
+
protocolSelection,
|
|
132
|
+
normalizedAlias: (0, normalizer_1.normalize)(alt),
|
|
133
|
+
kind: 'protocol-alias',
|
|
134
|
+
weight: 1.2
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// 4. Code + name combined phrase (helps "RX TORAX" style searches)
|
|
95
139
|
if (code && name) {
|
|
96
140
|
const combined = `${code} ${name}`;
|
|
97
141
|
rows.push({
|
|
@@ -101,7 +145,7 @@ function buildAliases(hs) {
|
|
|
101
145
|
weight: 1.0
|
|
102
146
|
});
|
|
103
147
|
}
|
|
104
|
-
//
|
|
148
|
+
// 5. Service code alone
|
|
105
149
|
if (code) {
|
|
106
150
|
rows.push({
|
|
107
151
|
alias: code,
|
|
@@ -110,7 +154,7 @@ function buildAliases(hs) {
|
|
|
110
154
|
weight: 0.9
|
|
111
155
|
});
|
|
112
156
|
}
|
|
113
|
-
//
|
|
157
|
+
// 6. Comment field – may contain informal / abbreviation labels
|
|
114
158
|
if (hs.comment) {
|
|
115
159
|
rows.push({
|
|
116
160
|
alias: hs.comment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias-builder.js","sourceRoot":"","sources":["../../src/search/alias-builder.ts"],"names":[],"mappings":";;;AA2CA,oDAOC;AAwBD,oCA6DC;AArID,4CAA8D;AAC9D,6CAAwC;AAExC;;;;;GAKG;AACU,QAAA,2BAA2B,GAAG,wCAAwC,CAAA;AAEnF;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,SAAS,WAAW,CAAE,EAAqB;;IACzC,OAAO,MAAA,MAAA,MAAA,EAAE,CAAC,UAAU,0CAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,mCAA2B,CAAC,0CAAE,KAAK,mCAAI,EAAE,CAAA;AAC5F,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAE,EAAqB;;IACzD,OAAO,CACL,MAAA,MAAA,MAAA,MAAA,EAAE,CAAC,SAAS,0CACR,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,2CAA+B,CAAC,0CACxD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,WAAW,mCAAI,EAAE,CAAA,EAAA,CAAC,0CAC/B,MAAM,CAAC,OAAO,CAAC,mCAAI,EAAE,CAC1B,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,KAAK,CAAE,IAAgB;IAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAA;IACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM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C;YACR,KAAK,EAAE,QAAQ;YACf,eAAe,EAAE,IAAA,sBAAS,EAAC,QAAQ,CAAC;YACpC,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,wBAAwB;IACxB,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,CAAC,IAAI,CAAC;YACR,KAAK,EAAE,IAAI;YACX,eAAe,EAAE,IAAA,sBAAS,EAAC,IAAI,CAAC;YAChC,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,gEAAgE;IAChE,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC;YACR,KAAK,EAAE,EAAE,CAAC,OAAO;YACjB,eAAe,EAAE,IAAA,sBAAS,EAAC,EAAE,CAAC,OAAO,CAAC;YACtC,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,wEAAwE;IACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACjE,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAA;AACxB,CAAC","sourcesContent":["import type { HealthcareService } from '@medplum/fhirtypes'\nimport type { AliasRow } from '../db/types'\nimport { HS_SEARCH_ALIASES_EXTENSION_URL } from '../constants'\nimport { normalize } from './normalizer'\n\n/**\n * FHIR identifier system used by the search index to store and extract service codes.\n *\n * Note: this value may differ from SERVICE_CODES_SYSTEM in constants.ts which is\n * used by the admin UI. Use this constant whenever interacting with the search index.\n */\nexport const SEARCH_SERVICE_CODES_SYSTEM = 'http://fuego.health/fhir/service-codes'\n\n/**\n * Build the list of alias rows to index for a given HealthcareService resource.\n *\n * Each alias carries a `weight` that scales the trigram similarity score\n * during ranking, giving more prominent results for exact name matches\n * vs. code matches vs. abbreviation matches.\n *\n * Weight scale:\n * 1.5 – canonical name (primary display)\n * 1.2 – HS_SEARCH_ALIASES_EXTENSION_URL extension entries (alternative labels)\n * 1.0 – code + name combined phrase (searchable compound)\n * 0.9 – service code identifier alone\n * 0.7 – payer-specific / free-text comment aliases (hs.comment)\n */\n\n/**\n * Extract the service code from the SEARCH_SERVICE_CODES_SYSTEM identifier.\n * @param hs - HealthcareService resource to read.\n * @returns Service code value or an empty string when missing.\n */\nfunction extractCode (hs: HealthcareService): string {\n return hs.identifier?.find((id) => id.system === SEARCH_SERVICE_CODES_SYSTEM)?.value ?? ''\n}\n\n/**\n * Extract custom search aliases from the HS_SEARCH_ALIASES_EXTENSION_URL extension.\n * Returns an empty array when none are present.\n * @param hs - HealthcareService resource to read.\n * @returns Non-empty extension alias strings.\n */\nexport function extractSearchAliases (hs: HealthcareService): string[] {\n return (\n hs.extension\n ?.filter((e) => e.url === HS_SEARCH_ALIASES_EXTENSION_URL)\n ?.map((e) => e.valueString ?? '')\n ?.filter(Boolean) ?? []\n )\n}\n\n/**\n * Deduplicate alias rows by normalizedAlias, keeping the one with the highest\n * weight when multiple rows resolve to the same normalised form.\n * @param rows - Candidate alias rows before deduplication.\n * @returns Rows deduplicated by `normalizedAlias` with highest weight kept.\n */\nfunction dedup (rows: AliasRow[]): AliasRow[] {\n const seen = new Map<string, AliasRow>()\n for (const row of rows) {\n const existing = seen.get(row.normalizedAlias)\n if (!existing || row.weight > existing.weight) {\n seen.set(row.normalizedAlias, row)\n }\n }\n return Array.from(seen.values())\n}\n\n/**\n * Build all alias rows for a single HealthcareService resource.\n * @param hs - Source HealthcareService resource.\n * @returns Alias rows ready to persist in the search index.\n */\nexport function buildAliases (hs: HealthcareService): AliasRow[] {\n const name = hs.name ?? ''\n const code = extractCode(hs)\n const rows: AliasRow[] = []\n\n // 1. Canonical name (highest weight)\n if (name) {\n rows.push({\n alias: name,\n normalizedAlias: normalize(name),\n kind: 'canonical',\n weight: 1.5\n })\n }\n\n // 2. Custom search aliases from HS_SEARCH_ALIASES_EXTENSION_URL extension\n for (const alt of extractSearchAliases(hs)) {\n if (alt !== name) {\n rows.push({\n alias: alt,\n normalizedAlias: normalize(alt),\n kind: 'alias',\n weight: 1.2\n })\n }\n }\n\n // 3. Code + name combined phrase (helps \"RX TORAX\" style searches)\n if (code && name) {\n const combined = `${code} ${name}`\n rows.push({\n alias: combined,\n normalizedAlias: normalize(combined),\n kind: 'code-name',\n weight: 1.0\n })\n }\n\n // 4. Service code alone\n if (code) {\n rows.push({\n alias: code,\n normalizedAlias: normalize(code),\n kind: 'code',\n weight: 0.9\n })\n }\n\n // 5. Comment field – may contain informal / abbreviation labels\n if (hs.comment) {\n rows.push({\n alias: hs.comment,\n normalizedAlias: normalize(hs.comment),\n kind: 'alias',\n weight: 0.7\n })\n }\n\n // Remove empty normalised aliases (e.g. a code that is all punctuation)\n const nonEmpty = rows.filter((r) => r.normalizedAlias.length > 0)\n return dedup(nonEmpty)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"alias-builder.js","sourceRoot":"","sources":["../../src/search/alias-builder.ts"],"names":[],"mappings":";;;AA4CA,oDAOC;AAQD,oEAcC;AAuCD,oCA0EC;AAxLD,4CAAwG;AACxG,6CAAwC;AAGxC;;;;;GAKG;AACU,QAAA,2BAA2B,GAAG,wCAAwC,CAAA;AAEnF;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,SAAS,WAAW,CAAE,EAAqB;;IACzC,OAAO,MAAA,MAAA,MAAA,EAAE,CAAC,UAAU,0CAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,KAAK,mCAA2B,CAAC,0CAAE,KAAK,mCAAI,EAAE,CAAA;AAC5F,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAE,EAAqB;;IACzD,OAAO,CACL,MAAA,MAAA,MAAA,MAAA,EAAE,CAAC,SAAS,0CACR,MAAM,CAAC,CAAC,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SACZ,CAAC,CAAA;IACJ,CAAC;IAED,gEAAgE;IAChE,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC;YACR,KAAK,EAAE,EAAE,CAAC,OAAO;YACjB,eAAe,EAAE,IAAA,sBAAS,EAAC,EAAE,CAAC,OAAO,CAAC;YACtC,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,wEAAwE;IACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACjE,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAA;AACxB,CAAC","sourcesContent":["import type { Extension, HealthcareService } from '@medplum/fhirtypes'\nimport type { AliasRow } from '../db/types'\nimport { HS_SEARCH_ALIASES_EXTENSION_URL, HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL } from '../constants'\nimport { normalize } from './normalizer'\nimport { ProtocolSelection } from '../plan-definition-group'\n\n/**\n * FHIR identifier system used by the search index to store and extract service codes.\n *\n * Note: this value may differ from SERVICE_CODES_SYSTEM in constants.ts which is\n * used by the admin UI. Use this constant whenever interacting with the search index.\n */\nexport const SEARCH_SERVICE_CODES_SYSTEM = 'http://fuego.health/fhir/service-codes'\n\n/**\n * Build the list of alias rows to index for a given HealthcareService resource.\n *\n * Each alias carries a `weight` that scales the trigram similarity score\n * during ranking, giving more prominent results for exact name matches\n * vs. code matches vs. abbreviation matches.\n *\n * Weight scale:\n * 1.5 – canonical name (primary display)\n * 1.2 – HS_SEARCH_ALIASES_EXTENSION_URL extension entries (alternative labels)\n * 1.0 – code + name combined phrase (searchable compound)\n * 0.9 – service code identifier alone\n * 0.7 – payer-specific / free-text comment aliases (hs.comment)\n */\n\n/**\n * Extract the service code from the SEARCH_SERVICE_CODES_SYSTEM identifier.\n * @param hs - HealthcareService resource to read.\n * @returns Service code value or an empty string when missing.\n */\nfunction extractCode (hs: HealthcareService): string {\n return hs.identifier?.find((id) => id.system === SEARCH_SERVICE_CODES_SYSTEM)?.value ?? ''\n}\n\n/**\n * Extract custom search aliases from the HS_SEARCH_ALIASES_EXTENSION_URL extension.\n * Returns an empty array when none are present.\n * @param hs - HealthcareService resource to read.\n * @returns Non-empty extension alias strings.\n */\nexport function extractSearchAliases (hs: HealthcareService): string[] {\n return (\n hs.extension\n ?.filter((e) => e.url === HS_SEARCH_ALIASES_EXTENSION_URL)\n ?.map((e) => e.valueString ?? '')\n ?.filter(Boolean) ?? []\n )\n}\n\n/**\n * Extract custom search aliases from the HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL extension.\n * Returns an empty array when none are present.\n * @param hs - HealthcareService resource to read.\n * @returns Non-empty extension alias strings.\n */\nexport function extractSearchProtocolAliases (hs: HealthcareService): [string, ProtocolSelection][] {\n return (\n hs.extension\n ?.filter((e) => e.url === HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL && e.extension !== undefined)\n ?.map((e) => [\n getExtensionStringValue(e.extension, 'alias'),\n {\n actionId: getExtensionStringValue(e.extension, 'protocol'),\n addonIds: e.extension\n ?.filter((a): a is Extension & { valueString: string } => a.url === 'addon' && a.valueString !== undefined)\n .map((a) => a.valueString) ?? []\n }\n ]) ?? []\n )\n}\n\nfunction getExtensionStringValue (extension: Extension[] | undefined, url: string): string {\n const result = extension?.find((e) => e.url === url)?.valueString\n\n if (result === undefined) {\n throw new Error(`No string value for extension url ${url}`)\n }\n\n return result\n}\n\n/**\n * Deduplicate alias rows by normalizedAlias, keeping the one with the highest\n * weight when multiple rows resolve to the same normalised form.\n * @param rows - Candidate alias rows before deduplication.\n * @returns Rows deduplicated by `normalizedAlias` with highest weight kept.\n */\nfunction dedup (rows: AliasRow[]): AliasRow[] {\n const seen = new Map<string, AliasRow>()\n for (const row of rows) {\n let key = row.normalizedAlias\n if (row.protocolSelection) {\n key += `:${row.protocolSelection.actionId}:${row.protocolSelection.addonIds.slice().sort().join(',')}`\n }\n\n const existing = seen.get(key)\n if (!existing || row.weight > existing.weight) {\n seen.set(key, row)\n }\n }\n return Array.from(seen.values())\n}\n\n/**\n * Build all alias rows for a single HealthcareService resource.\n * @param hs - Source HealthcareService resource.\n * @returns Alias rows ready to persist in the search index.\n */\nexport function buildAliases (hs: HealthcareService): AliasRow[] {\n const name = hs.name ?? ''\n const code = extractCode(hs)\n const rows: AliasRow[] = []\n\n // 1. Canonical name (highest weight)\n if (name) {\n rows.push({\n alias: name,\n normalizedAlias: normalize(name),\n kind: 'canonical',\n weight: 1.5\n })\n }\n\n // 2. Custom search aliases from HS_SEARCH_ALIASES_EXTENSION_URL extension\n for (const alt of extractSearchAliases(hs)) {\n if (alt !== name) {\n rows.push({\n alias: alt,\n normalizedAlias: normalize(alt),\n kind: 'alias',\n weight: 1.2\n })\n }\n }\n\n // 3. Custom search aliases from HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL extension\n for (const [alt, protocolSelection] of extractSearchProtocolAliases(hs)) {\n if (alt !== name) {\n rows.push({\n alias: alt,\n protocolSelection,\n normalizedAlias: normalize(alt),\n kind: 'protocol-alias',\n weight: 1.2\n })\n }\n }\n\n // 4. Code + name combined phrase (helps \"RX TORAX\" style searches)\n if (code && name) {\n const combined = `${code} ${name}`\n rows.push({\n alias: combined,\n normalizedAlias: normalize(combined),\n kind: 'code-name',\n weight: 1.0\n })\n }\n\n // 5. Service code alone\n if (code) {\n rows.push({\n alias: code,\n normalizedAlias: normalize(code),\n kind: 'code',\n weight: 0.9\n })\n }\n\n // 6. Comment field – may contain informal / abbreviation labels\n if (hs.comment) {\n rows.push({\n alias: hs.comment,\n normalizedAlias: normalize(hs.comment),\n kind: 'alias',\n weight: 0.7\n })\n }\n\n // Remove empty normalised aliases (e.g. a code that is all punctuation)\n const nonEmpty = rows.filter((r) => r.normalizedAlias.length > 0)\n return dedup(nonEmpty)\n}\n"]}
|