@kenyaemr/esm-ward-app 8.5.1-pre.67 → 8.5.1-pre.69

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/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0","emrapi":"^2.0.0 || 2.0.0-SNAPSHOT"},"optionalBackendDependencies":{"bedmanagement":{"version":"^6.0.0 || 6.0.0-SNAPSHOT","feature":{"flagName":"bedmanagement-module","label":"Ward App Patient Service","description":"This module, if installed, provides services for managing patients admitted to the ward."}}},"extensions":[{"name":"ward-dashboard-link","component":"wardDashboardLink","slot":"homepage-dashboard-slot","meta":{"name":"ward","slot":"ward-dashboard-slot","title":"Wards"}},{"component":"root","name":"ward-dashboard","slot":"ward-dashboard-slot"},{"component":"wardView","name":"ward-view","slot":"ward-view-slot"},{"component":"wardPatientActionButtonExtension","name":"ward-patient-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"wardPatientNotesActionButtonExtension","name":"ward-inpatient-notes-form-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"coloredObsTagCardRowExtension","name":"colored-obs-tags-card-row","slot":"ward-patient-card-slot"},{"name":"transfer-swap-patient-siderail-button","slot":"action-menu-ward-patient-items-slot","component":"patientTransferAndSwapWorkspaceSiderailIcon"},{"name":"patient-discharge-siderail-button","slot":"action-menu-ward-patient-items-slot","component":"patientDischargeWorkspaceSideRailIcon"},{"name":"clinical-forms-workspace-siderail-button","component":"clinicalFormWorkspaceSideRailIcon","slot":"action-menu-ward-patient-items-slot"},{"name":"admission-requests-workspace-siderail-button","component":"admissionRequestsWorkspaceSideRailIcon","slot":"action-menu-ward-patient-admission-requests-items-slot"},{"name":"create-admission-request-workspace-siderail-button","component":"createAdmissionEncounterWorkspaceSideRailIcon","slot":"action-menu-ward-patient-admission-requests-items-slot"},{"component":"defaultWardView","name":"default-ward","slot":"default-ward"},{"component":"maternalWardView","name":"maternal-ward","slot":"maternal-ward"},{"component":"patientDischargeDocumentPreview","name":"patient-discharge-document-preview-modal"},{"component":"wardPatientWorkspaceBanner","name":"ward-patient-workspace-banner","slot":"ward-workspace-patient-banner-slot"},{"name":"in-patient-dashboard-link","component":"inPatientChartLink","order":7,"meta":{"slot":"patient-chart-in-patient-dashboard-slot","path":"in-patient","layoutMode":"anchored","columns":1,"columnSpan":1}},{"name":"in-patient-dashboard","slot":"patient-chart-in-patient-dashboard-slot","component":"inPatientChartDashboard","meta":{"fullWidth":false}}],"workspaces":[{"name":"admission-requests-workspace","component":"admissionRequestWorkspace","title":"admissionRequests","type":"pending-admission-requests","width":"wider"},{"name":"create-admission-encounter-workspace","component":"createAdmissionEncounterWorkspace","title":"admitPatient","type":"patient-search-workspace","width":"wider"},{"name":"ward-patient-notes-workspace","component":"wardPatientNotesWorkspace","type":"ward-patient-notes","title":"inpatientNotesWorkspaceTitle"},{"name":"admit-patient-form-workspace","component":"admitPatientFormWorkspace","title":"admissionRequests","type":"admission-requests"},{"name":"ward-patient-workspace","component":"wardPatientWorkspace","type":"ward","title":"Ward patient","width":"extra-wide"},{"name":"patient-transfer-swap-workspace","component":"patientTransferAndSwapWorkspace","title":"transfers","type":"transfer-swap-bed-form"},{"name":"patient-transfer-request-workspace","component":"patientTransferRequestWorkspace","title":"transferRequest","type":"transfer-request-form"},{"name":"patient-discharge-workspace","component":"patientDischargeWorkspace","title":"discharge","width":"extra-wide","canMaximize":true,"type":"ward-patient-discharge"},{"name":"ward-patient-clinical-forms-workspace","component":"patientClinicalFormsWorkspace","title":"clinicalForms","type":"ward-patient-clinical-forms","width":"wider"},{"name":"cancel-admission-request-workspace","component":"cancelAdmissionRequestWorkspace","title":"cancelAdmissionRequest","type":"cancel-admission-request"}],"workspaceGroups":[{"name":"ward-patient","members":["ward-patient-workspace","ward-patient-notes-workspace","patient-transfer-swap-workspace","patient-discharge-workspace","ward-patient-clinical-forms-workspace","add-drug-order","order-basket","add-lab-order"]},{"name":"ward-patient-admission-requests","members":["admission-requests-workspace","create-admission-encounter-workspace"]}],"version":"8.5.1-pre.67"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.2.0","emrapi":"^2.0.0 || 2.0.0-SNAPSHOT"},"optionalBackendDependencies":{"bedmanagement":{"version":"^6.0.0 || 6.0.0-SNAPSHOT","feature":{"flagName":"bedmanagement-module","label":"Ward App Patient Service","description":"This module, if installed, provides services for managing patients admitted to the ward."}}},"extensions":[{"name":"ward-dashboard-link","component":"wardDashboardLink","slot":"homepage-dashboard-slot","meta":{"name":"ward","slot":"ward-dashboard-slot","title":"Wards"}},{"component":"root","name":"ward-dashboard","slot":"ward-dashboard-slot"},{"component":"wardView","name":"ward-view","slot":"ward-view-slot"},{"component":"wardPatientActionButtonExtension","name":"ward-patient-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"wardPatientNotesActionButtonExtension","name":"ward-inpatient-notes-form-action-button","slot":"action-menu-ward-patient-items-slot"},{"component":"coloredObsTagCardRowExtension","name":"colored-obs-tags-card-row","slot":"ward-patient-card-slot"},{"name":"transfer-swap-patient-siderail-button","slot":"action-menu-ward-patient-items-slot","component":"patientTransferAndSwapWorkspaceSiderailIcon"},{"name":"patient-discharge-siderail-button","slot":"action-menu-ward-patient-items-slot","component":"patientDischargeWorkspaceSideRailIcon"},{"name":"clinical-forms-workspace-siderail-button","component":"clinicalFormWorkspaceSideRailIcon","slot":"action-menu-ward-patient-items-slot"},{"name":"admission-requests-workspace-siderail-button","component":"admissionRequestsWorkspaceSideRailIcon","slot":"action-menu-ward-patient-admission-requests-items-slot"},{"name":"create-admission-request-workspace-siderail-button","component":"createAdmissionEncounterWorkspaceSideRailIcon","slot":"action-menu-ward-patient-admission-requests-items-slot"},{"component":"defaultWardView","name":"default-ward","slot":"default-ward"},{"component":"maternalWardView","name":"maternal-ward","slot":"maternal-ward"},{"component":"patientDischargeDocumentPreview","name":"patient-discharge-document-preview-modal"},{"component":"wardPatientWorkspaceBanner","name":"ward-patient-workspace-banner","slot":"ward-workspace-patient-banner-slot"},{"name":"in-patient-dashboard-link","component":"inPatientChartLink","order":7,"meta":{"slot":"patient-chart-in-patient-dashboard-slot","path":"in-patient","layoutMode":"anchored","columns":1,"columnSpan":1}},{"name":"in-patient-dashboard","slot":"patient-chart-in-patient-dashboard-slot","component":"inPatientChartDashboard","meta":{"fullWidth":false}}],"workspaces":[{"name":"admission-requests-workspace","component":"admissionRequestWorkspace","title":"admissionRequests","type":"pending-admission-requests","width":"wider"},{"name":"create-admission-encounter-workspace","component":"createAdmissionEncounterWorkspace","title":"admitPatient","type":"patient-search-workspace","width":"wider"},{"name":"ward-patient-notes-workspace","component":"wardPatientNotesWorkspace","type":"ward-patient-notes","title":"inpatientNotesWorkspaceTitle"},{"name":"admit-patient-form-workspace","component":"admitPatientFormWorkspace","title":"admissionRequests","type":"admission-requests"},{"name":"ward-patient-workspace","component":"wardPatientWorkspace","type":"ward","title":"Ward patient","width":"extra-wide"},{"name":"patient-transfer-swap-workspace","component":"patientTransferAndSwapWorkspace","title":"transfers","type":"transfer-swap-bed-form"},{"name":"patient-transfer-request-workspace","component":"patientTransferRequestWorkspace","title":"transferRequest","type":"transfer-request-form"},{"name":"patient-discharge-workspace","component":"patientDischargeWorkspace","title":"discharge","width":"extra-wide","canMaximize":true,"type":"ward-patient-discharge"},{"name":"ward-patient-clinical-forms-workspace","component":"patientClinicalFormsWorkspace","title":"clinicalForms","type":"ward-patient-clinical-forms","width":"wider"},{"name":"cancel-admission-request-workspace","component":"cancelAdmissionRequestWorkspace","title":"cancelAdmissionRequest","type":"cancel-admission-request"}],"workspaceGroups":[{"name":"ward-patient","members":["ward-patient-workspace","ward-patient-notes-workspace","patient-transfer-swap-workspace","patient-discharge-workspace","ward-patient-clinical-forms-workspace","add-drug-order","order-basket","add-lab-order"]},{"name":"ward-patient-admission-requests","members":["admission-requests-workspace","create-admission-encounter-workspace"]}],"version":"8.5.1-pre.69"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-ward-app",
3
- "version": "8.5.1-pre.67",
3
+ "version": "8.5.1-pre.69",
4
4
  "description": "Ward and bed management module for O3",
5
5
  "browser": "dist/kenyaemr-esm-ward-app.js",
6
6
  "main": "src/index.ts",
@@ -382,44 +382,71 @@ export const configSchema: ConfigSchema = {
382
382
  {
383
383
  label: 'Cardex Nursing Plan',
384
384
  uuid: '1f81d5e2-3569-40cf-bbb9-361a53ba409b',
385
+ tags: [],
385
386
  },
386
387
  {
387
388
  label: 'IPD Procedure Form',
388
389
  uuid: '2b9c2b94-0b03-416a-b312-eef49b42f72c',
390
+ tags: [],
389
391
  },
390
392
  {
391
393
  label: 'Newborn Unit Admission ',
392
394
  uuid: '5b0a08f5-87c1-40cc-8c09-09c33b44523d',
393
395
  hideExpression: 'ageInDays < 28',
396
+ tags: [],
394
397
  },
395
398
  {
396
399
  label: 'Partograph Form',
397
400
  uuid: '3791e5b7-2cdc-44fc-982b-a81135367c96',
398
- hideExpression: 'age >= 10 && gender === "female"',
401
+ tags: [{ uuid: '7680b7ee-6880-450c-8b7e-2a748b6f9dc7', tag: 'Labour & Delivery Ward' }],
399
402
  },
400
403
  {
401
404
  uuid: '87379b0a-738b-4799-9736-cdac614cee2a',
402
405
  label: 'Doctors Note',
403
- },
404
- {
405
- uuid: '07dc609f-e607-43d6-9dc3-8bd405c4226a',
406
- label: 'Post Delivery',
406
+ tags: [],
407
407
  },
408
408
  {
409
409
  uuid: 'ac043326-c5f0-4d11-9e6f-f7266b3f3859',
410
410
  label: 'Post Operation',
411
+ tags: [],
411
412
  },
412
413
  {
413
414
  uuid: 'a14824ca-29af-4d37-b9da-6bdee39f8808',
414
415
  label: 'Pre-Operation Checklist',
416
+ tags: [],
415
417
  },
416
418
  {
417
419
  uuid: 'b4bfa7a3-f6ed-4339-a4ec-b076463c0696',
418
420
  label: 'Fluid Intake',
421
+ tags: [],
419
422
  },
420
423
  {
421
424
  uuid: '3efe6966-a011-4d24-aa43-d3051bfbb8e3',
422
425
  label: 'Initial Nursing Cardex',
426
+ tags: [],
427
+ },
428
+ {
429
+ uuid: '57b8bb54-321f-4b94-bba5-58850527bfd6',
430
+ label: 'Maternity inpatient form',
431
+ tags: [{ uuid: 'dab3c2bb-0b0b-4ebd-8f99-3ad44996d311', tag: 'Antenantal Ward' }],
432
+ },
433
+ {
434
+ uuid: '98a781d2-b777-4756-b4c9-c9b0deb3483c',
435
+ label: 'Inpatient Discharge form',
436
+ tags: [
437
+ { uuid: 'dab3c2bb-0b0b-4ebd-8f99-3ad44996d311', tag: 'Antenantal Ward' },
438
+ { uuid: '7680b7ee-6880-450c-8b7e-2a748b6f9dc7', tag: 'Labour & Delivery Ward' },
439
+ ],
440
+ },
441
+ {
442
+ uuid: '496c7cc3-0eea-4e84-a04c-2292949e2f7f',
443
+ label: 'Delivery form',
444
+ tags: [{ uuid: '7680b7ee-6880-450c-8b7e-2a748b6f9dc7', tag: 'Labour & Delivery Ward' }],
445
+ },
446
+ {
447
+ uuid: '07dc609f-e607-43d6-9dc3-8bd405c4226a',
448
+ label: 'Post Delivery form',
449
+ tags: [{ uuid: '473001b4-5a6e-4e2e-b39c-f54edea89c6f', tag: 'Postnatal Ward' }], // Postnatal and Maternity tags
423
450
  },
424
451
  ],
425
452
  },
@@ -474,7 +501,12 @@ export interface WardConfigObject {
474
501
  clinicalConsultationEncounterType: string;
475
502
  doctorsNoteEncounterType: string;
476
503
  admissionRequestFormUuid: string;
477
- inPatientForms: Array<{ label: string; uuid: string; hideExpression: string }>;
504
+ inPatientForms: Array<{
505
+ label: string;
506
+ uuid: string;
507
+ hideExpression: string;
508
+ tags: Array<{ uuid: string; tag: string }>;
509
+ }>;
478
510
  inPatientVisitTypeUuid: string;
479
511
  }
480
512
 
@@ -1,7 +1,7 @@
1
- import { type Encounter, openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
1
+ import { type Encounter, type FetchResponse, openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
- import type { InpatientRequest as AdmissionRequest } from '../types';
4
3
  import type { WardConfigObject } from '../config-schema';
4
+ import type { InpatientRequest as AdmissionRequest } from '../types';
5
5
 
6
6
  export const usePatientEncounters = (patientUuid: string) => {
7
7
  const { inPatientForms } = useConfig<WardConfigObject>();
@@ -54,3 +54,20 @@ export const useAdmissionRequest = (patientUuid: string) => {
54
54
  mutate: mutate,
55
55
  };
56
56
  };
57
+
58
+ type Tag = { uuid: string; display: string; name: string; description: string };
59
+
60
+ export const useAdmissionLocationTags = (locationUuid?: string) => {
61
+ const rep = 'custom:(tags:(uuid,display,name,description))';
62
+ const url = `${restBaseUrl}/location/${locationUuid}?v=${rep}`;
63
+ const { data, error, isLoading, mutate } = useSWR<FetchResponse<{ tags: Array<Tag> }>>(
64
+ locationUuid ? url : null,
65
+ openmrsFetch,
66
+ );
67
+ return {
68
+ tags: data?.data?.tags ?? [],
69
+ isLoading,
70
+ error,
71
+ mutate,
72
+ };
73
+ };
@@ -11,6 +11,7 @@ import {
11
11
  import { launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';
12
12
  import dayjs from 'dayjs';
13
13
  import { type WardConfigObject } from '../config-schema';
14
+ import { useAdmissionLocationTags } from './in-patient.resource';
14
15
  type InpatientFormsProps = {
15
16
  patientUuid: string;
16
17
  patient: fhir.Patient;
@@ -18,21 +19,37 @@ type InpatientFormsProps = {
18
19
  };
19
20
  const InpatientForms: FC<InpatientFormsProps> = ({ patientUuid, patient, emrConfiguration }) => {
20
21
  const { t } = useTranslation();
21
- const { inPatientForms } = useConfig<WardConfigObject>();
22
22
  const { currentVisit } = useVisit(patientUuid);
23
- const filteredForms = inPatientForms.filter((form) => {
24
- if (!form.hideExpression) {
25
- return true;
26
- }
27
- const age = dayjs().diff(dayjs(patient.birthDate), 'year');
28
- const ageInDays = dayjs().diff(dayjs(patient.birthDate), 'day');
29
- const ageInMonths = dayjs().diff(dayjs(patient.birthDate), 'month');
30
- const gender = patient.gender;
31
- const hide = form.hideExpression
32
- ? evaluateAsBoolean(form.hideExpression, { age, gender, ageInDays, ageInMonths })
33
- : false;
34
- return hide;
35
- });
23
+ const admissionLocation = useMemo(
24
+ () =>
25
+ currentVisit?.encounters?.find((en) => en.encounterType?.uuid === emrConfiguration?.admissionEncounterType?.uuid)
26
+ ?.location,
27
+ [currentVisit?.encounters, emrConfiguration?.admissionEncounterType?.uuid],
28
+ );
29
+ const { error: tagsError, isLoading: isloadingTags, tags } = useAdmissionLocationTags(admissionLocation?.uuid);
30
+
31
+ const { inPatientForms } = useConfig<WardConfigObject>();
32
+ const filteredForms = useMemo(
33
+ () =>
34
+ inPatientForms.filter((form) => {
35
+ const age = dayjs().diff(dayjs(patient.birthDate), 'year');
36
+ const ageInDays = dayjs().diff(dayjs(patient.birthDate), 'day');
37
+ const ageInMonths = dayjs().diff(dayjs(patient.birthDate), 'month');
38
+ const gender = patient.gender;
39
+
40
+ const shouldHideBasedOnExpression = form.hideExpression
41
+ ? evaluateAsBoolean(form.hideExpression, { age, gender, ageInDays, ageInMonths })
42
+ : false;
43
+
44
+ const shouldHideBasedOnTags = form.tags?.length
45
+ ? !form.tags.some((tag) => tags.some((t) => t.uuid === tag.uuid))
46
+ : false;
47
+
48
+ // Keep the form if it should NOT be hidden by either condition
49
+ return !shouldHideBasedOnExpression && !shouldHideBasedOnTags;
50
+ }),
51
+ [inPatientForms, patient.birthDate, patient.gender, tags],
52
+ );
36
53
 
37
54
  const isPatientAdmitted = useMemo(() => {
38
55
  const hasAdmissionEncounter = currentVisit.encounters.some(
@@ -63,6 +80,8 @@ const InpatientForms: FC<InpatientFormsProps> = ({ patientUuid, patient, emrConf
63
80
  if (!isPatientAdmitted) {
64
81
  return null;
65
82
  }
83
+
84
+ if (isloadingTags) return null;
66
85
  return (
67
86
  <ComboButton size="sm" label={t('inPatientForms', 'In-Patient Forms')}>
68
87
  {filteredForms.map((form) => (