Logic to Create New Drug Order

In order to create a new Drug Order for a Patient using rest api :

  1. How do I create Encounter (Or shall I fetch any existing encounter, @hariniparth is using an exisintg encouter type to create a new one line 338) https://github.com/HariniParth/OpenMRS-DrugOrders/blob/master/omod/src/main/java/org/openmrs/module/drugorders/page/controller/DrugordersPageController.java

  2. What will be encounter type for “Drug Order Encounter”.

  3. What will be the care settings

  4. What will be the provider.

  5. What will be the location. (Is it the location of logged in user?)

  6. Is date time “now”?

  7. Does back end checks patient allergic drugs or front end has to check it?

In general I would suggest that you create an encounter that contains drug orders in it.

Here is some JS code that does this, in case it helps: https://github.com/openmrs/openmrs-module-orderentryui/blob/eb3ce9076416ed74943fc2ca2706a7ae6a1edf31/omod/src/main/webapp/resources/scripts/order-entry.js#L214

Thank Darius. What will be encounter type. I have seen this list in production database. ‘Admission’ ‘Check In’ ‘Check Out’ ‘Discharge’ ‘Transfer’ ‘Visit Note’ ‘Vitals’

Or should I create encounter type “drug order”

Yes I suggest creating a new encounter type called “Drug Order”

My assumption is that in a real world setting there would naturally be some sort of encounter that occurred where an orderable was ordered by a health provider, so you wouldn’t have to figure out the encounter and its type. If you are just setting up test data, then you can use any encounter of your choice.

How do I Obtain CareSettings when I place a new Drug Order.

Via the Java API:

Context.getOrderService().getCareSettingByName("Outpatient"); //Fetch Outpatient care setting
Context.getOrderService().getCareSettingByName("Inpatient"); //Fetch Inpatient care setting

Via the rest API:

GET .../ws/rest/v1/caresetting/Outpatient    //Fetch Outpatient care setting
GET .../ws/rest/v1/caresetting/Inpatient   //Fetch Inpatient care setting

Of course you could use the uuids in place of the names of the care settings

Hi Wyclif Thank you for the reply. But How do we determine from which area Drug is being ordered out of those to available Care Settings. Or Shall I put a drop down for the user to select.

That is an implementation detail, as a developer you might not know in which setting the order was placed but the user will always do, therefore in your user interface you can prompt the user to select the appropriate one from the two.

Thank you Wyclif. I have got the answer.

Where we are calculating this line for Drug Order: @darius “display”: “(NEW) Ibuprofen 400 MG Oral Tablet: 1.0 Tablet Oral Four times daily 7 Days test dosing instructions”,