@fuego-systems/core 0.1.11 → 0.1.14
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 +63 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +66 -2
- package/dist/constants.js.map +1 -1
- package/dist/plan-definition-group.d.ts +17 -3
- package/dist/plan-definition-group.d.ts.map +1 -1
- package/dist/plan-definition-group.js +38 -13
- package/dist/plan-definition-group.js.map +1 -1
- package/dist/search/normalizer.d.ts.map +1 -1
- package/dist/search/normalizer.js +5 -1
- package/dist/search/normalizer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare const EGES_EQUIPO_SYSTEM = "https://www.cdrossi.com/eges/equipo";
|
|
|
9
9
|
export declare const EGES_TURNO_SYSTEM = "https://www.cdrossi.com/eges/turno";
|
|
10
10
|
export declare const EGES_PRACTICA_SYSTEM = "https://www.cdrossi.com/eges/practica";
|
|
11
11
|
export declare const EGES_PRESTACION_SYSTEM = "https://www.cdrossi.com/eges/prestacion";
|
|
12
|
+
export declare const EGES_CONDICION_RESPUESTA_SYSTEM = "https://www.cdrossi.com/eges/condicion-respuesta";
|
|
12
13
|
export declare const RENAPER_BASE = "https://www.argentina.gob.ar/interior/renaper";
|
|
13
14
|
export declare const MATRICULA_NACIONAL_SYSTEM = "https://www.argentina.gob.ar/interior/renaper/matricula-nacional";
|
|
14
15
|
export declare const MATRICULA_PROVINCIAL_SYSTEM = "https://www.argentina.gob.ar/interior/renaper/matricula-provincial";
|
|
@@ -27,6 +28,53 @@ export declare const MIGRATE_SITE_TASK_CODE = "eges-migrate-site";
|
|
|
27
28
|
export declare const MIGRATE_SERVICE_TASK_CODE = "eges-migrate-service";
|
|
28
29
|
export declare const MIGRATE_APPOINTMENT_TASK_CODE = "eges-migrate-appointment";
|
|
29
30
|
export declare const REVIEW_APPOINTMENT_TASK_CODE = "review-appointment";
|
|
31
|
+
export declare const SYNCHRONIZE_APPOINTMENT_TASK_CODE = "synchronize-appointment";
|
|
32
|
+
/**
|
|
33
|
+
* Coding system for `Task.businessStatus` values used by the Rossi admin
|
|
34
|
+
* review workflow. Distinct from `Task.status` (FHIR lifecycle), which is
|
|
35
|
+
* driven by the booking pipeline. `businessStatus` captures staff-side
|
|
36
|
+
* review state that is independent of whether the appointment has been
|
|
37
|
+
* confirmed in EGES.
|
|
38
|
+
*/
|
|
39
|
+
export declare const TASK_BUSINESS_STATUS_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/task-business-status";
|
|
40
|
+
/**
|
|
41
|
+
* `Task.businessStatus.coding[].code` value set by the reception role when
|
|
42
|
+
* marking a review as seen/checked, without confirming the underlying
|
|
43
|
+
* appointment.
|
|
44
|
+
*/
|
|
45
|
+
export declare const TASK_BUSINESS_STATUS_REVIEWED_CODE = "reviewed";
|
|
46
|
+
/** `system|code` search token for `Task?business-status` filters on the reviewed state. */
|
|
47
|
+
export declare const TASK_BUSINESS_STATUS_REVIEWED_TOKEN = "https://www.cdrossi.com/fhir/CodeSystem/task-business-status|reviewed";
|
|
48
|
+
/**
|
|
49
|
+
* Task.code value identifying a "send appointment confirmation email" job. The
|
|
50
|
+
* code is fully self-describing (not an `eges-migrate-*` migration code) — these
|
|
51
|
+
* Tasks are produced by the appointments-portal $create flow rather than the
|
|
52
|
+
* EGES migration pipeline.
|
|
53
|
+
*/
|
|
54
|
+
export declare const SEND_APPOINTMENT_CONFIRMATION_EMAIL_TASK_CODE = "send-appointment-confirmation-email";
|
|
55
|
+
/** Task.input code for the booking-session UUID (mirrors `ServiceRequest.requisition.value`). */
|
|
56
|
+
export declare const EMAIL_TASK_INPUT_SESSION_GROUP_ID = "session-group-id";
|
|
57
|
+
/** Task.input code for the recipient email address resolved from `Patient.telecom`. */
|
|
58
|
+
export declare const EMAIL_TASK_INPUT_RECIPIENT_EMAIL = "recipient-email";
|
|
59
|
+
/** Task.input code carrying `Patient/{id}` for the recipient's patient record. */
|
|
60
|
+
export declare const EMAIL_TASK_INPUT_PATIENT_REF = "patient-ref";
|
|
61
|
+
/** Task.input code for the optional IANA timezone used to format appointment times in the email. */
|
|
62
|
+
export declare const EMAIL_TASK_INPUT_TIMEZONE = "timezone";
|
|
63
|
+
/** Task.output code for the recipient email address that was actually used. */
|
|
64
|
+
export declare const EMAIL_TASK_OUTPUT_RECIPIENT = "recipient";
|
|
65
|
+
/** Task.output code for the count of appointments included in the email body. */
|
|
66
|
+
export declare const EMAIL_TASK_OUTPUT_APPOINTMENT_COUNT = "appointment-count";
|
|
67
|
+
/**
|
|
68
|
+
* Task.output code for the rendered email subject line. Captured on the Task
|
|
69
|
+
* in both success and failure paths so the rendered message can be inspected
|
|
70
|
+
* locally (no SMTP/SES configured) and audited in prod (no need to hunt
|
|
71
|
+
* through SES logs).
|
|
72
|
+
*/
|
|
73
|
+
export declare const EMAIL_TASK_OUTPUT_SUBJECT = "subject";
|
|
74
|
+
/** Task.output code for the rendered email HTML body. Companion to `subject`/`text`. */
|
|
75
|
+
export declare const EMAIL_TASK_OUTPUT_HTML = "html";
|
|
76
|
+
/** Task.output code for the rendered email plain-text body. Companion to `subject`/`html`. */
|
|
77
|
+
export declare const EMAIL_TASK_OUTPUT_TEXT = "text";
|
|
30
78
|
export declare const HL7_IMPORT_TASK_SYSTEM = "http://example.org/CodeSystem/hl7-import-tasks";
|
|
31
79
|
export declare const HL7_IMPORT_APPOINTMENT_TASK_CODE = "import-orm-o01-appointment";
|
|
32
80
|
export declare const HL7_IMPORT_TASK_INPUT_SYSTEM = "http://example.org/CodeSystem/hl7-import-task-inputs";
|
|
@@ -54,6 +102,21 @@ export declare const HS_ACTION_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem
|
|
|
54
102
|
* assumptions on orderDetail.
|
|
55
103
|
*/
|
|
56
104
|
export declare const HS_ADDON_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/hs-addon";
|
|
105
|
+
/**
|
|
106
|
+
* Coding system used on `DocumentReference.type` for portal-uploaded medical
|
|
107
|
+
* orders. Doubles as an identifier system so we can dedupe a `(session, order)`
|
|
108
|
+
* pair across the sibling `Appointment/$create` calls the portal issues in
|
|
109
|
+
* parallel for a multi-study booking.
|
|
110
|
+
*/
|
|
111
|
+
export declare const MEDICAL_ORDER_DOCUMENT_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/medical-order-document";
|
|
112
|
+
/** `DocumentReference.type.coding[0].code` value paired with MEDICAL_ORDER_DOCUMENT_SYSTEM. */
|
|
113
|
+
export declare const MEDICAL_ORDER_DOCUMENT_CODE = "medical-order";
|
|
114
|
+
/**
|
|
115
|
+
* Complex extension attached to DocumentReference. Sub-extensions carry the
|
|
116
|
+
* structured OCR metadata (doctor, diagnosis, insurer, plan, patient data, …)
|
|
117
|
+
* the appointments-portal parses from each scanned medical order.
|
|
118
|
+
*/
|
|
119
|
+
export declare const ORDER_METADATA_EXTENSION_URL = "https://www.cdrossi.com/fhir/StructureDefinition/order-metadata";
|
|
57
120
|
/** Coding system for custom PlanDefinition types */
|
|
58
121
|
export declare const PD_TYPE_SYSTEM = "https://www.cdrossi.com/fhir/CodeSystem/plan-definition-type";
|
|
59
122
|
/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */
|
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,mDAA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M,uBAAuB,6DAA6C,CAAA;AAEjF,oEAAoE;AACpE,eAAO,MAAM,iBAAiB,uDAAuC,CAAA;AAErE,wGAAwG;AACxG,eAAO,MAAM,yBAAyB,iEAAiD,CAAA;AAEvF,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,gEAAgD,CAAA;AAErF,gIAAgI;AAChI,eAAO,MAAM,mCAAmC,2EAA2D,CAAA;AAE3G;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,uEAAuD,CAAA;AAEnG;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wCAAwC,gFAAgE,CAAA;AAIrH,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB,qDAAqC,CAAA;AAE3E,wCAAwC;AACxC,eAAO,MAAM,eAAe,4DAA4D,CAAA;AAExF,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,QAAQ,CAAA;AAEtC,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,SAAS,CAAA;AAIxC,6EAA6E;AAC7E,eAAO,MAAM,gCAAgC,4DAA4C,CAAA;AAIzF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sCAAsB,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kBAAkB,CAAA;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,6EAA6D,CAAA;AAErG;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,yDAAyC,CAAA;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6DAA6D,CAAA;AACpG,eAAO,MAAM,wBAAwB,SAAS,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = exports.BILLING_CODES_ORG_EXTENSION = exports.BILLING_CODES_TAG_CODE = exports.BILLING_CODES_TAG_SYSTEM = exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = void 0;
|
|
3
|
+
exports.HS_ACTION_SYSTEM = exports.SERVICE_REQUEST_GROUP_SYSTEM = exports.HL7_IMPORT_TASK_OUTPUT_SYSTEM = exports.HL7_IMPORT_TASK_INPUT_SYSTEM = exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = exports.HL7_IMPORT_TASK_SYSTEM = exports.EMAIL_TASK_OUTPUT_TEXT = exports.EMAIL_TASK_OUTPUT_HTML = exports.EMAIL_TASK_OUTPUT_SUBJECT = exports.EMAIL_TASK_OUTPUT_APPOINTMENT_COUNT = exports.EMAIL_TASK_OUTPUT_RECIPIENT = exports.EMAIL_TASK_INPUT_TIMEZONE = exports.EMAIL_TASK_INPUT_PATIENT_REF = exports.EMAIL_TASK_INPUT_RECIPIENT_EMAIL = exports.EMAIL_TASK_INPUT_SESSION_GROUP_ID = exports.SEND_APPOINTMENT_CONFIRMATION_EMAIL_TASK_CODE = exports.TASK_BUSINESS_STATUS_REVIEWED_TOKEN = exports.TASK_BUSINESS_STATUS_REVIEWED_CODE = exports.TASK_BUSINESS_STATUS_SYSTEM = exports.SYNCHRONIZE_APPOINTMENT_TASK_CODE = 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_CONDICION_RESPUESTA_SYSTEM = exports.EGES_PRESTACION_SYSTEM = exports.EGES_PRACTICA_SYSTEM = exports.EGES_TURNO_SYSTEM = exports.EGES_EQUIPO_SYSTEM = exports.EGES_MEDICO_ASOCIACION_SYSTEM = exports.EGES_MEDICO_SYSTEM = exports.EGES_SUCURSAL_SYSTEM = exports.EGES_DOCUMENTO_SYSTEM = exports.EGES_PACIENTE_SYSTEM = exports.EGES_SYSTEM_BASE = exports.FHIR_BASE = void 0;
|
|
4
|
+
exports.BILLING_CID_CONTEXT_CODE = exports.BILLING_CID_CONTEXT_SYSTEM = exports.BILLING_CID_PD_IDENTIFIER_SYSTEM = exports.BILLING_CODES_ORG_EXTENSION = exports.BILLING_CODES_TAG_CODE = exports.BILLING_CODES_TAG_SYSTEM = exports.INSURANCE_PLAN_IDENTIFIER_SYSTEM = exports.ORG_TYPE_PROV_CODE = exports.ORG_TYPE_PAY_CODE = exports.ORG_TYPE_SYSTEM = exports.INSURER_IDENTIFIER_SYSTEM = exports.HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = exports.HS_SEARCH_ALIASES_EXTENSION_URL = exports.PD_HEALTHCARE_SERVICE_EXTENSION_URL = exports.HS_BILLING_EXTENSION_URL = exports.HS_PROTOCOL_EXTENSION_URL = exports.SPECIALITY_SYSTEM = exports.SERVICE_CATEGORY_SYSTEM = exports.SERVICE_CODES_SYSTEM = exports.PD_TYPE_PROTOCOL_GROUP = exports.PD_TYPE_SYSTEM = exports.ORDER_METADATA_EXTENSION_URL = exports.MEDICAL_ORDER_DOCUMENT_CODE = exports.MEDICAL_ORDER_DOCUMENT_SYSTEM = exports.HS_ADDON_SYSTEM = void 0;
|
|
5
5
|
exports.FHIR_BASE = 'https://www.cdrossi.com/fhir';
|
|
6
6
|
exports.EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges';
|
|
7
7
|
exports.EGES_PACIENTE_SYSTEM = `${exports.EGES_SYSTEM_BASE}/paciente`;
|
|
@@ -13,6 +13,7 @@ exports.EGES_EQUIPO_SYSTEM = `${exports.EGES_SYSTEM_BASE}/equipo`;
|
|
|
13
13
|
exports.EGES_TURNO_SYSTEM = `${exports.EGES_SYSTEM_BASE}/turno`;
|
|
14
14
|
exports.EGES_PRACTICA_SYSTEM = `${exports.EGES_SYSTEM_BASE}/practica`;
|
|
15
15
|
exports.EGES_PRESTACION_SYSTEM = `${exports.EGES_SYSTEM_BASE}/prestacion`;
|
|
16
|
+
exports.EGES_CONDICION_RESPUESTA_SYSTEM = `${exports.EGES_SYSTEM_BASE}/condicion-respuesta`;
|
|
16
17
|
exports.RENAPER_BASE = 'https://www.argentina.gob.ar/interior/renaper';
|
|
17
18
|
exports.MATRICULA_NACIONAL_SYSTEM = `${exports.RENAPER_BASE}/matricula-nacional`;
|
|
18
19
|
exports.MATRICULA_PROVINCIAL_SYSTEM = `${exports.RENAPER_BASE}/matricula-provincial`;
|
|
@@ -32,6 +33,53 @@ exports.MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`;
|
|
|
32
33
|
exports.MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`;
|
|
33
34
|
exports.MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`;
|
|
34
35
|
exports.REVIEW_APPOINTMENT_TASK_CODE = 'review-appointment';
|
|
36
|
+
exports.SYNCHRONIZE_APPOINTMENT_TASK_CODE = 'synchronize-appointment';
|
|
37
|
+
/**
|
|
38
|
+
* Coding system for `Task.businessStatus` values used by the Rossi admin
|
|
39
|
+
* review workflow. Distinct from `Task.status` (FHIR lifecycle), which is
|
|
40
|
+
* driven by the booking pipeline. `businessStatus` captures staff-side
|
|
41
|
+
* review state that is independent of whether the appointment has been
|
|
42
|
+
* confirmed in EGES.
|
|
43
|
+
*/
|
|
44
|
+
exports.TASK_BUSINESS_STATUS_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/task-business-status`;
|
|
45
|
+
/**
|
|
46
|
+
* `Task.businessStatus.coding[].code` value set by the reception role when
|
|
47
|
+
* marking a review as seen/checked, without confirming the underlying
|
|
48
|
+
* appointment.
|
|
49
|
+
*/
|
|
50
|
+
exports.TASK_BUSINESS_STATUS_REVIEWED_CODE = 'reviewed';
|
|
51
|
+
/** `system|code` search token for `Task?business-status` filters on the reviewed state. */
|
|
52
|
+
exports.TASK_BUSINESS_STATUS_REVIEWED_TOKEN = `${exports.TASK_BUSINESS_STATUS_SYSTEM}|${exports.TASK_BUSINESS_STATUS_REVIEWED_CODE}`;
|
|
53
|
+
/**
|
|
54
|
+
* Task.code value identifying a "send appointment confirmation email" job. The
|
|
55
|
+
* code is fully self-describing (not an `eges-migrate-*` migration code) — these
|
|
56
|
+
* Tasks are produced by the appointments-portal $create flow rather than the
|
|
57
|
+
* EGES migration pipeline.
|
|
58
|
+
*/
|
|
59
|
+
exports.SEND_APPOINTMENT_CONFIRMATION_EMAIL_TASK_CODE = 'send-appointment-confirmation-email';
|
|
60
|
+
/** Task.input code for the booking-session UUID (mirrors `ServiceRequest.requisition.value`). */
|
|
61
|
+
exports.EMAIL_TASK_INPUT_SESSION_GROUP_ID = 'session-group-id';
|
|
62
|
+
/** Task.input code for the recipient email address resolved from `Patient.telecom`. */
|
|
63
|
+
exports.EMAIL_TASK_INPUT_RECIPIENT_EMAIL = 'recipient-email';
|
|
64
|
+
/** Task.input code carrying `Patient/{id}` for the recipient's patient record. */
|
|
65
|
+
exports.EMAIL_TASK_INPUT_PATIENT_REF = 'patient-ref';
|
|
66
|
+
/** Task.input code for the optional IANA timezone used to format appointment times in the email. */
|
|
67
|
+
exports.EMAIL_TASK_INPUT_TIMEZONE = 'timezone';
|
|
68
|
+
/** Task.output code for the recipient email address that was actually used. */
|
|
69
|
+
exports.EMAIL_TASK_OUTPUT_RECIPIENT = 'recipient';
|
|
70
|
+
/** Task.output code for the count of appointments included in the email body. */
|
|
71
|
+
exports.EMAIL_TASK_OUTPUT_APPOINTMENT_COUNT = 'appointment-count';
|
|
72
|
+
/**
|
|
73
|
+
* Task.output code for the rendered email subject line. Captured on the Task
|
|
74
|
+
* in both success and failure paths so the rendered message can be inspected
|
|
75
|
+
* locally (no SMTP/SES configured) and audited in prod (no need to hunt
|
|
76
|
+
* through SES logs).
|
|
77
|
+
*/
|
|
78
|
+
exports.EMAIL_TASK_OUTPUT_SUBJECT = 'subject';
|
|
79
|
+
/** Task.output code for the rendered email HTML body. Companion to `subject`/`text`. */
|
|
80
|
+
exports.EMAIL_TASK_OUTPUT_HTML = 'html';
|
|
81
|
+
/** Task.output code for the rendered email plain-text body. Companion to `subject`/`html`. */
|
|
82
|
+
exports.EMAIL_TASK_OUTPUT_TEXT = 'text';
|
|
35
83
|
exports.HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks';
|
|
36
84
|
exports.HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment';
|
|
37
85
|
exports.HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs';
|
|
@@ -60,6 +108,22 @@ exports.HS_ACTION_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/hs-action`;
|
|
|
60
108
|
* assumptions on orderDetail.
|
|
61
109
|
*/
|
|
62
110
|
exports.HS_ADDON_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/hs-addon`;
|
|
111
|
+
// ─── Medical order documents (portal requisitions) ──────────────────────────
|
|
112
|
+
/**
|
|
113
|
+
* Coding system used on `DocumentReference.type` for portal-uploaded medical
|
|
114
|
+
* orders. Doubles as an identifier system so we can dedupe a `(session, order)`
|
|
115
|
+
* pair across the sibling `Appointment/$create` calls the portal issues in
|
|
116
|
+
* parallel for a multi-study booking.
|
|
117
|
+
*/
|
|
118
|
+
exports.MEDICAL_ORDER_DOCUMENT_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/medical-order-document`;
|
|
119
|
+
/** `DocumentReference.type.coding[0].code` value paired with MEDICAL_ORDER_DOCUMENT_SYSTEM. */
|
|
120
|
+
exports.MEDICAL_ORDER_DOCUMENT_CODE = 'medical-order';
|
|
121
|
+
/**
|
|
122
|
+
* Complex extension attached to DocumentReference. Sub-extensions carry the
|
|
123
|
+
* structured OCR metadata (doctor, diagnosis, insurer, plan, patient data, …)
|
|
124
|
+
* the appointments-portal parses from each scanned medical order.
|
|
125
|
+
*/
|
|
126
|
+
exports.ORDER_METADATA_EXTENSION_URL = `${exports.FHIR_BASE}/StructureDefinition/order-metadata`;
|
|
63
127
|
// ─── PlanDefinition type ─────────────────────────────────────────────────────
|
|
64
128
|
/** Coding system for custom PlanDefinition types */
|
|
65
129
|
exports.PD_TYPE_SYSTEM = `${exports.FHIR_BASE}/CodeSystem/plan-definition-type`;
|
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,w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AAA,wBAAwB,GAAG,GAAG,iBAAS,OAAO,CAAA;AAE3D;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,eAAe,CAAA;AAErD;;;;;;;;GAQG;AACU,QAAA,2BAA2B,GAAG,GAAG,iBAAS,8CAA8C,CAAA;AAErG;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,GAAG,iBAAS,0BAA0B,CAAA;AAEtF;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,0DAA0D,CAAA;AACvF,QAAA,wBAAwB,GAAG,MAAM,CAAA","sourcesContent":["export const FHIR_BASE = 'https://www.cdrossi.com/fhir'\nexport const EGES_SYSTEM_BASE = 'https://www.cdrossi.com/eges'\n\nexport const EGES_PACIENTE_SYSTEM = `${EGES_SYSTEM_BASE}/paciente`\nexport const EGES_DOCUMENTO_SYSTEM = `${EGES_SYSTEM_BASE}/documentos`\nexport const EGES_SUCURSAL_SYSTEM = `${EGES_SYSTEM_BASE}/sucursal`\nexport const EGES_MEDICO_SYSTEM = `${EGES_SYSTEM_BASE}/medico`\nexport const EGES_MEDICO_ASOCIACION_SYSTEM = `${EGES_SYSTEM_BASE}/medico-asociacion`\nexport const EGES_EQUIPO_SYSTEM = `${EGES_SYSTEM_BASE}/equipo`\nexport const EGES_TURNO_SYSTEM = `${EGES_SYSTEM_BASE}/turno`\nexport const EGES_PRACTICA_SYSTEM = `${EGES_SYSTEM_BASE}/practica`\nexport const EGES_PRESTACION_SYSTEM = `${EGES_SYSTEM_BASE}/prestacion`\nexport const RENAPER_BASE = 'https://www.argentina.gob.ar/interior/renaper'\nexport const MATRICULA_NACIONAL_SYSTEM = `${RENAPER_BASE}/matricula-nacional`\nexport const MATRICULA_PROVINCIAL_SYSTEM = `${RENAPER_BASE}/matricula-provincial`\n\nexport const SCHEDULING_PARAMETERS_EXTENSION_URL = 'http://medplum.com/fhir/StructureDefinition/scheduling-parameters'\nexport const REQUIRES_PRACTITIONER_EXTENSION_URL = `${FHIR_BASE}/requires-practitioner`\nexport const SERVICE_TYPE_SYSTEM = `${FHIR_BASE}/service-type`\n\nexport const PRACTITIONER_ROLE_SYSTEM = `${FHIR_BASE}/CodeSystem/practitioner-role`\nexport const PRACTITIONER_ROLE_REFERRING_CODE = 'referring'\n\nconst MIGRATE_TASK_BASE = 'eges-migrate'\nexport const MIGRATE_TASK_SYSTEM = `${FHIR_BASE}/tasks`\nexport const MIGRATE_TASK_INPUT_SYSTEM = `${FHIR_BASE}/task-inputs`\nexport const MIGRATE_TASK_OUTPUT_SYSTEM = `${FHIR_BASE}/task-outputs`\nexport const MIGRATE_PRACTITIONER_TASK_CODE = `${MIGRATE_TASK_BASE}-practitioner`\nexport const MIGRATE_PATIENT_TASK_CODE = `${MIGRATE_TASK_BASE}-patient`\nexport const MIGRATE_DEVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-device`\nexport const MIGRATE_SITE_TASK_CODE = `${MIGRATE_TASK_BASE}-site`\nexport const MIGRATE_SERVICE_TASK_CODE = `${MIGRATE_TASK_BASE}-service`\nexport const MIGRATE_APPOINTMENT_TASK_CODE = `${MIGRATE_TASK_BASE}-appointment`\nexport const REVIEW_APPOINTMENT_TASK_CODE = 'review-appointment'\n\nexport const HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks'\nexport const HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment'\nexport const HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs'\nexport const HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs'\n\n// ─── ServiceRequest ──────────────────────────────────────────────────────────\n\n/**\n * Identifier system used as `ServiceRequest.requisition.system` to correlate\n * multiple ServiceRequests (one per Appointment) authored in the same\n * appointments-portal wizard session. Maps to FHIR R4 `requisition` — \"A\n * shared identifier common to all service requests that were authorized more\n * or less simultaneously by a single author, representing the composite or\n * group identifier.\"\n */\nexport const SERVICE_REQUEST_GROUP_SYSTEM = `${FHIR_BASE}/service-request-group`\n\n/**\n * Coding system for HealthcareService action (variant) selections recorded\n * on `ServiceRequest.orderDetail[]`. The `code` is the PlanDefinition action\n * id from the contained protocol on the HealthcareService, and `display` is\n * the human-readable action label (e.g. \"Frente y perfil\").\n */\nexport const HS_ACTION_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-action`\n\n/**\n * Coding system for HealthcareService addon selections recorded on\n * `ServiceRequest.orderDetail[]`. Same id/label shape as HS_ACTION_SYSTEM —\n * the distinct URI lets readers filter action vs. addons without ordering\n * assumptions on orderDetail.\n */\nexport const HS_ADDON_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-addon`\n\n// ─── PlanDefinition type ─────────────────────────────────────────────────────\n\n/** Coding system for custom PlanDefinition types */\nexport const PD_TYPE_SYSTEM = `${FHIR_BASE}/CodeSystem/plan-definition-type`\n\n/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */\nexport const PD_TYPE_PROTOCOL_GROUP = 'protocol-group'\n\n// ─── HealthcareService model ──────────────────────────────────────────────────\n\n/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */\nexport const SERVICE_CODES_SYSTEM = `${FHIR_BASE}/CodeSystem/service-codes`\n\n/** Coding system for service categories on HealthcareService.category */\nexport const SERVICE_CATEGORY_SYSTEM = `${FHIR_BASE}/CodeSystem/service-category`\n\n/** Coding system for specialities on HealthcareService.specialty */\nexport const SPECIALITY_SYSTEM = `${FHIR_BASE}/CodeSystem/speciality`\n\n/** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */\nexport const HS_PROTOCOL_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-protocol`\n\n/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */\nexport const HS_BILLING_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-billing`\n\n/** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */\nexport const PD_HEALTHCARE_SERVICE_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/pd-healthcare-service`\n\n/**\n * Extension URL for additional search aliases on HealthcareService.\n *\n * Stored as multiple same-URL extensions, each with a `valueString`.\n * These are indexed at weight 1.2 by the search indexer.\n * Using an extension instead of HealthcareService.alias[] because the local\n * FHIR profile does not permit the standard alias field.\n *\n * @example\n * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: \"placa de tórax\" }\n */\nexport const HS_SEARCH_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-aliases`\n\n/**\n * @example\n * {\n * url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,\n * extension: [\n * { url: \"alias\", valueString: \"placa de tórax\" },\n * { url: \"protocol\", valueString: \"9a9056df-0e54-4c2a-a3ce-eb58405f1ec9\" },\n * { url: \"addon\", valueString: \"a7101b76-6f1a-4562-8689-edaee07d6b95\" },\n * { url: \"addon\", valueString: \"97b7c2ce-6f1a-4562-8689-f21a8673e009\" }\n * ]\n * }\n */\nexport const HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-protocol-aliases`\n\n// ─── Organization (payer / insurance company) ─────────────────────────────────\n\n/** Identifier system for insurance company (payer) Organization resources */\nexport const INSURER_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurers`\n\n/** HL7 organization-type code system */\nexport const ORG_TYPE_SYSTEM = 'http://terminology.hl7.org/CodeSystem/organization-type'\n\n/** organization-type code for payer/insurance */\nexport const ORG_TYPE_PAY_CODE = 'pay'\n\n/** organization-type code for healthcare provider (the main clinic) */\nexport const ORG_TYPE_PROV_CODE = 'prov'\n\n// ─── InsurancePlan ────────────────────────────────────────────────────────────\n\n/** Identifier system for InsurancePlan resources (specific plan products) */\nexport const INSURANCE_PLAN_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurance-plans`\n\n// ─── Billing CodeSystem discovery tag ────────────────────────────────────────\n\n/**\n * Tag system applied to every billing-codes CodeSystem resource,\n * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.\n */\nexport const BILLING_CODES_TAG_SYSTEM = `${FHIR_BASE}/tags`\n\n/**\n * Tag code that marks a CodeSystem as a billing codes system.\n * Every billing CodeSystem must carry:\n * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]\n */\nexport const BILLING_CODES_TAG_CODE = 'billing-codes'\n\n/**\n * Extension URL stored on a billing CodeSystem to record which billing\n * Organization (obra social) owns / uses this billing code system.\n *\n * Value type: Reference (Organization)\n *\n * Example:\n * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]\n */\nexport const BILLING_CODES_ORG_EXTENSION = `${FHIR_BASE}/extensions/billing-code-system-organization`\n\n/**\n * Identifier system used to tag every billing ChargeItemDefinition with the ID\n * of the PlanDefinition it belongs to, enabling reliable search via\n * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.\n * (The FHIR R4 `instance` search parameter is not supported by Medplum.)\n */\nexport const BILLING_CID_PD_IDENTIFIER_SYSTEM = `${FHIR_BASE}/billing/plan-definition`\n\n/**\n * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.\n * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM\n * useContext.code.code = BILLING_CID_CONTEXT_CODE\n * useContext.valueReference → InsurancePlan\n */\nexport const BILLING_CID_CONTEXT_SYSTEM = 'http://terminology.hl7.org/CodeSystem/usage-context-type'\nexport const BILLING_CID_CONTEXT_CODE = 'user'\n"]}
|
|
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,qBAA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A;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 EGES_CONDICION_RESPUESTA_SYSTEM = `${EGES_SYSTEM_BASE}/condicion-respuesta`\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'\nexport const SYNCHRONIZE_APPOINTMENT_TASK_CODE = 'synchronize-appointment'\n\n/**\n * Coding system for `Task.businessStatus` values used by the Rossi admin\n * review workflow. Distinct from `Task.status` (FHIR lifecycle), which is\n * driven by the booking pipeline. `businessStatus` captures staff-side\n * review state that is independent of whether the appointment has been\n * confirmed in EGES.\n */\nexport const TASK_BUSINESS_STATUS_SYSTEM = `${FHIR_BASE}/CodeSystem/task-business-status`\n\n/**\n * `Task.businessStatus.coding[].code` value set by the reception role when\n * marking a review as seen/checked, without confirming the underlying\n * appointment.\n */\nexport const TASK_BUSINESS_STATUS_REVIEWED_CODE = 'reviewed'\n\n/** `system|code` search token for `Task?business-status` filters on the reviewed state. */\nexport const TASK_BUSINESS_STATUS_REVIEWED_TOKEN =\n `${TASK_BUSINESS_STATUS_SYSTEM}|${TASK_BUSINESS_STATUS_REVIEWED_CODE}`\n\n/**\n * Task.code value identifying a \"send appointment confirmation email\" job. The\n * code is fully self-describing (not an `eges-migrate-*` migration code) — these\n * Tasks are produced by the appointments-portal $create flow rather than the\n * EGES migration pipeline.\n */\nexport const SEND_APPOINTMENT_CONFIRMATION_EMAIL_TASK_CODE = 'send-appointment-confirmation-email'\n\n/** Task.input code for the booking-session UUID (mirrors `ServiceRequest.requisition.value`). */\nexport const EMAIL_TASK_INPUT_SESSION_GROUP_ID = 'session-group-id'\n\n/** Task.input code for the recipient email address resolved from `Patient.telecom`. */\nexport const EMAIL_TASK_INPUT_RECIPIENT_EMAIL = 'recipient-email'\n\n/** Task.input code carrying `Patient/{id}` for the recipient's patient record. */\nexport const EMAIL_TASK_INPUT_PATIENT_REF = 'patient-ref'\n\n/** Task.input code for the optional IANA timezone used to format appointment times in the email. */\nexport const EMAIL_TASK_INPUT_TIMEZONE = 'timezone'\n\n/** Task.output code for the recipient email address that was actually used. */\nexport const EMAIL_TASK_OUTPUT_RECIPIENT = 'recipient'\n\n/** Task.output code for the count of appointments included in the email body. */\nexport const EMAIL_TASK_OUTPUT_APPOINTMENT_COUNT = 'appointment-count'\n\n/**\n * Task.output code for the rendered email subject line. Captured on the Task\n * in both success and failure paths so the rendered message can be inspected\n * locally (no SMTP/SES configured) and audited in prod (no need to hunt\n * through SES logs).\n */\nexport const EMAIL_TASK_OUTPUT_SUBJECT = 'subject'\n\n/** Task.output code for the rendered email HTML body. Companion to `subject`/`text`. */\nexport const EMAIL_TASK_OUTPUT_HTML = 'html'\n\n/** Task.output code for the rendered email plain-text body. Companion to `subject`/`html`. */\nexport const EMAIL_TASK_OUTPUT_TEXT = 'text'\n\nexport const HL7_IMPORT_TASK_SYSTEM = 'http://example.org/CodeSystem/hl7-import-tasks'\nexport const HL7_IMPORT_APPOINTMENT_TASK_CODE = 'import-orm-o01-appointment'\nexport const HL7_IMPORT_TASK_INPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-inputs'\nexport const HL7_IMPORT_TASK_OUTPUT_SYSTEM = 'http://example.org/CodeSystem/hl7-import-task-outputs'\n\n// ─── ServiceRequest ──────────────────────────────────────────────────────────\n\n/**\n * Identifier system used as `ServiceRequest.requisition.system` to correlate\n * multiple ServiceRequests (one per Appointment) authored in the same\n * appointments-portal wizard session. Maps to FHIR R4 `requisition` — \"A\n * shared identifier common to all service requests that were authorized more\n * or less simultaneously by a single author, representing the composite or\n * group identifier.\"\n */\nexport const SERVICE_REQUEST_GROUP_SYSTEM = `${FHIR_BASE}/service-request-group`\n\n/**\n * Coding system for HealthcareService action (variant) selections recorded\n * on `ServiceRequest.orderDetail[]`. The `code` is the PlanDefinition action\n * id from the contained protocol on the HealthcareService, and `display` is\n * the human-readable action label (e.g. \"Frente y perfil\").\n */\nexport const HS_ACTION_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-action`\n\n/**\n * Coding system for HealthcareService addon selections recorded on\n * `ServiceRequest.orderDetail[]`. Same id/label shape as HS_ACTION_SYSTEM —\n * the distinct URI lets readers filter action vs. addons without ordering\n * assumptions on orderDetail.\n */\nexport const HS_ADDON_SYSTEM = `${FHIR_BASE}/CodeSystem/hs-addon`\n\n// ─── Medical order documents (portal requisitions) ──────────────────────────\n\n/**\n * Coding system used on `DocumentReference.type` for portal-uploaded medical\n * orders. Doubles as an identifier system so we can dedupe a `(session, order)`\n * pair across the sibling `Appointment/$create` calls the portal issues in\n * parallel for a multi-study booking.\n */\nexport const MEDICAL_ORDER_DOCUMENT_SYSTEM = `${FHIR_BASE}/CodeSystem/medical-order-document`\n\n/** `DocumentReference.type.coding[0].code` value paired with MEDICAL_ORDER_DOCUMENT_SYSTEM. */\nexport const MEDICAL_ORDER_DOCUMENT_CODE = 'medical-order'\n\n/**\n * Complex extension attached to DocumentReference. Sub-extensions carry the\n * structured OCR metadata (doctor, diagnosis, insurer, plan, patient data, …)\n * the appointments-portal parses from each scanned medical order.\n */\nexport const ORDER_METADATA_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/order-metadata`\n\n// ─── PlanDefinition type ─────────────────────────────────────────────────────\n\n/** Coding system for custom PlanDefinition types */\nexport const PD_TYPE_SYSTEM = `${FHIR_BASE}/CodeSystem/plan-definition-type`\n\n/** Type code that marks a PlanDefinition as a protocol-group (wrapping multiple concrete PDs) */\nexport const PD_TYPE_PROTOCOL_GROUP = 'protocol-group'\n\n// ─── HealthcareService model ──────────────────────────────────────────────────\n\n/** Identifier system for service codes on HealthcareService (mirrors the ServiceCodes CodeSystem URL) */\nexport const SERVICE_CODES_SYSTEM = `${FHIR_BASE}/CodeSystem/service-codes`\n\n/** Coding system for service categories on HealthcareService.category */\nexport const SERVICE_CATEGORY_SYSTEM = `${FHIR_BASE}/CodeSystem/service-category`\n\n/** Coding system for specialities on HealthcareService.specialty */\nexport const SPECIALITY_SYSTEM = `${FHIR_BASE}/CodeSystem/speciality`\n\n/** Extension URL for the mandatory PlanDefinition (clinical protocol) reference on HealthcareService */\nexport const HS_PROTOCOL_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-protocol`\n\n/** Extension URL for the optional ChargeItemDefinition (billing) reference on HealthcareService */\nexport const HS_BILLING_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-billing`\n\n/** Extension URL for the back-reference to the HealthcareService (study) for which this PlanDefinition is the protocol group */\nexport const PD_HEALTHCARE_SERVICE_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/pd-healthcare-service`\n\n/**\n * Extension URL for additional search aliases on HealthcareService.\n *\n * Stored as multiple same-URL extensions, each with a `valueString`.\n * These are indexed at weight 1.2 by the search indexer.\n * Using an extension instead of HealthcareService.alias[] because the local\n * FHIR profile does not permit the standard alias field.\n *\n * @example\n * { url: HS_SEARCH_ALIASES_EXTENSION_URL, valueString: \"placa de tórax\" }\n */\nexport const HS_SEARCH_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-aliases`\n\n/**\n * @example\n * {\n * url: HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL,\n * extension: [\n * { url: \"alias\", valueString: \"placa de tórax\" },\n * { url: \"protocol\", valueString: \"9a9056df-0e54-4c2a-a3ce-eb58405f1ec9\" },\n * { url: \"addon\", valueString: \"a7101b76-6f1a-4562-8689-edaee07d6b95\" },\n * { url: \"addon\", valueString: \"97b7c2ce-6f1a-4562-8689-f21a8673e009\" }\n * ]\n * }\n */\nexport const HS_SEARCH_PROTOCOL_ALIASES_EXTENSION_URL = `${FHIR_BASE}/StructureDefinition/hs-search-protocol-aliases`\n\n// ─── Organization (payer / insurance company) ─────────────────────────────────\n\n/** Identifier system for insurance company (payer) Organization resources */\nexport const INSURER_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurers`\n\n/** HL7 organization-type code system */\nexport const ORG_TYPE_SYSTEM = 'http://terminology.hl7.org/CodeSystem/organization-type'\n\n/** organization-type code for payer/insurance */\nexport const ORG_TYPE_PAY_CODE = 'pay'\n\n/** organization-type code for healthcare provider (the main clinic) */\nexport const ORG_TYPE_PROV_CODE = 'prov'\n\n// ─── InsurancePlan ────────────────────────────────────────────────────────────\n\n/** Identifier system for InsurancePlan resources (specific plan products) */\nexport const INSURANCE_PLAN_IDENTIFIER_SYSTEM = `${FHIR_BASE}/CodeSystem/insurance-plans`\n\n// ─── Billing CodeSystem discovery tag ────────────────────────────────────────\n\n/**\n * Tag system applied to every billing-codes CodeSystem resource,\n * enabling dynamic discovery via `CodeSystem?_tag=<system>|<code>`.\n */\nexport const BILLING_CODES_TAG_SYSTEM = `${FHIR_BASE}/tags`\n\n/**\n * Tag code that marks a CodeSystem as a billing codes system.\n * Every billing CodeSystem must carry:\n * meta.tag = [{ system: BILLING_CODES_TAG_SYSTEM, code: BILLING_CODES_TAG_CODE }]\n */\nexport const BILLING_CODES_TAG_CODE = 'billing-codes'\n\n/**\n * Extension URL stored on a billing CodeSystem to record which billing\n * Organization (obra social) owns / uses this billing code system.\n *\n * Value type: Reference (Organization)\n *\n * Example:\n * extension: [{ url: BILLING_CODES_ORG_EXTENSION, valueReference: { reference: 'Organization/123' } }]\n */\nexport const BILLING_CODES_ORG_EXTENSION = `${FHIR_BASE}/extensions/billing-code-system-organization`\n\n/**\n * Identifier system used to tag every billing ChargeItemDefinition with the ID\n * of the PlanDefinition it belongs to, enabling reliable search via\n * `ChargeItemDefinition?identifier=<system>|<planDefinitionId>`.\n * (The FHIR R4 `instance` search parameter is not supported by Medplum.)\n */\nexport const BILLING_CID_PD_IDENTIFIER_SYSTEM = `${FHIR_BASE}/billing/plan-definition`\n\n/**\n * Usage-context type system used to scope a ChargeItemDefinition to a specific InsurancePlan.\n * useContext.code.system = BILLING_CID_CONTEXT_SYSTEM\n * useContext.code.code = BILLING_CID_CONTEXT_CODE\n * useContext.valueReference → InsurancePlan\n */\nexport const BILLING_CID_CONTEXT_SYSTEM = 'http://terminology.hl7.org/CodeSystem/usage-context-type'\nexport const BILLING_CID_CONTEXT_CODE = 'user'\n"]}
|
|
@@ -17,6 +17,13 @@ export interface ProtocolActionInfo {
|
|
|
17
17
|
* `undefined` means the PD has not been configured (use `isDefault` as fallback).
|
|
18
18
|
*/
|
|
19
19
|
readonly prechecked?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Only meaningful on addon (sub-action) entries. When `true`, the addon is
|
|
22
|
+
* always included whenever its parent action is selected — it is not shown
|
|
23
|
+
* as a togglable option in the consumer UI. Encoded in FHIR as
|
|
24
|
+
* `PlanDefinitionAction.requiredBehavior === 'must'`.
|
|
25
|
+
*/
|
|
26
|
+
readonly mandatory?: boolean;
|
|
20
27
|
/** Optional sub-actions (addons) with `any` selection behavior. */
|
|
21
28
|
readonly addons: readonly ProtocolActionInfo[];
|
|
22
29
|
}
|
|
@@ -30,6 +37,11 @@ export interface ProtocolGroupActionEntry {
|
|
|
30
37
|
readonly display: string;
|
|
31
38
|
readonly code: string;
|
|
32
39
|
readonly duration?: Duration;
|
|
40
|
+
/**
|
|
41
|
+
* Only meaningful on addon entries. When `true`, the addon is always
|
|
42
|
+
* included with the parent action and is hidden from the consumer UI.
|
|
43
|
+
*/
|
|
44
|
+
readonly mandatory?: boolean;
|
|
33
45
|
/** Optional sub-action entries (addons). */
|
|
34
46
|
readonly addons?: readonly ProtocolGroupActionEntry[];
|
|
35
47
|
}
|
|
@@ -122,7 +134,9 @@ export interface ResolvedProtocol {
|
|
|
122
134
|
*
|
|
123
135
|
* - The selected top-level action gets `precheckBehavior: "yes"`, all others `"no"`.
|
|
124
136
|
* - Within the selected action, each addon sub-action is stamped according to
|
|
125
|
-
* whether its id appears in `selection.addonIds`.
|
|
137
|
+
* whether its id appears in `selection.addonIds`. **Mandatory addons**
|
|
138
|
+
* (`requiredBehavior === 'must'`) are always stamped `"yes"` regardless of
|
|
139
|
+
* the caller-provided ids.
|
|
126
140
|
* - Unselected top-level actions have all their sub-actions stamped as `"no"`.
|
|
127
141
|
*
|
|
128
142
|
* The returned PD is a shallow copy — the original is never mutated.
|
|
@@ -148,8 +162,8 @@ export declare function resolveProtocolSelection(pd: PlanDefinition, selection:
|
|
|
148
162
|
* (one whose actions have been stamped with `precheckBehavior` via
|
|
149
163
|
* {@link configureProtocolGroup}).
|
|
150
164
|
*
|
|
151
|
-
* Falls back to `id === "default"` with
|
|
152
|
-
* `precheckBehavior: "yes"`.
|
|
165
|
+
* Falls back to `id === "default"` with mandatory addons of that default
|
|
166
|
+
* action when no action has `precheckBehavior: "yes"`.
|
|
153
167
|
*
|
|
154
168
|
* @param pd - a (possibly configured) protocol-group PlanDefinition
|
|
155
169
|
* @returns the selection encoded in the PD, or the default selection
|
|
@@ -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,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAC/C;AAED,sDAAsD;AACtD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;I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,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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,iBAAiB,GAC3B,cAAc,CA6BhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,cAAc,EAClB,SAAS,EAAE,iBAAiB,GAC3B,gBAAgB,CA4BlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAE,EAAE,EAAE,cAAc,GAAG,iBAAiB,CAwB5E"}
|
|
@@ -85,7 +85,7 @@ function getProtocolGroupHealthcareServiceReference(pd) {
|
|
|
85
85
|
function buildProtocolGroup(title, entries, existingId, hsReference) {
|
|
86
86
|
const actions = entries.map((e) => {
|
|
87
87
|
var _a;
|
|
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));
|
|
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, addon.mandatory));
|
|
89
89
|
const action = buildAction(e.isDefault ? 'default' : e.id, e.display, e.ref, e.code, e.duration, e.question, e.label);
|
|
90
90
|
// Top-level actions use exactly-one selection behavior
|
|
91
91
|
action.selectionBehavior = 'exactly-one';
|
|
@@ -124,7 +124,9 @@ function buildProtocolGroup(title, entries, existingId, hsReference) {
|
|
|
124
124
|
*
|
|
125
125
|
* - The selected top-level action gets `precheckBehavior: "yes"`, all others `"no"`.
|
|
126
126
|
* - Within the selected action, each addon sub-action is stamped according to
|
|
127
|
-
* whether its id appears in `selection.addonIds`.
|
|
127
|
+
* whether its id appears in `selection.addonIds`. **Mandatory addons**
|
|
128
|
+
* (`requiredBehavior === 'must'`) are always stamped `"yes"` regardless of
|
|
129
|
+
* the caller-provided ids.
|
|
128
130
|
* - Unselected top-level actions have all their sub-actions stamped as `"no"`.
|
|
129
131
|
*
|
|
130
132
|
* The returned PD is a shallow copy — the original is never mutated.
|
|
@@ -149,10 +151,12 @@ function configureProtocolGroup(pd, selection) {
|
|
|
149
151
|
const isSelected = a.id === selection.actionId;
|
|
150
152
|
const subActions = ((_a = a.action) !== null && _a !== void 0 ? _a : []).map((sub) => {
|
|
151
153
|
var _a;
|
|
152
|
-
|
|
154
|
+
const isMandatory = sub.requiredBehavior === 'must';
|
|
155
|
+
const isOn = isSelected && (isMandatory || addonSet.has((_a = sub.id) !== null && _a !== void 0 ? _a : ''));
|
|
156
|
+
return {
|
|
153
157
|
...sub,
|
|
154
|
-
precheckBehavior:
|
|
155
|
-
}
|
|
158
|
+
precheckBehavior: isOn ? 'yes' : 'no'
|
|
159
|
+
};
|
|
156
160
|
});
|
|
157
161
|
return {
|
|
158
162
|
...a,
|
|
@@ -180,7 +184,13 @@ function resolveProtocolSelection(pd, selection) {
|
|
|
180
184
|
}
|
|
181
185
|
const addonSet = new Set(selection.addonIds);
|
|
182
186
|
const resolvedAddons = ((_b = selected.action) !== null && _b !== void 0 ? _b : [])
|
|
183
|
-
.filter((sub) => {
|
|
187
|
+
.filter((sub) => {
|
|
188
|
+
if (!sub.id || !sub.definitionCanonical) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const isMandatory = sub.requiredBehavior === 'must';
|
|
192
|
+
return isMandatory || addonSet.has(sub.id);
|
|
193
|
+
})
|
|
184
194
|
.map((sub) => ({
|
|
185
195
|
protocolRef: sub.definitionCanonical,
|
|
186
196
|
serviceType: getActionServiceCode(sub),
|
|
@@ -200,26 +210,37 @@ function resolveProtocolSelection(pd, selection) {
|
|
|
200
210
|
* (one whose actions have been stamped with `precheckBehavior` via
|
|
201
211
|
* {@link configureProtocolGroup}).
|
|
202
212
|
*
|
|
203
|
-
* Falls back to `id === "default"` with
|
|
204
|
-
* `precheckBehavior: "yes"`.
|
|
213
|
+
* Falls back to `id === "default"` with mandatory addons of that default
|
|
214
|
+
* action when no action has `precheckBehavior: "yes"`.
|
|
205
215
|
*
|
|
206
216
|
* @param pd - a (possibly configured) protocol-group PlanDefinition
|
|
207
217
|
* @returns the selection encoded in the PD, or the default selection
|
|
208
218
|
*/
|
|
209
219
|
function readProtocolSelection(pd) {
|
|
210
|
-
var _a, _b, _c, _d;
|
|
220
|
+
var _a, _b, _c, _d, _e;
|
|
211
221
|
const actions = (_a = pd.action) !== null && _a !== void 0 ? _a : [];
|
|
212
222
|
// Look for an action explicitly marked as prechecked
|
|
213
223
|
const prechecked = actions.find((a) => a.precheckBehavior === 'yes');
|
|
214
224
|
if (prechecked === null || prechecked === void 0 ? void 0 : prechecked.id) {
|
|
215
225
|
const addonIds = ((_b = prechecked.action) !== null && _b !== void 0 ? _b : [])
|
|
216
|
-
.filter((sub) =>
|
|
226
|
+
.filter((sub) => {
|
|
227
|
+
if (!sub.id) {
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
if (sub.requiredBehavior === 'must') {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
return sub.precheckBehavior === 'yes';
|
|
234
|
+
})
|
|
217
235
|
.map((sub) => sub.id);
|
|
218
236
|
return { actionId: prechecked.id, addonIds };
|
|
219
237
|
}
|
|
220
|
-
// Fallback: default action
|
|
238
|
+
// Fallback: default action with its mandatory addons (if any)
|
|
221
239
|
const defaultAction = (_c = actions.find((a) => a.id === 'default')) !== null && _c !== void 0 ? _c : actions[0];
|
|
222
|
-
|
|
240
|
+
const mandatoryAddonIds = ((_d = defaultAction === null || defaultAction === void 0 ? void 0 : defaultAction.action) !== null && _d !== void 0 ? _d : [])
|
|
241
|
+
.filter((sub) => Boolean(sub.id) && sub.requiredBehavior === 'must')
|
|
242
|
+
.map((sub) => sub.id);
|
|
243
|
+
return { actionId: (_e = defaultAction === null || defaultAction === void 0 ? void 0 : defaultAction.id) !== null && _e !== void 0 ? _e : '', addonIds: mandatoryAddonIds };
|
|
223
244
|
}
|
|
224
245
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
|
225
246
|
function getActionServiceCode(action) {
|
|
@@ -253,10 +274,11 @@ function extractActionInfo(a, isDefault) {
|
|
|
253
274
|
protocolCode: getActionServiceCode(a),
|
|
254
275
|
duration: a.timingDuration,
|
|
255
276
|
prechecked: precheckToBool(a.precheckBehavior),
|
|
277
|
+
mandatory: a.requiredBehavior === 'must' ? true : undefined,
|
|
256
278
|
addons: subActions
|
|
257
279
|
};
|
|
258
280
|
}
|
|
259
|
-
function buildAction(id, title, ref, code, duration, question, labelOverride) {
|
|
281
|
+
function buildAction(id, title, ref, code, duration, question, labelOverride, mandatory) {
|
|
260
282
|
const action = {
|
|
261
283
|
id,
|
|
262
284
|
title,
|
|
@@ -274,6 +296,9 @@ function buildAction(id, title, ref, code, duration, question, labelOverride) {
|
|
|
274
296
|
if (labelOverride) {
|
|
275
297
|
action.textEquivalent = labelOverride;
|
|
276
298
|
}
|
|
299
|
+
if (mandatory) {
|
|
300
|
+
action.requiredBehavior = 'must';
|
|
301
|
+
}
|
|
277
302
|
return action;
|
|
278
303
|
}
|
|
279
304
|
//# sourceMappingURL=plan-definition-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-definition-group.js","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":";;AA8DA,0CAIC;AAUD,gDAMC;AAQD,gDASC;AAQD,kDAEC;AAQD,gGAEC;AAaD,gDAiEC;AAoDD,wDA4BC;AAWD,4DA6BC;AAaD,sDAiBC;AA1VD,2CAA8H;AAqD9H,gFAAgF;AAEhF;;;;;GAKG;AACH,SAAgB,eAAe,CAAE,EAAkB;;IACjD,OAAO,CAAC,MAAA,MAAA,EAAE,CAAC,IAAI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G,aAAa,CAAA;IACvC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import type { Duration, PlanDefinition, PlanDefinitionAction } from '@medplum/fhirtypes'\nimport { PD_HEALTHCARE_SERVICE_EXTENSION_URL, PD_TYPE_PROTOCOL_GROUP, PD_TYPE_SYSTEM, SERVICE_TYPE_SYSTEM } from './constants'\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Information about a single action inside a protocol-group PD. */\nexport interface ProtocolActionInfo {\n readonly actionId: string\n readonly isDefault: boolean\n /** Short label for the variant (e.g. \"Helicoidal\") */\n readonly label: string\n /** User-facing question to select this variant */\n readonly question: string\n readonly protocolRef: string\n readonly protocolDisplay: string\n readonly protocolCode: string\n readonly duration?: Duration\n /**\n * Whether this action is pre-selected in a **configured** protocol-group.\n * Set by {@link configureProtocolGroup} via FHIR `precheckBehavior`.\n * `undefined` means the PD has not been configured (use `isDefault` as fallback).\n */\n readonly prechecked?: boolean\n /** Optional sub-actions (addons) with `any` selection behavior. */\n readonly addons: readonly ProtocolActionInfo[]\n}\n\n/** Entry used to build a protocol-group PD action. */\nexport interface ProtocolGroupActionEntry {\n readonly id: string\n readonly isDefault: boolean\n readonly label: string\n readonly question: string\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n /** Optional sub-action entries (addons). */\n readonly addons?: readonly ProtocolGroupActionEntry[]\n}\n\n// ─── Backward-compat aliases ────────────────────────────────────────────────\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport type ProtocolVariantInfo = ProtocolActionInfo\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport interface ProtocolDefaultInfo {\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n}\n\n// ─── Detection ───────────────────────────────────────────────────────────────\n\n/**\n * Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).\n *\n * @param pd - the PlanDefinition to check\n * @returns whether the PlanDefinition is a protocol-group\n */\nexport function isProtocolGroup (pd: PlanDefinition): boolean {\n return (pd.type?.coding ?? []).some(\n (c) => c.system === PD_TYPE_SYSTEM && c.code === PD_TYPE_PROTOCOL_GROUP\n )\n}\n\n// ─── Extraction ──────────────────────────────────────────────────────────────\n\n/**\n * Extracts all protocol actions from a protocol-group PD (preserving order).\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of action info objects (the one with `isDefault === true` is the default)\n */\nexport function getProtocolActions (pd: PlanDefinition): ProtocolActionInfo[] {\n return (pd.action ?? [])\n .filter((a): a is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(a.definitionCanonical)\n )\n .map((a) => extractActionInfo(a, a.id === 'default'))\n}\n\n/**\n * Extracts the default protocol action from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns the default protocol info, or undefined if not found\n */\nexport function getDefaultProtocol (pd: PlanDefinition): ProtocolDefaultInfo | undefined {\n const action = (pd.action ?? []).find((a) => a.id === 'default')\n if (!action?.definitionCanonical) { return undefined }\n return {\n ref: action.definitionCanonical,\n display: action.title ?? '',\n code: getActionServiceCode(action),\n duration: action.timingDuration\n }\n}\n\n/**\n * Extracts the non-default variant actions from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of variant info objects\n */\nexport function getProtocolVariants (pd: PlanDefinition): ProtocolActionInfo[] {\n return getProtocolActions(pd).filter((a) => !a.isDefault)\n}\n\n/**\n * Extracts the HealthcareService reference linked to a protocol-group PD.\n *\n * @param pd - the PlanDefinition to inspect\n * @returns the referenced HealthcareService, if present\n */\nexport function getProtocolGroupHealthcareServiceReference (pd: PlanDefinition): string | undefined {\n return pd.extension?.find((e) => e.url === PD_HEALTHCARE_SERVICE_EXTENSION_URL)?.valueReference?.reference\n}\n\n// ─── Construction ────────────────────────────────────────────────────────────\n\n/**\n * Builds a protocol-group PlanDefinition resource.\n *\n * @param title - human-readable title for the group (e.g. \"TAC de hombro — Protocolos\")\n * @param entries - protocol action entries (at least one should have `isDefault: true`)\n * @param existingId - optional ID to reuse when updating an existing group PD\n * @param hsReference - optional HealthcareService reference stored on the group PD\n * @returns the constructed protocol-group PlanDefinition\n */\nexport function buildProtocolGroup (\n title: string,\n entries: readonly ProtocolGroupActionEntry[],\n existingId?: string,\n hsReference?: string\n): PlanDefinition {\n const actions: PlanDefinitionAction[] = entries.map((e) => {\n const subActions = (e.addons ?? []).map((addon) =>\n buildAction(\n addon.id,\n addon.display,\n addon.ref,\n addon.code,\n addon.duration,\n addon.question,\n addon.label\n )\n )\n\n const action = buildAction(\n e.isDefault ? 'default' : e.id,\n e.display,\n e.ref,\n e.code,\n e.duration,\n e.question,\n e.label\n )\n\n // Top-level actions use exactly-one selection behavior\n action.selectionBehavior = 'exactly-one'\n\n if (subActions.length > 0) {\n action.action = subActions\n // When an action has sub-actions (addons), they use `any` grouping\n action.groupingBehavior = 'logical-group'\n }\n\n return action\n })\n\n const pd: PlanDefinition = {\n resourceType: 'PlanDefinition',\n status: 'active',\n title,\n type: {\n coding: [{ system: PD_TYPE_SYSTEM, code: PD_TYPE_PROTOCOL_GROUP }]\n },\n action: actions\n }\n\n if (hsReference) {\n pd.extension = [\n {\n url: PD_HEALTHCARE_SERVICE_EXTENSION_URL,\n valueReference: { reference: hsReference }\n }\n ]\n }\n\n if (existingId) {\n pd.id = existingId\n }\n\n return pd\n}\n\n// ─── Selection / Configuration ──────────────────────────────────────────────\n\n/**\n * A user's selection within a protocol-group PlanDefinition.\n *\n * Represents the patient's choices when configuring a HealthcareService:\n * one main action (from the `exactly-one` selection) plus zero or more\n * addon sub-actions.\n */\nexport interface ProtocolSelection {\n /** The `action.id` of the chosen top-level action. */\n readonly actionId: string\n /** The `action.id`s of toggled-on addon sub-actions within the selected action. */\n readonly addonIds: readonly string[]\n}\n\n/** Resolved booking parameters for a single protocol action. */\nexport interface ResolvedProtocolAction {\n /** The `definitionCanonical` reference to the order-set PlanDefinition. */\n readonly protocolRef: string\n /** The service-type code for slot searching / billing. */\n readonly serviceType: string\n /** Estimated duration for this action. */\n readonly duration?: Duration\n}\n\n/** Fully resolved booking parameters produced by {@link resolveProtocolSelection}. */\nexport interface ResolvedProtocol {\n /** Resolved main action. */\n readonly main: ResolvedProtocolAction\n /** Resolved addon actions (empty when none selected). */\n readonly addons: readonly ResolvedProtocolAction[]\n}\n\n/**\n * Returns a **configured** copy of a protocol-group PlanDefinition by stamping\n * `precheckBehavior` on every action according to the given selection.\n *\n * - The selected top-level action gets `precheckBehavior: \"yes\"`, all others `\"no\"`.\n * - Within the selected action, each addon sub-action is stamped according to\n * whether its id appears in `selection.addonIds`.\n * - Unselected top-level actions have all their sub-actions stamped as `\"no\"`.\n *\n * The returned PD is a shallow copy — the original is never mutated.\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns a new PlanDefinition with `precheckBehavior` set on every action\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function configureProtocolGroup (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): PlanDefinition {\n const actions = pd.action ?? []\n const found = actions.some((a) => a.id === selection.actionId)\n if (!found) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n\n return {\n ...pd,\n action: actions.map((a) => {\n const isSelected = a.id === selection.actionId\n const subActions = (a.action ?? []).map((sub) => ({\n ...sub,\n precheckBehavior: (isSelected && addonSet.has(sub.id ?? '')) ? 'yes' as const : 'no' as const\n }))\n\n return {\n ...a,\n precheckBehavior: isSelected ? 'yes' as const : 'no' as const,\n ...(a.action ? { action: subActions } : {})\n }\n })\n }\n}\n\n/**\n * Resolves a protocol-group PlanDefinition + selection into concrete booking\n * parameters (service-type codes, definitionCanonical references, durations).\n *\n * @param pd - a protocol-group PlanDefinition\n * @param selection - the user's action + addon selection\n * @returns the resolved main + addon protocol references and codes\n * @throws if the selected `actionId` is not found in the PD\n */\nexport function resolveProtocolSelection (\n pd: PlanDefinition,\n selection: ProtocolSelection\n): ResolvedProtocol {\n const actions = pd.action ?? []\n const selected = actions.find((a) => a.id === selection.actionId)\n if (!selected?.definitionCanonical) {\n throw new Error(`Action \"${selection.actionId}\" not found in protocol-group PlanDefinition`)\n }\n\n const addonSet = new Set(selection.addonIds)\n const resolvedAddons: ResolvedProtocolAction[] = (selected.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string; id: string } =>\n Boolean(sub.id) && addonSet.has(sub.id ?? '') && Boolean(sub.definitionCanonical)\n )\n .map((sub) => ({\n protocolRef: sub.definitionCanonical,\n serviceType: getActionServiceCode(sub),\n duration: sub.timingDuration\n }))\n\n return {\n main: {\n protocolRef: selected.definitionCanonical,\n serviceType: getActionServiceCode(selected),\n duration: selected.timingDuration\n },\n addons: resolvedAddons\n }\n}\n\n/**\n * Reads the current selection from a **configured** protocol-group PlanDefinition\n * (one whose actions have been stamped with `precheckBehavior` via\n * {@link configureProtocolGroup}).\n *\n * Falls back to `id === \"default\"` with no addons if no action has\n * `precheckBehavior: \"yes\"`.\n *\n * @param pd - a (possibly configured) protocol-group PlanDefinition\n * @returns the selection encoded in the PD, or the default selection\n */\nexport function readProtocolSelection (pd: PlanDefinition): ProtocolSelection {\n const actions = pd.action ?? []\n\n // Look for an action explicitly marked as prechecked\n const prechecked = actions.find((a) => a.precheckBehavior === 'yes')\n if (prechecked?.id) {\n const addonIds = (prechecked.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { id: string } =>\n sub.precheckBehavior === 'yes' && Boolean(sub.id)\n )\n .map((sub) => sub.id)\n return { actionId: prechecked.id, addonIds }\n }\n\n // Fallback: default action, no addons\n const defaultAction = actions.find((a) => a.id === 'default') ?? actions[0]\n return { actionId: defaultAction?.id ?? '', addonIds: [] }\n}\n\n// ─── Internal helpers ───────────────────────────────────────────────────────\n\nfunction getActionServiceCode (action: PlanDefinitionAction): string {\n const coding = (action.code ?? [])\n .flatMap((cc) => cc.coding ?? [])\n .find((c) => c.system === SERVICE_TYPE_SYSTEM)\n return coding?.code ?? ''\n}\n\nfunction precheckToBool (value: string | undefined): boolean | undefined {\n if (value === 'yes') { return true }\n if (value === 'no') { return false }\n return undefined\n}\n\nfunction extractActionInfo (a: PlanDefinitionAction & { definitionCanonical: string }, isDefault: boolean): ProtocolActionInfo {\n const subActions = (a.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(sub.definitionCanonical)\n )\n .map((sub) => extractActionInfo(sub, false))\n\n return {\n actionId: a.id ?? '',\n isDefault,\n label: a.textEquivalent ?? a.title ?? '',\n question: a.description ?? '',\n protocolRef: a.definitionCanonical,\n protocolDisplay: a.title ?? '',\n protocolCode: getActionServiceCode(a),\n duration: a.timingDuration,\n prechecked: precheckToBool(a.precheckBehavior),\n addons: subActions\n }\n}\n\nfunction buildAction (\n id: string,\n title: string,\n ref: string,\n code: string,\n duration?: Duration,\n question?: string,\n labelOverride?: string\n): PlanDefinitionAction {\n const action: PlanDefinitionAction = {\n id,\n title,\n definitionCanonical: ref\n }\n if (code) {\n action.code = [{ coding: [{ system: SERVICE_TYPE_SYSTEM, code }] }]\n }\n if (duration) {\n action.timingDuration = duration\n }\n if (question) {\n action.description = question\n }\n if (labelOverride) {\n action.textEquivalent = labelOverride\n }\n return action\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plan-definition-group.js","sourceRoot":"","sources":["../src/plan-definition-group.ts"],"names":[],"mappings":";;AA0EA,0CAIC;AAUD,gDAMC;AAQD,gDASC;AAQD,kDAEC;AAQD,gGAEC;AAaD,gDAkEC;AAsDD,wDAgCC;AAWD,4DA+BC;AAaD,sDAwBC;AAtXD,2CAA8H;AAiE9H,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,0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,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC3D,MAAM,EAAE,UAAU;KACnB,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAClB,EAAU,EACV,KAAa,EACb,GAAW,EACX,IAAY,EACZ,QAAmB,EACnB,QAAiB,EACjB,aAAsB,EACtB,SAAmB;IAEnB,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,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAA;IAClC,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import type { Duration, PlanDefinition, PlanDefinitionAction } from '@medplum/fhirtypes'\nimport { PD_HEALTHCARE_SERVICE_EXTENSION_URL, PD_TYPE_PROTOCOL_GROUP, PD_TYPE_SYSTEM, SERVICE_TYPE_SYSTEM } from './constants'\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Information about a single action inside a protocol-group PD. */\nexport interface ProtocolActionInfo {\n readonly actionId: string\n readonly isDefault: boolean\n /** Short label for the variant (e.g. \"Helicoidal\") */\n readonly label: string\n /** User-facing question to select this variant */\n readonly question: string\n readonly protocolRef: string\n readonly protocolDisplay: string\n readonly protocolCode: string\n readonly duration?: Duration\n /**\n * Whether this action is pre-selected in a **configured** protocol-group.\n * Set by {@link configureProtocolGroup} via FHIR `precheckBehavior`.\n * `undefined` means the PD has not been configured (use `isDefault` as fallback).\n */\n readonly prechecked?: boolean\n /**\n * Only meaningful on addon (sub-action) entries. When `true`, the addon is\n * always included whenever its parent action is selected — it is not shown\n * as a togglable option in the consumer UI. Encoded in FHIR as\n * `PlanDefinitionAction.requiredBehavior === 'must'`.\n */\n readonly mandatory?: 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 /**\n * Only meaningful on addon entries. When `true`, the addon is always\n * included with the parent action and is hidden from the consumer UI.\n */\n readonly mandatory?: boolean\n /** Optional sub-action entries (addons). */\n readonly addons?: readonly ProtocolGroupActionEntry[]\n}\n\n// ─── Backward-compat aliases ────────────────────────────────────────────────\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport type ProtocolVariantInfo = ProtocolActionInfo\n\n/** @deprecated Use {@link ProtocolActionInfo} instead. */\nexport interface ProtocolDefaultInfo {\n readonly ref: string\n readonly display: string\n readonly code: string\n readonly duration?: Duration\n}\n\n// ─── Detection ───────────────────────────────────────────────────────────────\n\n/**\n * Returns `true` if the PlanDefinition is a protocol-group (wrapping multiple concrete PDs).\n *\n * @param pd - the PlanDefinition to check\n * @returns whether the PlanDefinition is a protocol-group\n */\nexport function isProtocolGroup (pd: PlanDefinition): boolean {\n return (pd.type?.coding ?? []).some(\n (c) => c.system === PD_TYPE_SYSTEM && c.code === PD_TYPE_PROTOCOL_GROUP\n )\n}\n\n// ─── Extraction ──────────────────────────────────────────────────────────────\n\n/**\n * Extracts all protocol actions from a protocol-group PD (preserving order).\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of action info objects (the one with `isDefault === true` is the default)\n */\nexport function getProtocolActions (pd: PlanDefinition): ProtocolActionInfo[] {\n return (pd.action ?? [])\n .filter((a): a is PlanDefinitionAction & { definitionCanonical: string } =>\n Boolean(a.definitionCanonical)\n )\n .map((a) => extractActionInfo(a, a.id === 'default'))\n}\n\n/**\n * Extracts the default protocol action from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns the default protocol info, or undefined if not found\n */\nexport function getDefaultProtocol (pd: PlanDefinition): ProtocolDefaultInfo | undefined {\n const action = (pd.action ?? []).find((a) => a.id === 'default')\n if (!action?.definitionCanonical) { return undefined }\n return {\n ref: action.definitionCanonical,\n display: action.title ?? '',\n code: getActionServiceCode(action),\n duration: action.timingDuration\n }\n}\n\n/**\n * Extracts the non-default variant actions from a protocol-group PD.\n *\n * @param pd - the protocol-group PlanDefinition\n * @returns array of variant info objects\n */\nexport function getProtocolVariants (pd: PlanDefinition): ProtocolActionInfo[] {\n return getProtocolActions(pd).filter((a) => !a.isDefault)\n}\n\n/**\n * Extracts the HealthcareService reference linked to a protocol-group PD.\n *\n * @param pd - the PlanDefinition to inspect\n * @returns the referenced HealthcareService, if present\n */\nexport function getProtocolGroupHealthcareServiceReference (pd: PlanDefinition): string | undefined {\n return pd.extension?.find((e) => e.url === PD_HEALTHCARE_SERVICE_EXTENSION_URL)?.valueReference?.reference\n}\n\n// ─── Construction ────────────────────────────────────────────────────────────\n\n/**\n * Builds a protocol-group PlanDefinition resource.\n *\n * @param title - human-readable title for the group (e.g. \"TAC de hombro — Protocolos\")\n * @param entries - protocol action entries (at least one should have `isDefault: true`)\n * @param existingId - optional ID to reuse when updating an existing group PD\n * @param hsReference - optional HealthcareService reference stored on the group PD\n * @returns the constructed protocol-group PlanDefinition\n */\nexport function buildProtocolGroup (\n title: string,\n entries: readonly ProtocolGroupActionEntry[],\n existingId?: string,\n hsReference?: string\n): PlanDefinition {\n const actions: PlanDefinitionAction[] = entries.map((e) => {\n const subActions = (e.addons ?? []).map((addon) =>\n buildAction(\n addon.id,\n addon.display,\n addon.ref,\n addon.code,\n addon.duration,\n addon.question,\n addon.label,\n addon.mandatory\n )\n )\n\n const action = buildAction(\n e.isDefault ? 'default' : e.id,\n e.display,\n e.ref,\n e.code,\n e.duration,\n e.question,\n e.label\n )\n\n // Top-level actions use exactly-one selection behavior\n action.selectionBehavior = 'exactly-one'\n\n if (subActions.length > 0) {\n action.action = subActions\n // When an action has sub-actions (addons), they use `any` grouping\n action.groupingBehavior = 'logical-group'\n }\n\n return action\n })\n\n const pd: PlanDefinition = {\n resourceType: 'PlanDefinition',\n status: 'active',\n title,\n type: {\n coding: [{ system: PD_TYPE_SYSTEM, code: PD_TYPE_PROTOCOL_GROUP }]\n },\n action: actions\n }\n\n if (hsReference) {\n pd.extension = [\n {\n url: PD_HEALTHCARE_SERVICE_EXTENSION_URL,\n valueReference: { reference: hsReference }\n }\n ]\n }\n\n if (existingId) {\n pd.id = existingId\n }\n\n return pd\n}\n\n// ─── Selection / Configuration ──────────────────────────────────────────────\n\n/**\n * A user's selection within a protocol-group PlanDefinition.\n *\n * Represents the patient's choices when configuring a HealthcareService:\n * one main action (from the `exactly-one` selection) plus zero or more\n * addon sub-actions.\n */\nexport interface ProtocolSelection {\n /** The `action.id` of the chosen top-level action. */\n readonly actionId: string\n /** The `action.id`s of toggled-on addon sub-actions within the selected action. */\n readonly addonIds: readonly string[]\n}\n\n/** Resolved booking parameters for a single protocol action. */\nexport interface ResolvedProtocolAction {\n /** The `definitionCanonical` reference to the order-set PlanDefinition. */\n readonly protocolRef: string\n /** The service-type code for slot searching / billing. */\n readonly serviceType: string\n /** Estimated duration for this action. */\n readonly duration?: Duration\n}\n\n/** Fully resolved booking parameters produced by {@link resolveProtocolSelection}. */\nexport interface ResolvedProtocol {\n /** Resolved main action. */\n readonly main: ResolvedProtocolAction\n /** Resolved addon actions (empty when none selected). */\n readonly addons: readonly ResolvedProtocolAction[]\n}\n\n/**\n * Returns a **configured** copy of a protocol-group PlanDefinition by stamping\n * `precheckBehavior` on every action according to the given selection.\n *\n * - The selected top-level action gets `precheckBehavior: \"yes\"`, all others `\"no\"`.\n * - Within the selected action, each addon sub-action is stamped according to\n * whether its id appears in `selection.addonIds`. **Mandatory addons**\n * (`requiredBehavior === 'must'`) are always stamped `\"yes\"` regardless of\n * the caller-provided ids.\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 const isMandatory = sub.requiredBehavior === 'must'\n const isOn = isSelected && (isMandatory || addonSet.has(sub.id ?? ''))\n return {\n ...sub,\n precheckBehavior: isOn ? 'yes' as const : 'no' as const\n }\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 if (!sub.id || !sub.definitionCanonical) { return false }\n const isMandatory = sub.requiredBehavior === 'must'\n return isMandatory || addonSet.has(sub.id)\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 mandatory addons of that default\n * action when no action has `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 if (!sub.id) { return false }\n if (sub.requiredBehavior === 'must') { return true }\n return sub.precheckBehavior === 'yes'\n })\n .map((sub) => sub.id)\n return { actionId: prechecked.id, addonIds }\n }\n\n // Fallback: default action with its mandatory addons (if any)\n const defaultAction = actions.find((a) => a.id === 'default') ?? actions[0]\n const mandatoryAddonIds = (defaultAction?.action ?? [])\n .filter((sub): sub is PlanDefinitionAction & { id: string } =>\n Boolean(sub.id) && sub.requiredBehavior === 'must'\n )\n .map((sub) => sub.id)\n return { actionId: defaultAction?.id ?? '', addonIds: mandatoryAddonIds }\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 mandatory: a.requiredBehavior === 'must' ? true : undefined,\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 mandatory?: boolean\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 if (mandatory) {\n action.requiredBehavior = 'must'\n }\n return action\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../src/search/normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA4CH;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAuBlE"}
|
|
@@ -47,7 +47,11 @@ const ABBREVIATIONS = [
|
|
|
47
47
|
[/\bnutri\b/g, 'nutricion'],
|
|
48
48
|
[/\blab\b/g, 'laboratorio'],
|
|
49
49
|
[/\bpat\b/g, 'patologia'],
|
|
50
|
-
[/\brad\b/g, 'radiologia']
|
|
50
|
+
[/\brad\b/g, 'radiologia'],
|
|
51
|
+
[/\btv\b/g, 'transvaginal'],
|
|
52
|
+
[/\becodoppler\b/g, 'doppler'],
|
|
53
|
+
[/\becodopler\b/g, 'doppler'],
|
|
54
|
+
[/\becodopple\b/g, 'doppler']
|
|
51
55
|
];
|
|
52
56
|
/**
|
|
53
57
|
* Normalise a text string for storage or query comparison.
|