@openmrs/esm-dispensing-app 1.0.1-pre.99 → 1.1.0

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 (86) hide show
  1. package/.eslintrc +3 -1
  2. package/.husky/pre-commit +0 -0
  3. package/.husky/pre-push +0 -0
  4. package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +541 -0
  5. package/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -0
  6. package/README.md +35 -0
  7. package/jest.config.js +15 -0
  8. package/package.json +13 -10
  9. package/src/components/action-buttons.component.test.tsx +244 -0
  10. package/src/components/action-buttons.component.tsx +137 -0
  11. package/src/components/action-buttons.scss +5 -0
  12. package/src/components/medication-card.component.test.tsx +40 -0
  13. package/src/components/medication-card.component.tsx +10 -17
  14. package/src/components/medication-card.scss +5 -2
  15. package/src/components/medication-dispense-review.scss +9 -0
  16. package/src/components/medication-event.component.tsx +94 -0
  17. package/src/components/{medication-event-card.scss → medication-event.scss} +0 -9
  18. package/src/components/patient-details.component.tsx +4 -27
  19. package/src/components/patient-details.scss +0 -3
  20. package/src/config-schema.ts +141 -2
  21. package/src/constants.ts +24 -0
  22. package/src/dashboard/dispensing-dashboard.component.tsx +38 -0
  23. package/src/declarations.d.tsx +2 -0
  24. package/src/dispensing-tiles/dispensing-tiles.resource.tsx +2 -0
  25. package/src/dispensing.component.tsx +2 -12
  26. package/src/dispensing.test.tsx +1 -1
  27. package/src/forms/close-dispense-form.component.tsx +236 -0
  28. package/src/forms/dispense-form.component.tsx +124 -142
  29. package/src/forms/{dispense-form.scss → forms.scss} +6 -0
  30. package/src/forms/medication-dispense-review.component.test.tsx +142 -0
  31. package/src/forms/medication-dispense-review.component.tsx +562 -0
  32. package/src/forms/overlay/overlay.component.tsx +3 -1
  33. package/src/forms/pause-dispense-form.component.tsx +236 -0
  34. package/src/history/history-and-comments.component.tsx +326 -0
  35. package/src/history/history-and-comments.scss +57 -0
  36. package/src/index.ts +20 -35
  37. package/src/location/location.resource.test.tsx +189 -0
  38. package/src/location/location.resource.tsx +27 -0
  39. package/src/medication/medication.resource.test.tsx +181 -0
  40. package/src/medication/medication.resource.tsx +54 -0
  41. package/src/medication-dispense/medication-dispense.resource.test.tsx +294 -0
  42. package/src/medication-dispense/medication-dispense.resource.tsx +113 -45
  43. package/src/medication-request/medication-request.resource.test.tsx +1389 -0
  44. package/src/medication-request/medication-request.resource.tsx +145 -84
  45. package/src/pharmacy-header/pharmacy-header.component.tsx +5 -3
  46. package/src/pharmacy-header/pharmacy-header.scss +2 -2
  47. package/src/pharmacy-header/pharmacy-illustration.component.tsx +4 -4
  48. package/src/prescriptions/prescription-details.component.tsx +139 -0
  49. package/src/{components → prescriptions}/prescription-details.scss +13 -3
  50. package/src/{components → prescriptions}/prescription-expanded.component.tsx +9 -36
  51. package/src/{components → prescriptions}/prescription-expanded.scss +0 -18
  52. package/src/prescriptions/prescription-tab-lists.component.tsx +64 -18
  53. package/src/prescriptions/prescription-tab-panel.component.tsx +46 -26
  54. package/src/prescriptions/prescriptions.scss +8 -0
  55. package/src/routes.json +30 -0
  56. package/src/types.ts +196 -71
  57. package/src/utils.test.ts +3001 -0
  58. package/src/utils.ts +663 -42
  59. package/translations/en.json +60 -2
  60. package/translations/fr.json +100 -0
  61. package/.github/workflows/node.js.yml +0 -95
  62. package/dist/247.js +0 -1
  63. package/dist/294.js +0 -2
  64. package/dist/294.js.LICENSE.txt +0 -9
  65. package/dist/299.js +0 -1
  66. package/dist/484.js +0 -1
  67. package/dist/574.js +0 -1
  68. package/dist/595.js +0 -2
  69. package/dist/595.js.LICENSE.txt +0 -1
  70. package/dist/781.js +0 -1
  71. package/dist/900.js +0 -2
  72. package/dist/900.js.LICENSE.txt +0 -29
  73. package/dist/935.js +0 -2
  74. package/dist/935.js.LICENSE.txt +0 -19
  75. package/dist/96.js +0 -1
  76. package/dist/main.js +0 -1
  77. package/dist/openmrs-esm-dispensing-app.js +0 -1
  78. package/dist/openmrs-esm-dispensing-app.js.buildmanifest.json +0 -330
  79. package/dist/openmrs-esm-dispensing-app.old +0 -1
  80. package/jest.config.json +0 -18
  81. package/src/components/history-and-comments.component.tsx +0 -117
  82. package/src/components/history-and-comments.scss +0 -30
  83. package/src/components/medication-dispense-review.component.tsx +0 -263
  84. package/src/components/medication-event-card.component.tsx +0 -90
  85. package/src/components/prescription-details.component.tsx +0 -67
  86. package/src/forms/initialize-dispense-form-from-requests.component.tsx +0 -56
