Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Twiineenock committed Dec 19, 2024
1 parent ee59431 commit 79e51c1
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 77 deletions.
1 change: 1 addition & 0 deletions packages/esm-patient-common-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './error-state';
export * from './form-entry-interop';
export * from './form-entry/form-entry';
export * from './get-patient-uuid-from-url';
export * from './lab-resource';
export * from './launchStartVisitPrompt';
export * from './nav-group/createDashboardGroup';
export * from './nav-group/DashboardGroupExtension';
Expand Down
2 changes: 2 additions & 0 deletions packages/esm-patient-common-lib/src/lab-resource/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './lab.resource';
export * from './test-order.component';
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { openmrsFetch, restBaseUrl, type FetchResponse, type OpenmrsResource } from '@openmrs/esm-framework';
import { type Order } from '@openmrs/esm-patient-common-lib';
import { type OrderAction, type Order } from '@openmrs/esm-patient-common-lib';
import useSWR from 'swr';
import { type Encounter, type Observation } from '../types/encounter';
import { type OrderDiscontinuationPayload } from '../types/order';

const labEncounterRepresentation =
'custom:(uuid,encounterDatetime,encounterType,location:(uuid,name),' +
Expand Down Expand Up @@ -72,6 +71,17 @@ export interface Mapping {
resourceVersion: string;
}

export interface OrderDiscontinuationPayload {
previousOrder: string;
type: string;
action: OrderAction;
careSetting: string;
encounter: string;
patient: string;
concept: string;
orderer: string;
}

