EMR Api: Saving medication is throwing error in user locale

Hi. We noticed that, when user logged in different locale (user locale i.e french) other than English (Default Locale) is choosing dose, duration and quantity units in default locale as there is no translation available in their user locale, is throwing an exception while saving it.

Error log

ERROR - BaseRestController.handleException(124) |2023-11-29T12:55:29,501| 'DrugOrder(2.0null of Paracetamol 500mg from null to null)' failed to validate with reason: doseUnits: Dose Units is required when dose is specified, quantityUnits: Quantity units is required when quantity is specified org.openmrs.api.ValidationException: 'DrugOrder(2.0null of Paracetamol 500mg from null to null)' failed to validate with reason: doseUnits: Dose Units is required when dose is specified, quantityUnits: Quantity units is required when quantity is specified at org.openmrs.validator.ValidateUtil.validate(ValidateUtil.java:88) ~[openmrs-api-2.5.12.jar:?] at org.openmrs.aop.RequiredDataAdvice.before(RequiredDataAdvice.java:128) ~[openmrs-api-2.5.12.jar:?] at

you can check code here

The method conceptService.getConceptByName(name) is searching the concept name only with the user locale. That is the issue. It should also check for concept names in default locale (en) for which translations is not available in user locale (fr)

The possible solution for the above issue is to make use of OrderService getDoseUnits(), getDurationUnts() method as we did here which returns all of the dose and duration units concept names in user locale along with concept names in default locale for those of which translation is not there.

cc: @angshuonline @gsluthra

1 Like