Drug Order Entry

Hi all I am working on a feature on AMPATH Point Of Care to allow a clinician to prescribe drugs to a patient. I’m using the order entry API. I tried to submit a drug order and I got some errors:

So this is the payload I am trying to submit

    {
      "patient": "eec087c0-8d33-4381-944a-1f8889be2872",
      "concept": "a890c3aa-1350-11df-a1f1-0026b9348838",
      "careSetting": "6f0c9a92-6f24-11e3-af88-005056821db0",
      "orderer": "pb6e58ea-1359-11df-a1f1-0026b9348838",
      "encounter": "ff277dc1-832a-46e8-b9e2-ed1feb13c78c",
      "drug": "b41c22a2-2496-4588-93e4-435ac5896156",
      "dose": "2",
      "doseUnits": "a8a07f8e-1350-11df-a1f1-0026b9348838",
      "route": "db0c5937-3874-4eae-9566-9a645ad7ac65",
      "frequency": "a8a05dc4-1350-11df-a1f1-0026b9348838",
      "duration": 7,
      "durationUnits": "a899baaa-1350-11df-a1f1-0026b9348838",
      "asNeeded": false,
      "numRefills": 3,
      "type": "drugorder",
      "action": "NEW"
    }

And the response I get is:

{
    "error": {
        "message": "Invalid Submission",
        "code": "webservices.rest.error.invalid.submission",
        "globalErrors": [],
        "fieldErrors": {
            "frequency": [
                {
                    "code": "DrugOrder.error.frequencyIsNullForDosingTypeSimple",
                    "message": "Frequency is required for simple dosing type"
                }
            ],
            "durationUnits": [
                {
                    "code": "DrugOrder.error.durationUnitsNotMappedToSnomedCtDurationCode",
                    "message": "Duration units must be mapped to SNOMED CT duration code with the map type set to SAME-AS"
                },
                {
                    "code": "DrugOrder.error.notAmongAllowedConcepts",
                    "message": "The units concept must be among allowed concepts"
                },
                {
                    "code": "DrugOrder.error.durationUnitsNotMappedToSnomedCtDurationCode",
                    "message": "Duration units must be mapped to SNOMED CT duration code with the map type set to SAME-AS"
                }
            ],
            "doseUnits": [
                {
                    "code": "DrugOrder.error.notAmongAllowedConcepts",
                    "message": "The units concept must be among allowed concepts"
                }
            ],
            "route": [
                {
                    "code": "DrugOrder.error.routeNotAmongAllowedConcepts",
                    "message": "The route concept must be among allowed concepts as specified by the order.drugRoutesConceptUuid global property"
                }
            ]
        }
    }
}

We are using OpenMRS version 1.11.

I will be grateful if someone could take a look at it and tell me what the problem could be. Thanks in advance.

It also helps to mention the version of the rest module that you are using.

We are using Rest WS 2.17.1cd94b

Thanks.

I would try to see what happens when using the latest release of the rest webservices module.

Thanks Daniel. We upgraded to 2.19.0.f2b4a2 and still got the exact same error response.

Which exact rest url are you posting to?

This is the link https://test2.ampath.or.ke:8443/amrs/ws/rest/v1/order

In the order_frequency table, do you have a frequency with this uuid? a8a05dc4-1350-11df-a1f1-0026b9348838

It represents ONCE A DAY

Can i look at the values in the various fields for this row?

