OpenMRS REST API Usage

84 views
Skip to first unread message

Jitendra Singh Bhati

unread,
Jul 1, 2014, 8:31:47 AM7/1/14
to raxa-jss-em...@googlegroups.com
Hello all,

I want to use OpenMRS REST API in my android application.
I referred https://wiki.openmrs.org/display/docs/REST+Web+Service+Resources+in+OpenMRS+1.9#RESTWebServiceResourcesinOpenMRS1.9-Person but it does not say how to create request json object so am getting bad request response.
Can you please suggest me which code or examples I can refer for the same?



~ Jitendra

John Stoecker

unread,
Jul 1, 2014, 9:35:02 AM7/1/14
to raxa-jss-em...@googlegroups.com

Hi Jitendra,

For person specifically, the page you have is correct - check the POST create representation. You will notice how names and gender are bold, which means they are required for the person object. Then for name, check the personname post create documentation on the same page.

Your json will look like:

          {"gender": "M",
          "names": [
              {"givenName":"Joe", "familyName":"Smith"}]
          }

The openmrs Dev mailing list and other pages on their wiki could help you even further. Happy coding!

--
You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jitendra Singh Bhati

unread,
Jul 1, 2014, 11:35:27 AM7/1/14
to raxa-jss-em...@googlegroups.com
HI John,

Thanks for the nice explanation. Yes OpenMRS has give URL and representation but no examples of usage which makes it complex to use them.

Can you please confirm below steps for patient creation based on your example:
- Use URL: POST /ws/rest/v1/patient
- In representation I can see Person and Identifiers as bold so I should refer Person and PatientIdentifier
- In PatientIdentifier, identifier and identifiertype are bold so I must use them. Same way for patient
- In IdentifierType, name and description are bold so I must use them as well 
- In PatientName, givenName and familyName are bold so I must include.

How can I create request object with all these values, if you can please give example?

To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-developers+unsub...@googlegroups.com.

John Stoecker

unread,
Jul 1, 2014, 12:40:33 PM7/1/14
to raxa-jss-em...@googlegroups.com

Yes, all those are correct but instead of creating a new identifierType use the uuid of one already existing (rather than name and description). To find the uuid on identifierType, do a GET call and note the uuid.

You will want to nest person inside patient, just like I nested name inside person.

To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.

Jitendra Singh Bhati

unread,
Jul 1, 2014, 1:25:07 PM7/1/14
to raxa-jss-em...@googlegroups.com
Thanks John. Will try.


You received this message because you are subscribed to a topic in the Google Groups "Raxa JSS EMR Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/raxa-jss-emr-developers/5uBLet2Wqlk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to raxa-jss-emr-deve...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Jitendra

Jitendra Singh Bhati

unread,
Jul 2, 2014, 5:02:32 AM7/2/14
to raxa-jss-em...@googlegroups.com
Hi all,

I have added patient in OpenMRS database by following John's instruction. Thanks John.

In my android app,I have few fields to be added in OpenMRS through REST API like weight, height, allergy, drug, blood sugar, glucose etc. 
How to add them? I mean which REST API URL I should use?


~ Jitendra
Thanks John. Will try.


To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-developers+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-developers+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Raxa JSS EMR Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/raxa-jss-emr-developers/5uBLet2Wqlk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to raxa-jss-emr-developers+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Jitendra

John Stoecker

unread,
Jul 2, 2014, 7:12:42 AM7/2/14
to raxa-jss-em...@googlegroups.com

The easiest way is to post an obs for each. In obs, the concept will be the uuid for weight, or height, etc, and the value as whatever the user inputs.

To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.

Jitendra Singh Bhati

unread,
Jul 2, 2014, 11:13:35 AM7/2/14
to raxa-jss-em...@googlegroups.com
Thanks John.

~ Jitendra
Thanks John. Will try.


You received this message because you are subscribed to a topic in the Google Groups "Raxa JSS EMR Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/raxa-jss-emr-developers/5uBLet2Wqlk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to raxa-jss-emr-developers+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Jitendra

--
You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.

Jitendra Singh Bhati

unread,
Jul 3, 2014, 7:30:18 AM7/3/14
to raxa-jss-em...@googlegroups.com
Hello John,

I have Register and Login screen. User first register and we are saving all the provided values into OpenMRS DB using REST API. When I checked password in Users table, password is not in the same format as when entered.
I figured out that using SHA-512 encoding, they encode password+salt.
I tried simple example and got the same password.

When the registered user tries to login using username and password, I want to retreve SALT value from OpenMRS DB using REST API. But my Json object does not have Salt value.
How to retrieve Salt value using REST API (/ws/rest/v1/user)?


~ Jitendra

John Stoecker

unread,
Jul 4, 2014, 12:09:25 AM7/4/14
to raxa-jss-em...@googlegroups.com

There isn't a way to get salt over rest in openmrs. Instead just see if you get a 200 or 201 response from a /session call to authenticate users.

Also check the password and security documentation in openmrs wiki to get more info about salt.

To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.

Jitendra Singh Bhati

unread,
Jul 4, 2014, 12:45:53 AM7/4/14
to raxa-jss-em...@googlegroups.com
Thanks John.

Jitendra Singh Bhati

unread,
Jul 4, 2014, 8:34:25 AM7/4/14
to raxa-jss-em...@googlegroups.com
Hello John,

I am trying to retrieve all the OBS records of patient id =7 through REST API.
Below is the URL: localhost:8080/openmrs/ws/rest/v1/obs?personId=7 But this url is giving empty result.
Is it the correct way to retrieve values from OpenMRS through REST API?


~ Jitendra

Jitendra Singh Bhati

unread,
Jul 4, 2014, 8:46:49 AM7/4/14
to raxa-jss-em...@googlegroups.com
Hi all,

I am trying to insert DrugOrder with the help of Post request to webservice.

JSON Object:
{"patient":"3d9c8b7d-15c8-4cba-8985-2e1e2a6e2ca6","concept":"8569217d-fb4e-11e3-abba-570f47353569","drug":"131168f4-15f5-102d-96e4-000c29c2a5d7"}

 All the uuids in the above query are present in patient,concept and drug tables.
 
Exception:
 
 log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.BasicClientConnectionManager).
log4j:WARN Please initialize the log4j system properly.
java.lang.RuntimeException: Failed : HTTP error code in post: 500
at ApiAuthRest.getRequestPost(ApiAuthRest.java:50)
at DrugOrder.main(DrugOrder.java:32)
I did check the server logs but I could find the following statement in logs 
127.0.0.1 - - [04/Jul/2014:17:59:04 +0530] "POST /openmrs/ws/rest/v1/order HTTP/1.1" 500 6941

Please help me resolve the issue


~Jitendra

Surajit Nundy

unread,
Jul 4, 2014, 9:06:03 AM7/4/14
to raxa-jss-em...@googlegroups.com
Hi:

This is a group specific to the Raxa project (www.raxa.org). Please post these OpenMRS queries on the OpenMRS dev group, you will have more luck.

Thanks,
Surajit
> To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Raxa JSS EMR Developers" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/raxa-jss-emr-developers/5uBLet2Wqlk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to raxa-jss-emr-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Regards,
> Jitendra
>
> --
> You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups "Raxa JSS EMR Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to raxa-jss-emr-deve...@googlegroups.com.

Daniel Pepper

unread,
Jul 4, 2014, 9:10:39 AM7/4/14
to raxa-jss-em...@googlegroups.com
:) Thank you
Reply all
Reply to author
Forward
0 new messages