@@ -0,0 +1,94 @@
1
+ import React from "react";
2
+ import {
3
+ DosageInstruction,
4
+ MedicationDispense,
5
+ MedicationRequest,
6
+ Quantity,
7
+ } from "../types";
8
+ import styles from "./medication-event.scss";
9
+ import {
10
+ getDosageInstruction,
11
+ getQuantity,
12
+ getRefillsAllowed,
13
+ getMedicationDisplay,
14
+ getMedicationReferenceOrCodeableConcept,
15
+ } from "../utils";
16
+ import { useTranslation } from "react-i18next";
17
+
18
+ // can render MedicationRequest or MedicationDispense
19
+ const MedicationEvent: React.FC<{
20
+ medicationEvent: MedicationRequest | MedicationDispense;
21
+ status?;
22
+ }> = ({ medicationEvent, status = null }) => {
23
+ const { t } = useTranslation();
24
+ const dosageInstruction: DosageInstruction = getDosageInstruction(
25
+ medicationEvent.dosageInstruction
26
+ );
27
+ const quantity: Quantity = getQuantity(medicationEvent);
28
+ const refillsAllowed: number = getRefillsAllowed(medicationEvent);
29
+
30
+ return (
31
+ <div>
32
+ <p className={styles.medicationName}>
33
+ {status}
34
+ <strong>
35
+ {getMedicationDisplay(
36
+ getMedicationReferenceOrCodeableConcept(medicationEvent)
37
+ )}
38
+ </strong>
39
+ </p>
40
+
41
+ {dosageInstruction && (
42
+ <p className={styles.bodyLong01}>
43
+ <span className={styles.label01}>
44
+ {t("dose", "Dose").toUpperCase()}
45
+ </span>{" "}
46
+ <span className={styles.dosage}>
47
+ {dosageInstruction.doseAndRate &&
48
+ dosageInstruction?.doseAndRate.map((doseAndRate, index) => {
49
+ return (
50
+ <span key={index}>
51
+ {doseAndRate?.doseQuantity?.value}{" "}
52
+ {doseAndRate?.doseQuantity?.unit}
53
+ </span>
54
+ );
55
+ })}
56
+ </span>{" "}
57
+ &mdash; {dosageInstruction?.route?.text} &mdash;{" "}
58
+ {dosageInstruction?.timing?.code?.text}{" "}
59
+ {dosageInstruction?.timing?.repeat?.duration
60
+ ? "for " +
61
+ dosageInstruction?.timing?.repeat?.duration +
62
+ " " +
63
+ dosageInstruction?.timing?.repeat?.durationUnit
64
+ : " "}
65
+ </p>
66
+ )}
67
+
68
+ {quantity && (
69
+ <p className={styles.bodyLong01}>
70
+ <span className={styles.label01}>
71
+ {t("quantity", "Quantity").toUpperCase()}
72
+ </span>{" "}
73
+ <span className={styles.quantity}>
74
+ {quantity.value} {quantity.unit}
75
+ </span>
76
+ </p>
77
+ )}
78
+
79
+ {(refillsAllowed || refillsAllowed === 0) && (
80
+ <p className={styles.bodyLong01}>
81
+ <span className={styles.label01}>
82
+ {t("refills", "Refills").toUpperCase()}
83
+ </span>{" "}
84
+ <span className={styles.refills}>{refillsAllowed}</span>
85
+ </p>
86
+ )}
87
+ {dosageInstruction?.text && (
88
+ <p className={styles.bodyLong01}>{dosageInstruction.text}</p>
89
+ )}
90
+ </div>
91
+ );
92
+ };
93
+
94
+ export default MedicationEvent;
@@ -2,15 +2,6 @@
2
2
  @use '@carbon/styles/scss/type';
