I am posting the following drug order payload using REST. The drug is non coded which means the drug is null makes the associated concept null as well.
[POST] /ws/rest/v1/encounter
{
"patient": "4389389b-8366-42fe-b38f-4d995cdf4b5a",
"encounterType": "e22e39fd-7db2-45e7-80f1-60fa0d5a4378",
"visit": null,
"location": null,
"encounterProviders": [{
"provider": "f9badd80-ab76-11e2-9e96-0800200c9a66",
"encounterRole": "240b26f9-dd88-4172-823d-4a8bfeb7841f"
}],
"orders": [{
"action": "NEW",
"type": "drugorder",
"careSetting": "6f0c9a92-6f24-11e3-af88-005056821db0",
"orderer": "f9badd80-ab76-11e2-9e96-0800200c9a66",
"commentToFulfiller": "",
"dosingType": "org.openmrs.FreeTextDosingInstructions",
"numRefills": 0,
"quantity": 0,
"quantityUnits": null,
"previousOrder": null,
"dose": null,
"doseUnits": null,
"frequency": null,
"asNeeded": false,
"asNeededCondition": null,
"route": null,
"duration": null,
"durationUnits": null,
"dosingInstructions": "Take as much as you like",
"autoExpireDate": null,
"drugNonCoded": "This is not coded drug"
}]
}
Unfortunately this is not valid as far as the API is concerned throwing the following error.
{ “error”: { “message”: “[‘DrugOrder(nullnull of this is not coded from null to null)’ failed to validate with reason: concept: Cannot be empty or null, quantityUnits: Quantity units is required when quantity is specified]”, “code”: “org.openmrs.validator.ValidateUtil:78”, “detail”: "org.openmrs.api.ValidationException: ‘DrugOrder(nullnull of this is not coded from null to null)’ failed to validate with reason: concept: Cannot be empty or null, quantityUnits: Quantity units is required when quantity is specified\n\tat org.openmrs.validator.ValidateUtil.validate(ValidateUtil.java:78)\n\tat org.openmrs.aop.RequiredDataAdvice.before(RequiredDataAdvice.java:124)
The underlying drug_order
table has been changed to allow non coded drug orders (see here). But this section of DrugOrderValidator still requires the drug and concept to be specified.
One way to make this work is to use a place holder drug which can be linked to concept non coded, but is this how it is supposed to work? I guess what I am asking is, is there a need to update the validator to take into account the non coded drug or is the current behavior intended by design?
Thoughts?
@wyclif & @burke I have to call you guys here because you have a lot to do with the new order entry API.