@kenyaemr/esm-pharmacy-app 5.2.1-pre.724

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 (85) hide show
  1. package/.turbo/turbo-build.log +32 -0
  2. package/LICENSE.md +401 -0
  3. package/README.md +5 -0
  4. package/dist/102.js +1 -0
  5. package/dist/102.js.map +1 -0
  6. package/dist/130.js +2 -0
  7. package/dist/130.js.LICENSE.txt +3 -0
  8. package/dist/130.js.map +1 -0
  9. package/dist/152.js +1 -0
  10. package/dist/152.js.map +1 -0
  11. package/dist/255.js +2 -0
  12. package/dist/255.js.LICENSE.txt +9 -0
  13. package/dist/255.js.map +1 -0
  14. package/dist/303.js +1 -0
  15. package/dist/303.js.map +1 -0
  16. package/dist/341.js +1 -0
  17. package/dist/341.js.map +1 -0
  18. package/dist/368.js +1 -0
  19. package/dist/368.js.map +1 -0
  20. package/dist/383.js +1 -0
  21. package/dist/383.js.map +1 -0
  22. package/dist/419.js +1 -0
  23. package/dist/419.js.map +1 -0
  24. package/dist/515.js +1 -0
  25. package/dist/515.js.map +1 -0
  26. package/dist/574.js +1 -0
  27. package/dist/591.js +2 -0
  28. package/dist/591.js.LICENSE.txt +32 -0
  29. package/dist/591.js.map +1 -0
  30. package/dist/682.js +2 -0
  31. package/dist/682.js.LICENSE.txt +35 -0
  32. package/dist/682.js.map +1 -0
  33. package/dist/729.js +1 -0
  34. package/dist/729.js.map +1 -0
  35. package/dist/75.js +1 -0
  36. package/dist/75.js.map +1 -0
  37. package/dist/784.js +2 -0
  38. package/dist/784.js.LICENSE.txt +9 -0
  39. package/dist/784.js.map +1 -0
  40. package/dist/883.js +1 -0
  41. package/dist/883.js.map +1 -0
  42. package/dist/kenyaemr-esm-pharmacy-app.js +1 -0
  43. package/dist/kenyaemr-esm-pharmacy-app.js.buildmanifest.json +556 -0
  44. package/dist/kenyaemr-esm-pharmacy-app.js.map +1 -0
  45. package/dist/main.js +1 -0
  46. package/dist/main.js.map +1 -0
  47. package/dist/routes.json +1 -0
  48. package/jest.config.js +8 -0
  49. package/package.json +55 -0
  50. package/src/autosuggest/autosuggest.component.tsx +187 -0
  51. package/src/autosuggest/autosuggest.scss +62 -0
  52. package/src/config-schema.ts +43 -0
  53. package/src/declarations.d.ts +6 -0
  54. package/src/hooks/index.ts +4 -0
  55. package/src/hooks/usePharmacy.ts +17 -0
  56. package/src/hooks/usePharmacyPatients.ts +48 -0
  57. package/src/hooks/usePharmacyUsers.ts +43 -0
  58. package/src/hooks/useUserMappedPharmacies.ts +47 -0
  59. package/src/index.ts +41 -0
  60. package/src/pharamacy-forms/delete-confirm-dialog.modal.tsx +26 -0
  61. package/src/pharamacy-forms/pharamacy-assignment-form.workspace.tsx +121 -0
  62. package/src/pharamacy-forms/pharmacy-assignment-form.scss +125 -0
  63. package/src/pharmacy-component/pharmacy.component.tsx +14 -0
  64. package/src/pharmacy-detail/pharmacy-detail.component.tsx +14 -0
  65. package/src/pharmacy-detail-header/pharmacy-detail-header.component.tsx +41 -0
  66. package/src/pharmacy-header/pharmacy-header.component.tsx +36 -0
  67. package/src/pharmacy-header/pharmacy-header.scss +71 -0
  68. package/src/pharmacy-header/pharmacy-illustration.component.tsx +13 -0
  69. package/src/pharmacy-left-panel/pharmacy-left-panel-link.component.tsx +40 -0
  70. package/src/pharmacy-tables/pharmacy-patients.component.tsx +221 -0
  71. package/src/pharmacy-tables/pharmacy-table.component.tsx +164 -0
  72. package/src/pharmacy-tables/pharmacy-tables.scss +49 -0
  73. package/src/pharmacy-tables/pharmacy-users.component.tsx +197 -0
  74. package/src/pharmacy-tabs/pharmacy-tabs-component.tsx +28 -0
  75. package/src/pharmacy-tabs/pharmacy-tabs.scss +28 -0
  76. package/src/pharmacy.resources.ts +55 -0
  77. package/src/root.component.tsx +19 -0
  78. package/src/root.scss +15 -0
  79. package/src/root.test.tsx +5 -0
  80. package/src/routes.json +38 -0
  81. package/src/setup-tests.ts +1 -0
  82. package/src/types/index.ts +67 -0
  83. package/translations/en.json +27 -0
  84. package/tsconfig.json +5 -0
  85. package/webpack.config.js +1 -0
