Skip to content

Commit 66e2f3d

Browse files
Merge branch 'main' into O3-4970
2 parents 6ecbac0 + 12bd984 commit 66e2f3d

File tree

3 files changed

+163
-152
lines changed

3 files changed

+163
-152
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Requirements
22

33
- [ ] This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a [conventional commit](https://o3-docs.openmrs.org/docs/frontend-modules/contributing.en-US#contributing-guidelines) label. See existing PR titles for inspiration.
4-
- [ ] My work is based on designs, which are linked or shown either in the Jira ticket or the description below.
4+
- [ ] My work is based on designs, which are linked or shown either in the Jira ticket or the description below. (See also: [Styleguide](http://om.rs/o3ui))
55
- [ ] My work includes tests or is validated by existing tests.
66

77
## Summary

packages/esm-patient-medications-app/src/add-drug-order/drug-order-form.component.tsx

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,19 @@ export function DrugOrderForm({
131131
allowSelectingDrug,
132132
}: DrugOrderFormProps) {
133133
const { t } = useTranslation();
134-
const config = useConfig<ConfigObject>();
134+
const { daysDurationUnit, prescriberProviderRoles } = useConfig<ConfigObject>();
135135
const isTablet = useLayoutType() === 'tablet';
136136
const { orderConfigObject, error: errorFetchingOrderConfig } = useOrderConfig();
137137

138138
const isProviderManagementModuleInstalled = useFeatureFlag('providermanagement-module');
139139
const allowAndSupportSelectingPrescribingClinician =
140140
isProviderManagementModuleInstalled && allowSelectingPrescribingClinician;
141141

142-
const { data: providers, isLoading: isLoadingProviders } = useProviders(
143-
allowAndSupportSelectingPrescribingClinician ? config.prescriberProviderRoles : null,
144-
);
142+
const {
143+
data: providers,
144+
isLoading: isLoadingProviders,
145+
error: errorLoadingProviders,
146+
} = useProviders(allowAndSupportSelectingPrescribingClinician ? prescriberProviderRoles : null);
145147
const [isSaving, setIsSaving] = useState(false);
146148

147149
const { currentProvider } = useSession();
@@ -234,11 +236,11 @@ export function DrugOrderForm({
234236
() =>
235237
orderConfigObject?.durationUnits ?? [
236238
{
237-
valueCoded: config?.daysDurationUnit?.uuid,
238-
value: config?.daysDurationUnit?.display,
239+
valueCoded: daysDurationUnit?.uuid,
240+
value: daysDurationUnit?.display,
239241
},
240242
],
241-
[orderConfigObject, config?.daysDurationUnit],
243+
[orderConfigObject, daysDurationUnit],
242244
);
243245

244246
const orderFrequencies: Array<MedicationFrequency> = useMemo(() => {
@@ -329,32 +331,41 @@ export function DrugOrderForm({
329331
/>
330332
</InputWrapper>
331333
)}
332-
{allowAndSupportSelectingPrescribingClinician && !isLoadingProviders && providers.length === 0 && (
333-
<InlineNotification
334-
kind="warning"
335-
lowContrast
336-
className={styles.inlineNotification}
337-
title={t('noCliniciansFound', 'No clinicians found')}
338-
subtitle={t(
339-
'noCliniciansFoundDescription',
340-
'Cannot select prescribing clinician because no clinicians with appropriate roles are found. Check configuration.',
341-
)}
342-
/>
343-
)}
344-
{allowAndSupportSelectingPrescribingClinician && !isLoadingProviders && (
345-
<ControlledFieldInput
346-
control={control}
347-
name="orderer"
348-
type="comboBox"
349-
getValues={getValues}
350-
id="orderer"
351-
shouldFilterItem={filterItemsByProviderName}
352-
placeholder={t('prescribingClinician', 'Prescribing Clinician')}
353-
titleText={t('prescribingClinician', 'Prescribing Clinician')}
354-
items={providers}
355-
itemToString={(item: Provider) => item?.person?.display}
356-
/>
357-
)}
334+
{allowAndSupportSelectingPrescribingClinician &&
335+
!isLoadingProviders &&
336+
(providers?.length > 0 ? (
337+
<ControlledFieldInput
338+
control={control}
339+
name="orderer"
340+
type="comboBox"
341+
getValues={getValues}
342+
id="orderer"
343+
shouldFilterItem={filterItemsByProviderName}
344+
placeholder={t('prescribingClinician', 'Prescribing Clinician')}
345+
titleText={t('prescribingClinician', 'Prescribing Clinician')}
346+
items={providers}
347+
itemToString={(item: Provider) => item?.person?.display}
348+
/>
349+
) : errorLoadingProviders ? (
350+
<InlineNotification
351+
kind="warning"
352+
lowContrast
353+
className={styles.inlineNotification}
354+
title={t('errorLoadingProviders', 'Error loading clinicians list')}
355+
subtitle={t('tryReopeningTheForm', 'Please try launching the form again')}
356+
/>
357+
) : (
358+
<InlineNotification
359+
kind="warning"
360+
lowContrast
361+
className={styles.inlineNotification}
362+
title={t('noCliniciansFound', 'No clinicians found')}
363+
subtitle={t(
364+
'noCliniciansFoundDescription',
365+
'Cannot select prescribing clinician because no clinicians with appropriate roles are found. Check configuration.',
366+
)}
367+
/>
368+
))}
358369
</Stack>
359370
</section>
360371
)}

0 commit comments

Comments
 (0)