# Saving obs value drug via REST

**URL:** <https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483>\
**Category:** Development\
**Tags:** rest\
**Created:** [May 30, 2016, 12:16pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483 "2016-05-30T12:16:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkimaina](https://talk.openmrs.org/letter_avatar/nkimaina/32/5_5575768a8748004e209b776fc1b2916d.png) [@nkimaina](https://talk.openmrs.org/u/nkimaina)\
**Post date:** [May 30, 2016, 12:16pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/1 "2016-05-30T12:16:37Z")

</div>

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:

```auto
{
    "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?

---

<div class="post-metadata">

**Author:** ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)\
**Post date:** [May 30, 2016, 12:33pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/2 "2016-05-30T12:33:46Z")

</div>

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](http://burkeware.com/openmrs-data-model/openmrs-data-model-1.11.html#order)?

Perhaps have a look at the [obs resource](https://psbrandt.io/openmrs-contrib-apidocs/#operation--obs-post) and [order resource](https://psbrandt.io/openmrs-contrib-apidocs/#operation--order-post) 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?

---

<div class="post-metadata">

**Author:** ![nkimaina](https://talk.openmrs.org/letter_avatar/nkimaina/32/5_5575768a8748004e209b776fc1b2916d.png) [@nkimaina](https://talk.openmrs.org/u/nkimaina)\
**Post date:** [May 30, 2016, 2:45pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/3 "2016-05-30T14:45:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jdick](https://talk.openmrs.org/letter_avatar/jdick/32/5_5575768a8748004e209b776fc1b2916d.png) [@jdick](https://talk.openmrs.org/u/jdick)\
**Post date:** [May 30, 2016, 2:57pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/4 "2016-05-30T14:57:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pascal](https://talk.openmrs.org/letter_avatar/pascal/32/5_5575768a8748004e209b776fc1b2916d.png) [@pascal](https://talk.openmrs.org/u/pascal)\
**Post date:** [May 30, 2016, 3:16pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/5 "2016-05-30T15:16:16Z")

</div>

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`).

---

<div class="post-metadata">

**Author:** ![willa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/willa/32/256_2.png) [@willa](https://talk.openmrs.org/u/willa)\
**Post date:** [May 30, 2016, 3:17pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/6 "2016-05-30T15:17:01Z")

</div>

@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](https://github.com/openmrs/openmrs-module-webservices.rest/blob/master/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java#L304-L317) 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"
}
```

---

<div class="post-metadata">

**Author:** ![werick](https://talk.openmrs.org/letter_avatar/werick/32/5_5575768a8748004e209b776fc1b2916d.png) [@werick](https://talk.openmrs.org/u/werick)\
**Post date:** [May 30, 2016, 3:17pm UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/7 "2016-05-30T15:17:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nkimaina](https://talk.openmrs.org/letter_avatar/nkimaina/32/5_5575768a8748004e209b776fc1b2916d.png) [@nkimaina](https://talk.openmrs.org/u/nkimaina)\
**Post date:** [May 31, 2016, 6:29am UTC](https://talk.openmrs.org/t/saving-obs-value-drug-via-rest/6483/8 "2016-05-31T06:29:33Z")

</div>

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