@pih/esm-commons-app 2.1.1-pre.15 → 2.1.1-pre.154
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 -35
- package/dist/117.js +1 -0
- package/dist/117.js.map +1 -0
- package/dist/125.js +1 -0
- package/dist/125.js.map +1 -0
- package/dist/163.js +1 -0
- package/dist/163.js.map +1 -0
- package/dist/240.js +1 -0
- package/dist/240.js.map +1 -0
- package/dist/294.js +1 -0
- package/dist/294.js.map +1 -0
- package/dist/347.js +1 -0
- package/dist/347.js.map +1 -0
- package/dist/349.js +1 -0
- package/dist/349.js.map +1 -0
- package/dist/378.js +1 -0
- package/dist/378.js.map +1 -0
- package/dist/395.js +33 -0
- package/dist/395.js.map +1 -0
- package/dist/466.js +1 -0
- package/dist/466.js.map +1 -0
- package/dist/499.js +1 -0
- package/dist/499.js.map +1 -0
- package/dist/508.js +1 -0
- package/dist/508.js.map +1 -0
- package/dist/61.js +1 -0
- package/dist/61.js.map +1 -0
- package/dist/646.js +17 -0
- package/dist/646.js.map +1 -0
- package/dist/664.js +1 -0
- package/dist/664.js.map +1 -0
- package/dist/689.js +1 -0
- package/dist/689.js.map +1 -0
- package/dist/701.js +1 -0
- package/dist/701.js.map +1 -0
- package/dist/712.js +1 -0
- package/dist/712.js.map +1 -0
- package/dist/72.js +1 -0
- package/dist/72.js.map +1 -0
- package/dist/743.js +1 -0
- package/dist/743.js.map +1 -0
- package/dist/771.js +1 -0
- package/dist/771.js.map +1 -0
- package/dist/830.js +1 -0
- package/dist/830.js.map +1 -0
- package/dist/846.js +11 -0
- package/dist/846.js.map +1 -0
- package/dist/852.js +1 -0
- package/dist/852.js.map +1 -0
- package/dist/855.js +1 -0
- package/dist/855.js.map +1 -0
- package/dist/859.js +1 -0
- package/dist/859.js.map +1 -0
- package/dist/867.js +1 -0
- package/dist/867.js.map +1 -0
- package/dist/912.js +1 -0
- package/dist/912.js.map +1 -0
- package/dist/913.js +1 -0
- package/dist/913.js.map +1 -0
- package/dist/959.js +1 -0
- package/dist/959.js.map +1 -0
- package/dist/985.js +1 -0
- package/dist/985.js.map +1 -0
- package/dist/989.js +1 -0
- package/dist/989.js.map +1 -0
- package/dist/main.js +3 -1
- package/dist/main.js.map +1 -1
- package/dist/pih-esm-commons-app.js +3 -1
- package/dist/pih-esm-commons-app.js.buildmanifest.json +642 -107
- package/dist/pih-esm-commons-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +7 -10
- package/rspack.config.js +1 -0
- package/src/config-schema.ts +85 -0
- package/src/declarations.d.ts +2 -0
- package/src/dispensing/prescription-label-print-action.extension.test.tsx +47 -0
- package/src/dispensing/prescription-label-print-action.extension.tsx +45 -0
- package/src/dispensing/prescription-label-print.modal.test.tsx +125 -0
- package/src/dispensing/prescription-label-print.modal.tsx +139 -0
- package/src/dispensing/prescription-label-print.types.ts +16 -0
- package/src/dispensing/zebra-label-print-action.extension.tsx +66 -0
- package/src/dispensing/zebra-label-print.resource.ts +70 -0
- package/src/dispensing/zebra-pdf-print.ts +108 -0
- package/src/hooks/useConceptReferenceRanges.ts +128 -0
- package/src/hooks/useEncounters.ts +22 -0
- package/src/hooks/useVisitAttribute.ts +37 -0
- package/src/index.ts +49 -12
- package/src/routes.json +76 -11
- package/src/service-queues-app/maternal-triage-form.workspace.tsx +111 -0
- package/src/service-queues-app/maternal-triage-queue-actions.extension.tsx +132 -0
- package/src/service-queues-app/maternal-triage-queue-actions.resource.ts +84 -0
- package/src/service-queues-app/maternal-trial-queue-actions.scss +14 -0
- package/src/service-queues-app/types.ts +58 -0
- package/src/ward-app/VitalsTable.tsx +361 -0
- package/src/ward-app/inborn-outborn-tag-row.extension.tsx +79 -0
- package/src/ward-app/inborn-outborn-tag-row.scss +57 -0
- package/src/ward-app/o2-iframe.component.tsx +13 -4
- package/src/ward-app/o2-pregnancy-infant-dashboard.extension.tsx +29 -10
- package/src/ward-app/o2-pregnancy-infant-dashboard.scss +5 -0
- package/src/ward-app/o2-visit-summary-action-button.component.tsx +17 -0
- package/src/ward-app/o2-visit-summary-workspace.component.tsx +104 -26
- package/src/ward-app/o2-vital-signs-action-button.component.tsx +17 -0
- package/src/ward-app/o2-vital-signs-workspace.component.tsx +65 -0
- package/src/ward-app/types.ts +7 -4
- package/translations/en.json +32 -3
- package/translations/es.json +15 -1
- package/translations/fr.json +15 -1
- package/dist/138.js +0 -1
- package/dist/138.js.map +0 -1
- package/dist/291.js +0 -1
- package/dist/291.js.map +0 -1
- package/dist/300.js +0 -1
- package/dist/372.js +0 -1
- package/dist/372.js.map +0 -1
- package/dist/41.js +0 -2
- package/dist/41.js.LICENSE.txt +0 -9
- package/dist/41.js.map +0 -1
- package/dist/411.js +0 -2
- package/dist/411.js.LICENSE.txt +0 -5
- package/dist/411.js.map +0 -1
- package/dist/449.js +0 -2
- package/dist/449.js.LICENSE.txt +0 -9
- package/dist/449.js.map +0 -1
- package/dist/55.js +0 -1
- package/dist/641.js +0 -1
- package/dist/641.js.map +0 -1
- package/dist/660.js +0 -1
- package/dist/660.js.map +0 -1
- package/dist/831.js +0 -2
- package/dist/831.js.LICENSE.txt +0 -5
- package/dist/831.js.map +0 -1
- package/dist/90.js +0 -1
- package/dist/90.js.map +0 -1
- package/dist/99.js +0 -1
- package/src/ward-app/o2-visit-summary-action-button.extension.tsx +0 -18
- package/webpack.config.js +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Minimal interfaces — mirror the relevant fields from the dispensing app's types
|
|
2
|
+
// without introducing a hard dependency on that module.
|
|
3
|
+
export interface MedicationDispense {
|
|
4
|
+
id?: string;
|
|
5
|
+
status?: string;
|
|
6
|
+
medicationReference?: { display?: string };
|
|
7
|
+
quantity?: { value?: number; unit?: string };
|
|
8
|
+
whenHandedOver?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface MedicationRequestBundle {
|
|
12
|
+
request: { id?: string; medicationReference?: { display?: string } };
|
|
13
|
+
dispenses: Array<MedicationDispense>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const COMPLETED_STATUS = 'completed';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button } from '@carbon/react';
|
|
3
|
+
import { Printer } from '@carbon/react/icons';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { showSnackbar, useConfig } from '@openmrs/esm-framework';
|
|
6
|
+
import { type ConfigObject } from '../config-schema';
|
|
7
|
+
import { printDispenseLabelsToZebra } from './zebra-label-print.resource';
|
|
8
|
+
|
|
9
|
+
// Minimal interface — mirrors the relevant fields from the dispensing app's MedicationDispense type
|
|
10
|
+
// without introducing a hard dependency on that module.
|
|
11
|
+
interface MedicationDispense {
|
|
12
|
+
id?: string;
|
|
13
|
+
status?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ZebraLabelPrintActionProps {
|
|
17
|
+
medicationDispense: MedicationDispense;
|
|
18
|
+
patientUuid: string;
|
|
19
|
+
encounterUuid: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const COMPLETED_STATUS = 'completed';
|
|
23
|
+
|
|
24
|
+
const ZebraLabelPrintAction: React.FC<ZebraLabelPrintActionProps> = ({ medicationDispense }) => {
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
const { medicationDispenseLabel: config } = useConfig<ConfigObject>().dispensing;
|
|
27
|
+
const [isPrinting, setIsPrinting] = useState(false);
|
|
28
|
+
|
|
29
|
+
if (!config.enabled || medicationDispense?.status !== COMPLETED_STATUS || !medicationDispense?.id) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const handlePrint = () => {
|
|
34
|
+
setIsPrinting(true);
|
|
35
|
+
printDispenseLabelsToZebra({
|
|
36
|
+
dispenseUuids: [medicationDispense.id],
|
|
37
|
+
reportDefinitionUuid: config.reportDefinitionUuid,
|
|
38
|
+
reportDesignUuid: config.reportDesignUuid,
|
|
39
|
+
printMethod: config.printMethod,
|
|
40
|
+
browserPrintFeatureKey: config.browserPrintFeatureKey,
|
|
41
|
+
})
|
|
42
|
+
.then(() => {
|
|
43
|
+
showSnackbar({
|
|
44
|
+
kind: 'success',
|
|
45
|
+
title: t('success', 'Success'),
|
|
46
|
+
subtitle: t('labelSentToPrinter', 'Label sent to printer'),
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
.catch((err: Error) => {
|
|
50
|
+
showSnackbar({
|
|
51
|
+
kind: 'error',
|
|
52
|
+
title: t('printLabelFailed', 'Print label failed'),
|
|
53
|
+
subtitle: err?.message ?? t('unknownError', 'An unknown error occurred'),
|
|
54
|
+
});
|
|
55
|
+
})
|
|
56
|
+
.finally(() => setIsPrinting(false));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Button kind="ghost" size="sm" renderIcon={Printer} disabled={isPrinting} onClick={handlePrint}>
|
|
61
|
+
{isPrinting ? t('printing', 'Printing…') : t('printLabel', 'Print label')}
|
|
62
|
+
</Button>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default ZebraLabelPrintAction;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
+
import { getDefaultZebraDevice } from './zebra-pdf-print';
|
|
3
|
+
|
|
4
|
+
export interface PrintDispenseLabelsOptions {
|
|
5
|
+
/** Medication dispenses to print a label for; one page is printed per dispense. */
|
|
6
|
+
dispenseUuids: Array<string>;
|
|
7
|
+
/** Also print the summary label for the outer bag. */
|
|
8
|
+
printBagLabel?: boolean;
|
|
9
|
+
/** Prescription encounter, used by the report to build the bag label. */
|
|
10
|
+
encounterUuid?: string;
|
|
11
|
+
reportDefinitionUuid: string;
|
|
12
|
+
reportDesignUuid: string;
|
|
13
|
+
printMethod?: 'pdf-direct' | 'browser-print';
|
|
14
|
+
browserPrintFeatureKey?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function printDispenseLabelsToZebra({
|
|
18
|
+
dispenseUuids,
|
|
19
|
+
printBagLabel = false,
|
|
20
|
+
encounterUuid,
|
|
21
|
+
reportDefinitionUuid,
|
|
22
|
+
reportDesignUuid,
|
|
23
|
+
printMethod = 'pdf-direct',
|
|
24
|
+
browserPrintFeatureKey = '',
|
|
25
|
+
}: PrintDispenseLabelsOptions): Promise<void> {
|
|
26
|
+
// The reporting REST endpoint only reads single-valued parameters, so the list is sent comma-separated.
|
|
27
|
+
const params = new URLSearchParams({
|
|
28
|
+
medicationDispenseUuids: dispenseUuids.join(','),
|
|
29
|
+
printBagLabel: String(printBagLabel),
|
|
30
|
+
});
|
|
31
|
+
if (encounterUuid) {
|
|
32
|
+
params.set('encounterUuid', encounterUuid);
|
|
33
|
+
}
|
|
34
|
+
const url = `${restBaseUrl}/reportingrest/runReport/${reportDefinitionUuid}/${reportDesignUuid}?${params.toString()}`;
|
|
35
|
+
|
|
36
|
+
const [response, device] = await Promise.all([openmrsFetch(url, { method: 'POST' }), getDefaultZebraDevice()]);
|
|
37
|
+
|
|
38
|
+
const pdf = await response.blob();
|
|
39
|
+
|
|
40
|
+
if (device) {
|
|
41
|
+
try {
|
|
42
|
+
if (printMethod === 'pdf-direct') {
|
|
43
|
+
await device.sendFile(pdf);
|
|
44
|
+
} else {
|
|
45
|
+
const options = browserPrintFeatureKey ? { keys: { pdf: browserPrintFeatureKey } } : undefined;
|
|
46
|
+
await device.convertAndSendFile(pdf, options);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
} catch {
|
|
50
|
+
// fall through to browser print dialog
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
openBrowserPrintDialog(pdf);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function openBrowserPrintDialog(blob: Blob): void {
|
|
58
|
+
const url = URL.createObjectURL(blob);
|
|
59
|
+
const iframe = document.createElement('iframe');
|
|
60
|
+
iframe.style.cssText = 'position:fixed;width:0;height:0;opacity:0;pointer-events:none;';
|
|
61
|
+
iframe.src = url;
|
|
62
|
+
document.body.appendChild(iframe);
|
|
63
|
+
iframe.onload = () => {
|
|
64
|
+
iframe.contentWindow?.print();
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
document.body.removeChild(iframe);
|
|
67
|
+
URL.revokeObjectURL(url);
|
|
68
|
+
}, 60_000);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Zebra Browser Print client for PDF label printing.
|
|
3
|
+
*
|
|
4
|
+
* Both print pathways route through the Zebra Browser Print helper app
|
|
5
|
+
* running locally at 127.0.0.1:9100 (HTTP) or 127.0.0.1:9101 (HTTPS).
|
|
6
|
+
* The helper must be installed and running on the user's machine.
|
|
7
|
+
*
|
|
8
|
+
* PATHWAY 1 — PDF Direct (recommended for Link-OS printers):
|
|
9
|
+
* Sends raw PDF bytes to the helper via POST /write.
|
|
10
|
+
* The helper proxies the bytes to the printer, which rasterizes the PDF
|
|
11
|
+
* internally using its own firmware renderer. Requires the printer to have
|
|
12
|
+
* Link-OS with apl.enable = "pdf". No license key needed.
|
|
13
|
+
*
|
|
14
|
+
* PATHWAY 2 — Browser Print conversion (fallback for older printers):
|
|
15
|
+
* Sends the PDF to the helper via POST /convert.
|
|
16
|
+
* The helper converts PDF→ZPL and sends the resulting ZPL to the printer.
|
|
17
|
+
* Works on any Zebra printer. On Windows/macOS with the official Zebra helper,
|
|
18
|
+
* a PDF conversion license key is required. On Linux with the open-source shim
|
|
19
|
+
* (pih/zebra-printing-tools), no key is needed.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const HELPER_BASE =
|
|
23
|
+
typeof location !== 'undefined' && location.protocol === 'https:'
|
|
24
|
+
? 'https://127.0.0.1:9101'
|
|
25
|
+
: 'http://127.0.0.1:9100';
|
|
26
|
+
|
|
27
|
+
async function helperRequest(method: string, path: string, body?: string | FormData): Promise<string> {
|
|
28
|
+
const opts: RequestInit = { method };
|
|
29
|
+
if (body !== undefined) {
|
|
30
|
+
if (typeof body === 'string') {
|
|
31
|
+
opts.headers = { 'Content-Type': 'text/plain;charset=UTF-8' };
|
|
32
|
+
opts.body = body;
|
|
33
|
+
} else {
|
|
34
|
+
opts.body = body; // FormData — do not set Content-Type; fetch supplies the multipart boundary
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const r = await fetch(HELPER_BASE + path, opts);
|
|
38
|
+
const text = await r.text();
|
|
39
|
+
if (!r.ok) throw new Error(`Zebra helper ${method} ${path} → ${r.status}: ${text}`);
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class ZebraDevice {
|
|
44
|
+
private readonly _json: object;
|
|
45
|
+
private _queue: Promise<unknown> = Promise.resolve();
|
|
46
|
+
|
|
47
|
+
constructor(json: object) {
|
|
48
|
+
this._json = json;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private _enqueue<T>(op: () => Promise<T>): Promise<T> {
|
|
52
|
+
// Serialize all operations on this device so concurrent calls don't
|
|
53
|
+
// interleave their /write+/read pairs and produce garbled responses.
|
|
54
|
+
const next = this._queue.then(
|
|
55
|
+
() => op(),
|
|
56
|
+
() => op(),
|
|
57
|
+
);
|
|
58
|
+
this._queue = next.catch(() => {});
|
|
59
|
+
return next;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* PDF Direct: raw PDF bytes → printer firmware renders them.
|
|
64
|
+
* Simpler and faster when the printer supports it (Link-OS, apl.enable = "pdf").
|
|
65
|
+
*/
|
|
66
|
+
sendFile(pdfBlob: Blob): Promise<string> {
|
|
67
|
+
return this._enqueue(() => {
|
|
68
|
+
const fd = new FormData();
|
|
69
|
+
fd.append('json', JSON.stringify({ device: this._json }));
|
|
70
|
+
fd.append('blob', pdfBlob);
|
|
71
|
+
return helperRequest('POST', '/write', fd);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Browser Print conversion: helper converts PDF→ZPL, then sends ZPL.
|
|
77
|
+
* Works on any Zebra printer. Pass options.keys.pdf for Windows/macOS.
|
|
78
|
+
*/
|
|
79
|
+
convertAndSendFile(pdfBlob: Blob, options?: { keys?: { pdf?: string } }): Promise<string> {
|
|
80
|
+
return this._enqueue(() => {
|
|
81
|
+
const opts: Record<string, unknown> = { action: 'print', ...options };
|
|
82
|
+
if (!opts.fromFormat && pdfBlob.type) {
|
|
83
|
+
const t = pdfBlob.type.toLowerCase();
|
|
84
|
+
if (t.startsWith('image/') || t.startsWith('application/')) {
|
|
85
|
+
opts.fromFormat = t.replace('image/', '').replace('application/', '').replace('x-ms-', '');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const fd = new FormData();
|
|
89
|
+
fd.append('json', JSON.stringify({ options: opts, device: this._json }));
|
|
90
|
+
fd.append('blob', pdfBlob);
|
|
91
|
+
return helperRequest('POST', '/convert', fd);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the default device registered with the Browser Print helper,
|
|
98
|
+
* or null if the helper is not running or no device is configured.
|
|
99
|
+
*/
|
|
100
|
+
export async function getDefaultZebraDevice(): Promise<ZebraDevice | null> {
|
|
101
|
+
try {
|
|
102
|
+
const text = await helperRequest('GET', '/default?type=printer');
|
|
103
|
+
if (!text) return null;
|
|
104
|
+
return new ZebraDevice(JSON.parse(text));
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import useSWRImmutable from 'swr/immutable';
|
|
2
|
+
import { restBaseUrl, openmrsFetch } from '@openmrs/esm-framework';
|
|
3
|
+
|
|
4
|
+
export type ObservationInterpretation =
|
|
5
|
+
| 'normal'
|
|
6
|
+
| 'high'
|
|
7
|
+
| 'critically_high'
|
|
8
|
+
| 'off_scale_high'
|
|
9
|
+
| 'low'
|
|
10
|
+
| 'critically_low'
|
|
11
|
+
| 'off_scale_low';
|
|
12
|
+
|
|
13
|
+
export type ReferenceRangeValue = number | null | undefined;
|
|
14
|
+
|
|
15
|
+
export interface ObsReferenceRanges {
|
|
16
|
+
hiAbsolute: ReferenceRangeValue;
|
|
17
|
+
hiCritical: ReferenceRangeValue;
|
|
18
|
+
hiNormal: ReferenceRangeValue;
|
|
19
|
+
lowNormal: ReferenceRangeValue;
|
|
20
|
+
lowCritical: ReferenceRangeValue;
|
|
21
|
+
lowAbsolute: ReferenceRangeValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ConceptReferenceRangeResponse {
|
|
25
|
+
results: Array<{
|
|
26
|
+
concept: string;
|
|
27
|
+
display: string;
|
|
28
|
+
hiNormal?: number | null;
|
|
29
|
+
hiAbsolute?: number | null;
|
|
30
|
+
hiCritical?: number | null;
|
|
31
|
+
lowNormal?: number | null;
|
|
32
|
+
lowAbsolute?: number | null;
|
|
33
|
+
lowCritical?: number | null;
|
|
34
|
+
units?: string | null;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function fetchReferenceRange(
|
|
39
|
+
conceptUuid: string,
|
|
40
|
+
patientUuid: string | undefined,
|
|
41
|
+
): Promise<ObsReferenceRanges | undefined> {
|
|
42
|
+
const url = `${restBaseUrl}/conceptreferencerange/?concept=${conceptUuid}&v=full${
|
|
43
|
+
patientUuid ? `&patient=${patientUuid}` : ''
|
|
44
|
+
}`;
|
|
45
|
+
const response = await openmrsFetch<ConceptReferenceRangeResponse>(url);
|
|
46
|
+
const conceptData = response.data?.results?.[0];
|
|
47
|
+
|
|
48
|
+
if (!conceptData) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
hiNormal: conceptData.hiNormal ?? null,
|
|
54
|
+
hiAbsolute: conceptData.hiAbsolute ?? null,
|
|
55
|
+
hiCritical: conceptData.hiCritical ?? null,
|
|
56
|
+
lowNormal: conceptData.lowNormal ?? null,
|
|
57
|
+
lowAbsolute: conceptData.lowAbsolute ?? null,
|
|
58
|
+
lowCritical: conceptData.lowCritical ?? null,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function calculateInterpretation(
|
|
63
|
+
value: string | number | object | undefined,
|
|
64
|
+
range?: ObsReferenceRanges,
|
|
65
|
+
): ObservationInterpretation {
|
|
66
|
+
if (!range || value === undefined || value === null || value === '') {
|
|
67
|
+
return 'normal';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const numericValue =
|
|
71
|
+
typeof value === 'string' ? Number.parseFloat(value) : typeof value === 'number' ? value : undefined;
|
|
72
|
+
|
|
73
|
+
if (numericValue === undefined || Number.isNaN(numericValue)) {
|
|
74
|
+
return 'normal';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (Number.isNaN(numericValue)) {
|
|
78
|
+
return 'normal';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (range.hiAbsolute !== null && range.hiAbsolute !== undefined && numericValue > range.hiAbsolute) {
|
|
82
|
+
return 'off_scale_high';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (range.hiCritical !== null && range.hiCritical !== undefined && numericValue >= range.hiCritical) {
|
|
86
|
+
return 'critically_high';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (range.hiNormal !== null && range.hiNormal !== undefined && numericValue > range.hiNormal) {
|
|
90
|
+
return 'high';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (range.lowAbsolute !== null && range.lowAbsolute !== undefined && numericValue < range.lowAbsolute) {
|
|
94
|
+
return 'off_scale_low';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (range.lowCritical !== null && range.lowCritical !== undefined && numericValue <= range.lowCritical) {
|
|
98
|
+
return 'critically_low';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (range.lowNormal !== null && range.lowNormal !== undefined && numericValue < range.lowNormal) {
|
|
102
|
+
return 'low';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return 'normal';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function useConceptReferenceRanges(patientUuid: string | undefined, conceptUuids: string[]) {
|
|
109
|
+
const stableConceptUuids = conceptUuids.filter(Boolean).sort();
|
|
110
|
+
const shouldFetch = Boolean(patientUuid && stableConceptUuids.length > 0);
|
|
111
|
+
const cacheKey = shouldFetch ? ['conceptReferenceRanges', patientUuid, stableConceptUuids.join(',')] : null;
|
|
112
|
+
|
|
113
|
+
const { data, error, isLoading } = useSWRImmutable(cacheKey, async () => {
|
|
114
|
+
const entries = await Promise.all(
|
|
115
|
+
stableConceptUuids.map(
|
|
116
|
+
async (conceptUuid) => [conceptUuid, await fetchReferenceRange(conceptUuid, patientUuid)] as const,
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return Object.fromEntries(entries.filter(([, range]) => range !== undefined)) as Record<string, ObsReferenceRanges>;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
referenceRangeMap: data ?? {},
|
|
125
|
+
error,
|
|
126
|
+
isLoading,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { restBaseUrl, useOpenmrsFetchAll } from '@openmrs/esm-framework';
|
|
2
|
+
import { type Encounter } from '../service-queues-app/types';
|
|
3
|
+
|
|
4
|
+
interface EncounterSearchParams {
|
|
5
|
+
patient: string;
|
|
6
|
+
visit?: string;
|
|
7
|
+
encounterType?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useEncounters(params: EncounterSearchParams) {
|
|
11
|
+
const url = `${restBaseUrl}/encounter?`;
|
|
12
|
+
const searchParams = new URLSearchParams();
|
|
13
|
+
searchParams.append('patient', params.patient);
|
|
14
|
+
if (params.visit) {
|
|
15
|
+
searchParams.append('visit', params.visit);
|
|
16
|
+
}
|
|
17
|
+
if (params.encounterType) {
|
|
18
|
+
searchParams.append('encounterType', params.encounterType);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return useOpenmrsFetchAll<Encounter>(url + searchParams.toString());
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { restBaseUrl, useOpenmrsFetchAll } from '@openmrs/esm-framework';
|
|
2
|
+
|
|
3
|
+
export interface VisitAttribute {
|
|
4
|
+
uuid: string;
|
|
5
|
+
display?: string;
|
|
6
|
+
value: boolean | string | number;
|
|
7
|
+
attributeType: {
|
|
8
|
+
uuid: string;
|
|
9
|
+
display?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
const visitAttributeCustomRepresentation =
|
|
15
|
+
'custom:(uuid,value,attributeType:(uuid,display))';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Fetches the attribute of a given type for a given visit.
|
|
19
|
+
*
|
|
20
|
+
* The default visit representation used by the ward admission/request hooks does not include
|
|
21
|
+
* attribute values, so this hook queries the visit's attribute subresource directly and returns the
|
|
22
|
+
* single attribute matching `attributeTypeUuid` (or `undefined` if the visit has no such attribute).
|
|
23
|
+
*
|
|
24
|
+
* @param visitUuid the visit whose attributes to fetch. When falsy, no request is made.
|
|
25
|
+
* @param attributeTypeUuid the visit attribute type to look for.
|
|
26
|
+
*/
|
|
27
|
+
export function useVisitAttribute(visitUuid: string, attributeTypeUuid: string) {
|
|
28
|
+
const apiUrl = visitUuid
|
|
29
|
+
? `${restBaseUrl}/visit/${visitUuid}/attribute?v=${visitAttributeCustomRepresentation}`
|
|
30
|
+
: null;
|
|
31
|
+
|
|
32
|
+
const { data, ...rest } = useOpenmrsFetchAll<VisitAttribute>(apiUrl);
|
|
33
|
+
|
|
34
|
+
const attribute = data?.find((attr) => attr.attributeType?.uuid === attributeTypeUuid);
|
|
35
|
+
|
|
36
|
+
return { attribute, value: attribute?.value, ...rest };
|
|
37
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,31 +5,68 @@
|
|
|
5
5
|
* microfrontend.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { getAsyncLifecycle } from '@openmrs/esm-framework';
|
|
8
|
+
import { getAsyncLifecycle, defineConfigSchema } from '@openmrs/esm-framework';
|
|
9
|
+
import { configSchema } from './config-schema';
|
|
9
10
|
|
|
10
11
|
const moduleName = '@pih/esm-commons-app';
|
|
11
|
-
const options = {
|
|
12
|
-
featureName: 'commons',
|
|
13
|
-
moduleName,
|
|
14
|
-
};
|
|
15
12
|
|
|
16
13
|
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');
|
|
17
14
|
|
|
18
|
-
// export const root = getAsyncLifecycle(() => import('./root.component'), options);
|
|
19
|
-
|
|
20
15
|
export const o2VisitSummaryWorkspaceSideRailIcon = getAsyncLifecycle(
|
|
21
|
-
() => import('./ward-app/o2-visit-summary-action-button.
|
|
22
|
-
|
|
16
|
+
() => import('./ward-app/o2-visit-summary-action-button.component'),
|
|
17
|
+
{ featureName: 'o2VisitSummaryWorkspaceSideRailIcon', moduleName },
|
|
23
18
|
);
|
|
24
19
|
|
|
25
20
|
export const o2VisitSummaryWorkspace = getAsyncLifecycle(
|
|
26
21
|
() => import('./ward-app/o2-visit-summary-workspace.component'),
|
|
27
|
-
|
|
22
|
+
{ featureName: 'o2VisitSummaryWorkspace', moduleName },
|
|
28
23
|
);
|
|
29
24
|
|
|
25
|
+
export const o2VitalSignsWorkspaceSideRailIcon = getAsyncLifecycle(
|
|
26
|
+
() => import('./ward-app/o2-vital-signs-action-button.component'),
|
|
27
|
+
{ featureName: 'o2VitalSignsWorkspaceSideRailIcon', moduleName },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const o2VitalSignsWorkspace = getAsyncLifecycle(() => import('./ward-app/o2-vital-signs-workspace.component'), {
|
|
31
|
+
featureName: 'o2VitalSignsWorkspace',
|
|
32
|
+
moduleName,
|
|
33
|
+
});
|
|
34
|
+
|
|
30
35
|
export const o2PregnancyInfantDashboard = getAsyncLifecycle(
|
|
31
36
|
() => import('./ward-app/o2-pregnancy-infant-dashboard.extension'),
|
|
32
|
-
|
|
37
|
+
{ featureName: 'o2PregnancyInfantDashboard', moduleName },
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const maternalTriageFormWorkspace = getAsyncLifecycle(
|
|
41
|
+
() => import('./service-queues-app/maternal-triage-form.workspace'),
|
|
42
|
+
{ featureName: 'maternalTriageFormWorkspace', moduleName },
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const triageWaitingQueueActions = getAsyncLifecycle(
|
|
46
|
+
() => import('./service-queues-app/maternal-triage-queue-actions.extension'),
|
|
47
|
+
{ featureName: 'triageWaitingQueueActions', moduleName },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const zebraLabelPrintAction = getAsyncLifecycle(
|
|
51
|
+
() => import('./dispensing/zebra-label-print-action.extension'),
|
|
52
|
+
{ featureName: 'zebraLabelPrintAction', moduleName },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const prescriptionLabelPrintAction = getAsyncLifecycle(
|
|
56
|
+
() => import('./dispensing/prescription-label-print-action.extension'),
|
|
57
|
+
{ featureName: 'prescriptionLabelPrintAction', moduleName },
|
|
33
58
|
);
|
|
34
59
|
|
|
35
|
-
export
|
|
60
|
+
export const prescriptionLabelPrintModal = getAsyncLifecycle(
|
|
61
|
+
() => import('./dispensing/prescription-label-print.modal'),
|
|
62
|
+
{ featureName: 'prescriptionLabelPrintModal', moduleName },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export const inbornOutbornTag = getAsyncLifecycle(() => import('./ward-app/inborn-outborn-tag-row.extension'), {
|
|
66
|
+
featureName: 'inbornOutbornTag',
|
|
67
|
+
moduleName,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export function startupApp() {
|
|
71
|
+
defineConfigSchema(moduleName, configSchema);
|
|
72
|
+
}
|
package/src/routes.json
CHANGED
|
@@ -1,28 +1,93 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.openmrs.org/routes.schema.json",
|
|
3
3
|
"pages": [
|
|
4
|
-
],
|
|
5
|
-
"extensions": [
|
|
6
4
|
{
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
5
|
+
"component": "root",
|
|
6
|
+
"route": "appointments"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"component": "root",
|
|
10
|
+
"route": "service-queues"
|
|
10
11
|
},
|
|
12
|
+
{
|
|
13
|
+
"component": "root",
|
|
14
|
+
"route": "dispensing2"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"component": "root",
|
|
18
|
+
"route": "ward"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"extensions": [
|
|
11
22
|
{
|
|
12
23
|
"name": "o2-pregnancy-infant-dashboard",
|
|
13
24
|
"component": "o2PregnancyInfantDashboard",
|
|
14
25
|
"slot": "ward-patient-workspace-content-slot"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "triage-waiting-queue-actions",
|
|
29
|
+
"component": "triageWaitingQueueActions",
|
|
30
|
+
"slot": "queue-table-triage-waiting-queue-actions-slot"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "zebra-label-print-action",
|
|
34
|
+
"component": "zebraLabelPrintAction",
|
|
35
|
+
"slot": "medication-dispense-action-slot"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "prescription-label-print-action",
|
|
39
|
+
"component": "prescriptionLabelPrintAction",
|
|
40
|
+
"slot": "prescription-actions-footer-slot"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "inborn-outborn-tag",
|
|
44
|
+
"component": "inbornOutbornTag",
|
|
45
|
+
"slot": "maternal-ward-patient-card-header-slot"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"modals": [
|
|
49
|
+
{
|
|
50
|
+
"name": "prescription-label-print-modal",
|
|
51
|
+
"component": "prescriptionLabelPrintModal"
|
|
15
52
|
}
|
|
16
53
|
],
|
|
17
|
-
"
|
|
54
|
+
"workspaces2": [
|
|
18
55
|
{
|
|
19
56
|
"name": "o2-visit-summary-workspace",
|
|
20
57
|
"component": "o2VisitSummaryWorkspace",
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
58
|
+
"window": "o2-visit-summary-window"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "o2-vital-signs-workspace",
|
|
62
|
+
"component": "o2VitalSignsWorkspace",
|
|
63
|
+
"window": "o2-vital-signs-window"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "maternal-triage-form-workspace",
|
|
67
|
+
"component": "maternalTriageFormWorkspace",
|
|
68
|
+
"window": "maternal-triage-form-window"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"workspaceWindows2": [
|
|
72
|
+
{
|
|
73
|
+
"name": "o2-visit-summary-window",
|
|
74
|
+
"icon": "o2VisitSummaryWorkspaceSideRailIcon",
|
|
75
|
+
"group": "ward-patient",
|
|
76
|
+
"width": "extra-wide",
|
|
77
|
+
"canMaximize": true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "o2-vital-signs-window",
|
|
81
|
+
"icon": "o2VitalSignsWorkspaceSideRailIcon",
|
|
82
|
+
"group": "ward-patient",
|
|
83
|
+
"width": "extra-wide",
|
|
84
|
+
"canMaximize": true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "maternal-triage-form-window",
|
|
88
|
+
"group": "service-queues",
|
|
89
|
+
"width": "extra-wide",
|
|
90
|
+
"canMaximize": true
|
|
26
91
|
}
|
|
27
92
|
]
|
|
28
93
|
}
|