Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Updating Imaging Orders and Procedure Orders to require Order Reason #11

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export function ImagingOrderForm({
commentsToFulfiller: z.string().optional(),
laterality: z.string().optional(),
bodySite: z.string().optional(),
orderReasonNonCoded: z.string().min(1, {
message: translateFrom(moduleName, 'addOrderReasonRequired', 'Order reason is required'),
}),
});

const {
Expand Down Expand Up @@ -317,6 +320,30 @@ export function ImagingOrderForm({
</InputWrapper>
</Column>
</Grid>
<Grid className={styles.gridRow}>
<Column lg={16} md={8} sm={4}>
<InputWrapper>
<Controller
name="orderReasonNonCoded"
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<TextArea
enableCounter
id="orderReasonNonCodedInput"
size="lg"
labelText={'Order Reason'}
value={value}
onChange={onChange}
onBlur={onBlur}
maxCount={500}
invalid={errors.orderReasonNonCoded?.message}
invalidText={errors.orderReasonNonCoded?.message}
/>
)}
/>
</InputWrapper>
</Column>
</Grid>
</div>
<div>
{showErrorNotification && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function prepImagingOrderPostData(
concept: order.testType.conceptUuid,
instructions: order.instructions,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
commentToFulfiller: order.commentsToFulfiller,
laterality: order.laterality,
bodySite: order.bodySite,
Expand All @@ -78,6 +79,7 @@ export function prepImagingOrderPostData(
concept: order.testType.conceptUuid,
instructions: order.instructions,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
commentToFulfiller: order.commentsToFulfiller,
laterality: order.laterality,
bodySite: order.bodySite,
Expand All @@ -96,6 +98,7 @@ export function prepImagingOrderPostData(
encounter: encounterUuid,
concept: order.testType.conceptUuid,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
commentToFulfiller: order.commentsToFulfiller,
laterality: order.laterality,
bodySite: order.bodySite,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
fulfillerStatus: string,
) => {
const responseFormat =
'custom:(uuid,orderNumber,patient:ref,concept:(uuid,display,conceptClass),action,careSetting,orderer:ref,urgency,instructions,bodySite,laterality,commentToFulfiller,procedures,display,fulfillerStatus,dateStopped,scheduledDate,dateActivated,fulfillerComment)';
'custom:(uuid,orderNumber,patient:ref,concept:(uuid,display,conceptClass),action,careSetting,orderer:ref,urgency,instructions,orderReasonNonCoded,bodySite,laterality,commentToFulfiller,procedures,display,fulfillerStatus,dateStopped,scheduledDate,dateActivated,fulfillerComment)';
const orderTypeParam = `orderTypes=${OrderTypeUuid}&activatedOnOrAfterDate=${activatedOnOrAfterDate}&activatedOnOrBeforeDate=${activatedOnOrBeforeDate}&isStopped=false&fulfillerStatus=${fulfillerStatus}&v=${responseFormat}`;

return `${restBaseUrl}/order?${orderTypeParam}`;
Expand All @@ -38,7 +38,7 @@
dateRange.at(1).toISOString(),
fulfillerStatus,
),
[radiologyOrderTypeUuid, dateRange.at(0).toISOString(), dateRange.at(1).toISOString(), fulfillerStatus],

Check warning on line 41 in packages/esm-imaging-orders-app/src/hooks/useOrdersWorklist.ts

View workflow job for this annotation

GitHub Actions / build

React Hook useMemo has a missing dependency: 'dateRange'. Either include it or remove the dependency array

Check warning on line 41 in packages/esm-imaging-orders-app/src/hooks/useOrdersWorklist.ts

View workflow job for this annotation

GitHub Actions / build

React Hook useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked

Check warning on line 41 in packages/esm-imaging-orders-app/src/hooks/useOrdersWorklist.ts

View workflow job for this annotation

GitHub Actions / build

React Hook useMemo has a complex expression in the dependency array. Extract it to a separate variable so it can be statically checked
);

const { data, error, isLoading, mutate } = useSWR<{ data: { results: Array<Result> } }>(apiUrl, openmrsFetch);
Expand Down
1 change: 1 addition & 0 deletions packages/esm-imaging-orders-app/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ImagingOrderBasketItem extends OrderBasketItem {
urgency?: string;
instructions?: string;
orderReason?: string;
orderReasonNonCoded?: string;
scheduleDate?: Date | string;
commentsToFulfiller?: string;
laterality?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-imaging-orders-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"saveAndClose": "Save & close",
"saveOrder": "Save order",
"scheduleDate": "Scheduled date",
"searchbypatientname": "Search by patient name",
"searchByPatientName": "Search by patient name",
"status": "Status",
"submitting": "Submitting...",
"successfullyRejected": "You have successfully rejected an Order with OrderNumber {{orderNumber}} ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
previousOrder: z.string().optional(),
frequency: z.string().optional(),
bodySite: z.string().optional(),
orderReasonNonCoded: z.string().min(1, {
message: translateFrom(moduleName, 'addOrderReasonRequired', 'Order reason is required'),
}),
});

const orderFrequencies: Array<OrderFrequency> = useMemo(
Expand Down Expand Up @@ -143,7 +146,7 @@
onWorkspaceClose: () => launchPatientWorkspace('order-basket'),
});
},
[orders, setOrders, closeWorkspace, session?.currentProvider?.uuid, defaultValues],

