@kenyaemr/esm-patient-clinical-view-app 5.4.2-pre.2674 → 5.4.2-pre.2680

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.
@@ -1,78 +1,13 @@
1
1
  import React from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { ComboButton, MenuItem, DataTableSkeleton } from '@carbon/react';
4
- import { CardHeader, EmptyState, useVisitOrOfflineVisit } from '@openmrs/esm-patient-common-lib';
5
- import { useConfig, useVisit, evaluateAsBoolean, launchWorkspace } from '@openmrs/esm-framework';
6
- import dayjs from 'dayjs';
7
- import { BedManagementConfig } from '../config-schema';
8
- import { usePatientEncounters } from './in-patient.resource';
9
- import InPatientTable from './in-patient-table/in-patient-table.component';
2
+ import AdmissionRequest from './admission-request.component';
10
3
 
11
4
  type InPatientProps = {
12
5
  patientUuid: string;
13
6
  patient: fhir.Patient;
14
7
  };
15
8
 
16
- const InPatient: React.FC<InPatientProps> = ({ patientUuid, patient }) => {
17
- const { t } = useTranslation();
18
- const { inpatientVisitUuid } = useConfig<BedManagementConfig>();
19
- const { currentVisit } = useVisitOrOfflineVisit(patientUuid);
20
- const { inPatientForms } = useConfig<BedManagementConfig>();
21
- const { encounters, isLoading, mutate } = usePatientEncounters(patientUuid);
22
-
23
- const hasInPatientVisit = currentVisit?.visitType.uuid === inpatientVisitUuid;
24
- const filteredForms = inPatientForms.filter((form) => {
25
- if (!form.hideExpression) {
26
- return true;
27
- }
28
- const age = dayjs().diff(dayjs(patient.birthDate), 'year');
29
- const ageInDays = dayjs().diff(dayjs(patient.birthDate), 'day');
30
- const ageInMonths = dayjs().diff(dayjs(patient.birthDate), 'month');
31
- const gender = patient.gender;
32
- const hide = form.hideExpression
33
- ? evaluateAsBoolean(form.hideExpression, { age, gender, ageInDays, ageInMonths })
34
- : false;
35
- return hide;
36
- });
37
-
38
- const handleLaunchForm = (form: { label: string; uuid: string }) => {
39
- launchWorkspace('patient-form-entry-workspace', {
40
- workspaceTitle: form.label,
41
- mutateForm: () => mutate(),
42
- formInfo: {
43
- encounterUuid: '',
44
- formUuid: form.uuid,
45
- additionalProps: {},
46
- },
47
- });
48
- };
49
-
50
- if (!hasInPatientVisit) {
51
- return (
52
- <EmptyState
53
- displayText={t('inPatientVisitMessage', 'in-patient encounter found for current {{visitType}} visit', {
54
- visitType: currentVisit?.visitType.display,
55
- })}
56
- headerTitle={t('inPatientView', 'In Patient View')}
57
- />
58
- );
59
- }
60
-
61
- return (
62
- <div>
63
- <CardHeader title={t('inPatient', 'In Patient')}>
64
- <ComboButton size="sm" label={t('inPatientForms', 'In-Patient Forms')}>
65
- {filteredForms.map((form) => (
66
- <MenuItem key={form.uuid} onClick={() => handleLaunchForm(form)} label={form.label} />
67
- ))}
68
- </ComboButton>
69
- </CardHeader>
70
- <div>
71
- {isLoading && <DataTableSkeleton aria-label="encounters" />}
72
- {!isLoading && <InPatientTable tableRows={encounters} currentVisit={currentVisit} />}
73
- </div>
74
- </div>
75
- );
9
+ const InPatient: React.FC<InPatientProps> = ({ patientUuid }) => {
10
+ return <AdmissionRequest patientUuid={patientUuid} />;
76
11
  };
77
12
 
78
13
  export default InPatient;
@@ -1,7 +1,7 @@
1
- import { openmrsFetch, useConfig } from '@openmrs/esm-framework';
1
+ import { type Encounter, openmrsFetch, restBaseUrl, useConfig } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
- import { Encounter } from './encounter-observations/visit.resource';
4
3
  import { BedManagementConfig } from '../config-schema';
4
+ import { AdmissionRequest } from '../types';
5
5
 
6
6
  export const usePatientEncounters = (patientUuid: string) => {
7
7
  const { inPatientForms } = useConfig<BedManagementConfig>();
@@ -24,3 +24,33 @@ export const usePatientEncounters = (patientUuid: string) => {
24
24
  mutate,
25
25
  };
26
26
  };
27
+
28
+ const defaultRep =
29
+ 'custom:(' +
30
+ 'dispositionLocation,' +
31
+ 'dispositionType,' +
32
+ 'disposition,' +
33
+ 'dispositionEncounter:full,' +
34
+ 'patient:(uuid,identifiers,voided,' +
35
+ 'person:(uuid,display,gender,age,birthdate,birthtime,preferredName,preferredAddress,dead,deathDate)),' +
36
+ 'dispositionObsGroup,' +
37
+ 'visit)';
38
+
39
+ export const useAdmissionRequest = (patientUuid: string) => {
40
+ const patientUuids = [patientUuid];
41
+ const searchParams = new URLSearchParams();
42
+ searchParams.set('dispositionType', 'ADMIT');
43
+ searchParams.set('patients', patientUuids.join(','));
44
+ searchParams.set('v', defaultRep);
45
+
46
+ const url = `${restBaseUrl}/emrapi/inpatient/request?${searchParams.toString()}`;
47
+
48
+ const { data, isLoading, error, mutate } = useSWR<{ data: { results: Array<AdmissionRequest> } }>(url, openmrsFetch);
49
+
50
+ return {
51
+ admissionRequest: data?.data?.results ?? [],
52
+ isLoading: isLoading,
53
+ error: error,
54
+ mutate: mutate,
55
+ };
56
+ };
@@ -1,4 +1,5 @@
1
- import { OpenmrsResource } from '@openmrs/esm-framework';
1
+ import { AuditInfo, EncounterType, type Obs, type OpenmrsResource } from '@openmrs/esm-framework';
2
+ import { type Form } from '@openmrs/esm-patient-common-lib';
2
3
  export interface OpenmrsEncounter extends OpenmrsResource {
3
4
  encounterDatetime: string;
4
5
  encounterType: {
@@ -262,3 +263,29 @@ export interface ContactAttributeData {
262
263
  livingWithClient?: string;
263
264
  ipvOutCome?: string;
264
265
  }
266
+
267
+ interface DispositionEncounter extends OpenmrsResource {
268
+ encounterDatetime: string;
269
+ patient: OpenmrsResource;
270
+ location: OpenmrsResource;
271
+ form: Form;
272
+ encounterType: EncounterType;
273
+ obs: Obs[];
274
+ orders: any[];
275
+ voided: boolean;
276
+ auditInfo: AuditInfo;
277
+ visit: Visit;
278
+ encounterProviders: any[];
279
+ diagnoses: any[];
280
+ resourceVersion: string;
281
+ }
282
+
283
+ export interface AdmissionRequest {
284
+ dispositionLocation: OpenmrsResource;
285
+ dispositionType: string;
286
+ disposition: Concept;
287
+ dispositionEncounter: DispositionEncounter;
288
+ patient: Patient;
289
+ dispositionObsGroup: Obs;
290
+ visit: Visit;
291
+ }
@@ -10,6 +10,10 @@
10
10
  "addPNSContact": "የPNS እውቂያ ጨምር",
11
11
  "addRelationship": "ግንኙነት ጨምር",
12
12
  "admissionDate": "የመግቢያ ቀን",
13
+ "admissionLocation": "መግቢያ ቦታ",
14
+ "admissionRequest": "የመግቢያ ጥያቄ",
15
+ "admissionRequests": "የመግቢያ ጥያቄዎች",
16
+ "admissionType": "የመግቢያ ዓይነት",
13
17
  "admissionWard": "የመግቢያ Ward",
14
18
  "admittingDoctor": "የሚያስገባ ሀኪም",
15
19
  "age": "ዕድሜ",
@@ -59,6 +63,7 @@
59
63
  "dischargeDate": "የመልቀቂያ ቀን",
60
64
  "dischargingDoctor": "የሚለቅ ሀኪም",
61
65
  "discontinuationCases": "የማቋረጥ ጉዳዮች",
66
+ "disposition": "Disposition",
62
67
  "edit": "አስተካክል",
63
68
  "editContactList": "የእውቂያ ዝርዝር አስተካክል",
64
69
  "editEncounter": "አስተካክል",
@@ -103,11 +108,7 @@
103
108
  "htsResult": "የመጨረሻ ውጤት",
104
109
  "htsScreening": "HTS ምርመራ",
105
110
  "htsTestType": "የምርመራ አይነት",
106
- "inPatient": "የውስጥ ታካሚ",
107
- "inPatientForms": "የውስጥ ታካሚ ቅጾች",
108
111
  "inPatientSummary": "የውስጥ ታካሚ ማጠቃለያ",
109
- "inPatientView": "የውስጥ ታካሚ እይታ",
110
- "inPatientVisitMessage": "ለአሁኑ {{visitType}} ጉብኝት የውስጥ ታካሚ ግኝት ተገኝቷል",
111
112
  "ipvOutcome": "IPV ውጤት",
112
113
  "ipvOutCome": "IPV ውጤት",
113
114
  "ipvQuestions": "IPV ጥያቄዎች",
@@ -167,6 +168,7 @@
167
168
  "remarks": "ማስታወሻዎች",
168
169
  "reportingMonth": "ወር",
169
170
  "reportingYear": "ዓመት",
171
+ "requestDatetime": "Request Datetime",
170
172
  "save": "አስቀምጥ",
171
173
  "savedRelationship": "ግንኙነት በተሳካ ሁኔታ ተቋርጧል",
172
174
  "selectClinic": "ክሊኒክ ምረጥ",
@@ -10,6 +10,10 @@
10
10
  "addPNSContact": "Add PNS Contact",
11
11
  "addRelationship": "Add relationship",
12
12
  "admissionDate": "Admission Date",
13
+ "admissionLocation": "Admission Location",
14
+ "admissionRequest": "Admission Request",
15
+ "admissionRequests": "admission requests",
16
+ "admissionType": "Admission Type",
13
17
  "admissionWard": "Admission Ward",
14
18
  "admittingDoctor": "Admitting Doctor",
15
19
  "age": "Age",
@@ -59,6 +63,7 @@
59
63
  "dischargeDate": "Discharge Date",
60
64
  "dischargingDoctor": "Discharging Doctor",
61
65
  "discontinuationCases": "Discontinuation cases",
66
+ "disposition": "Disposition",
62
67
  "edit": "Edit",
63
68
  "editContactList": "Edit contact list",
64
69
  "editEncounter": "Edit",
@@ -103,11 +108,7 @@
103
108
  "htsResult": "Final result",
104
109
  "htsScreening": "HTS Screening",
105
110
  "htsTestType": "Test type",
106
- "inPatient": "In Patient",
107
- "inPatientForms": "In-Patient Forms",
108
111
  "inPatientSummary": "In Patient Summary",
109
- "inPatientView": "In Patient View",
110
- "inPatientVisitMessage": "in-patient encounter found for current {{visitType}} visit",
111
112
  "ipvOutcome": "IPV Outcome",
112
113
  "ipvOutCome": "IPV Outcome",
113
114
  "ipvQuestions": "IPV Questions",
@@ -167,6 +168,7 @@
167
168
  "remarks": "Remarks",
168
169
  "reportingMonth": "Month",
169
170
  "reportingYear": "Year",
171
+ "requestDatetime": "Request Datetime",
170
172
  "save": "Save",
171
173
  "savedRelationship": "Relationship ended successfully",
172
174
  "selectClinic": "Select Clinic",
@@ -10,6 +10,10 @@
10
10
  "addPNSContact": "Add PNS Contact",
11
11
  "addRelationship": "Add relationship",
12
12
  "admissionDate": "Admission Date",
13
+ "admissionLocation": "Admission Location",
14
+ "admissionRequest": "Admission Request",
15
+ "admissionRequests": "admission requests",
16
+ "admissionType": "Admission Type",
13
17
  "admissionWard": "Admission Ward",
14
18
  "admittingDoctor": "Admitting Doctor",
15
19
  "age": "Age",
@@ -59,6 +63,7 @@
59
63
  "dischargeDate": "Discharge Date",
60
64
  "dischargingDoctor": "Discharging Doctor",
61
65
  "discontinuationCases": "Discontinuation cases",
66
+ "disposition": "Disposition",
62
67
  "edit": "Edit",
63
68
  "editContactList": "Edit contact list",
64
69
  "editEncounter": "Edit",
@@ -103,11 +108,7 @@
103
108
  "htsResult": "Final result",
104
109
  "htsScreening": "HTS Screening",
105
110
  "htsTestType": "Test type",
106
- "inPatient": "In Patient",
107
- "inPatientForms": "In-Patient Forms",
108
111
  "inPatientSummary": "In Patient Summary",
109
- "inPatientView": "In Patient View",
110
- "inPatientVisitMessage": "in-patient encounter found for current {{visitType}} visit",
111
112
  "ipvOutcome": "IPV Outcome",
112
113
  "ipvOutCome": "IPV Outcome",
113
114
  "ipvQuestions": "IPV Questions",
@@ -167,6 +168,7 @@
167
168
  "remarks": "Remarks",
168
169
  "reportingMonth": "Month",
169
170
  "reportingYear": "Year",
171
+ "requestDatetime": "Request Datetime",
170
172
  "save": "Save",
171
173
  "savedRelationship": "Relationship ended successfully",
172
174
  "selectClinic": "Select Clinic",