@kenyaemr/esm-ward-app 8.5.4-pre.96 → 8.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/dist/1033.js +1 -0
- package/dist/1033.js.map +1 -0
- package/dist/1364.js +1 -0
- package/dist/1364.js.map +1 -0
- package/dist/1480.js +1 -0
- package/dist/1480.js.map +1 -0
- package/dist/1613.css +1 -0
- package/dist/1613.css.map +1 -0
- package/dist/1613.js +1 -0
- package/dist/1613.js.map +1 -0
- package/dist/1646.js +1 -0
- package/dist/1646.js.map +1 -0
- package/dist/1744.js +1 -0
- package/dist/1744.js.map +1 -0
- package/dist/1869.js +1 -0
- package/dist/1869.js.map +1 -0
- package/dist/1877.js +1 -0
- package/dist/1877.js.map +1 -0
- package/dist/193.js +1 -0
- package/dist/193.js.map +1 -0
- package/dist/1992.css +1 -0
- package/dist/1992.css.map +1 -0
- package/dist/1992.js +1 -0
- package/dist/1992.js.map +1 -0
- package/dist/2007.js +1 -0
- package/dist/2007.js.map +1 -0
- package/dist/2101.css +1 -0
- package/dist/2101.css.map +1 -0
- package/dist/2101.js +1 -0
- package/dist/2101.js.map +1 -0
- package/dist/2304.js +1 -0
- package/dist/2304.js.map +1 -0
- package/dist/2317.js +1 -0
- package/dist/2317.js.map +1 -0
- package/dist/2326.css +1 -0
- package/dist/2326.css.map +1 -0
- package/dist/2326.js +1 -0
- package/dist/2326.js.map +1 -0
- package/dist/2416.js +1 -0
- package/dist/2416.js.map +1 -0
- package/dist/2446.css +1 -0
- package/dist/2446.css.map +1 -0
- package/dist/2446.js +1 -0
- package/dist/2446.js.map +1 -0
- package/dist/2724.css +1 -0
- package/dist/2724.css.map +1 -0
- package/dist/2724.js +1 -0
- package/dist/2724.js.map +1 -0
- package/dist/2764.js +1 -0
- package/dist/2764.js.map +1 -0
- package/dist/282.js +1 -0
- package/dist/282.js.map +1 -0
- package/dist/2881.js +1 -0
- package/dist/2881.js.map +1 -0
- package/dist/297.js +1 -0
- package/dist/297.js.map +1 -0
- package/dist/2988.js +1 -0
- package/dist/2988.js.map +1 -0
- package/dist/3012.css +1 -0
- package/dist/3012.css.map +1 -0
- package/dist/3012.js +43 -0
- package/dist/3012.js.map +1 -0
- package/dist/3253.css +1 -0
- package/dist/3253.css.map +1 -0
- package/dist/3253.js +1 -0
- package/dist/3253.js.map +1 -0
- package/dist/3276.css +1 -0
- package/dist/3276.css.map +1 -0
- package/dist/3276.js +1 -0
- package/dist/3276.js.map +1 -0
- package/dist/3378.js +1 -0
- package/dist/3378.js.map +1 -0
- package/dist/3428.css +1 -0
- package/dist/3428.css.map +1 -0
- package/dist/3428.js +1 -0
- package/dist/3428.js.map +1 -0
- package/dist/3446.css +1 -0
- package/dist/3446.css.map +1 -0
- package/dist/3446.js +1 -0
- package/dist/3446.js.map +1 -0
- package/dist/3720.js +1 -0
- package/dist/3720.js.map +1 -0
- package/dist/3824.js +1 -0
- package/dist/3824.js.map +1 -0
- package/dist/3877.js +1 -0
- package/dist/3877.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/3989.js +1 -0
- package/dist/3989.js.map +1 -0
- package/dist/4106.js +1 -0
- package/dist/4106.js.map +1 -0
- package/dist/4111.js +1 -0
- package/dist/4111.js.map +1 -0
- package/dist/4145.js +1 -0
- package/dist/4145.js.map +1 -0
- package/dist/4162.js +1 -0
- package/dist/4162.js.map +1 -0
- package/dist/4266.css +1 -0
- package/dist/4266.css.map +1 -0
- package/dist/4266.js +1 -0
- package/dist/4266.js.map +1 -0
- package/dist/4304.js +1 -0
- package/dist/4304.js.map +1 -0
- package/dist/434.js +1 -0
- package/dist/434.js.map +1 -0
- package/dist/4348.js +1 -0
- package/dist/4348.js.map +1 -0
- package/dist/4383.js +1 -0
- package/dist/4383.js.map +1 -0
- package/dist/4658.js +1 -0
- package/dist/4658.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/4777.js +1 -0
- package/dist/4777.js.map +1 -0
- package/dist/4847.css +1 -0
- package/dist/4847.css.map +1 -0
- package/dist/4847.js +1 -0
- package/dist/4847.js.map +1 -0
- package/dist/4883.css +1 -0
- package/dist/4883.css.map +1 -0
- package/dist/4883.js +1 -0
- package/dist/4883.js.map +1 -0
- package/dist/502.js +1 -0
- package/dist/502.js.map +1 -0
- package/dist/5050.css +1 -0
- package/dist/5050.css.map +1 -0
- package/dist/5050.js +1 -0
- package/dist/5050.js.map +1 -0
- package/dist/5060.css +1 -0
- package/dist/5060.css.map +1 -0
- package/dist/5060.js +1 -0
- package/dist/5060.js.map +1 -0
- package/dist/5117.js +1 -0
- package/dist/5117.js.map +1 -0
- package/dist/5132.js +1 -0
- package/dist/5132.js.map +1 -0
- package/dist/5145.js +1 -0
- package/dist/5145.js.map +1 -0
- package/dist/5181.js +1 -0
- package/dist/5181.js.map +1 -0
- package/dist/5460.css +1 -0
- package/dist/5460.css.map +1 -0
- package/dist/5460.js +1 -0
- package/dist/5460.js.map +1 -0
- package/dist/5493.css +1 -0
- package/dist/5493.css.map +1 -0
- package/dist/5493.js +1 -0
- package/dist/5493.js.map +1 -0
- package/dist/5503.js +1 -0
- package/dist/5503.js.map +1 -0
- package/dist/5576.js +1 -0
- package/dist/5576.js.map +1 -0
- package/dist/5591.css +1 -0
- package/dist/5591.css.map +1 -0
- package/dist/5591.js +1 -0
- package/dist/5591.js.map +1 -0
- package/dist/5644.js +1 -0
- package/dist/5644.js.map +1 -0
- package/dist/5650.js +1 -0
- package/dist/5650.js.map +1 -0
- package/dist/5697.js +1 -0
- package/dist/5697.js.map +1 -0
- package/dist/5862.css +1 -0
- package/dist/5862.css.map +1 -0
- package/dist/5862.js +1 -0
- package/dist/5862.js.map +1 -0
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/5976.js +1 -0
- package/dist/5976.js.map +1 -0
- package/dist/6047.js +1 -0
- package/dist/6047.js.map +1 -0
- package/dist/6079.css +1 -0
- package/dist/6079.css.map +1 -0
- package/dist/6079.js +1 -0
- package/dist/6079.js.map +1 -0
- package/dist/6126.js +1 -0
- package/dist/6126.js.map +1 -0
- package/dist/6196.js +1 -0
- package/dist/6196.js.map +1 -0
- package/dist/6358.js +1 -0
- package/dist/6358.js.map +1 -0
- package/dist/636.js +1 -0
- package/dist/636.js.map +1 -0
- package/dist/6371.js +1 -0
- package/dist/6371.js.map +1 -0
- package/dist/6377.js +1 -0
- package/dist/6377.js.map +1 -0
- package/dist/6380.css +1 -0
- package/dist/6380.css.map +1 -0
- package/dist/6380.js +1 -0
- package/dist/6380.js.map +1 -0
- package/dist/6444.js +1 -0
- package/dist/6444.js.map +1 -0
- package/dist/6482.css +1 -0
- package/dist/6482.css.map +1 -0
- package/dist/6482.js +1 -0
- package/dist/6482.js.map +1 -0
- package/dist/6508.js +1 -0
- package/dist/6508.js.map +1 -0
- package/dist/6703.css +1 -0
- package/dist/6703.css.map +1 -0
- package/dist/6703.js +1 -0
- package/dist/6703.js.map +1 -0
- package/dist/6724.js +1 -0
- package/dist/6724.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/6904.js +1 -0
- package/dist/6904.js.map +1 -0
- package/dist/7045.js +1 -0
- package/dist/7045.js.map +1 -0
- package/dist/7175.js +1 -0
- package/dist/7175.js.map +1 -0
- package/dist/7240.css +1 -0
- package/dist/7240.css.map +1 -0
- package/dist/7240.js +1 -0
- package/dist/7240.js.map +1 -0
- package/dist/7683.js +1 -0
- package/dist/7683.js.map +1 -0
- package/dist/7742.js +1 -0
- package/dist/7742.js.map +1 -0
- package/dist/7849.js +1 -0
- package/dist/7849.js.map +1 -0
- package/dist/7891.css +1 -0
- package/dist/7891.css.map +1 -0
- package/dist/7891.js +1 -0
- package/dist/7891.js.map +1 -0
- package/dist/7912.js +1 -0
- package/dist/7912.js.map +1 -0
- package/dist/7984.js +1 -0
- package/dist/7984.js.map +1 -0
- package/dist/8202.js +20 -0
- package/dist/8202.js.map +1 -0
- package/dist/8302.css +1 -0
- package/dist/8302.css.map +1 -0
- package/dist/8302.js +1 -0
- package/dist/8302.js.map +1 -0
- package/dist/8358.js +1 -0
- package/dist/8358.js.map +1 -0
- package/dist/8359.js +1 -0
- package/dist/8359.js.map +1 -0
- package/dist/8448.css +1 -0
- package/dist/8448.css.map +1 -0
- package/dist/8448.js +1 -0
- package/dist/8448.js.map +1 -0
- package/dist/8502.js +1 -0
- package/dist/8502.js.map +1 -0
- package/dist/8695.js +1 -0
- package/dist/8695.js.map +1 -0
- package/dist/8923.css +1 -0
- package/dist/8923.css.map +1 -0
- package/dist/8923.js +24 -0
- package/dist/8923.js.map +1 -0
- package/dist/8990.js +1 -0
- package/dist/8990.js.map +1 -0
- package/dist/9011.js +1 -0
- package/dist/9011.js.map +1 -0
- package/dist/903.js +1 -0
- package/dist/903.js.map +1 -0
- package/dist/9049.js +1 -0
- package/dist/9049.js.map +1 -0
- package/dist/9061.js +1 -0
- package/dist/9061.js.map +1 -0
- package/dist/9072.js +1 -0
- package/dist/9072.js.map +1 -0
- package/dist/9080.css +1 -0
- package/dist/9080.css.map +1 -0
- package/dist/9080.js +1 -0
- package/dist/9080.js.map +1 -0
- package/dist/9124.css +1 -0
- package/dist/9124.css.map +1 -0
- package/dist/9124.js +1 -0
- package/dist/9124.js.map +1 -0
- package/dist/9143.js +1 -0
- package/dist/9143.js.map +1 -0
- package/dist/9301.js +1 -0
- package/dist/9301.js.map +1 -0
- package/dist/9309.css +1 -0
- package/dist/9309.css.map +1 -0
- package/dist/9427.js +1 -0
- package/dist/9427.js.map +1 -0
- package/dist/9456.css +1 -0
- package/dist/9456.css.map +1 -0
- package/dist/9456.js +1 -0
- package/dist/9456.js.map +1 -0
- package/dist/9712.js +1 -0
- package/dist/9712.js.map +1 -0
- package/dist/9771.js +1 -0
- package/dist/9771.js.map +1 -0
- package/dist/9806.js +1 -0
- package/dist/9806.js.map +1 -0
- package/dist/9875.css +1 -0
- package/dist/9875.css.map +1 -0
- package/dist/9875.js +60 -0
- package/dist/9875.js.map +1 -0
- package/dist/9926.css +1 -0
- package/dist/9926.css.map +1 -0
- package/dist/9926.js +1 -0
- package/dist/9926.js.map +1 -0
- package/dist/9976.css +1 -0
- package/dist/9976.css.map +1 -0
- package/dist/9976.js +1 -0
- package/dist/9976.js.map +1 -0
- package/dist/kenyaemr-esm-ward-app.js +3 -5
- package/dist/kenyaemr-esm-ward-app.js.buildmanifest.json +1137 -943
- package/dist/kenyaemr-esm-ward-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +5 -4
- package/rspack.config.js +3 -1
- package/src/autosuggest/autosuggest.component.tsx +203 -0
- package/src/autosuggest/autosuggest.scss +75 -0
- package/src/autosuggest/patient-search-info.component.tsx +40 -0
- package/src/autosuggest/patient-search-info.scss +37 -0
- package/src/autosuggest/search-empty-state.component.tsx +27 -0
- package/src/autosuggest/search-empty-state.scss +18 -0
- package/src/billing/create-bill.resource.ts +147 -0
- package/src/billing/create-bill.scss +122 -0
- package/src/billing/create-bill.workspace.tsx +468 -0
- package/src/config-schema.ts +224 -5
- package/src/declarations.d.ts +1 -0
- package/src/discharge-printouts/discharge-printout.preview-modal.scss +21 -0
- package/src/discharge-printouts/discharge-printout.preview-modal.tsx +67 -21
- package/src/discharge-printouts/discharge-printout.resource.ts +100 -45
- package/src/discharge-printouts/discharge-printouts.scss +9 -1
- package/src/discharge-printouts/discharge-summary.tsx +76 -50
- package/src/discharge-printouts/investigations-and-procedures.scss +48 -0
- package/src/discharge-printouts/investigrations-and-procedures.components.tsx +134 -0
- package/src/discharge-printouts/lab-results.tsx +1 -2
- package/src/discharge-printouts/use-print-preview.ts +35 -0
- package/src/hooks/critical-care-ward.utils.ts +136 -0
- package/src/hooks/use-patient-summary.tsx +101 -0
- package/src/hooks/useCriticalCareWardTab.ts +94 -0
- package/src/hooks/useEbolaIsolationSuspects.test.ts +24 -0
- package/src/hooks/useEbolaIsolationSuspects.ts +51 -0
- package/src/hooks/useFacilityRegistry.ts +32 -0
- package/src/hooks/useIpdDischargeEncounter.ts +3 -0
- package/src/hooks/useIsIsolationWard.ts +51 -0
- package/src/hooks/useSelectableWards.ts +72 -0
- package/src/hooks/useSummaryMetrics.ts +14 -4
- package/src/hooks/useWardPatientGrouping.ts +4 -4
- package/src/in-patient/admission-request.component.tsx +1 -1
- package/src/in-patient/bloodTransfusion/blood-transfusion-dashboard.component.tsx +15 -0
- package/src/in-patient/bloodTransfusion/components/blood-transfusion-chart.component.tsx +635 -0
- package/src/in-patient/bloodTransfusion/components/blood-transfusion-form.component.tsx +849 -0
- package/src/in-patient/bloodTransfusion/components/blood-transfusion.scss +741 -0
- package/src/in-patient/bloodTransfusion/components/provider-search.component.tsx +111 -0
- package/src/in-patient/bloodTransfusion/components/provider-search.scss +49 -0
- package/src/in-patient/bloodTransfusion/components/transfusion-time-picker.component.tsx +231 -0
- package/src/in-patient/bloodTransfusion/components/transfusion-time-picker.scss +142 -0
- package/src/in-patient/bloodTransfusion/config/blood-transfusion.defaults.ts +164 -0
- package/src/in-patient/bloodTransfusion/resources/blood-transfusion.resource.ts +238 -0
- package/src/in-patient/bloodTransfusion/resources/openmrs-encounter-search.ts +41 -0
- package/src/in-patient/bloodTransfusion/resources/provider.resource.ts +30 -0
- package/src/in-patient/bloodTransfusion/resources/resolve-encounter-type.ts +135 -0
- package/src/in-patient/bloodTransfusion/types/blood-transfusion.types.ts +90 -0
- package/src/in-patient/bloodTransfusion/utils/blood-transfusion-obs.mapper.ts +404 -0
- package/src/in-patient/bloodTransfusion/utils/blood-transfusion.utils.ts +356 -0
- package/src/in-patient/bloodTransfusion/utils/encounter-datetime.utils.ts +27 -0
- package/src/in-patient/bloodTransfusion/utils/openmrs-concept-metadata.ts +512 -0
- package/src/in-patient/bloodTransfusion/utils/openmrs-concept.utils.ts +41 -0
- package/src/in-patient/bloodTransfusion/utils/openmrs-error.utils.ts +79 -0
- package/src/in-patient/bloodTransfusion/utils/timezone.utils.ts +159 -0
- package/src/in-patient/bloodTransfusion/utils/variant-class.utils.ts +11 -0
- package/src/in-patient/ebola/case-followup-day-picker.component.tsx +217 -0
- package/src/in-patient/ebola/case-followup.component.test.tsx +373 -0
- package/src/in-patient/ebola/case-followup.component.tsx +569 -0
- package/src/in-patient/ebola/case-followup.resource.test.ts +205 -0
- package/src/in-patient/ebola/case-followup.resource.ts +509 -0
- package/src/in-patient/ebola/case-followup.scss +506 -0
- package/src/in-patient/ebola/case-followup.utils.test.ts +414 -0
- package/src/in-patient/ebola/case-followup.utils.ts +725 -0
- package/src/in-patient/ebola/case-identification-finding/case-identification-finding.component.test.tsx +88 -0
- package/src/in-patient/ebola/case-identification-finding/case-identification-finding.component.tsx +208 -0
- package/src/in-patient/ebola/case-identification-finding/case-identification-finding.resource.ts +32 -0
- package/src/in-patient/ebola/case-identification-finding/case-identification-finding.scss +39 -0
- package/src/in-patient/ebola/contact-list/add-contact-form.workspace.tsx +465 -0
- package/src/in-patient/ebola/contact-list/adresshierarchy.component.tsx +32 -0
- package/src/in-patient/ebola/contact-list/contact-list-form.scss +29 -0
- package/src/in-patient/ebola/contact-list/contact-list.resource.tsx +371 -0
- package/src/in-patient/ebola/contact-list/contact-list.types.ts +41 -0
- package/src/in-patient/ebola/contact-list/contact-listing.component.tsx +179 -0
- package/src/in-patient/ebola/contact-list/contact-listing.scss +15 -0
- package/src/in-patient/ebola/contact-list/contact-tracing-history.component.tsx +159 -0
- package/src/in-patient/ebola/contact-list/contact-tracing.resource.tsx +125 -0
- package/src/in-patient/ebola/contact-list/relationship-type.component.tsx +31 -0
- package/src/in-patient/ebola/contact-list/use-contact-mapping.ts +247 -0
- package/src/in-patient/ebola/index.ts +20 -0
- package/src/in-patient/in-patient.resource.tsx +0 -32
- package/src/in-patient/inpatient-detail-view.component.tsx +20 -5
- package/src/in-patient/inpatient-forms.component.tsx +2 -2
- package/src/in-patient/inpatient-tabs.component.tsx +29 -79
- package/src/in-patient/inpatient.scss +5 -0
- package/src/in-patient/labourCareGuide/alert-rules.ts +4 -5
- package/src/in-patient/labourCareGuide/components/summary-of-labour-section.component.tsx +408 -0
- package/src/in-patient/labourCareGuide/constants/admission-form.constants.ts +3 -0
- package/src/in-patient/labourCareGuide/constants/summary-of-labour.constants.ts +102 -0
- package/src/in-patient/labourCareGuide/forms/admission-details-form.component.tsx +58 -7
- package/src/in-patient/labourCareGuide/forms/baby-form.component.tsx +18 -3
- package/src/in-patient/labourCareGuide/forms/index.ts +1 -0
- package/src/in-patient/labourCareGuide/forms/labour-care-guide-forms.component.tsx +54 -1
- package/src/in-patient/labourCareGuide/forms/lcg-session-correction-wizard.component.tsx +122 -75
- package/src/in-patient/labourCareGuide/forms/shared-decision-making-form.component.tsx +229 -227
- package/src/in-patient/labourCareGuide/forms/summary-of-labour-form.component.tsx +887 -0
- package/src/in-patient/labourCareGuide/forms/time-picker-dropdown.component.tsx +47 -62
- package/src/in-patient/labourCareGuide/forms/time-picker-dropdown.scss +3 -2
- package/src/in-patient/labourCareGuide/forms/vital-range-limits.test.tsx +140 -0
- package/src/in-patient/labourCareGuide/forms/woman-form.component.tsx +23 -3
- package/src/in-patient/labourCareGuide/graphs/baby.component.tsx +1 -1
- package/src/in-patient/labourCareGuide/hooks/use-lcg-data.ts +47 -2
- package/src/in-patient/labourCareGuide/labour-care-guide-header.component.tsx +17 -3
- package/src/in-patient/labourCareGuide/labour-care-guide.component.tsx +378 -59
- package/src/in-patient/labourCareGuide/labour-care-guide.scss +209 -0
- package/src/in-patient/labourCareGuide/maternity-inpatient-form.workspace.tsx +75 -0
- package/src/in-patient/labourCareGuide/partography-data-form.scss +121 -40
- package/src/in-patient/labourCareGuide/partography.resource.ts +21 -88
- package/src/in-patient/labourCareGuide/resources/admission-details.resource.ts +10 -10
- package/src/in-patient/labourCareGuide/resources/baby.resource.ts +35 -12
- package/src/in-patient/labourCareGuide/resources/labour-progress.resource.ts +9 -6
- package/src/in-patient/labourCareGuide/resources/labour-time-set-select-setup.resource.ts +7 -6
- package/src/in-patient/labourCareGuide/resources/lcg-encounter-fetch.ts +98 -0
- package/src/in-patient/labourCareGuide/resources/lcg-session-correction.resource.ts +24 -13
- package/src/in-patient/labourCareGuide/resources/medication.resource.ts +6 -5
- package/src/in-patient/labourCareGuide/resources/shared-decision-making.resource.ts +6 -4
- package/src/in-patient/labourCareGuide/resources/summary-of-labour.resource.ts +472 -0
- package/src/in-patient/labourCareGuide/resources/supportive-care.resource.ts +13 -9
- package/src/in-patient/labourCareGuide/summary-of-labour-prefill.utils.ts +436 -0
- package/src/in-patient/labourCareGuide/time-slot-utils.ts +33 -4
- package/src/in-patient/labourCareGuide/types/concept-uuids.constants.ts +1 -0
- package/src/in-patient/labourCareGuide/types/index.ts +21 -6
- package/src/in-patient/partograph.component.tsx +1 -13
- package/src/in-patient/time-ago.ts +34 -0
- package/src/in-patient/treatmentChart/nursing-cardex-plan.resource.ts +111 -20
- package/src/in-patient/treatmentChart/nursing-cardex-plan.workspace.scss +30 -0
- package/src/in-patient/treatmentChart/nursing-cardex-plan.workspace.tsx +223 -25
- package/src/in-patient/treatmentChart/nursing-treatment-sheet.resource.ts +90 -0
- package/src/in-patient/treatmentChart/nursing-treatment-sheet.utils.test.ts +272 -0
- package/src/in-patient/treatmentChart/nursing-treatment-sheet.utils.ts +169 -0
- package/src/in-patient/treatmentChart/use-nursing-cardex-form-schema.ts +2 -14
- package/src/index.ts +17 -0
- package/src/routes.json +78 -2
- package/src/types/index.ts +3 -3
- package/src/ward-patients/admitted-patients.tsx +61 -56
- package/src/ward-patients/awaiting-admission-patients.tsx +70 -52
- package/src/ward-patients/discharge-in-patients.tsx +102 -48
- package/src/ward-patients/discharge-patient-action.component.tsx +80 -0
- package/src/ward-patients/discharge-patients.tsx +73 -62
- package/src/ward-patients/ebola-awaiting-admission-patients.tsx +213 -0
- package/src/ward-patients/patient-cells.scss +13 -0
- package/src/ward-patients/patient-cells.tsx +75 -19
- package/src/ward-patients/table-state-components.tsx +48 -3
- package/src/ward-patients/unassigned-patient.scss +9 -0
- package/src/ward-patients/unassigned-patients.tsx +215 -0
- package/src/ward-patients/ward-patient.scss +121 -15
- package/src/ward-patients/ward-patients-slots.ts +12 -0
- package/src/ward-patients/ward-patients-table.test.tsx +65 -17
- package/src/ward-patients/ward-patients-table.tsx +90 -23
- package/src/ward-view/_ward-theme.scss +16 -0
- package/src/ward-view/default-ward/default-ward-view.component.tsx +40 -8
- package/src/ward-view/linelist-wards/Filters.tsx +27 -13
- package/src/ward-view/linelist-wards/Header.tsx +28 -14
- package/src/ward-view/linelist-wards/Metrics.tsx +52 -11
- package/src/ward-view/linelist-wards/linelist-wards.scss +169 -17
- package/src/ward-view/materal-ward/ward-switch.scss +66 -0
- package/src/ward-view/ward-switch.modal.tsx +74 -35
- package/src/ward-view/ward-view-content-wrapper.tsx +46 -18
- package/src/ward-view/ward-view-ui.store.ts +53 -0
- package/src/ward-view/ward-view.resource.ts +5 -5
- package/src/ward-view/ward-view.scss +96 -8
- package/src/ward-workspace/admission-request-workspace/admission-requests-workspace.test.tsx +3 -1
- package/src/ward-workspace/admit-patient-button.component.tsx +24 -2
- package/src/ward-workspace/admit-patient-button.test.tsx +131 -0
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.test.tsx +34 -0
- package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.workspace.tsx +7 -187
- package/src/ward-workspace/admit-patient-form-workspace/facility-bed-capacity-notification.component.tsx +41 -0
- package/src/ward-workspace/admit-patient-form-workspace/patient-admission.resources.ts +0 -49
- package/src/ward-workspace/create-admission-encounter/create-admission-encounter.test.tsx +3 -1
- package/src/ward-workspace/kenya-emr-patient-discharge/patient-discharge.resource.tsx +25 -23
- package/src/ward-workspace/kenya-emr-patient-discharge/patient-discharge.workspace.tsx +24 -10
- package/translations/am.json +7 -1
- package/translations/en.json +223 -25
- package/translations/fr.json +169 -26
- package/translations/sw.json +7 -1
- package/dist/1084.js +0 -1
- package/dist/1084.js.map +0 -1
- package/dist/1189.js +0 -1
- package/dist/1189.js.map +0 -1
- package/dist/12.js +0 -17
- package/dist/12.js.map +0 -1
- package/dist/126.js +0 -1
- package/dist/1308.js +0 -1
- package/dist/1308.js.map +0 -1
- package/dist/1374.js +0 -1
- package/dist/1374.js.map +0 -1
- package/dist/1387.js +0 -1
- package/dist/1387.js.map +0 -1
- package/dist/15.js +0 -1
- package/dist/1564.js +0 -1
- package/dist/1567.js +0 -1
- package/dist/1567.js.map +0 -1
- package/dist/1739.js +0 -1
- package/dist/1739.js.map +0 -1
- package/dist/1845.js +0 -1
- package/dist/1972.js +0 -1
- package/dist/1972.js.map +0 -1
- package/dist/2016.js +0 -1
- package/dist/2016.js.map +0 -1
- package/dist/2117.js +0 -1
- package/dist/2117.js.map +0 -1
- package/dist/215.js +0 -1
- package/dist/2178.js +0 -1
- package/dist/239.js +0 -1
- package/dist/239.js.map +0 -1
- package/dist/2486.js +0 -1
- package/dist/2486.js.map +0 -1
- package/dist/2512.js +0 -1
- package/dist/2512.js.map +0 -1
- package/dist/2566.js +0 -1
- package/dist/2710.js +0 -1
- package/dist/2710.js.map +0 -1
- package/dist/2759.js +0 -1
- package/dist/2823.js +0 -15
- package/dist/2823.js.map +0 -1
- package/dist/3089.js +0 -1
- package/dist/3089.js.map +0 -1
- package/dist/3230.js +0 -1
- package/dist/3261.js +0 -1
- package/dist/3261.js.map +0 -1
- package/dist/3321.js +0 -1
- package/dist/3321.js.map +0 -1
- package/dist/3350.js +0 -1
- package/dist/3399.js +0 -1
- package/dist/3399.js.map +0 -1
- package/dist/3441.js +0 -1
- package/dist/3547.js +0 -1
- package/dist/3547.js.map +0 -1
- package/dist/3548.js +0 -1
- package/dist/3548.js.map +0 -1
- package/dist/3565.js +0 -1
- package/dist/3571.js +0 -1
- package/dist/3571.js.map +0 -1
- package/dist/364.js +0 -1
- package/dist/364.js.map +0 -1
- package/dist/3746.js +0 -1
- package/dist/3837.js +0 -1
- package/dist/3837.js.map +0 -1
- package/dist/3925.js +0 -1
- package/dist/3946.js +0 -1
- package/dist/400.js +0 -1
- package/dist/400.js.map +0 -1
- package/dist/401.js +0 -1
- package/dist/401.js.map +0 -1
- package/dist/4206.js +0 -1
- package/dist/4206.js.map +0 -1
- package/dist/4480.js +0 -1
- package/dist/4480.js.map +0 -1
- package/dist/4635.js +0 -1
- package/dist/4635.js.map +0 -1
- package/dist/4684.js +0 -1
- package/dist/4684.js.map +0 -1
- package/dist/4735.js +0 -1
- package/dist/4735.js.map +0 -1
- package/dist/4744.js +0 -1
- package/dist/4744.js.map +0 -1
- package/dist/4894.js +0 -1
- package/dist/4970.js +0 -1
- package/dist/4970.js.map +0 -1
- package/dist/5069.js +0 -1
- package/dist/5069.js.map +0 -1
- package/dist/5090.js +0 -1
- package/dist/5090.js.map +0 -1
- package/dist/5130.js +0 -1
- package/dist/5187.js +0 -1
- package/dist/5411.js +0 -1
- package/dist/5411.js.map +0 -1
- package/dist/5441.js +0 -1
- package/dist/5441.js.map +0 -1
- package/dist/5463.js +0 -1
- package/dist/5463.js.map +0 -1
- package/dist/5491.js +0 -1
- package/dist/5491.js.map +0 -1
- package/dist/5496.js +0 -1
- package/dist/5496.js.map +0 -1
- package/dist/5595.js +0 -1
- package/dist/5659.js +0 -1
- package/dist/5659.js.map +0 -1
- package/dist/5706.js +0 -1
- package/dist/5706.js.map +0 -1
- package/dist/5930.js +0 -1
- package/dist/5930.js.map +0 -1
- package/dist/5961.js +0 -1
- package/dist/6061.js +0 -1
- package/dist/6061.js.map +0 -1
- package/dist/6133.js +0 -1
- package/dist/6180.js +0 -1
- package/dist/6180.js.map +0 -1
- package/dist/6296.js +0 -1
- package/dist/6296.js.map +0 -1
- package/dist/6322.js +0 -1
- package/dist/6322.js.map +0 -1
- package/dist/6455.js +0 -1
- package/dist/6455.js.map +0 -1
- package/dist/6456.js +0 -1
- package/dist/6466.js +0 -1
- package/dist/6613.js +0 -1
- package/dist/6783.js +0 -1
- package/dist/6925.js +0 -1
- package/dist/6925.js.map +0 -1
- package/dist/7091.js +0 -1
- package/dist/7091.js.map +0 -1
- package/dist/7263.js +0 -1
- package/dist/7263.js.map +0 -1
- package/dist/7348.js +0 -1
- package/dist/7431.js +0 -1
- package/dist/7431.js.map +0 -1
- package/dist/7543.js +0 -1
- package/dist/7607.js +0 -1
- package/dist/772.js +0 -1
- package/dist/775.js +0 -1
- package/dist/775.js.map +0 -1
- package/dist/7783.js +0 -1
- package/dist/7783.js.map +0 -1
- package/dist/7844.js +0 -1
- package/dist/7844.js.map +0 -1
- package/dist/7965.js +0 -1
- package/dist/7965.js.map +0 -1
- package/dist/8171.js +0 -1
- package/dist/8171.js.map +0 -1
- package/dist/8488.js +0 -1
- package/dist/8488.js.map +0 -1
- package/dist/8660.js +0 -1
- package/dist/8660.js.map +0 -1
- package/dist/8727.js +0 -1
- package/dist/8736.js +0 -1
- package/dist/8736.js.map +0 -1
- package/dist/8847.js +0 -1
- package/dist/9009.js +0 -1
- package/dist/9009.js.map +0 -1
- package/dist/9015.js +0 -1
- package/dist/906.js +0 -1
- package/dist/9065.js +0 -1
- package/dist/9182.js +0 -1
- package/dist/9314.js +0 -1
- package/dist/9314.js.map +0 -1
- package/dist/9339.js +0 -1
- package/dist/9361.js +0 -1
- package/dist/9361.js.map +0 -1
- package/dist/9453.js +0 -1
- package/dist/9535.js +0 -22
- package/dist/9535.js.map +0 -1
- package/dist/9610.js +0 -1
- package/dist/9610.js.map +0 -1
- package/dist/9668.js +0 -1
- package/dist/9668.js.map +0 -1
- package/dist/9727.js +0 -1
- package/dist/9727.js.map +0 -1
- package/dist/9734.js +0 -1
- package/dist/9734.js.map +0 -1
- package/dist/9833.js +0 -1
- package/dist/9833.js.map +0 -1
- package/dist/9848.js +0 -1
- package/dist/9848.js.map +0 -1
- package/dist/9876.js +0 -1
- package/dist/9876.js.map +0 -1
- package/dist/9920.js +0 -1
- package/dist/9938.js +0 -1
- package/dist/main.js +0 -5
- package/dist/main.js.map +0 -1
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TRANSFUSION_FLAG_RULES,
|
|
3
|
+
TRANSFUSION_INPUT_LIMITS,
|
|
4
|
+
TRANSFUSION_NO_REACTION,
|
|
5
|
+
TRANSFUSION_OBSERVATION_ROWS,
|
|
6
|
+
type TransfusionObservationRowDef,
|
|
7
|
+
} from '../config/blood-transfusion.defaults';
|
|
8
|
+
import {
|
|
9
|
+
type BloodTransfusion,
|
|
10
|
+
type BloodTransfusionStore,
|
|
11
|
+
type TransfusionObservation,
|
|
12
|
+
type TransfusionRequiredField,
|
|
13
|
+
} from '../types/blood-transfusion.types';
|
|
14
|
+
/** Minutes after the due time before a missing reading counts as overdue. */
|
|
15
|
+
export const TRANSFUSION_OVERDUE_GRACE_MINUTES = 10;
|
|
16
|
+
|
|
17
|
+
export const emptyTransfusionStore = (): BloodTransfusionStore => ({ transfusions: [] });
|
|
18
|
+
|
|
19
|
+
export function upsertTransfusion(store: BloodTransfusionStore, transfusion: BloodTransfusion): BloodTransfusionStore {
|
|
20
|
+
const others = store.transfusions.filter((item) => item.id !== transfusion.id);
|
|
21
|
+
return { ...store, transfusions: [...others, transfusion] };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function sortTransfusions(transfusions: BloodTransfusion[]): BloodTransfusion[] {
|
|
25
|
+
return [...transfusions].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** T-YYMMDD-NN, numbered per patient per day. */
|
|
29
|
+
export function nextTransfusionNumber(store: BloodTransfusionStore, date: string): string {
|
|
30
|
+
const prefix = `T-${date.slice(2, 4)}${date.slice(5, 7)}${date.slice(8, 10)}-`;
|
|
31
|
+
const used = store.transfusions
|
|
32
|
+
.map((item) => item.number)
|
|
33
|
+
.filter((number) => number.startsWith(prefix))
|
|
34
|
+
.map((number) => Number(number.slice(prefix.length)))
|
|
35
|
+
.filter(Number.isFinite);
|
|
36
|
+
return `${prefix}${String((used.length ? Math.max(...used) : 0) + 1).padStart(2, '0')}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Days up to 28, months up to 2 years, then years. */
|
|
40
|
+
export function ageLabel(birthDate: string | undefined, now: Date): string | undefined {
|
|
41
|
+
if (!birthDate) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const birth = new Date(birthDate);
|
|
45
|
+
if (Number.isNaN(birth.getTime())) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const days = Math.floor(
|
|
49
|
+
(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) -
|
|
50
|
+
Date.UTC(birth.getFullYear(), birth.getMonth(), birth.getDate())) /
|
|
51
|
+
86_400_000,
|
|
52
|
+
);
|
|
53
|
+
if (days < 0) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (days <= 28) {
|
|
57
|
+
return days === 1 ? '1 day' : `${days} days`;
|
|
58
|
+
}
|
|
59
|
+
let months = (now.getFullYear() - birth.getFullYear()) * 12 + (now.getMonth() - birth.getMonth());
|
|
60
|
+
if (now.getDate() < birth.getDate()) {
|
|
61
|
+
months -= 1;
|
|
62
|
+
}
|
|
63
|
+
if (months < 24) {
|
|
64
|
+
return months <= 1 ? '1 mo' : `${months} mo`;
|
|
65
|
+
}
|
|
66
|
+
return `${Math.floor(months / 12)} yrs`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function addMinutes(time: string | undefined, minutes: number): string | undefined {
|
|
70
|
+
const match = time?.match(/^(\d{1,2}):(\d{2})$/);
|
|
71
|
+
if (!match) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const total = (((Number(match[1]) * 60 + Number(match[2]) + minutes) % 1440) + 1440) % 1440;
|
|
75
|
+
return `${String(Math.floor(total / 60)).padStart(2, '0')}:${String(total % 60).padStart(2, '0')}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** When a row's reading is due, from the start time (or the end time for the 4-hours-after row). */
|
|
79
|
+
export function observationDueTime(
|
|
80
|
+
row: TransfusionObservationRowDef,
|
|
81
|
+
timeStarted: string | undefined,
|
|
82
|
+
endedTime: string | undefined,
|
|
83
|
+
): string | undefined {
|
|
84
|
+
if (row.anchor === 'before') {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return addMinutes(row.anchor === 'end' ? endedTime : timeStarted, row.offsetMinutes ?? 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Earliest clock time allowed for `rowId`: the latest Exact Time already set on any
|
|
92
|
+
* earlier observation row. Later slots cannot go backwards in the chart.
|
|
93
|
+
*/
|
|
94
|
+
export function previousObservationMinTime(
|
|
95
|
+
rowId: string,
|
|
96
|
+
observations: BloodTransfusion['observations'],
|
|
97
|
+
): string | undefined {
|
|
98
|
+
let minTime: string | undefined;
|
|
99
|
+
for (const row of TRANSFUSION_OBSERVATION_ROWS) {
|
|
100
|
+
if (row.id === rowId) {
|
|
101
|
+
return minTime;
|
|
102
|
+
}
|
|
103
|
+
const time = observations[row.id]?.time;
|
|
104
|
+
if (time?.includes(':') && (!minTime || time > minTime)) {
|
|
105
|
+
minTime = time;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return minTime;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type ObservationFlags = { temperature?: string; pulse?: string };
|
|
112
|
+
|
|
113
|
+
export function observationFlags(
|
|
114
|
+
baseline: TransfusionObservation | undefined,
|
|
115
|
+
reading: TransfusionObservation | undefined,
|
|
116
|
+
isBaseline = false,
|
|
117
|
+
): ObservationFlags {
|
|
118
|
+
const flags: ObservationFlags = {};
|
|
119
|
+
const temperature = reading?.temperature;
|
|
120
|
+
if (temperature !== undefined) {
|
|
121
|
+
if (temperature >= TRANSFUSION_FLAG_RULES.feverC) {
|
|
122
|
+
flags.temperature = 'fever';
|
|
123
|
+
} else if (
|
|
124
|
+
!isBaseline &&
|
|
125
|
+
baseline?.temperature !== undefined &&
|
|
126
|
+
temperature - baseline.temperature >= TRANSFUSION_FLAG_RULES.temperatureRiseC
|
|
127
|
+
) {
|
|
128
|
+
flags.temperature = 'rise';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const pulse = reading?.pulse;
|
|
132
|
+
if (
|
|
133
|
+
!isBaseline &&
|
|
134
|
+
pulse !== undefined &&
|
|
135
|
+
baseline?.pulse !== undefined &&
|
|
136
|
+
pulse - baseline.pulse >= TRANSFUSION_FLAG_RULES.pulseRiseBpm
|
|
137
|
+
) {
|
|
138
|
+
flags.pulse = 'rise';
|
|
139
|
+
}
|
|
140
|
+
return flags;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Any reaction other than "None" ticked. */
|
|
144
|
+
export function hasTransfusionReaction(reactions: string[]): boolean {
|
|
145
|
+
return reactions.some((id) => id !== TRANSFUSION_NO_REACTION);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** "None" excludes every other reaction and vice versa. */
|
|
149
|
+
export function toggleTransfusionReaction(reactions: string[], id: string, checked: boolean): string[] {
|
|
150
|
+
if (!checked) {
|
|
151
|
+
return reactions.filter((item) => item !== id);
|
|
152
|
+
}
|
|
153
|
+
if (id === TRANSFUSION_NO_REACTION) {
|
|
154
|
+
return [TRANSFUSION_NO_REACTION];
|
|
155
|
+
}
|
|
156
|
+
return [...reactions.filter((item) => item !== TRANSFUSION_NO_REACTION && item !== id), id];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function hasAbnormalObservation(transfusion: BloodTransfusion): boolean {
|
|
160
|
+
const baseline = transfusion.observations.before;
|
|
161
|
+
return Object.entries(transfusion.observations).some(([id, reading]) => {
|
|
162
|
+
const flags = observationFlags(baseline, reading, id === 'before');
|
|
163
|
+
return Boolean(flags.temperature || flags.pulse);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type TransfusionVitalField = 'temperature' | 'pulse' | 'respiratoryRate' | 'systolic' | 'diastolic';
|
|
168
|
+
|
|
169
|
+
export const TRANSFUSION_VITAL_FIELDS: TransfusionVitalField[] = [
|
|
170
|
+
'temperature',
|
|
171
|
+
'pulse',
|
|
172
|
+
'respiratoryRate',
|
|
173
|
+
'systolic',
|
|
174
|
+
'diastolic',
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
/** True when a vital is filled in but outside the range OpenMRS accepts. */
|
|
178
|
+
export function isVitalOutOfRange(field: TransfusionVitalField, value: number | undefined): boolean {
|
|
179
|
+
if (value === undefined || Number.isNaN(value)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const { min, max } = TRANSFUSION_INPUT_LIMITS[field];
|
|
183
|
+
return value < min || value > max;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function outOfRangeVitals(reading: TransfusionObservation | undefined): TransfusionVitalField[] {
|
|
187
|
+
return TRANSFUSION_VITAL_FIELDS.filter((field) => isVitalOutOfRange(field, reading?.[field]));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Observation rows holding a vital OpenMRS would reject. */
|
|
191
|
+
export function rowsWithOutOfRangeVitals(transfusion: BloodTransfusion): string[] {
|
|
192
|
+
return Object.entries(transfusion.observations)
|
|
193
|
+
.filter(([, reading]) => outOfRangeVitals(reading).length > 0)
|
|
194
|
+
.map(([rowId]) => rowId);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const blank = (value: unknown) => value === undefined || value === null || String(value).trim() === '';
|
|
198
|
+
|
|
199
|
+
/** Fields that must be filled before a transfusion record can be submitted. */
|
|
200
|
+
export function missingForSubmit(transfusion: BloodTransfusion): TransfusionRequiredField[] {
|
|
201
|
+
const missing: TransfusionRequiredField[] = [];
|
|
202
|
+
const required: Array<[TransfusionRequiredField, unknown]> = [
|
|
203
|
+
['transfusionDate', transfusion.transfusionDate],
|
|
204
|
+
['transfusionTime', transfusion.transfusionTime],
|
|
205
|
+
['donorNumber', transfusion.donorNumber],
|
|
206
|
+
['startedBy', transfusion.startedBy],
|
|
207
|
+
['counterCheckedBy', transfusion.counterCheckedBy],
|
|
208
|
+
['timeStarted', transfusion.timeStarted],
|
|
209
|
+
['baselineTemperature', transfusion.observations.before?.temperature],
|
|
210
|
+
['baselinePulse', transfusion.observations.before?.pulse],
|
|
211
|
+
['endedDate', transfusion.endedDate],
|
|
212
|
+
['endedTime', transfusion.endedTime],
|
|
213
|
+
['amountMl', transfusion.amountMl],
|
|
214
|
+
];
|
|
215
|
+
for (const [field, value] of required) {
|
|
216
|
+
if (blank(value)) {
|
|
217
|
+
missing.push(field);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!transfusion.bloodTypes.length) {
|
|
221
|
+
missing.push('bloodTypes');
|
|
222
|
+
}
|
|
223
|
+
if (transfusion.bloodTypes.includes('others') && blank(transfusion.otherType)) {
|
|
224
|
+
missing.push('otherType');
|
|
225
|
+
}
|
|
226
|
+
return missing;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** The end must not be before the start of the transfusion. */
|
|
230
|
+
export function isEndBeforeStart(transfusion: BloodTransfusion): boolean {
|
|
231
|
+
const { transfusionDate, timeStarted, endedDate, endedTime } = transfusion;
|
|
232
|
+
if (!transfusionDate || !timeStarted || !endedDate || !endedTime) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
return `${endedDate}T${endedTime}` < `${transfusionDate}T${timeStarted}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** The start can't be later than the facility clock (`nowLocal` is `YYYY-MM-DDTHH:MM`). */
|
|
239
|
+
export function isStartInFuture(transfusion: BloodTransfusion, nowLocal: string): boolean {
|
|
240
|
+
const { transfusionDate, timeStarted } = transfusion;
|
|
241
|
+
if (!transfusionDate || !timeStarted) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return `${transfusionDate}T${timeStarted}` > nowLocal;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** `YYYY-MM-DDTHH:MM` local (facility) timestamp shifted by whole minutes. */
|
|
248
|
+
export function addMinutesToLocal(date: string | undefined, time: string | undefined, minutes: number) {
|
|
249
|
+
const d = date?.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
250
|
+
const t = time?.match(/^(\d{1,2}):(\d{2})$/);
|
|
251
|
+
if (!d || !t) {
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
const ms = Date.UTC(Number(d[1]), Number(d[2]) - 1, Number(d[3]), Number(t[1]), Number(t[2]) + minutes);
|
|
255
|
+
return new Date(ms).toISOString().slice(0, 16);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Full local due timestamp for a row, so overdue checks work across midnight. */
|
|
259
|
+
export function observationDueAt(row: TransfusionObservationRowDef, transfusion: BloodTransfusion) {
|
|
260
|
+
if (row.anchor === 'before') {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
return row.anchor === 'end'
|
|
264
|
+
? addMinutesToLocal(transfusion.endedDate, transfusion.endedTime, row.offsetMinutes ?? 0)
|
|
265
|
+
: addMinutesToLocal(transfusion.transfusionDate, transfusion.timeStarted, row.offsetMinutes ?? 0);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function isObservationRecorded(reading: TransfusionObservation | undefined): boolean {
|
|
269
|
+
return (
|
|
270
|
+
reading?.temperature !== undefined ||
|
|
271
|
+
reading?.pulse !== undefined ||
|
|
272
|
+
reading?.respiratoryRate !== undefined ||
|
|
273
|
+
reading?.systolic !== undefined ||
|
|
274
|
+
reading?.diastolic !== undefined
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export type ObservationRowState = 'recorded' | 'overdue' | 'due' | 'upcoming' | 'notApplicable';
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Rows after the transfusion ended (other than the 4-hours-after check) are not needed.
|
|
282
|
+
* `nowLocal` is the facility clock as `YYYY-MM-DDTHH:MM`.
|
|
283
|
+
*/
|
|
284
|
+
export function observationRowState(
|
|
285
|
+
row: TransfusionObservationRowDef,
|
|
286
|
+
transfusion: BloodTransfusion,
|
|
287
|
+
nowLocal: string,
|
|
288
|
+
): ObservationRowState {
|
|
289
|
+
if (isObservationRecorded(transfusion.observations[row.id])) {
|
|
290
|
+
return 'recorded';
|
|
291
|
+
}
|
|
292
|
+
if (row.anchor === 'before') {
|
|
293
|
+
return transfusion.timeStarted ? 'overdue' : 'due';
|
|
294
|
+
}
|
|
295
|
+
const dueAt = observationDueAt(row, transfusion);
|
|
296
|
+
const endedAt = addMinutesToLocal(transfusion.endedDate, transfusion.endedTime, 0);
|
|
297
|
+
if (row.anchor === 'start' && dueAt && endedAt && dueAt > endedAt) {
|
|
298
|
+
return 'notApplicable';
|
|
299
|
+
}
|
|
300
|
+
if (!dueAt) {
|
|
301
|
+
return 'upcoming';
|
|
302
|
+
}
|
|
303
|
+
const overdueAt = addMinutesToLocal(dueAt.slice(0, 10), dueAt.slice(11), TRANSFUSION_OVERDUE_GRACE_MINUTES) ?? dueAt;
|
|
304
|
+
if (nowLocal > overdueAt) {
|
|
305
|
+
return 'overdue';
|
|
306
|
+
}
|
|
307
|
+
return nowLocal >= dueAt ? 'due' : 'upcoming';
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export type TransfusionProgress = {
|
|
311
|
+
recorded: number;
|
|
312
|
+
expected: number;
|
|
313
|
+
overdue: number;
|
|
314
|
+
nextDue?: string;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export function transfusionProgress(transfusion: BloodTransfusion, nowLocal: string): TransfusionProgress {
|
|
318
|
+
const progress: TransfusionProgress = { recorded: 0, expected: 0, overdue: 0 };
|
|
319
|
+
for (const row of TRANSFUSION_OBSERVATION_ROWS) {
|
|
320
|
+
const state = observationRowState(row, transfusion, nowLocal);
|
|
321
|
+
if (state === 'notApplicable') {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
progress.expected += 1;
|
|
325
|
+
if (state === 'recorded') {
|
|
326
|
+
progress.recorded += 1;
|
|
327
|
+
} else if (state === 'overdue') {
|
|
328
|
+
progress.overdue += 1;
|
|
329
|
+
} else if (!progress.nextDue) {
|
|
330
|
+
progress.nextDue = observationDueAt(row, transfusion);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return progress;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export type TransfusionPhase = 'draft' | 'inProgress' | 'ended' | 'submitted';
|
|
337
|
+
|
|
338
|
+
export function transfusionPhase(transfusion: BloodTransfusion): TransfusionPhase {
|
|
339
|
+
if (transfusion.status === 'submitted') {
|
|
340
|
+
return 'submitted';
|
|
341
|
+
}
|
|
342
|
+
if (transfusion.endedTime) {
|
|
343
|
+
return 'ended';
|
|
344
|
+
}
|
|
345
|
+
return transfusion.timeStarted ? 'inProgress' : 'draft';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/** Calendar day the transfusion started on. */
|
|
349
|
+
export function transfusionChartDay(transfusion: BloodTransfusion): string | undefined {
|
|
350
|
+
return transfusion.transfusionDate;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function transfusionsEqual(a: BloodTransfusion, b: BloodTransfusion): boolean {
|
|
354
|
+
const strip = ({ updatedAt: _u, encounterUuid: _e, syncedRows: _s, ...rest }: BloodTransfusion) => rest;
|
|
355
|
+
return JSON.stringify(strip(a)) === JSON.stringify(strip(b));
|
|
356
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { toOmrsIsoString } from '@openmrs/esm-framework';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OpenMRS rejects an encounterDatetime in the future or outside the visit's start/stop range.
|
|
5
|
+
* Grid entries are stamped at the slot hour, which can fall before a visit that started mid-hour,
|
|
6
|
+
* so clamp into [visit start, min(now, visit stop)]. Grid placement is kept on the obs comment.
|
|
7
|
+
*/
|
|
8
|
+
export function toVisitSafeEncounterDatetime(
|
|
9
|
+
iso: string,
|
|
10
|
+
visitStartDatetime?: string,
|
|
11
|
+
visitStopDatetime?: string,
|
|
12
|
+
now: Date = new Date(),
|
|
13
|
+
): string {
|
|
14
|
+
const requested = new Date(iso);
|
|
15
|
+
let safeMs = Number.isNaN(requested.getTime()) ? now.getTime() : requested.getTime();
|
|
16
|
+
|
|
17
|
+
const stopMs = visitStopDatetime ? new Date(visitStopDatetime).getTime() : Number.NaN;
|
|
18
|
+
const upperMs = Number.isNaN(stopMs) ? now.getTime() : Math.min(now.getTime(), stopMs);
|
|
19
|
+
safeMs = Math.min(safeMs, upperMs);
|
|
20
|
+
|
|
21
|
+
const startMs = visitStartDatetime ? new Date(visitStartDatetime).getTime() : Number.NaN;
|
|
22
|
+
if (!Number.isNaN(startMs)) {
|
|
23
|
+
safeMs = Math.max(safeMs, startMs);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return toOmrsIsoString(new Date(safeMs));
|
|
27
|
+
}
|