@@ -0,0 +1,55 @@
1
+ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+ import { z } from 'zod';
3
+
4
+ export const pharmacyAssignmentFormSchema = z.object({
5
+ entityIdentifier: z.string().min(1, 'Required'),
6
+ entityType: z.enum(['org.openmrs.User', 'org.openmrs.Patient']),
7
+ basisIdentifier: z.string().min(1, 'Required'),
8
+ basisType: z.enum(['org.openmrs.Location']).optional().default('org.openmrs.Location'),
9
+ });
10
+
11
+ export async function fetchPerson(query: string, abortController: AbortController) {
12
+ const patientsRes = await openmrsFetch(`${restBaseUrl}/patient?q=${query}`, {
13
+ signal: abortController.signal,
14
+ });
15
+ return patientsRes.data.results;
16
+ }
17
+ export async function fetchUser(query: string, abortController: AbortController) {
18
+ const customPresentation = 'custom:(uuid,display,person:(display))';
19
+ const patientsRes = await openmrsFetch(`${restBaseUrl}/user?q=${query}&v=${customPresentation}`, {
20
+ signal: abortController.signal,
21
+ });
22
+ return patientsRes.data.results;
23
+ }
24
+
25
+ export const saveMapping = async (data: z.infer<typeof pharmacyAssignmentFormSchema>) => {
26
+ const url = `${restBaseUrl}/datafilter/entitybasismap`;
27
+ const response = await openmrsFetch(url, {
28
+ method: 'POST',
29
+ body: JSON.stringify(data),
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ },
33
+ });
34
+
35
+ if (response.ok) {
36
+ return await response.text();
37
+ }
38
+ throw new Error(`Error mapping patient`);
39
+ };
40
+
41
+ export const revokePharamacyAssignment = async (data: z.infer<typeof pharmacyAssignmentFormSchema>) => {
42
+ const url = `${restBaseUrl}/datafilter/revoke`;
43
+ const response = await openmrsFetch(url, {
44
+ method: 'POST',
45
+ body: JSON.stringify(data),
46
+ headers: {
47
+ 'Content-Type': 'application/json',
48
+ },
49
+ });
50
+
51
+ if (response.ok) {
52
+ return await response.text();
53
+ }
54
+ throw new Error(`Error revoking mapping`);
55
+ };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { BrowserRouter, Route, Routes } from 'react-router-dom';
3
+ import PharmacyComponent from './pharmacy-component/pharmacy.component';
4
+ import PharmacyDetail from './pharmacy-detail/pharmacy-detail.component';
5
+
6
+ const Root: React.FC = () => {
7
+ const baseName = window.getOpenmrsSpaBase() + 'home/pharmacy';
8
+
9
+ return (
10
+ <BrowserRouter basename={baseName}>
11
+ <Routes>
12
+ <Route path="/" element={<PharmacyComponent />} />
13
+ <Route path="/:pharmacyUuid" element={<PharmacyDetail />} />
14
+ </Routes>
15
+ </BrowserRouter>
16
+ );
17
+ };
18
+
19
+ export default Root;
package/src/root.scss ADDED
@@ -0,0 +1,15 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+
4
+ .container {
5
+ padding: spacing.$spacing-07;
6
+ }
7
+
8
+ .welcome {
9
+ @include type.type-style('heading-04');
10
+ margin: spacing.$spacing-05 0;
11
+ }
12
+
13
+ .explainer {
14
+ margin-bottom: 2rem;
15
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ describe('Root', () => {
4
+ test('should render', () => {});
5
+ });
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "https://json.openmrs.org/routes.schema.json",
3
+ "backendDependencies": {
4
+ "fhir2": ">=1.2",
5
+ "webservices.rest": "^2.24.0"
6
+ },
7
+ "extensions": [
8
+ {
9
+ "component": "pharmacyDashboardLink",
10
+ "name": "pharmacy-dashboard-link",
11
+ "slot": "homepage-dashboard-slot",
12
+ "meta": {
13
+ "name": "pharmacy",
14
+ "title": "pharmacy",
15
+ "slot": "pharmacy-dashboard-slot"
16
+ }
17
+ },
18
+ {
19
+ "component": "root",
20
+ "name": "pharmacy-dashboard-root",
21
+ "slot": "pharmacy-dashboard-slot"
22
+ },
23
+ {
24
+ "name": "pharmacy-assignment-form",
25
+ "component": "pharmacyAssignmentForm"
26
+ },
27
+ {
28
+ "name": "pharmacy-delete-confirm-dialog",
29
+ "component": "pharmacyDeleteConfirmDialog"
30
+ }
31
+ ],
32
+ "pages": [
33
+ {
34
+ "component": "root",
35
+ "route": "pharmacy"
36
+ }
37
+ ]
38
+ }
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -0,0 +1,67 @@
1
+ import { Location, Patient } from '@openmrs/esm-framework';
2
+
3
+ export interface Pharmacy extends Location {
4
+ //Inherits Uuid,display,name
5
+ description?: string;
6
+ cityVillage?: string;
7
+ stateProvince?: string;
8
+ countyDistrict?: string;
9
+ dateMaped: string;
10
+ mflCode: string;
11
+ }
12
+
13
+ interface Basis {
14
+ uuid: string;
15
+ name: string;
16
+ country?: string;
17
+ address3?: string;
18
+ countyDistrict?: string;
19
+ address2?: string;
20
+ address1?: string;
21
+ address6?: string;
22
+ address5?: string;
23
+ cityVillage?: string;
24
+ address4?: string;
25
+ 'Master Facility Code'?: string;
26
+ }
27
+
28
+ export interface PhamarcyUserMapping {
29
+ uuid: string;
30
+ dateCreated: number;
31
+ entity: {
32
+ name: string;
33
+ uuid: string;
34
+ };
35
+ basis: Basis;
36
+ }
37
+
38
+ export interface PharamacyPatientMapping {
39
+ uuid: string;
40
+ dateCreated: number;
41
+ entity: {
42
+ OpenMRSID?: string;
43
+ identifier?: string;
44
+ gender?: string;
45
+ name: string;
46
+ uuid: string;
47
+ age?: number;
48
+ 'Telephone contact'?: string;
49
+ };
50
+ basis: Basis;
51
+ }
52
+
53
+ export interface PharmacyPatient {
54
+ uuid: string;
55
+ openmrsId?: string;
56
+ name: string;
57
+ age?: number;
58
+ gender?: string;
59
+ telephoneContact?: string;
60
+ dateMapped: string;
61
+ }
62
+
63
+ export interface PharmacyUser {
64
+ uuid: string;
65
+ name: string;
66
+ dateMapped: string;
67
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "actions": "Actions",
3
+ "age": "Age",
4
+ "assignPatient": "Assign Patient",
5
+ "assignUser": "Assign User",
6
+ "cityVillage": "City village",
7
+ "communityPharmacies": "Community pharmacies",
8
+ "contact": "Contact",
9
+ "countyDistrict": "County District",
10
+ "dateMapped": "Date Mapped",
11
+ "enroll": "Enroll new body",
12
+ "name": "NAME",
13
+ "noCommunityPharmacyToList": "No Community Pharmacies to list.",
14
+ "noPharmacyPatients": "No Pharmacy Patients to list.",
15
+ "noPharmacyUsers": "No Pharmacy users to list.",
16
+ "openmrsId": "OpenMRS ID",
17
+ "pharmacies": "Phamacies",
18
+ "pharmacy": "Commity pharmacy",
19
+ "pharmacyPatients": "Pharmacy Patients",
20
+ "pharmacySummary": "Pharmacy Summary",
21
+ "pharmacyUsers": "Pharmacy Users",
22
+ "sex": "Sex",
23
+ "stateProvince": "State province",
24
+ "tagPharmacy": "Tag pharmacy",
25
+ "viewReport": "View Report",
26
+ "warning": "Warning!"
27
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["src/**/*"],
4
+ "exclude": ["src/**/*.test.tsx"]
5
+ }
@@ -0,0 +1 @@
1
+ module.exports = require('openmrs/default-webpack-config');