@openmrs/esm-generic-patient-widgets-app 11.3.1-patch.9064 → 11.3.1-patch.9310
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 +22 -19
- package/dist/1119.js +1 -1
- package/dist/1197.js +1 -1
- package/dist/2146.js +1 -1
- package/dist/2499.js +2 -0
- package/dist/2499.js.map +1 -0
- package/dist/2690.js +1 -1
- package/dist/3099.js +1 -1
- package/dist/3204.js +2 -0
- package/dist/3204.js.map +1 -0
- package/dist/3584.js +1 -1
- package/dist/4055.js +1 -1
- package/dist/4132.js +1 -1
- package/dist/4300.js +1 -1
- package/dist/4335.js +1 -1
- package/dist/4341.js +1 -0
- package/dist/4341.js.map +1 -0
- package/dist/4618.js +1 -1
- package/dist/4652.js +1 -1
- package/dist/4944.js +1 -1
- package/dist/5173.js +1 -1
- package/dist/5241.js +1 -1
- package/dist/5442.js +1 -1
- package/dist/5661.js +1 -1
- package/dist/5670.js +1 -1
- package/dist/5670.js.map +1 -1
- package/dist/6022.js +1 -1
- package/dist/6336.js +1 -0
- package/dist/6336.js.map +1 -0
- package/dist/6468.js +1 -1
- package/dist/6679.js +1 -1
- package/dist/6840.js +1 -1
- package/dist/6859.js +1 -1
- package/dist/7097.js +1 -1
- package/dist/7159.js +1 -1
- package/dist/723.js +1 -1
- package/dist/7617.js +1 -1
- package/dist/795.js +1 -1
- package/dist/8163.js +1 -1
- package/dist/8349.js +1 -1
- package/dist/8618.js +1 -1
- package/dist/890.js +1 -1
- package/dist/9214.js +1 -1
- package/dist/9351.js +1 -0
- package/dist/9351.js.map +1 -0
- package/dist/9538.js +1 -1
- package/dist/9569.js +1 -1
- package/dist/986.js +1 -1
- package/dist/9879.js +1 -1
- package/dist/9895.js +1 -1
- package/dist/9900.js +1 -1
- package/dist/9913.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-generic-patient-widgets-app.js +1 -1
- package/dist/openmrs-esm-generic-patient-widgets-app.js.buildmanifest.json +246 -246
- package/dist/openmrs-esm-generic-patient-widgets-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -3
- package/src/obs-graph/obs-graph.component.tsx +81 -32
- package/src/obs-graph/obs-graph.scss +19 -11
- package/src/obs-switchable/obs-switchable.component.tsx +8 -3
- package/src/obs-switchable/obs-switchable.test.tsx +45 -29
- package/src/obs-table/obs-table.component.tsx +6 -4
- package/src/obs-table-horizontal/obs-table-horizontal.component.tsx +7 -4
- package/src/resources/useConcepts.ts +41 -0
- package/src/resources/useObs.ts +31 -4
- package/translations/am.json +1 -0
- package/translations/ar.json +1 -0
- package/translations/ar_SY.json +1 -0
- package/translations/bn.json +1 -0
- package/translations/de.json +1 -0
- package/translations/en.json +1 -0
- package/translations/en_US.json +1 -0
- package/translations/es.json +1 -0
- package/translations/es_MX.json +1 -0
- package/translations/fr.json +1 -0
- package/translations/he.json +1 -0
- package/translations/hi.json +1 -0
- package/translations/hi_IN.json +1 -0
- package/translations/id.json +1 -0
- package/translations/it.json +1 -0
- package/translations/ka.json +1 -0
- package/translations/km.json +1 -0
- package/translations/ku.json +1 -0
- package/translations/ky.json +1 -0
- package/translations/lg.json +1 -0
- package/translations/ne.json +1 -0
- package/translations/pl.json +1 -0
- package/translations/pt.json +1 -0
- package/translations/pt_BR.json +1 -0
- package/translations/qu.json +1 -0
- package/translations/ro_RO.json +1 -0
- package/translations/ru_RU.json +1 -0
- package/translations/si.json +1 -0
- package/translations/sw.json +1 -0
- package/translations/sw_KE.json +1 -0
- package/translations/tr.json +1 -0
- package/translations/tr_TR.json +1 -0
- package/translations/uk.json +1 -0
- package/translations/uz.json +1 -0
- package/translations/uz@Latn.json +1 -0
- package/translations/uz_UZ.json +1 -0
- package/translations/vi.json +1 -0
- package/translations/zh.json +1 -0
- package/translations/zh_CN.json +1 -0
- package/dist/1559.js +0 -2
- package/dist/1559.js.map +0 -1
- package/dist/5639.js +0 -1
- package/dist/5639.js.map +0 -1
- package/dist/5986.js +0 -1
- package/dist/5986.js.map +0 -1
- package/dist/6781.js +0 -2
- package/dist/6781.js.map +0 -1
- package/dist/8803.js +0 -1
- package/dist/8803.js.map +0 -1
- /package/dist/{1559.js.LICENSE.txt → 2499.js.LICENSE.txt} +0 -0
- /package/dist/{6781.js.LICENSE.txt → 3204.js.LICENSE.txt} +0 -0
package/src/resources/useObs.ts
CHANGED
|
@@ -2,11 +2,15 @@ import useSWR from 'swr';
|
|
|
2
2
|
import { openmrsFetch, fhirBaseUrl, useConfig } from '@openmrs/esm-framework';
|
|
3
3
|
import { type ConfigObjectSwitchable } from '../config-schema-obs-switchable';
|
|
4
4
|
import { type ConfigObjectHorizontal } from '../config-schema-obs-horizontal';
|
|
5
|
+
import { useConcepts } from './useConcepts';
|
|
5
6
|
|
|
6
7
|
type CommonConfig = ConfigObjectSwitchable | ConfigObjectHorizontal;
|
|
7
8
|
|
|
8
9
|
export interface UseObsResult {
|
|
9
|
-
data:
|
|
10
|
+
data: {
|
|
11
|
+
observations: Array<ObsResult>;
|
|
12
|
+
concepts: Array<{ uuid: string; display: string }>;
|
|
13
|
+
};
|
|
10
14
|
error: Error;
|
|
11
15
|
isLoading: boolean;
|
|
12
16
|
isValidating: boolean;
|
|
@@ -27,10 +31,16 @@ export type ObsResult = fhir.Observation & {
|
|
|
27
31
|
|
|
28
32
|
export const pageSize = 100;
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Fetches the observations for the concepts in the config for this widget.
|
|
36
|
+
* For any concept that has neither label nor obs, the concept is fetched to
|
|
37
|
+
* get the label.
|
|
38
|
+
*/
|
|
39
|
+
export function useObs(patientUuid: string): UseObsResult {
|
|
31
40
|
const { encounterTypes, data, showEncounterType } = useConfig<CommonConfig>();
|
|
32
41
|
const urlEncounterTypes: string = encounterTypes.length ? `&encounter.type=${encounterTypes.toString()}` : '';
|
|
33
42
|
|
|
43
|
+
// TODO: Make sorting respect oldestFirst/graphOldestFirst
|
|
34
44
|
let url = `${fhirBaseUrl}/Observation?subject:Patient=${patientUuid}&code=${data
|
|
35
45
|
.map((d) => d.concept)
|
|
36
46
|
.join(',')}&_summary=data&_sort=-date&_count=${pageSize}${urlEncounterTypes}`;
|
|
@@ -41,11 +51,28 @@ export function useObs(patientUuid: string, includeEncounters: boolean = false):
|
|
|
41
51
|
|
|
42
52
|
const { data: result, error, isLoading, isValidating } = useSWR<{ data: fhir.Bundle }, Error>(url, openmrsFetch);
|
|
43
53
|
|
|
54
|
+
const obsForConcept = Object.fromEntries(
|
|
55
|
+
data.map((d) => [
|
|
56
|
+
d.concept,
|
|
57
|
+
result?.data?.entry?.find((e) => (e.resource as fhir.Observation).code.coding.find((c) => d.concept === c.code)),
|
|
58
|
+
]),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const conceptsNeedingLabel = data.filter((d) => result && !d.label && !obsForConcept[d.concept]);
|
|
62
|
+
|
|
63
|
+
const { concepts: conceptsForLabels } = useConcepts(conceptsNeedingLabel.map((d) => d.concept));
|
|
64
|
+
const concepts = data.map((d) => ({
|
|
65
|
+
uuid: d.concept,
|
|
66
|
+
display:
|
|
67
|
+
d.label ||
|
|
68
|
+
obsForConcept[d.concept]?.resource?.code?.text ||
|
|
69
|
+
conceptsForLabels.find((c) => c.uuid === d.concept)?.display,
|
|
70
|
+
}));
|
|
71
|
+
|
|
44
72
|
const encounters = showEncounterType ? getEncountersByResources(result?.data?.entry) : [];
|
|
45
73
|
const observations = filterAndMapObservations(result?.data?.entry, encounters);
|
|
46
|
-
|
|
47
74
|
return {
|
|
48
|
-
data: observations,
|
|
75
|
+
data: { observations, concepts },
|
|
49
76
|
error: error,
|
|
50
77
|
isLoading,
|
|
51
78
|
isValidating,
|
package/translations/am.json
CHANGED
package/translations/ar.json
CHANGED
package/translations/ar_SY.json
CHANGED
package/translations/bn.json
CHANGED
package/translations/de.json
CHANGED
package/translations/en.json
CHANGED
package/translations/en_US.json
CHANGED
package/translations/es.json
CHANGED
package/translations/es_MX.json
CHANGED
package/translations/fr.json
CHANGED
package/translations/he.json
CHANGED
package/translations/hi.json
CHANGED
package/translations/hi_IN.json
CHANGED
package/translations/id.json
CHANGED
package/translations/it.json
CHANGED
package/translations/ka.json
CHANGED
package/translations/km.json
CHANGED
package/translations/ku.json
CHANGED
package/translations/ky.json
CHANGED
package/translations/lg.json
CHANGED
package/translations/ne.json
CHANGED
package/translations/pl.json
CHANGED
package/translations/pt.json
CHANGED
package/translations/pt_BR.json
CHANGED
package/translations/qu.json
CHANGED
package/translations/ro_RO.json
CHANGED
package/translations/ru_RU.json
CHANGED
package/translations/si.json
CHANGED
package/translations/sw.json
CHANGED
package/translations/sw_KE.json
CHANGED
package/translations/tr.json
CHANGED
package/translations/tr_TR.json
CHANGED
package/translations/uk.json
CHANGED
package/translations/uz.json
CHANGED
package/translations/uz_UZ.json
CHANGED
package/translations/vi.json
CHANGED
package/translations/zh.json
CHANGED