3
3
  @import "~@openmrs/esm-styleguide/src/vars";
4
4
 
5
- .medicationEventTile {
6
- width: 100%;
7
- margin: 2px 0 8px;
8
- padding: 0 8px 0 8px;
9
- background-color: #fff;
10
- border-left: 4px solid #007d79;
11
- color: $text-02;
12
- margin-bottom: 1rem !important;
13
- }
14
5
 
15
6
  .medicationName {
16
7
  font-size: 15px !important;
@@ -1,19 +1,14 @@
1
1
  import React, { useEffect } from "react";
2
2
  import {
3
3
  attach,
4
- ConfigurableLink,
5
4
  detach,
6
5
  ExtensionSlot,
7
- formatDate,
8
- interpolateString,
9
- parseDate,
10
6
  PatientUuid,
11
7
  useConfig,
12
8
  usePatient,
13
9
  } from "@openmrs/esm-framework";
14
10
  import styles from "./patient-details.scss";
15
11
  import { useTranslation } from "react-i18next";
16
- import { Patient } from "../types";
17
12
 
18
13
  const PatientDetails: React.FC<{
19
14
  patientUuid: PatientUuid;
@@ -36,28 +31,10 @@ const PatientDetails: React.FC<{
36
31
 
37
32
  const patientAvatar = (
38
33
  <div className={styles.patientAvatar} role="img">
39
- <ExtensionSlot
40
- extensionSlotName="patient-photo-slot"
41
- state={patientPhotoSlotState}
42
- />
34
+ <ExtensionSlot name="patient-photo-slot" state={patientPhotoSlotState} />
43
35
  </div>
44
36
  );
45
37
 
46
- const getGender = (gender) => {
47
- switch (gender) {
48
- case "M":
49
- return t("male", "Male");
50
- case "F":
51
- return t("female", "Female");
52
- case "O":
53
- return t("other", "Other");
54
- case "U":
55
- return t("unknown", "Unknown");
56
- default:
57
- return gender;
58
- }
59
- };
60
-
61
38
  useEffect(() => {
62
39
  attach("dispensing-patient-banner-slot", "patient-banner");
63
40
  attach("dispensing-patient-vitals-slot", "vitals-overview-widget");
@@ -75,7 +52,7 @@ const PatientDetails: React.FC<{
75
52
  {patient && (
76
53
  <div className={styles.patientDetailsContainer}>
77
54
  <ExtensionSlot
78
- extensionSlotName="dispensing-patient-banner-slot"
55
+ name="dispensing-patient-banner-slot"
79
56
  state={{
80
57
  patient,
81
58
  patientUuid: patientUuid,
@@ -83,7 +60,7 @@ const PatientDetails: React.FC<{
83
60
  />
84
61
 
85
62
  <ExtensionSlot
86
- extensionSlotName="dispensing-patient-vitals-slot"
63
+ name="dispensing-patient-vitals-slot"
87
64
  state={{
88
65
  patient,
89
66
  patientUuid: patientUuid,
@@ -91,7 +68,7 @@ const PatientDetails: React.FC<{
91
68
  />
92
69
 
93
70
  <ExtensionSlot
94
- extensionSlotName="dispensing-patient-allergies-slot"
71
+ name="dispensing-patient-allergies-slot"
95
72
  state={{
96
73
  patient,
97
74
  patientUuid: patientUuid,
@@ -85,9 +85,6 @@
85
85
  color: $interactive-01;
86
86
  }
87
87
 
88
- :global(.cds--tooltip--definition .cds--tooltip__trigger) {
89
- border-bottom: none;
90
- }
91
88
 
92
89
  .buttonCol {
93
90
  display: flex;
@@ -1,4 +1,4 @@
1
- import { Type, validator } from "@openmrs/esm-framework";
1
+ import { Type } from "@openmrs/esm-framework";
2
2
 
3
3
  /**
4
4
  * This is the config schema. It expects a configuration object which
@@ -25,8 +25,147 @@ export const configSchema = {
25
25
  _type: Type.String,
26
26
  _default: "Pharmacy",
27
27
  },
28
+ actionButtons: {
29
+ pauseButton: {
30
+ enabled: {
31
+ _type: Type.Boolean,
32
+ _description:
33
+ "Enabled/Disable including a Pause button in the button action bar",
34
+ _default: true,
35
+ },
36
+ },
37
+ closeButton: {
38
+ enabled: {
39
+ _type: Type.Boolean,
40
+ _description:
41
+ "Enabled/Disable including a Close button in the button action bar",
42
+ _default: true,
43
+ },
44
+ },
45
+ },
46
+ dispenseBehavior: {
47
+ allowModifyingPrescription: {
48
+ _type: Type.Boolean,
49
+ _description:
50
+ "Enable/Disable editing the prescription. If Disabled, Quantity will be he only editable field on prescription form. Note that thins means that quantity units will need to be mandatory and set correctly on the prescription.",
51
+ _default: true,
52
+ },
53
+ restrictTotalQuantityDispensed: {
54
+ _type: Type.Boolean,
55
+ _description:
56
+ "Enable/Disable restricting dispensing quantity greater than total quantity ordered. Marks prescription as complete when total quantity dispensed. If true, allowModifyingPrescription *must* be false, as this functionality relies solely on numeric quantity and assumes no change in formulation, dosage, unit, etc",
57
+ _default: false,
58
+ },
59
+ },
60
+ medicationRequestExpirationPeriodInDays: {
61
+ _type: Type.Number,
62
+ _description:
63
+ "Medication Requests older that this will be considered expired",
64
+ _default: 90,
65
+ },
66
+ locationBehavior: {
67
+ locationColumn: {
68
+ enabled: {
69
+ _type: Type.Boolean,
70
+ _description:
71
+ "Enabled/Disable including a Location column in the main prescriptions table showing ordering location",
72
+ _default: false,
73
+ },
74
+ },
75
+ locationFilter: {
76
+ enabled: {
77
+ _type: Type.Boolean,
78
+ _description:
79
+ "Enable/Disable Location filter on main prescriptions page",
80
+ _default: false,
81
+ },
82
+ tag: {
83
+ _type: Type.String,
84
+ _description:
85
+ "Name of the location tag to use when fetching locations to populate filter",
86
+ _default: "Login Location",
87
+ },
88
+ },
89
+ },
90
+ refreshInterval: {
91
+ _type: Type.Number,
92
+ _description:
93
+ "The interval, in milliseconds, to query the backend for new/changed data",
94
+ _default: 60000,
95
+ },
96
+ valueSets: {
97
+ reasonForPause: {
98
+ uuid: {
99
+ _type: Type.UUID,
100
+ _description:
101
+ "UUID for the Value Set of valid answers to the 'Reason for Pause' question. Defaults to CIEL value set: https://app.openconceptlab.org/#/orgs/CIEL/sources/CIEL/concepts/168099/",
102
+ _default: "2dd3e5c0-3d3f-4f3d-9860-19b3f9ab26ff",
103
+ },
104
+ },
105
+ reasonForClose: {
106
+ uuid: {
107
+ _type: Type.UUID,
108
+ _description:
109
+ "UUID for the Value Set of valid answers to the 'Reason for Close' question. Defaults to CIEL value set: https://app.openconceptlab.org/#/orgs/CIEL/sources/CIEL/concepts/168099/",
110
+ _default: "bd6c1fc2-7cfc-4562-94a0-e4765e5e977e",
111
+ },
112
+ },
113
+ substitutionReason: {
114
+ uuid: {
115
+ _type: Type.UUID,
116
+ _description:
117
+ "UUID for the Value Set of valid answers to the 'Reason for Substitution' question. Defaults to CIEL value set: https://app.openconceptlab.org/#/orgs/CIEL/sources/CIEL/concepts/167862/",
118
+ _default: "de8671b8-ed2e-4f7e-a9f8-dcd00878f2eb",
119
+ },
120
+ },
121
+ substitutionType: {
122
+ uuid: {
123
+ _type: Type.UUID,
124
+ _description:
125
+ "UUID for the Value Set of valid answers to the 'Type of Substitution' question. Defaults to CIEL value set: https://app.openconceptlab.org/#/orgs/CIEL/sources/CIEL/concepts/167859/",
126
+ _default: "b9c5bca0-d026-4245-a4d2-e4c0a8999082",
127
+ },
128
+ },
129
+ },
28
130
  };
29
131
 
30
132
  export type PharmacyConfig = {
31
- appName: String;
133
+ appName: string;
134
+ actionButtons: {
135
+ pauseButton: {
136
+ enabled: boolean;
137
+ };
138
+ closeButton: {
139
+ enabled: boolean;
140
+ };
141
+ };
142
+ refreshInterval: number;
143
+ dispenseBehavior: {
144
+ allowModifyingPrescription: boolean;
145
+ restrictTotalQuantityDispensed: boolean;
146
+ };
147
+ medicationRequestExpirationPeriodInDays: number;
148
+ locationBehavior: {
149
+ locationColumn: {
150
+ enabled: boolean;
151
+ };
152
+ locationFilter: {
153
+ enabled: boolean;
154
+ tag: string;
155
+ };
156
+ };
157
+ valueSets: {
158
+ reasonForPause: {
159
+ uuid: string;
160
+ };
161
+ reasonForClose: {
162
+ uuid: string;
163
+ };
164
+ substitutionReason: {
165
+ uuid: string;
166
+ };
167
+ substitutionType: {
168
+ uuid: string;
169
+ };
170
+ };
32
171
  };
package/src/constants.ts CHANGED
@@ -1,3 +1,27 @@
1
1
  export const spaRoot = window["getOpenmrsSpaBase"];
2
2
  export const basePath = "/dispensing";
3
3
  export const spaBasePath = `${window.spaBase}${basePath}`;
4
+
5
+ // defined in FHIR 2 module
6
+ export const OPENMRS_FHIR_PREFIX = "http://fhir.openmrs.org";
7
+ export const OPENMRS_FHIR_EXT_PREFIX = OPENMRS_FHIR_PREFIX + "/ext";
8
+ export const OPENMRS_FHIR_EXT_MEDICINE = OPENMRS_FHIR_EXT_PREFIX + "/medicine";
9
+ export const OPENMRS_FHIR_EXT_DISPENSE_RECORDED =
10
+ OPENMRS_FHIR_EXT_PREFIX + "/medicationdispense/recorded";
11
+ export const OPENMRS_FHIR_EXT_REQUEST_FULFILLER_STATUS =
12
+ OPENMRS_FHIR_EXT_PREFIX + "/medicationrequest/fullfillerstatus";
13
+
14
+ export const PRIVILEGE_CREATE_DISPENSE = "Task: dispensing.create.dispense";
15
+ export const PRIVILEGE_CREATE_DISPENSE_MODIFY_DETAILS =
16
+ "Task: dispensing.create.dispense.allowSubstitutions";
17
+ export const PRIVILEGE_EDIT_DISPENSE = "Task: dispensing.edit.dispense";
18
+ export const PRIVILEGE_DELETE_DISPENSE = "Task: dispensing.delete.dispense";
19
+ export const PRIVILEGE_DELETE_DISPENSE_THIS_PROVIDER_ONLY =
20
+ "Task: dispensing.delete.dispense.ifCreator";
21
+
22
+ export const JSON_MERGE_PATH_MIME_TYPE = "application/merge-patch+json";
23
+
24
+ export const PRESCRIPTIONS_TABLE_ENDPOINT =
25
+ "Encounter?_query=encountersWithMedicationRequests";
26
+
27
+ export const PRESCRIPTION_DETAILS_ENDPOINT = "MedicationRequest";
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import { InlineNotification } from "@carbon/react";
3
+ import Overlay from "../forms/overlay/overlay.component";
4
+ import { PharmacyHeader } from "../pharmacy-header/pharmacy-header.component";
5
+ import PrescriptionTabLists from "../prescriptions/prescription-tab-lists.component";
6
+ import { PharmacyConfig } from "../config-schema";
7
+ import { useConfig } from "@openmrs/esm-framework";
8
+ import { useTranslation } from "react-i18next";
9
+
10
+ export default function DispensingDashboard() {
11
+ const config = useConfig() as PharmacyConfig;
12
+ const { t } = useTranslation();
13
+ if (
14
+ config.dispenseBehavior.restrictTotalQuantityDispensed &&
15
+ config.dispenseBehavior.allowModifyingPrescription
16
+ ) {
17
+ return (
18
+ <div className={`omrs-main-content`}>
19
+ <InlineNotification
20
+ title={t("dispensingAppError", "Dispensing App Error")}
21
+ subtitle={t(
22
+ "dispensingAppMisconfigurationMessage",
23
+ "Please contact your system administration: Misconfiguration - 'restrictTotalQuantityDispensed' cannot be enabled if 'allowModifyingPrescription' is enabled."
24
+ )}
25
+ />
26
+ </div>
27
+ );
28
+ } else {
29
+ return (
30
+ <div className={`omrs-main-content`}>
31
+ <PharmacyHeader />
32
+ {/* <DispensingTiles /> */}
33
+ <PrescriptionTabLists />
34
+ <Overlay />
35
+ </div>
36
+ );
37
+ }
38
+ }
@@ -1,3 +1,5 @@
1
1
  declare module "*.css";
2
2
  declare module "*.scss";
3
3
  declare module "*.svg";
4
+ declare module "@carbon/react";
5
+ declare type SideNavProps = {};
@@ -2,6 +2,8 @@ import useSWR from "swr";
2
2
  import useSWRImmutable from "swr/immutable";
3
3
  import { FetchResponse, openmrsFetch } from "@openmrs/esm-framework";
4
4
 
5
+ // NOT CURRENTLY USED
6
+
5
7
  export function useMetrics() {
6
8
  const metrics = {
7
9
  orders: 43,
@@ -1,16 +1,6 @@
1
1
  import React from "react";
2
- import { PharmacyHeader } from "./pharmacy-header/pharmacy-header.component";
3
- import DispensingTiles from "./dispensing-tiles/dispensing-tiles.component";
4
- import PrescriptionTabLists from "./prescriptions/prescription-tab-lists.component";
5
- import Overlay from "./forms/overlay/overlay.component";
2
+ import { ExtensionSlot } from "@openmrs/esm-framework";
6
3
 
7
4
  export default function Dispensing() {
8
- return (
9
- <div className={`omrs-main-content`}>
10
- <PharmacyHeader />
11
- {/* <DispensingTiles />*/}
12
- <PrescriptionTabLists />
13
- <Overlay />
14
- </div>
15
- );
5
+ return <ExtensionSlot name="dispensing-dashboard-slot" />;
16
6
  }
@@ -25,7 +25,7 @@ import { render } from "@testing-library/react";
25
25
  import Dispensing from "./dispensing.component";
26
26
 
27
27
  describe("<div/>", () => {
28
- it("does nothing", () => {
28
+ test("renders dispening without error", () => {
29
29
  render(<Dispensing />);
30
30
  });
31
31
  });