Saving obs value drug via REST

I am trying to save an obs via REST. The requirement is that it should be able to save the concept of a drug, as well as the formulation(that comes from the drug table). An ideal payload would be as follows:

{
    "person":"c6e4e026-3b49-4b64-81de-05cf8bd18594",
    "obsDatetime":"2014-10-01T00:00:00.000+0300",
    "concept":"a899cf5e-1350-11df-a1f1-0026b9348838",
    "value":"a8967656-1350-11df-a1f1-0026b9348838",
    "valueDrug": "0485075a-3111-11e0-8090-0026b9348838"
}

The concept is uuid for “current arv medication” concept. The value is concept uuid for “Nevirapine” and The value drug is drug uuid for “Nevirapine 200mg”.

I haven’t been able to save/retrieve this via rest. Any ideas on how I can achieve this via REST?

I’m not sure that what you are trying to do can be done using a single core REST resource (you could create your own in a module). Do you actually need to create the obs as well as the drug order?

Perhaps have a look at the obs resource and order resource docs and see if they help you.

Have you not been able to create an obs via rest at all? Or just the ones involving drugs that are you describing?

Thanks @pascal for the immediate response. I am able to submit obs with simple value and also with value coded. What I am not able to do is view/submit obs with value_drug. I want to be able to do this without using order api i.e. drug order for backward compatibility purpose with existing encounters since I want to be able to edit already saved data, that was saved using either html form entry or the other openmrs data collection modules, that support saving of obs with value_coded and value_drug.

CC @willa @jdick @burke @werick

@pascal, is the value_drug column in the obs table intended to be used exclusively for drug orders?

I’m not sure, but I don’t think so. I think the idea of obs and orders are separate.

The problem is that I don’t think you can save more than one value for an obs (e.g. value and value_drug).

@nkimaina you only need to specify the “value” field using the drug UUID. The REST API will set the concept value_coded for you (see the rest API piece of code that does this). See the required payload below.

{
    "person":"c6e4e026-3b49-4b64-81de-05cf8bd18594",
    "obsDatetime":"2014-10-01T00:00:00.000+0300",
    "concept":"a899cf5e-1350-11df-a1f1-0026b9348838",
    "value": "0485075a-3111-11e0-8090-0026b9348838"
}
1 Like

@nkimaina, This issue was already fixed in this ticket https://issues.openmrs.org/browse/RESTWS-577, Just get the latest web services module. Erick

1 Like

Thanks guys, that fixed it. Using version 2.14 of REST module did it.

1 Like