{
"uuid": "a8a05dc4-1350-11df-a1f1-0026b9348838",
"display": "ONCE A DAY",
"name": {
    "display": "ONCE A DAY",
    "uuid": "a9482248-1350-11df-a1f1-0026b9348838",
    "name": "ONCE A DAY",
    "locale": "en",
    "localePreferred": true,
    "conceptNameType": "FULLY_SPECIFIED",
    "links": [
        {
            "rel": "self",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a9482248-1350-11df-a1f1-0026b9348838"
        },
        {
            "rel": "full",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a9482248-1350-11df-a1f1-0026b9348838?v=full"
        }
    ],
    "resourceVersion": "1.9"
},
"datatype": {
    "uuid": "8d4a4c94-c2cc-11de-8d13-0010c6dffd0f",
    "display": "N/A",
    "name": "N/A",
    "description": "Not associated with a datatype (e.g., term answers, sets)",
    "hl7Abbreviation": "ZZ",
    "retired": false,
    "links": [
        {
            "rel": "self",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptdatatype/8d4a4c94-c2cc-11de-8d13-0010c6dffd0f"
        },
        {
            "rel": "full",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptdatatype/8d4a4c94-c2cc-11de-8d13-0010c6dffd0f?v=full"
        }
    ],
    "resourceVersion": "1.8"
},
"conceptClass": {
    "uuid": "8d492774-c2cc-11de-8d13-0010c6dffd0f",
    "display": "Misc",
    "name": "Misc",
    "description": "Terms which don't fit other categories",
    "retired": false,
    "links": [
        {
            "rel": "self",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptclass/8d492774-c2cc-11de-8d13-0010c6dffd0f"
        },
        {
            "rel": "full",
            "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptclass/8d492774-c2cc-11de-8d13-0010c6dffd0f?v=full"
        }
    ],
    "resourceVersion": "1.8"
},
"set": false,
"version": "0.1",
"retired": false,
"names": [
    {
        "display": "ONCE A DAY",
        "uuid": "a9482248-1350-11df-a1f1-0026b9348838",
        "name": "ONCE A DAY",
        "locale": "en",
        "localePreferred": true,
        "conceptNameType": "FULLY_SPECIFIED",
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a9482248-1350-11df-a1f1-0026b9348838"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a9482248-1350-11df-a1f1-0026b9348838?v=full"
            }
        ],
        "resourceVersion": "1.9"
    },
    {
        "display": "OMNI DEI",
        "uuid": "a958b1e4-1350-11df-a1f1-0026b9348838",
        "name": "OMNI DEI",
        "locale": "en",
        "localePreferred": false,
        "conceptNameType": null,
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a958b1e4-1350-11df-a1f1-0026b9348838"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a958b1e4-1350-11df-a1f1-0026b9348838?v=full"
            }
        ],
        "resourceVersion": "1.9"
    },
    {
        "display": "DAILY",
        "uuid": "dfc7c47a-c99d-4265-8b30-baa095b1c2f2",
        "name": "DAILY",
        "locale": "en",
        "localePreferred": false,
        "conceptNameType": null,
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/dfc7c47a-c99d-4265-8b30-baa095b1c2f2"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/dfc7c47a-c99d-4265-8b30-baa095b1c2f2?v=full"
            }
        ],
        "resourceVersion": "1.9"
    },
    {
        "display": "OD",
        "uuid": "a958b040-1350-11df-a1f1-0026b9348838",
        "name": "OD",
        "locale": "en",
        "localePreferred": false,
        "conceptNameType": null,
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a958b040-1350-11df-a1f1-0026b9348838"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/name/a958b040-1350-11df-a1f1-0026b9348838?v=full"
            }
        ],
        "resourceVersion": "1.9"
    }
],
"descriptions": [
    {
        "display": "General description of frequency:  once times a day.",
        "uuid": "a9044140-1350-11df-a1f1-0026b9348838",
        "description": "General description of frequency:  once times a day.",
        "locale": "en",
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/description/a9044140-1350-11df-a1f1-0026b9348838"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/description/a9044140-1350-11df-a1f1-0026b9348838?v=full"
            }
        ],
        "resourceVersion": "1.9"
    }
],
"mappings": [
    {
        "display": "local: 1891",
        "uuid": "6706cc3c-b226-4c4d-b3ba-25b30383190e",
        "conceptReferenceTerm": {
            "uuid": "5c3d59c4-92fc-3055-bca8-51831fdb4368",
            "display": "local: 1891",
            "links": [
                {
                    "rel": "self",
                    "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptreferenceterm/5c3d59c4-92fc-3055-bca8-51831fdb4368"
                }
            ]
        },
        "conceptMapType": {
            "uuid": "43ac5109-7d8c-11e1-909d-c80aa9edcf4e",
            "display": "NARROWER-THAN",
            "links": [
                {
                    "rel": "self",
                    "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/conceptmaptype/43ac5109-7d8c-11e1-909d-c80aa9edcf4e"
                }
            ]
        },
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/mapping/6706cc3c-b226-4c4d-b3ba-25b30383190e"
            },
            {
                "rel": "full",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838/mapping/6706cc3c-b226-4c4d-b3ba-25b30383190e?v=full"
            }
        ],
        "resourceVersion": "1.9"
    }
],
"answers": [],
"setMembers": [],
"auditInfo": {
    "creator": {
        "uuid": "5a9d0c72-13a9-11df-a1f1-0026b9348838",
        "display": "username-305",
        "links": [
            {
                "rel": "self",
                "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/user/5a9d0c72-13a9-11df-a1f1-0026b9348838"
            }
        ]
    },
    "dateCreated": "2008-04-04T10:57:09.000+0300",
    "changedBy": null,
    "dateChanged": null
},
"links": [
    {
        "rel": "self",
        "uri": "https://amrs.ampath.or.ke:8443/amrs/ws/rest/v1/concept/a8a05dc4-1350-11df-a1f1-0026b9348838"
    }
],
"resourceVersion": "1.11"

}

Can you paste the contents of the tomcat log at pastebin.com?

Are you able to get me just that section of the log which gets added when you make the rest call?

You need to share the logs appended after you attempt the post, as @dkayiwa said make sure you have an order frequency with a matching uuid. By the way, you don’t have to set orderer.

We have been tailing the longs on the api request. Nothing is showing up in catalina.out with regards to the request or the error generated. We tailed localhost_access_log which DOES record the api request.

Other advice?

At a glance it seems like you are submitting the concept uuid instead of the uuid of the order_frequency.

I believe that if you have configured things correctly then the orderentryconfig resource will give you back all the legally-configured options.

Thanks @darius. When I hit this endpoint, I get back: { “drugRoutes”: [], “drugDosingUnits”: [], “drugDispensingUnits”: [], “durationUnits”: [], “testSpecimenSources”: [], “orderFrequencies”: [] }

How and what exactly do we add to populate these?

This is documented (not well) here: https://wiki.openmrs.org/x/AAGSB#PlatformReleaseNotes1.10.0-RequiredconfigurationsfortheneworderentryAPI

You can also look at the CIEL concept dictionary for examples of how concepts are configured, e.g. units having a mapping to SNOMED CT.

We need to document this better, as a child of this wiki page.

Can you see if this current documentation gets you pointed in the right direction, and then create a proper wiki page for it?

Actually, I created a new wiki page of documentation here (quickly, in the background, while on a call): https://wiki.openmrs.org/display/docs/Configuring+Order+Entry

Please edit this to make it clearer as you go through the configuration process!