Maintaining sequence order for drug orders

Are you developing a custom user interface for this sorting of orders? You could take advantage of Order Attributes, which is how we extends domain objects with extra data.

Yes, we are developing a custom user interface. you mean to say i can put the expected sequence in orderattribute and using that front end could sort it and display the order’s in that sequence. I am using platform 2.5.10, where I can get rest API’s for orderattribute and orderattributetype? I tried this

GET /openmrs/ws/rest/v1/orderattribute
response
{
    "error": {
        "message": "Resource does not exist. Please check documentation for implemented resources and their paths [Unknown resource: v1/orderattribute]",
        "code": "org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl:416",


GET /openmrs/ws/rest/v1/orderattributetype
{
    "error": {
        "message": "Resource does not exist. Please check documentation for implemented resources and their paths [Unknown resource: v1/orderattributetype]",
        "code": "org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl:416",

I have noticed that when we added attributes to orders, we did not update the REST API to include them. Feel free to create a JIRA ticket for this under the webservices rest JIRA project.

1 Like

Thanks @dkayiwa, I have JIRA requested access, so that I can create ticket, just trying to understand, this must have been added based on some use-case, but if there is no rest API, how it is being used, is it internally some other function within core is using this?

Another question, the provider is looking to get a snapshot(in OPD setting, when visit is closed) of captured observations, active orders at that point of time to see what complaints were there and what medications were taken at that point of time. Any specific API we can use to get that.

* **Visit-Wise Snapshot**: At any point in the future, we want to retrieve a snapshot of all active medications a patient was taking after each visit in OPD scenerio. This includes drugs ordered in the current visit and those from previous visits that were still active at that time. The snapshot should reflect the provider’s preferred sequence. For example:
  * **Visit 1 Snapshot**: [Med1, Med2, Med3].
  * **Visit 2 Snapshot**: [Med1, Med4, Med2] (since Med3 is stopped, and Med4 is inserted).
  * Even later in future after multiple visits, provider should be able to fetch and see these exact snapshots.

Most Java-based modules use the Java API for core, so these features exist even if they weren’t exposed through the REST API.

1 Like

@dkayiwa I am waiting for Jira access to create ticket, once I have access, would create ticket and share here.

@dkayiwa @ibacher Any input on this question

You’ll almost certainly have to write some custom code to grab the snapshot, but you could ensure that is triggered when the visit closes, depending on what that means for your implementation. This type of thing, though, is usually only possible via a custom Java module.

1 Like

@dkayiwa I have created the task

Adding rest API for Order Attribute to do CRUD operation

Ok thanks. I have made it ready for work and added it to the list of community priorities.

1 Like

Hey everyone, I’ve started working on the OrderAttribute-related issue and could use some clarification. I’ve already implemented CRUD support for OrderAttributeType locally.

  1. While working on OrderAttributeResource#save, I noticed there doesn’t seem to be a DAO method in core to persist OrderAttribute. How is its lifecycle typically managed?

  2. I’m also running into a ConversionException during serialization/deserialization of transient object values — specifically while testing with FreeTextDatatype. I’m working on RefApp 3.x — could this be due to a missing module, or should I be handling this via guards in the @PropertyGetter/@PropertySetter methods?

Any insights would be appreciated — thanks!

Hey @dkayiwa , could you please help me out on this? Thanks.

You can take a look at these examples: ProgramEnrollmentResource2_2, ConceptResource2_0, LocationResource1_9

I would need to look at the full stack trace.

All the classes like ProgramEnrollmentResource2_2, ConceptResource2_0, and LocationResource1_9 have mutable parent entities. But Order is immutable once created right? So adding support for POST/PUT by extending the latest OrderResource2_2 leads to a ResourceDoesNotSupportOperationException.

What would be the recommended approach to work around this?

Also, when an Order is revised, what happens to the OrderAttribute(s) attached to the original? Are they automatically carried over to the new order, or do I need to manually copy them?

(That conversion exception earlier was a mistake on my end , please ignore it.)

Thank you.

Do you have a draft pull request that i can look at?

I have created a draft PR here.

I have put a comment on github.