Check warning on line 149 in packages/esm-procedure-orders-app/src/form/procedures-orders/add-procedures-order/procedures-order-form.component.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has a missing dependency: 'closeWorkspaceWithSavedChanges'. Either include it or remove the dependency array. If 'closeWorkspaceWithSavedChanges' changes too often, find the parent component that defines it and wrap that definition in useCallback
);

const cancelOrder = useCallback(() => {
Expand All @@ -161,7 +164,7 @@

useEffect(() => {
promptBeforeClosing(() => isDirty);
}, [isDirty]);

Check warning on line 167 in packages/esm-procedure-orders-app/src/form/procedures-orders/add-procedures-order/procedures-order-form.component.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useEffect has a missing dependency: 'promptBeforeClosing'. Either include it or remove the dependency array. If 'promptBeforeClosing' changes too often, find the parent component that defines it and wrap that definition in useCallback

const [showScheduleDate, setShowScheduleDate] = useState(false);

Expand Down Expand Up @@ -412,6 +415,30 @@
</InputWrapper>
</Column>
</Grid>
<Grid className={styles.gridRow}>
<Column lg={16} md={8} sm={4}>
<InputWrapper>
<Controller
name="orderReasonNonCoded"
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<TextArea
enableCounter
id="orderReasonNonCodedInput"
size="lg"
labelText={'Order Reason'}
value={value}
onChange={onChange}
onBlur={onBlur}
maxCount={500}
invalid={errors.orderReasonNonCoded?.message}
invalidText={errors.orderReasonNonCoded?.message}
/>
)}
/>
</InputWrapper>
</Column>
</Grid>
</div>
<div>
{showErrorNotification && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function prepProceduresOrderPostData(
commentToFulfiller: order.commentsToFulfiller,
instructions: order.instructions,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
bodySite: order.bodySite,
};
if (order.urgency === 'ON_SCHEDULED_DATE') {
Expand All @@ -122,6 +123,7 @@ export function prepProceduresOrderPostData(
commentToFulfiller: order.commentsToFulfiller,
instructions: order.instructions,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
previousOrder: order.previousOrder,
};
if (order.urgency === 'ON_SCHEDULED_DATE') {
Expand All @@ -144,6 +146,7 @@ export function prepProceduresOrderPostData(
numberOfRepeats: order.numberOfRepeats,
commentToFulfiller: order.commentsToFulfiller,
orderReason: order.orderReason,
orderReasonNonCoded: order.orderReasonNonCoded,
previousOrder: order.previousOrder,
};
if (order.urgency === 'ON_SCHEDULED_DATE') {
Expand Down
1 change: 1 addition & 0 deletions packages/esm-procedure-orders-app/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ export interface ProcedureOrderBasketItem extends OrderBasketItem {
instructions?: string;
previousOrder?: string;
orderReason?: string;
orderReasonNonCoded?: string;
scheduledDate?: string | Date;
commentsToFulfiller?: string;
laterality?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-procedure-orders-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"saveOrder": "Save order",
"saveReport": "Report updated sucessful",
"scheduleDate": "Scheduled date",
"searchbypatientname": "Search by patient name",
"searchByPatientName": "Search by patient name",
"searchThisList": "Search this list",
"selectOutcome": "Select outcome",
"sendEmail": "Send Email",
Expand Down
Loading