export function useOrderConceptByUuid(uuid: string) {
const apiUrl = `${restBaseUrl}/concept/${uuid}?v=${labConceptRepresentation}`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import styles from './test-order.scss';
import { type Order } from '@openmrs/esm-patient-common-lib';
import { type Order, useLabEncounter, useOrderConceptByUuid } from '@openmrs/esm-patient-common-lib';
import {
DataTable,
DataTableSkeleton,
Expand All @@ -14,14 +14,13 @@ import {
TableRow,
} from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { useLabEncounter, useOrderConceptByUuid } from '../lab-results/lab-results.resource';
import { useLayoutType } from '@openmrs/esm-framework';

interface TestOrderProps {
testOrder: Order;
}

const TestOrder: React.FC<TestOrderProps> = ({ testOrder }) => {
export const TestOrder: React.FC<TestOrderProps> = ({ testOrder }) => {
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const { concept, isLoading: isLoadingTestConcepts } = useOrderConceptByUuid(testOrder.concept.uuid);
Expand Down Expand Up @@ -112,5 +111,3 @@ const TestOrder: React.FC<TestOrderProps> = ({ testOrder }) => {
</div>
);
};

export default TestOrder;
1 change: 1 addition & 0 deletions packages/esm-patient-common-lib/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './encounter';
export * from './test-results';

export interface DashboardLinkConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useMemo } from 'react';
import styles from './general-order-table.scss';
import { type Order } from '@openmrs/esm-patient-common-lib';
import {
DataTable,
DataTableSkeleton,
Expand All @@ -14,7 +13,7 @@ import {
TableRow,
} from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { useLabEncounter, useOrderConceptByUuid } from '../lab-results/lab-results.resource';
import { type Order, useLabEncounter, useOrderConceptByUuid } from '@openmrs/esm-patient-common-lib';
import { useLayoutType } from '@openmrs/esm-framework';

interface GeneralOrderProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
type Order,
type OrderBasketItem,
type OrderType,
TestOrder,
useLaunchWorkspaceRequiringVisit,
useOrderBasket,
useOrderTypes,
Expand All @@ -58,7 +59,6 @@ import {
import { buildGeneralOrder, buildLabOrder, buildMedicationOrder } from '../utils';
import MedicationRecord from './medication-record.component';
import PrintComponent from '../print/print.component';
import TestOrder from './test-order.component';
import styles from './order-details-table.scss';
import GeneralOrderTable from './general-order-table.component';

Expand Down
7 changes: 0 additions & 7 deletions packages/esm-patient-orders-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ export const patientOrdersFormWorkspace = getAsyncLifecycle(
options,
);

// t('enterTestResults', 'Enter test results')
export const testResultsFormWorkspace = getAsyncLifecycle(
() => import('./lab-results/lab-results-form.component'),
options,
);

export const orderBasketActionMenu = getSyncLifecycle(orderBasketActionMenuComponent, options);

export const orderPriceDetailsExtension = getAsyncLifecycle(
Expand All @@ -55,7 +49,6 @@ export const ordersDashboardLink =
);

export const ordersDashboard = getSyncLifecycle(OrdersSummary, options);
export const labResult = getAsyncLifecycle(() => import('./lab-results/lab-result.component'), options);

// t('searchOrderables','Search orderables')
export const orderableConceptSearch = getAsyncLifecycle(
Expand Down
15 changes: 0 additions & 15 deletions packages/esm-patient-orders-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@
"slot": "action-menu-patient-chart-items-slot",
"order": 0
},
{
"name": "lab-result",
"component": "labResult",
"slot": "completed-lab-order-results-slot",
"meta": {
"fullWidth": false
}
},
{
"name": "patient-orders-summary-dashboard",
"component": "ordersDashboardLink",
Expand Down Expand Up @@ -70,13 +62,6 @@
"type": "order",
"canHide": false
},
{
"name": "test-results-form-workspace",
"title": "enterTestResults",
"component": "testResultsFormWorkspace",
"type": "lab-results",
"canHide": false
},
{
"name": "orderable-concept-workspace",
"title": "searchOrderables",
Expand Down
17 changes: 0 additions & 17 deletions packages/esm-patient-orders-app/src/types/order.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
import { type Order } from '@openmrs/esm-patient-common-lib';

export interface PatientMedicationFetchResponse {
results: Array<Order>;
}

export interface OrderDiscontinuationPayload {
previousOrder: string;
type: string;
action: string;
careSetting: string;
encounter: string;
patient: string;
concept: string;
orderer: { display: string; person: { display: string }; uuid: string };
}

export interface OrderPriceData {
resourceType: string;
id: string;
Expand Down
13 changes: 0 additions & 13 deletions packages/esm-patient-orders-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"cancellationDateRequired": "Cancellation date is required",
"cancelOrder": "Cancel order",
"checkFilters": "Check the filters above",
"chooseAnOption": "Choose an option",
"clearSearchResults": "Clear results",
"dateCannotBeBeforeToday": "Date cannot be before today",
"dateOfOrder": "Date of order",
Expand All @@ -23,28 +22,20 @@
"dose": "Dose",
"editResults": "Edit results",
"endDate": "End date",
"enterTestResults": "Enter test results",
"error": "Error",
"errorCancellingOrder": "Error cancelling order",
"errorFetchingTestTypes": "Error fetching results for \"{{searchTerm}}\"",
"errorSavingLabResults": "Error saving lab results",
"goToDrugOrderForm": "Order form",
"indication": "Indication",
"labResultError": "Error loading lab results",
"inStock": "In stock",
"instructions": "Instructions",
"launchOrderBasket": "Launch order basket",
"loading": "Loading",
"loadingInitialValues": "Loading initial values",
"loadinglabresults": "Loading lab results",
"loadingTestDetails": "Loading test details",
"medicationDurationAndUnit": "for {{duration}} {{durationUnit}}",
"medicationIndefiniteDuration": "Indefinite duration",
"medications": "Medications",
"modifyOrder": "Modify order",
"noMatchingOrdersToDisplay": "No matching orders to display",
"noResultsForTestTypeSearch": "No results to display for \"{{searchTerm}}\"",
"normalRange": "Normal range",
"onDate": "on",
"or": "or",
"order": "Order",
Expand All @@ -67,7 +58,6 @@
"Orders": "Orders",
"orderType": "Order type",
"outOfStock": "Out of stock",
"pleaseFillField": "Please fill at least one field",
"pleaseFillRequiredFields": "Please fill all the required fields",
"pleaseRequiredFields": "Please fill all required fields",
"price": "Price",
Expand All @@ -83,11 +73,9 @@
"referenceNumberTableHeader": "{{orderType}} reference number",
"refills": "Refills",
"removeFromBasket": "Remove from basket",
"result": "Result",
"returnToOrderBasket": "Return to order basket",
"saveAndClose": "Save and close",
"saveDrugOrderFailed": "Error ordering {{orderName}}",
"saveLabResults": "Save lab results",
"saveOrder": "Save order",
"saving": "Saving",
"searchAgain": "search again",
Expand All @@ -102,7 +90,6 @@
"startVisit": "Start visit",
"status": "Status",
"successfullyCancelledOrder": "Order {{orderNumber}} has been cancelled successfully",
"successfullySavedLabResults": "Lab results for {{orderNumber}} have been successfully updated",
"Test Order_few": "Test orders",
"testType": "Test type",
"tryReopeningTheWorkspaceAgain": "Please try launching the workspace again",
Expand Down
8 changes: 8 additions & 0 deletions packages/esm-patient-tests-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ export const testResultsDashboardLink =
options,
);

// t('enterTestResults', 'Enter test results')
export const testResultsFormWorkspace = getAsyncLifecycle(
() => import('./lab-results/lab-results-form.component'),
options,
);

export const labOrderPanel = getAsyncLifecycle(
() => import('./test-orders/lab-order-basket-panel/lab-order-basket-panel.extension'),
options,
Expand All @@ -60,3 +66,5 @@ export const timelineResultsModal = getAsyncLifecycle(
moduleName,
},
);

export const labResult = getAsyncLifecycle(() => import('./lab-results/lab-result.component'), options);
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Tile, InlineLoading , InlineNotification } from '@carbon/react';
import { type Order } from '@openmrs/esm-patient-common-lib';
import { Tile, InlineLoading, InlineNotification } from '@carbon/react';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useCompletedLabResults, useOrderConceptByUuid } from './lab-results.resource';
import { type Order, useCompletedLabResults, useOrderConceptByUuid, TestOrder } from '@openmrs/esm-patient-common-lib';
import styles from './lab-result.scss';
import TestOrder from '../components/test-order.component';

type LabResultsProps = {
order: Order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { NumberInput, Select, SelectItem, TextInput } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { type Control, Controller, type FieldErrors } from 'react-hook-form';
import { isCoded, isNumeric, isPanel, isText, type LabOrderConcept } from './lab-results.resource';
import { isCoded, isNumeric, isPanel, isText, type LabOrderConcept } from '@openmrs/esm-patient-common-lib';
import styles from './lab-results-form.scss';

interface ResultFormFieldProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Button, ButtonSet, Form, InlineLoading, InlineNotification, Stack } from '@carbon/react';
import { zodResolver } from '@hookform/resolvers/zod';
import { restBaseUrl, showSnackbar, useAbortController, useLayoutType } from '@openmrs/esm-framework';
import { type DefaultPatientWorkspaceProps, type Order } from '@openmrs/esm-patient-common-lib';
import React, { useCallback, useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
Expand All @@ -14,11 +13,14 @@ import {
isNumeric,
isPanel,
isText,
type DefaultPatientWorkspaceProps,
type Order,
type OrderAction,
updateObservation,
updateOrderResult,
useCompletedLabResults,
useOrderConceptByUuid,
} from './lab-results.resource';
} from '@openmrs/esm-patient-common-lib';
import { useLabResultsFormSchema } from './useLabResultsFormSchema';

export interface LabResultsFormProps extends DefaultPatientWorkspaceProps {
Expand Down Expand Up @@ -155,12 +157,12 @@ const LabResultsForm: React.FC<LabResultsFormProps> = ({
const orderDiscontinuationPayload = {
previousOrder: order.uuid,
type: 'testorder',
action: 'DISCONTINUE',
action: 'DISCONTINUE' as OrderAction,
careSetting: order.careSetting.uuid,
encounter: order.encounter.uuid,
patient: order.patient.uuid,
concept: order.concept.uuid,
orderer: order.orderer,
orderer: order.orderer.uuid,
};
const resultsStatusPayload = {
fulfillerStatus: 'COMPLETED',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import {
useOrderConceptByUuid,
useLabEncounter,
useObservation,
type Encounter,
type LabOrderConcept,
type Order,
updateOrderResult,
type Datatype,
useCompletedLabResults,
} from './lab-results.resource';
} from '@openmrs/esm-patient-common-lib';
import LabResultsForm from './lab-results-form.component';
import { type Order } from '@openmrs/esm-patient-common-lib';
import { type Encounter } from '../types/encounter';

const mockUseOrderConceptByUuid = jest.mocked(useOrderConceptByUuid);
const mockUseLabEncounter = jest.mocked(useLabEncounter);
const mockUseObservation = jest.mocked(useObservation);
const mockUseCompletedLabResults = jest.mocked(useCompletedLabResults);

jest.mock('./lab-results.resource', () => ({
...jest.requireActual('./lab-results.resource'),
jest.mock('@openmrs/esm-patient-common-lib', () => ({
...jest.requireActual('@openmrs/esm-patient-common-lib'),
useOrderConceptByUuid: jest.fn(),
useLabEncounter: jest.fn(),
useObservation: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { type LabOrderConcept, useOrderConceptByUuid } from './lab-results.resource';
import { type LabOrderConcept, useOrderConceptByUuid } from '@openmrs/esm-patient-common-lib';

type SchemaRecord = Record<string, z.ZodType>;

Expand Down
15 changes: 15 additions & 0 deletions packages/esm-patient-tests-app/src/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
"component": "labOrderPanel",
"slot": "order-basket-slot",
"order": 2
},
{
"name": "lab-result",
"component": "labResult",
"slot": "completed-lab-order-results-slot",
"meta": {
"fullWidth": false
}
}
],
"modals": [
Expand All @@ -52,6 +60,13 @@
"type": "order",
"component": "addLabOrderWorkspace",
"title": "addLabOrderWorkspaceTitle"
},
{
"name": "test-results-form-workspace",
"title": "enterTestResults",
"component": "testResultsFormWorkspace",
"type": "lab-results",
"canHide": false
}
]
}
Loading

0 comments on commit 79e51c1

Please sign in to comment.