@fuego-systems/core 0.1.4 → 0.1.5
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 +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plan-definition-group.d.ts +75 -0
- package/dist/plan-definition-group.d.ts.map +1 -0
- package/dist/plan-definition-group.js +143 -0
- package/dist/plan-definition-group.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export declare const HL7_IMPORT_TASK_SYSTEM = "http://example.org/CodeSystem/hl7
|
|
|
18
18
|
export declare const HL7_IMPORT_APPOINTMENT_TASK_CODE = "import-orm-o01-appointment";
|
|
19
19
|
export declare const HL7_IMPORT_TASK_INPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-inputs";
|
|
20
20
|
export declare const HL7_IMPORT_TASK_OUTPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-outputs";
|
|
21
|
+
/** Coding system for custom PlanDefinition types */
|
|
22
|
+
export declare const PD_TYPE_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/plan-definition-type";
|
|
23
|
+
/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */
|
|
24
|
+
export declare const PD_TYPE_PROTOCOL_GROUP = "protocol-group";
|
|
21
25
|
/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */
|
|
22
26
|
export declare const SERVICE_CODES_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/service-codes";
|
|
23
27
|
/** Coding system for service categories on HealthcareService.category */
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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ACH,eAAO,MAAM,0BAA0B,6DAA6D,CAAA;AACpG,eAAO,MAAM,wBAAwB,SAAS,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = exports.BILLING_CODES_ORG_EXTENSION = exports.BILLING_CODES_TAG_CODE = exports.BILLING_CODES_TAG_SYSTEM = exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = exports.ORG_TYPE_PROV_CODE = exports.ORG_TYPE_PAY_CODE = exports.ORG_TYPE_SYSTEM = exports.INSURER_IDENTIFIER_SYSTEM = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = exports.HL7_IMPORT_TASK_INPUT_SYSTEM = exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = exports.HL7_IMPORT_TASK_SYSTEM = exports.MIGRATE_APPOINTMENT_TASK_CODE = exports.MIGRATE_SERVICE_TASK_CODE = exports.MIGRATE_SITE_TASK_CODE = exports.MIGRATE_DEVICE_TASK_CODE = exports.MIGRATE_PATIENT_TASK_CODE = exports.MIGRATE_PRACTITIONER_TASK_CODE = exports.MIGRATE_TASK_OUTPUT_SYSTEM = exports.MIGRATE_TASK_INPUT_SYSTEM = exports.MIGRATE_TASK_SYSTEM = exports.PRACTITIONER_ROLE_REFERRING_CODE = exports.PRACTITIONER_ROLE_SYSTEM = exports.SERVICE_TYPE_SYSTEM = exports.REQUIRES_PRACTITIONER_EXTENSION_URL = exports.SCHEDULING_PARAMETERS_EXTENSION_URL = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
|
|
3
|
+
exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = exports.BILLING_CODES_ORG_EXTENSION = exports.BILLING_CODES_TAG_CODE = exports.BILLING_CODES_TAG_SYSTEM = exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = exports.ORG_TYPE_PROV_CODE = exports.ORG_TYPE_PAY_CODE = exports.ORG_TYPE_SYSTEM = exports.INSURER_IDENTIFIER_SYSTEM = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.PD_TYPE_PROTOCOL_GROUP = exports.PD_TYPE_SYSTEM = exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = exports.HL7_IMPORT_TASK_INPUT_SYSTEM = exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = exports.HL7_IMPORT_TASK_SYSTEM = exports.MIGRATE_APPOINTMENT_TASK_CODE = exports.MIGRATE_SERVICE_TASK_CODE = exports.MIGRATE_SITE_TASK_CODE = exports.MIGRATE_DEVICE_TASK_CODE = exports.MIGRATE_PATIENT_TASK_CODE = exports.MIGRATE_PRACTITIONER_TASK_CODE = exports.MIGRATE_TASK_OUTPUT_SYSTEM = exports.MIGRATE_TASK_INPUT_SYSTEM = exports.MIGRATE_TASK_SYSTEM = exports.PRACTITIONER_ROLE_REFERRING_CODE = exports.PRACTITIONER_ROLE_SYSTEM = exports.SERVICE_TYPE_SYSTEM = exports.REQUIRES_PRACTITIONER_EXTENSION_URL = exports.SCHEDULING_PARAMETERS_EXTENSION_URL = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
|
|
4
4
|
exports.FHIR_BASE = 'https://www.cdrossi.com/fhir';
|
|
5
5
|
exports.EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges';
|
|
6
6
|
exports.SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters';
|
|
@@ -22,6 +22,11 @@ exports.HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks
|
|
|
22
22
|
exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment';
|
|
23
23
|
exports.HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs';
|
|
24
24
|
exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs';
|
|
25
|
+
// ─── PlanDefinition type ─────────────────────────────────────────────────────
|
|
26
|
+
/** Coding system for custom PlanDefinition types */
|
|
27
|
+
exports.PD_TYPE_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/plan-definition-type`;
|
|
28
|
+
/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */
|
|
29
|
+
exports.PD_TYPE_PROTOCOL_GROUP = 'protocol-group';
|
|
25
30
|
// ─── HealthcareService model ──────────────────────────────────────────────────
|
|
26
31
|
/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */
|
|
27
32
|
exports.SERVICE_CODES_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/service-codes`;
|
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,mCAAmC,GAAG,mEAAmE,CAAA;AACzG,QAAA,mCAAmC,GAAG,GAAG,iBAAS,wBAAwB,CAAA;AAC1E,QAAA,mBAAmB,GAAG,GAAG,iBAAS,eAAe,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,iFAAiF;AAEjF,6EAA6E;AAChE,QAAA,yBAAyB,GAAG,GAAG,iBAAS,sBAAsB,CAAA;AAE3E,wCAAwC;AAC3B,QAAA,eAAe,GAAG,yDAAyD,CAAA;AAExF,iDAAiD;AACpC,QAAA,iBAAiB,GAAG,KAAK,CAAA;AAEtC,uEAAuE;AAC1D,QAAA,kBAAkB,GAAG,MAAM,CAAA;AAExC,iFAAiF;AAEjF,6EAA6E;AAChE,QAAA,gCAAgC,GAAG,GAAG,iBAAS,6BAA6B,CAAA;AAEzF,gFAAgF;AAEhF;;;GAGG;AACU,QAAA,wBAAwB,GAAG,GAAG,iBAAS,OAAO,CAAA;AAE3D;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,eAAe,CAAA;AAErD;;;;;;;;GAQG;AACU,QAAA,2BAA2B,GAAG,GAAG,iBAAS,8CAA8C,CAAA;AAErG;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,GAAG,iBAAS,0BAA0B,CAAA;AAEtF;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,0DAA0D,CAAA;AACvF,QAAA,wBAAwB,GAAG,MAAM,CAAA","sourcesContent":["export const FHIR_BASE = 'https://www.cdrossi.com/fhir'\nexport const EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges'\n\nexport const SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters'\nexport const REQUIRES_PRACTITIONER_EXTENSION_URL = `${FHIR_BASE}/requires-practitioner`\nexport const SERVICE_TYPE_SYSTEM = `${FHIR_BASE}/service-type`\n\nexport const PRACTITIONER_ROLE_SYSTEM = `${FHIR_BASE}/CodeSystem/practitioner-role`\nexport const PRACTITIONER_ROLE_REFERRING_CODE = 'referring'\n\nconst MIGRATE_TASK_BASE = 'eges-migrate'\nexport const MIGRATE_TASK_SYSTEM = `${FHIR_BASE}/tasks`\nexport const MIGRATE_TASK_INPUT_SYSTEM = `${FHIR_BASE}/task-inputs`\nexport const MIGRATE_TASK_OUTPUT_SYSTEM = `${FHIR_BASE}/task-outputs`\nexport const MIGRATE_PRACTITIONER_TASK_CODE = `${MIGRATE_TASK_BASE}-practitioner`\nexport const MIGRATE_PATIENT_TASK_CODE = `${MIGRATE_TASK_BASE}-patient`\nexport const MIGRATE_DEVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-device`\nexport const MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`\nexport const MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`\nexport const MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`\n\nexport const HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks'\nexport const HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment'\nexport const HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs'\nexport const HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs'\n\n// ─── HealthcareService model ──────────────────────────────────────────────────\n\n/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */\nexport const SERVICE_CODES_SYSTEM = `${FHIR_BASE}/CodeSystem/service-codes`\n\n/** Coding system for service categories on HealthcareService.category */\nexport const SERVICE_CATEGORY_SYSTEM = `${FHIR_BASE}/CodeSystem/service-category`\n\n/** Coding system for specialities on HealthcareService.specialty */\nexport const SPECIALITY_SYSTEM = `${FHIR_BASE}/CodeSystem/speciality`\n\n/** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */\nexport const HS_PROTOCOL_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-protocol`\n\n/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */\nexport const HS_BILLING_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-billing`\n\n/**\n * Extension URL for additional search aliases on HealthcareService.\n *\n * Stored as multiple same-URL extensions, each with a `valueString`.\n * These are indexed at weight 1.2 by the search indexer.\n * Using an extension instead of HealthcareService.alias[] because the local\n * FHIR profile does not permit the standard alias field.\n *\n * @example\n * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: \"placa de tórax\" }\n */\nexport const HS_SEARCH_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-aliases`\n\n// ─── Organization (payer / insurance company) ─────────────────────────────────\n\n/** Identifier system for insurance company (payer) Organization resources */\nexport const INSURER_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurers`\n\n/** HL7 organization-type code system */\nexport const ORG_TYPE_SYSTEM = 'http://terminology.hl7.org/CodeSystem/organization-type'\n\n/** organization-type code for payer/insurance */\nexport const ORG_TYPE_PAY_CODE = 'pay'\n\n/** organization-type code for healthcare provider (the main clinic) */\nexport const ORG_TYPE_PROV_CODE = 'prov'\n\n// ─── InsurancePlan ────────────────────────────────────────────────────────────\n\n/** Identifier system for InsurancePlan resources (specific plan products) */\nexport const INSURANCE_PLAN_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurance-plans`\n\n// ─── Billing CodeSystem discovery tag ────────────────────────────────────────\n\n/**\n * Tag system applied to every billing-codes CodeSystem resource,\n * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.\n */\nexport const BILLING_CODES_TAG_SYSTEM = `${FHIR_BASE}/tags`\n\n/**\n * Tag code that marks a CodeSystem as a billing codes system.\n * Every billing CodeSystem must carry:\n * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]\n */\nexport const BILLING_CODES_TAG_CODE = 'billing-codes'\n\n/**\n * Extension URL stored on a billing CodeSystem to record which billing\n * Organization (obra social) owns / uses this billing code system.\n *\n * Value type: Reference (Organization)\n *\n * Example:\n * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]\n */\nexport const BILLING_CODES_ORG_EXTENSION = `${FHIR_BASE}/extensions/billing-code-system-organization`\n\n/**\n * Identifier system used to tag every billing ChargeItemDefinition with the ID\n * of the PlanDefinition it belongs to, enabling reliable search via\n * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.\n * (The FHIR R4 `instance` search parameter is not supported by Medplum.)\n */\nexport const BILLING_CID_PD_IDENTIFIER_SYSTEM = `${FHIR_BASE}/billing/plan-definition`\n\n/**\n * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.\n * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM\n * useContext.code.code = BILLING_CID_CONTEXT_CODE\n * useContext.valueReference → InsurancePlan\n */\nexport const BILLING_CID_CONTEXT_SYSTEM = 'http://terminology.hl7.org/CodeSystem/usage-context-type'\nexport const BILLING_CID_CONTEXT_CODE = 'user'\n"]}
|
|
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,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,gCAAgC,GAAG,WAAW,CAAA;AAE3D,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC3B,QAAA,mBAAmB,GAAG,GAAG,iBAAS,QAAQ,CAAA;AAC1C,QAAA,yBAAyB,GAAG,GAAG,iBAAS,cAAc,CAAA;AACtD,QAAA,0BAA0B,GAAG,GAAG,iBAAS,eAAe,CAAA;AACxD,QAAA,8BAA8B,GAAG,GAAG,iBAAiB,eAAe,CAAA;AACpE,QAAA,yBAAyB,GAAG,GAAG,iBAAiB,UAAU,CAAA;AAC1D,QAAA,wBA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AA,gCAAgC,GAAG,GAAG,iBAAS,6BAA6B,CAAA;AAEzF,gFAAgF;AAEhF;;;GAGG;AACU,QAAA,wBAAwB,GAAG,GAAG,iBAAS,OAAO,CAAA;AAE3D;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,eAAe,CAAA;AAErD;;;;;;;;GAQG;AACU,QAAA,2BAA2B,GAAG,GAAG,iBAAS,8CAA8C,CAAA;AAErG;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,GAAG,iBAAS,0BAA0B,CAAA;AAEtF;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,0DAA0D,CAAA;AACvF,QAAA,wBAAwB,GAAG,MAAM,CAAA","sourcesContent":["export const FHIR_BASE = 'https://www.cdrossi.com/fhir'\nexport const EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges'\n\nexport const SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters'\nexport const REQUIRES_PRACTITIONER_EXTENSION_URL = `${FHIR_BASE}/requires-practitioner`\nexport const SERVICE_TYPE_SYSTEM = `${FHIR_BASE}/service-type`\n\nexport const PRACTITIONER_ROLE_SYSTEM = `${FHIR_BASE}/CodeSystem/practitioner-role`\nexport const PRACTITIONER_ROLE_REFERRING_CODE = 'referring'\n\nconst MIGRATE_TASK_BASE = 'eges-migrate'\nexport const MIGRATE_TASK_SYSTEM = `${FHIR_BASE}/tasks`\nexport const MIGRATE_TASK_INPUT_SYSTEM = `${FHIR_BASE}/task-inputs`\nexport const MIGRATE_TASK_OUTPUT_SYSTEM = `${FHIR_BASE}/task-outputs`\nexport const MIGRATE_PRACTITIONER_TASK_CODE = `${MIGRATE_TASK_BASE}-practitioner`\nexport const MIGRATE_PATIENT_TASK_CODE = `${MIGRATE_TASK_BASE}-patient`\nexport const MIGRATE_DEVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-device`\nexport const MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`\nexport const MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`\nexport const MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`\n\nexport const HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks'\nexport const HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment'\nexport const HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs'\nexport const HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs'\n\n// ─── 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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './scheduling/slot';
|
|
|
2
2
|
export * from './scheduling/appointment';
|
|
3
3
|
export type * from './scheduling/extension';
|
|
4
4
|
export * from './constants';
|
|
5
|
+
export * from './plan-definition-group';
|
|
5
6
|
export * from './fhir';
|
|
6
7
|
export type * from './db/types';
|
|
7
8
|
export * from './search/normalizer';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,mBAAmB,wBAAwB,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,0BAA0B,CAAA;AACxC,mBAAmB,wBAAwB,CAAA;AAC3C,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,QAAQ,CAAA;AACtB,mBAAmB,YAAY,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./scheduling/slot"), exports);
|
|
18
18
|
__exportStar(require("./scheduling/appointment"), exports);
|
|
19
19
|
__exportStar(require("./constants"), exports);
|
|
20
|
+
__exportStar(require("./plan-definition-group"), exports);
|
|
20
21
|
__exportStar(require("./fhir"), exports);
|
|
21
22
|
__exportStar(require("./search/normalizer"), exports);
|
|
22
23
|
__exportStar(require("./search/alias-builder"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AAExC,8CAA2B;AAC3B,yCAAsB;AAEtB,sDAAmC;AACnC,yDAAsC","sourcesContent":["export * from './scheduling/slot'\nexport * from './scheduling/appointment'\nexport type * from './scheduling/extension'\nexport * from './constants'\nexport * from './fhir'\nexport type * from './db/types'\nexport * from './search/normalizer'\nexport * from './search/alias-builder'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,2DAAwC;AAExC,8CAA2B;AAC3B,0DAAuC;AACvC,yCAAsB;AAEtB,sDAAmC;AACnC,yDAAsC","sourcesContent":["export * from './scheduling/slot'\nexport * from './scheduling/appointment'\nexport type * from './scheduling/extension'\nexport * from './constants'\nexport * from './plan-definition-group'\nexport * from './fhir'\nexport type * from './db/types'\nexport * from './search/normalizer'\nexport * from './search/alias-builder'\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Duration, PlanDefinition } from '@medplum/fhirtypes';
|
|
2
|
+
/** Information about a single action inside a protocol-group PD. */
|
|
3
|
+
export interface ProtocolActionInfo {
|
|
4
|
+
readonly actionId: string;
|
|
5
|
+
readonly isDefault: boolean;
|
|
6
|
+
/** Short label for the variant (e.g. "Helicoidal") */
|
|
7
|
+
readonly label: string;
|
|
8
|
+
/** User-facing question to select this variant */
|
|
9
|
+
readonly question: string;
|
|
10
|
+
readonly protocolRef: string;
|
|
11
|
+
readonly protocolDisplay: string;
|
|
12
|
+
readonly protocolCode: string;
|
|
13
|
+
readonly duration?: Duration;
|
|
14
|
+
/** Optional sub-actions (addons) with `any` selection behavior. */
|
|
15
|
+
readonly addons: readonly ProtocolActionInfo[];
|
|
16
|
+
}
|
|
17
|
+
/** Entry used to build a protocol-group PD action. */
|
|
18
|
+
export interface ProtocolGroupActionEntry {
|
|
19
|
+
readonly isDefault: boolean;
|
|
20
|
+
readonly label: string;
|
|
21
|
+
readonly question: string;
|
|
22
|
+
readonly ref: string;
|
|
23
|
+
readonly display: string;
|
|
24
|
+
readonly code: string;
|
|
25
|
+
readonly duration?: Duration;
|
|
26
|
+
/** Optional sub-action entries (addons). */
|
|
27
|
+
readonly addons?: readonly ProtocolGroupActionEntry[];
|
|
28
|
+
}
|
|
29
|
+
/** @deprecated Use {@link ProtocolActionInfo} instead. */
|
|
30
|
+
export type ProtocolVariantInfo = ProtocolActionInfo;
|
|
31
|
+
/** @deprecated Use {@link ProtocolActionInfo} instead. */
|
|
32
|
+
export interface ProtocolDefaultInfo {
|
|
33
|
+
readonly ref: string;
|
|
34
|
+
readonly display: string;
|
|
35
|
+
readonly code: string;
|
|
36
|
+
readonly duration?: Duration;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).
|
|
40
|
+
*
|
|
41
|
+
* @param pd - the PlanDefinition to check
|
|
42
|
+
* @returns whether the PlanDefinition is a protocol-group
|
|
43
|
+
*/
|
|
44
|
+
export declare function isProtocolGroup(pd: PlanDefinition): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Extracts all protocol actions from a protocol-group PD (preserving order).
|
|
47
|
+
*
|
|
48
|
+
* @param pd - the protocol-group PlanDefinition
|
|
49
|
+
* @returns array of action info objects (the one with `isDefault === true` is the default)
|
|
50
|
+
*/
|
|
51
|
+
export declare function getProtocolActions(pd: PlanDefinition): ProtocolActionInfo[];
|
|
52
|
+
/**
|
|
53
|
+
* Extracts the default protocol action from a protocol-group PD.
|
|
54
|
+
*
|
|
55
|
+
* @param pd - the protocol-group PlanDefinition
|
|
56
|
+
* @returns the default protocol info, or undefined if not found
|
|
57
|
+
*/
|
|
58
|
+
export declare function getDefaultProtocol(pd: PlanDefinition): ProtocolDefaultInfo | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Extracts the non-default variant actions from a protocol-group PD.
|
|
61
|
+
*
|
|
62
|
+
* @param pd - the protocol-group PlanDefinition
|
|
63
|
+
* @returns array of variant info objects
|
|
64
|
+
*/
|
|
65
|
+
export declare function getProtocolVariants(pd: PlanDefinition): ProtocolActionInfo[];
|
|
66
|
+
/**
|
|
67
|
+
* Builds a protocol-group PlanDefinition resource.
|
|
68
|
+
*
|
|
69
|
+
* @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
|
|
70
|
+
* @param entries - protocol action entries (at least one should have `isDefault: true`)
|
|
71
|
+
* @param existingId - optional ID to reuse when updating an existing group PD
|
|
72
|
+
* @returns the constructed protocol-group PlanDefinition
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildProtocolGroup(title: string, entries: readonly ProtocolGroupActionEntry[], existingId?: string): PlanDefinition;
|
|
75
|
+
//# sourceMappingURL=plan-definition-group.d.ts.map
|
|
@@ -0,0 +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,C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AAQ,CAAA;CAC7B;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAE,EAAE,EAAE,cAAc,GAAG,OAAO,CAI5D;AAID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAE,EAAE,EAAE,cAAc,GAAG,kBAAkB,EAAE,CAM5E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAE,EAAE,EAAE,cAAc,GAAG,mBAAmB,GAAG,SAAS,CASvF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAE,EAAE,EAAE,cAAc,GAAG,kBAAkB,EAAE,CAE7E;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,wBAAwB,EAAE,EAC5C,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAmDhB"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isProtocolGroup = isProtocolGroup;
|
|
4
|
+
exports.getProtocolActions = getProtocolActions;
|
|
5
|
+
exports.getDefaultProtocol = getDefaultProtocol;
|
|
6
|
+
exports.getProtocolVariants = getProtocolVariants;
|
|
7
|
+
exports.buildProtocolGroup = buildProtocolGroup;
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
// ─── Detection ───────────────────────────────────────────────────────────────
|
|
10
|
+
/**
|
|
11
|
+
* Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).
|
|
12
|
+
*
|
|
13
|
+
* @param pd - the PlanDefinition to check
|
|
14
|
+
* @returns whether the PlanDefinition is a protocol-group
|
|
15
|
+
*/
|
|
16
|
+
function isProtocolGroup(pd) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return ((_b = (_a = pd.type) === null || _a === void 0 ? void 0 : _a.coding) !== null && _b !== void 0 ? _b : []).some((c) => c.system === constants_1.PD_TYPE_SYSTEM && c.code === constants_1.PD_TYPE_PROTOCOL_GROUP);
|
|
19
|
+
}
|
|
20
|
+
// ─── Extraction ──────────────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Extracts all protocol actions from a protocol-group PD (preserving order).
|
|
23
|
+
*
|
|
24
|
+
* @param pd - the protocol-group PlanDefinition
|
|
25
|
+
* @returns array of action info objects (the one with `isDefault === true` is the default)
|
|
26
|
+
*/
|
|
27
|
+
function getProtocolActions(pd) {
|
|
28
|
+
var _a;
|
|
29
|
+
return ((_a = pd.action) !== null && _a !== void 0 ? _a : [])
|
|
30
|
+
.filter((a) => Boolean(a.definitionCanonical))
|
|
31
|
+
.map((a) => extractActionInfo(a, a.id === 'default'));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extracts the default protocol action from a protocol-group PD.
|
|
35
|
+
*
|
|
36
|
+
* @param pd - the protocol-group PlanDefinition
|
|
37
|
+
* @returns the default protocol info, or undefined if not found
|
|
38
|
+
*/
|
|
39
|
+
function getDefaultProtocol(pd) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const action = ((_a = pd.action) !== null && _a !== void 0 ? _a : []).find((a) => a.id === 'default');
|
|
42
|
+
if (!(action === null || action === void 0 ? void 0 : action.definitionCanonical)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
ref: action.definitionCanonical,
|
|
47
|
+
display: (_b = action.title) !== null && _b !== void 0 ? _b : '',
|
|
48
|
+
code: getActionServiceCode(action),
|
|
49
|
+
duration: action.timingDuration
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Extracts the non-default variant actions from a protocol-group PD.
|
|
54
|
+
*
|
|
55
|
+
* @param pd - the protocol-group PlanDefinition
|
|
56
|
+
* @returns array of variant info objects
|
|
57
|
+
*/
|
|
58
|
+
function getProtocolVariants(pd) {
|
|
59
|
+
return getProtocolActions(pd).filter((a) => !a.isDefault);
|
|
60
|
+
}
|
|
61
|
+
// ─── Construction ────────────────────────────────────────────────────────────
|
|
62
|
+
/**
|
|
63
|
+
* Builds a protocol-group PlanDefinition resource.
|
|
64
|
+
*
|
|
65
|
+
* @param title - human-readable title for the group (e.g. "TAC de hombro — Protocolos")
|
|
66
|
+
* @param entries - protocol action entries (at least one should have `isDefault: true`)
|
|
67
|
+
* @param existingId - optional ID to reuse when updating an existing group PD
|
|
68
|
+
* @returns the constructed protocol-group PlanDefinition
|
|
69
|
+
*/
|
|
70
|
+
function buildProtocolGroup(title, entries, existingId) {
|
|
71
|
+
const actions = entries.map((e) => {
|
|
72
|
+
var _a;
|
|
73
|
+
const subActions = ((_a = e.addons) !== null && _a !== void 0 ? _a : []).map((addon) => buildAction(crypto.randomUUID(), addon.display, addon.ref, addon.code, addon.duration, addon.question, addon.label));
|
|
74
|
+
const action = buildAction(e.isDefault ? 'default' : crypto.randomUUID(), e.display, e.ref, e.code, e.duration, e.question, e.label);
|
|
75
|
+
// Top-level actions use exactly-one selection behavior
|
|
76
|
+
action.selectionBehavior = 'exactly-one';
|
|
77
|
+
if (subActions.length > 0) {
|
|
78
|
+
action.action = subActions;
|
|
79
|
+
// When an action has sub-actions (addons), they use `any` grouping
|
|
80
|
+
action.groupingBehavior = 'logical-group';
|
|
81
|
+
}
|
|
82
|
+
return action;
|
|
83
|
+
});
|
|
84
|
+
const pd = {
|
|
85
|
+
resourceType: 'PlanDefinition',
|
|
86
|
+
status: 'active',
|
|
87
|
+
title,
|
|
88
|
+
type: {
|
|
89
|
+
coding: [{ system: constants_1.PD_TYPE_SYSTEM, code: constants_1.PD_TYPE_PROTOCOL_GROUP }]
|
|
90
|
+
},
|
|
91
|
+
action: actions
|
|
92
|
+
};
|
|
93
|
+
if (existingId) {
|
|
94
|
+
pd.id = existingId;
|
|
95
|
+
}
|
|
96
|
+
return pd;
|
|
97
|
+
}
|
|
98
|
+
// ─── Internal helpers ───────────────────────────────────────────────────────
|
|
99
|
+
function getActionServiceCode(action) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
const coding = ((_a = action.code) !== null && _a !== void 0 ? _a : [])
|
|
102
|
+
.flatMap((cc) => { var _a; return (_a = cc.coding) !== null && _a !== void 0 ? _a : []; })
|
|
103
|
+
.find((c) => c.system === constants_1.SERVICE_TYPE_SYSTEM);
|
|
104
|
+
return (_b = coding === null || coding === void 0 ? void 0 : coding.code) !== null && _b !== void 0 ? _b : '';
|
|
105
|
+
}
|
|
106
|
+
function extractActionInfo(a, isDefault) {
|
|
107
|
+
var _a, _b, _c, _d, _e, _f;
|
|
108
|
+
const subActions = ((_a = a.action) !== null && _a !== void 0 ? _a : [])
|
|
109
|
+
.filter((sub) => Boolean(sub.definitionCanonical))
|
|
110
|
+
.map((sub) => extractActionInfo(sub, false));
|
|
111
|
+
return {
|
|
112
|
+
actionId: (_b = a.id) !== null && _b !== void 0 ? _b : '',
|
|
113
|
+
isDefault,
|
|
114
|
+
label: (_d = (_c = a.textEquivalent) !== null && _c !== void 0 ? _c : a.title) !== null && _d !== void 0 ? _d : '',
|
|
115
|
+
question: (_e = a.description) !== null && _e !== void 0 ? _e : '',
|
|
116
|
+
protocolRef: a.definitionCanonical,
|
|
117
|
+
protocolDisplay: (_f = a.title) !== null && _f !== void 0 ? _f : '',
|
|
118
|
+
protocolCode: getActionServiceCode(a),
|
|
119
|
+
duration: a.timingDuration,
|
|
120
|
+
addons: subActions
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function buildAction(id, title, ref, code, duration, question, labelOverride) {
|
|
124
|
+
const action = {
|
|
125
|
+
id,
|
|
126
|
+
title,
|
|
127
|
+
definitionCanonical: ref
|
|
128
|
+
};
|
|
129
|
+
if (code) {
|
|
130
|
+
action.code = [{ coding: [{ system: constants_1.SERVICE_TYPE_SYSTEM, code }] }];
|
|
131
|
+
}
|
|
132
|
+
if (duration) {
|
|
133
|
+
action.timingDuration = duration;
|
|
134
|
+
}
|
|
135
|
+
if (question) {
|
|
136
|
+
action.description = question;
|
|
137
|
+
}
|
|
138
|
+
if (labelOverride) {
|
|
139
|
+
action.textEquivalent = labelOverride;
|
|
140
|
+
}
|
|
141
|
+
return action;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=plan-definition-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-definition-group.js","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":";;AAuDA,0CAIC;AAUD,gDAMC;AAQD,gDASC;AAQD,kDAEC;AAYD,gDAuDC;AAxKD,2CAAyF;AA8CzF,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;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAE,EAAkB;;IACpD,MAAM,MAAM,GAAG,CAAC,MAAA,EAAE,CAAC,MAAM,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAA;IAChE,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM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{ 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 /** 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// ─── 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 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 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"]}
|