Allergies using REST api

Hi All

I created some allergies via GUI and I tried to fetch allergies for given patient using REST api Unfortunately only 2 links below that discuss the problem were not enough to figure out the way to do for my version of the code 1.11 without downloading java source. Most probably i will but can someone just maybe exceptionally say how to use patient parameter instead of q parameter for the research of allergies ?

Thank you for advance

In fact the problem of the links in the first referenced post that AFAICS they do not point anywhere at present alas :frowning:

@abtimo can you first log on http://uat01.openmrs.org:8080/openmrs and then try the link again?

thank you very much for helping again

The two bespoken links that are pointing nowhere are :

Hi Arpit,

If you are running OpenMRS 2.x, then you are probably running into what I describe here about allergies: https://wiki.openmrs.org/questions/81920160/answers/8192016410

Hi Arpit,

Unfortunately the documentation of how to search on different resources is non-existent. See this post for how you can explore the code and find out what is supported without too much pain: https://wiki.openmrs.org/questions/80380259/answers/8038026213

Peeking quickly, both the problem and allergy resources expect a “patient” parameter, not a “q” parameter.


http://uat01.openmrs.org:8080/openmrs/ws/rest/v1/patient/c9c4e654-243e-47f1-8378-abab1b4326e3/allergy works, indeed

The version of http://uat01.openmrs.org:8080/openmrs is Version: 2.0.0 SNAPSHOT Build e2e473 and mine is Version: 1.11.6 Build 9f4e17

http:///openmrs/ws/rest/v1/patient//allergy

gives me

Unknown resource: v1/patient/allergy org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl:415 org.openmrs.api.APIException: Unknown resource: v1/patient/allergy at org.openmrs.module.webservices.rest.web.api.impl.RestServiceImpl.getResourceByName(RestServiceImpl.java:415)

we do not require very advanced allergy handling at present, i wanted just to retrieve the basic allergy for the patient information captured in the ref app GUI by API is this necessary to migrate to v2.0.0 ?

http://myhost:myport>/openmrs/ws/rest/v1/patient/my-patient-uuid/allergy

my link hereabove

@abtimo for versions before platform 2.x, the url is different. It should be like: …/ws/rest/v1/allergy?patient=uuidOfPatient

Thanks it worked, but it shows only allergy captured in patient dashboard and not in the ref application patient page… Thank you anyway it helps a lot. Is there any chance to find a sample of drug order in some uat environment just to retrieve and to see it’s structure ? I am getting the error messages that are probably because of naive input :

/openmrs/ws/rest/v1/order

‘{ “patient”: “efaab948-b3fa-4553-9c84-81594c91617e”, // patient uuid “type”: “drugorder”, as per spec “concept”: “71617AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA”, aspirine concept “encounter”: “cf8b6e9d-fced-4a1b-82b9-de356679f6a2”, visit manually created “careSetting”: “6f0c9a92-6f24-11e3-af88-005056821db0”, Outpatient caresetting uid “drug”: “74322f5c-7881-44e4-a053-48258e685923”, Aspirine created by api “orderer”: “8f87f4ca-8f71-4ee3-a100-112c9945a937”, Provider uuid “dose”: “1”, “doseUnits”: “tablette”, “route”: “Oral” , “frequency”: “daily”, “quantity”: “3”, “numRefills”: “2” }’

Response Body

{ “error”: { “message”: “Invalid Submission”, “code”: “webservices.rest.error.invalid.submission”, “globalErrors”: [], “fieldErrors”: { “drug”: [ { “code”: “error.general”, “message”: “Error while submitting form” } ], “concept”: [ { “code”: “error.concept”, “message”: “Invalid concept” } ], “doseUnits”: [ { “code”: “DrugOrder.error.doseUnitsIsNullForDosingTypeSimple”, “message”: “Dose units is required for simple dosing type” }, { “code”: “DrugOrder.error.doseUnitsRequiredWithDose”, “message”: “Dose Units is required when dose is specified” } ], “route”: [ { “code”: “DrugOrder.error.routeIsNullForDosingTypeSimple”, “message”: “Route is required for simple dosing type” } ], “frequency”: [ { “code”: “DrugOrder.error.frequencyIsNullForDosingTypeSimple”, “message”: “Frequency is required for simple dosing type” } ], “quantityUnits”: [ { “code”: “DrugOrder.error.quantityUnitsRequiredWithQuantity”, “message”: “Quantity units is required when quantity is specified” } ] } } }

Additional question, i can not find in the cloned code from git the samples of REST API tests, i checked out openmrs-core module, is this enough ?

This is the module that you are looking for: https://github.com/openmrs/openmrs-module-webservices.rest For sample and structure, have you seen this? http://uat02.openmrs.org:8080/openmrs/module/webservices/rest/apiDocs.htm

very good, thanks for the 1 st url, the second one i use always, but the question is about right values for parameteres, can not figure out the values for doses etc. aparently

doseUnits should be a uuid for the units concept. Is this test helpful? https://github.com/openmrs/openmrs-module-webservices.rest/blob/96b9aefbebefcdb88cb74d49dd52322256f744f7/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/OrderController2_0Test.java#L98

Thank you this is helpful, that said i am unable to create any dose unit nor retrieve existing from my installation. Nor routes , frequency nor quantity units either. At least it’s not possible via REST api. this test is for v.2 It would be great to see the same test for the v11. Or what i want is impossible and i have to use Java Api ? Or maybe i gan find the module that will permit capturing all of this via GUI ?

How people using v1.11 create and order drugs ? Please help, if possible before migration to the v2+ if nothing helps. But i would really like to avoid it for now.

Or maybe i can query directly the database in order to find out the required uuids? :-/

See the URLs that this REST client uses.

Particularly, see the orderentryconfig resource.

I see that this resource is not documented in the REST API doc browser. @pascal (or others) do you know what we’d have to do to add it?

And more tests:

Thank you so Much Darius. Downloaded and built the module, now

/openmrs/ws/rest/v1/orderentryconfig?v=full

shows meaningful information for routes dosing units and duration units now i can enter prescriptions with free text instructions Alas it’s still impossible with standard dosing instruction because (only !!! )frequencies are missing amongs required pqrqmeters. How we are supposed to configure frequencies (the api aparently either shows or updates order frequency object no way to use creation… ) ? i thing as soon as we enter these values we are ok for api order creation as well.

Thanks but i have small troubles to use java classes like these. I can build the module with maven of course but it appears uneasy yet at present to create custom tool based on java API to create configuration objects which uuid i require for order creation. Still the values in the tests are very helpful to get the working sample at least

If you have the CIEL dictionary, the Order Entry UI module will create Order Frequencies for you based on concept 160855 (see code here).

Basically you need to populate the order_frequency table.