@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.
Files changed (118) hide show
  1. package/.turbo/turbo-build.log +22 -19
  2. package/dist/1119.js +1 -1
  3. package/dist/1197.js +1 -1
  4. package/dist/2146.js +1 -1
  5. package/dist/2499.js +2 -0
  6. package/dist/2499.js.map +1 -0
  7. package/dist/2690.js +1 -1
  8. package/dist/3099.js +1 -1
  9. package/dist/3204.js +2 -0
  10. package/dist/3204.js.map +1 -0
  11. package/dist/3584.js +1 -1
  12. package/dist/4055.js +1 -1
  13. package/dist/4132.js +1 -1
  14. package/dist/4300.js +1 -1
  15. package/dist/4335.js +1 -1
  16. package/dist/4341.js +1 -0
  17. package/dist/4341.js.map +1 -0
  18. package/dist/4618.js +1 -1
  19. package/dist/4652.js +1 -1
  20. package/dist/4944.js +1 -1
  21. package/dist/5173.js +1 -1
  22. package/dist/5241.js +1 -1
  23. package/dist/5442.js +1 -1
  24. package/dist/5661.js +1 -1
  25. package/dist/5670.js +1 -1
  26. package/dist/5670.js.map +1 -1
  27. package/dist/6022.js +1 -1
  28. package/dist/6336.js +1 -0
  29. package/dist/6336.js.map +1 -0
  30. package/dist/6468.js +1 -1
  31. package/dist/6679.js +1 -1
  32. package/dist/6840.js +1 -1
  33. package/dist/6859.js +1 -1
  34. package/dist/7097.js +1 -1
  35. package/dist/7159.js +1 -1
  36. package/dist/723.js +1 -1
  37. package/dist/7617.js +1 -1
  38. package/dist/795.js +1 -1
  39. package/dist/8163.js +1 -1
  40. package/dist/8349.js +1 -1
  41. package/dist/8618.js +1 -1
  42. package/dist/890.js +1 -1
  43. package/dist/9214.js +1 -1
  44. package/dist/9351.js +1 -0
  45. package/dist/9351.js.map +1 -0
  46. package/dist/9538.js +1 -1
  47. package/dist/9569.js +1 -1
  48. package/dist/986.js +1 -1
  49. package/dist/9879.js +1 -1
  50. package/dist/9895.js +1 -1
  51. package/dist/9900.js +1 -1
  52. package/dist/9913.js +1 -1
  53. package/dist/main.js +1 -1
  54. package/dist/main.js.map +1 -1
  55. package/dist/openmrs-esm-generic-patient-widgets-app.js +1 -1
  56. package/dist/openmrs-esm-generic-patient-widgets-app.js.buildmanifest.json +246 -246
  57. package/dist/openmrs-esm-generic-patient-widgets-app.js.map +1 -1
  58. package/dist/routes.json +1 -1
  59. package/package.json +3 -3
  60. package/src/obs-graph/obs-graph.component.tsx +81 -32
  61. package/src/obs-graph/obs-graph.scss +19 -11
  62. package/src/obs-switchable/obs-switchable.component.tsx +8 -3
  63. package/src/obs-switchable/obs-switchable.test.tsx +45 -29
  64. package/src/obs-table/obs-table.component.tsx +6 -4
  65. package/src/obs-table-horizontal/obs-table-horizontal.component.tsx +7 -4
  66. package/src/resources/useConcepts.ts +41 -0
  67. package/src/resources/useObs.ts +31 -4
  68. package/translations/am.json +1 -0
  69. package/translations/ar.json +1 -0
  70. package/translations/ar_SY.json +1 -0
  71. package/translations/bn.json +1 -0
  72. package/translations/de.json +1 -0
  73. package/translations/en.json +1 -0
  74. package/translations/en_US.json +1 -0
  75. package/translations/es.json +1 -0
  76. package/translations/es_MX.json +1 -0
  77. package/translations/fr.json +1 -0
  78. package/translations/he.json +1 -0
  79. package/translations/hi.json +1 -0
  80. package/translations/hi_IN.json +1 -0
  81. package/translations/id.json +1 -0
  82. package/translations/it.json +1 -0
  83. package/translations/ka.json +1 -0
  84. package/translations/km.json +1 -0
  85. package/translations/ku.json +1 -0
  86. package/translations/ky.json +1 -0
  87. package/translations/lg.json +1 -0
  88. package/translations/ne.json +1 -0
  89. package/translations/pl.json +1 -0
  90. package/translations/pt.json +1 -0
  91. package/translations/pt_BR.json +1 -0
  92. package/translations/qu.json +1 -0
  93. package/translations/ro_RO.json +1 -0
  94. package/translations/ru_RU.json +1 -0
  95. package/translations/si.json +1 -0
  96. package/translations/sw.json +1 -0
  97. package/translations/sw_KE.json +1 -0
  98. package/translations/tr.json +1 -0
  99. package/translations/tr_TR.json +1 -0
  100. package/translations/uk.json +1 -0
  101. package/translations/uz.json +1 -0
  102. package/translations/uz@Latn.json +1 -0
  103. package/translations/uz_UZ.json +1 -0
  104. package/translations/vi.json +1 -0
  105. package/translations/zh.json +1 -0
  106. package/translations/zh_CN.json +1 -0
  107. package/dist/1559.js +0 -2
  108. package/dist/1559.js.map +0 -1
  109. package/dist/5639.js +0 -1
  110. package/dist/5639.js.map +0 -1
  111. package/dist/5986.js +0 -1
  112. package/dist/5986.js.map +0 -1
  113. package/dist/6781.js +0 -2
  114. package/dist/6781.js.map +0 -1
  115. package/dist/8803.js +0 -1
  116. package/dist/8803.js.map +0 -1
  117. /package/dist/{1559.js.LICENSE.txt → 2499.js.LICENSE.txt} +0 -0
  118. /package/dist/{6781.js.LICENSE.txt → 3204.js.LICENSE.txt} +0 -0
@@ -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: Array<ObsResult>;
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
- export function useObs(patientUuid: string, includeEncounters: boolean = false): UseObsResult {
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,
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "التاريخ والوقت",
3
4
  "encounterType": "نوع اللقاء"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Fecha y hora",
3
4
  "encounterType": "Tipo de encuentro"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date et heure",
3
4
  "encounterType": "Type de consultation"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "תאריך ושעה",
3
4
  "encounterType": "סוג הביקור"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Tanggal dan waktu",
3
4
  "encounterType": "Jenis pertemuan"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Data e ora",
3
4
  "encounterType": "Tipo di incontro"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "თარიღი და დრო",
3
4
  "encounterType": "კონსულტაციის ტიპი"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "កាលបរិច្ឆេទ និងម៉ោង",
3
4
  "encounterType": "ប្រភេទនៃការជួបប្រទះ"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Data e hora",
3
4
  "encounterType": "Tipo de consulta"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Data e hora",
3
4
  "encounterType": "Tipo de encontro"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Data si ora",
3
4
  "encounterType": "Tip intalnire"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Date and time",
3
4
  "encounterType": "Encounter type"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "Ngày và giờ",
3
4
  "encounterType": "Loại gặp gỡ"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "日期&时间",
3
4
  "encounterType": "问诊类型"
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
+ "date": "Date",
2
3
  "dateAndTime": "日期&时间",
3
4
  "encounterType": "问诊类型"
4
5
  }