diff --git a/src/components/orders-table/list-order-details.component.tsx b/src/components/orders-table/list-order-details.component.tsx index b3654e4a..f11f540a 100644 --- a/src/components/orders-table/list-order-details.component.tsx +++ b/src/components/orders-table/list-order-details.component.tsx @@ -9,9 +9,10 @@ import ResultForm from "../../results/result-form.component"; import styles from "./list-order-details.scss"; const ListOrderDetails: React.FC = (props) => { + const { t } = useTranslation(); const orders = props.groupedOrders?.orders; const patientId = props.groupedOrders?.patientId; - const { t } = useTranslation(); + return (
{orders && @@ -31,6 +32,7 @@ const ListOrderDetails: React.FC = (props) => { return (
= (props) => { value={row.orderNumber} /> - = ({

{label} - {" : "} + {": "} {value}

diff --git a/src/components/orders-table/orders-data-table.component.tsx b/src/components/orders-table/orders-data-table.component.tsx index d788def5..4cfd9228 100644 --- a/src/components/orders-table/orders-data-table.component.tsx +++ b/src/components/orders-table/orders-data-table.component.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useState } from "react"; +import dayjs from "dayjs"; import { useTranslation } from "react-i18next"; import { DataTable, @@ -23,7 +24,6 @@ import { TableToolbarSearch, Tile, } from "@carbon/react"; -import dayjs from "dayjs"; import { formatDate, parseDate, @@ -57,18 +57,18 @@ const OrdersDataTable: React.FC = (props) => { activatedOnOrAfterDate ); - const flattenedLabOrders = useMemo(() => { - return labOrders.map((eachObject) => { - return { - ...eachObject, - dateActivated: formatDate(parseDate(eachObject.dateActivated)), - patientName: eachObject.patient?.display.split("-")[1], - patientUuid: eachObject.patient?.uuid, - status: eachObject.fulfillerStatus ?? "--", - orderer: eachObject.orderer?.display.split("-")[1], - }; - }); - }, [labOrders]); + const flattenedLabOrders = useMemo( + () => + labOrders.map((labOrder) => ({ + ...labOrder, + dateActivated: formatDate(parseDate(labOrder.dateActivated)), + patientName: labOrder.patient?.display.split("-")[1], + patientUuid: labOrder.patient?.uuid, + status: labOrder.fulfillerStatus ?? "--", + orderer: labOrder.orderer, + })), + [labOrders] + ); function groupOrdersById(orders) { if (orders && orders.length > 0) { diff --git a/src/components/orders-table/orders-data-table.scss b/src/components/orders-table/orders-data-table.scss index eb139651..fb1c2651 100644 --- a/src/components/orders-table/orders-data-table.scss +++ b/src/components/orders-table/orders-data-table.scss @@ -26,7 +26,6 @@ :global(.cds--table-toolbar) { position: static; - margin: 0.5rem; } :global(.cds--overflow-menu) { @@ -48,12 +47,12 @@ } .toolbarItem { + margin-left: 1rem; display: flex; - margin: 5px 10px; align-items: center; & p { - padding-right: 5px; + padding-right: 0.5rem; @include type.type-style('body-01'); color: colors.$gray-70; } diff --git a/src/results/result-form.component.tsx b/src/results/result-form.component.tsx index 842069db..8336cd53 100644 --- a/src/results/result-form.component.tsx +++ b/src/results/result-form.component.tsx @@ -4,6 +4,7 @@ import { Button, ButtonSet, Form, + InlineLoading, InlineNotification, Stack, } from "@carbon/react"; @@ -45,11 +46,13 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { const { control, - register, formState: { isSubmitting }, getValues, handleSubmit, - } = useForm<{ testResult: string }>({ + register, + } = useForm<{ + testResult: string; + }>({ defaultValues: {}, }); @@ -70,7 +73,6 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { const onSubmit = () => { const formValues = getValues(); - const isEmptyForm = Object.values(formValues).every( (value) => value === "" || value === null || value === undefined ); @@ -114,6 +116,7 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { }); } else if (!concept.set && concept.setMembers.length === 0) { let value; + if ( concept.datatype.display === "Numeric" || concept.datatype.display === "Text" @@ -152,12 +155,12 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { encounter: order.encounter.uuid, patient: order.patient.uuid, concept: order.concept.uuid, - orderer: order.orderer, + orderer: order.orderer?.uuid, }; - updateOrderResult(encounterPayload, orderDiscontinuationPayload).then( - (response) => { - if (response.ok) { + updateOrderResult(encounterPayload, orderDiscontinuationPayload) + .then( + (res) => { showSnackbar({ isLowContrast: true, title: t("updateEncounter", "Update lab results"), @@ -180,6 +183,7 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { "You have successfully completed the test order" ), }); + mutate( (key) => typeof key === "string" && @@ -189,7 +193,6 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { undefined, { revalidate: true } ); - closeOverlay(); }, (err) => { showNotification({ @@ -204,18 +207,20 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { } ); - return response; + return res; + }, + (err) => { + showNotification({ + title: t("errorUpdatingEncounter", "Error updating test results"), + kind: "error", + critical: true, + description: err?.message, + }); } - }, - (err) => { - showNotification({ - title: t("errorUpdatingEncounter", "Error updating test results"), - kind: "error", - critical: true, - description: err?.message, - }); - } - ); + ) + .finally(() => { + closeOverlay(); + }); setShowEmptyFormErrorNotification(false); }; @@ -250,14 +255,19 @@ const ResultForm: React.FC = ({ order, patientUuid }) => { diff --git a/src/results/result-form.resource.ts b/src/results/result-form.resource.ts index 5693cfaa..4be536ca 100644 --- a/src/results/result-form.resource.ts +++ b/src/results/result-form.resource.ts @@ -308,7 +308,7 @@ export interface ObPayload { } // get order concept -export async function GetOrderConceptByUuid(uuid: string) { +export async function getOrderConceptByUuid(uuid: string) { const abortController = new AbortController(); return openmrsFetch(`${restBaseUrl}/concept/${uuid}?v=full`, { headers: { diff --git a/translations/en.json b/translations/en.json index ad4b72df..b51a9158 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1,6 +1,5 @@ { "all": "All", - "allFieldsRequired": "All fields are required", "cancel": "Cancel", "checkFilters": "Please check the filters above and try again", "chooseOption": "Choose an option", @@ -9,6 +8,7 @@ "date": "Date", "declinedStatus": "DECLINED", "discard": "Discard", + "error": "Error", "errorMarkingOrderFulfillStatus": "Error occurred while marking order fulfill status", "errorPickingOrder', 'Error picking order": "", "errorRejectingRequest": "Error rejecting lab request", @@ -39,6 +39,7 @@ "pickRequest": "Pick lab request", "pickRequestConfirmationText": "Continuing will update the request status to \"In Progress\" and advance it to the next stage. Are you sure you want to proceed?", "pickupLabRequest": "Pick up lab request", + "pleaseFillField": "Please fill at least one field", "previousPage": "Previous page", "procedure": "procedure", "receivedStatus": "RECEIVED", @@ -48,6 +49,7 @@ "rejectLabRequestTitle": "Lab request rejected", "results": "Results", "save": "Save", + "saving": "Saving", "searchThisList": "Search this list", "status": "Status", "tabletOverlay": "Tablet overlay",