VOID Order using Rest API

How Do I Void a Drug Order or Test Order using rest API.

Hey Yusuf,

There is an api documentation for this as here and shows the endpoint for voiding an order.

There is also this wiki documentation that seems to have more details. Here

I hope these help.:slight_smile:

1 Like

Hi, try this

DELETE /openmrs/ws/rest/v1/order/ORDER-UUID

You can specify a void reason via the reason request parameter

1 Like

Hi Eunice, @niccie @wyclif Thank you. What should be purge value for void.


Your most welcome.

Purge is a bool and by default without including it, its taken to be false thus your order is only soft deleted but once include and assigned to true the order will be completely deleted, ‘hard deleted’ .

1 Like

Thanks. :slight_smile: Its clear now.

Actually purge isn’t a boolean parameter as such, the way it’s implemented in the rest Api is such that if you don’t include it, it’s interpreted as a soft delete operation otherwise if you include it, it will result in a hard delete regardless of its value.

I personally think we should fix the rest API so that a hard delete only happens if one sets the value of the purge param to true.

You are right. I put purge=false and its doing hard delete. There is another question. If all orders under one encounter is deleted then empty encounter is left. Should I call a delete encounter if its last order in this encounter.


Thanks for the clarification. This is enlightening.

We need to update the documentation then as it states The resource will be voided/retired unless purge = ‘true’.

That’s an implementation specific thing you can implement, I personally don’t think you should delete an encounter just because it has no orders, there is other data collected in an encounter e.g obs which would still be relevant may be if there are no obs too then it would be fine. But more data in future versions will be collected within an encounter e.g diagnosis so your code might not be future proof.