Rest API for Provider Scheduling: Calculate Time Slot

Hello, How do I get time slot in appointmentBlockList (Provider Scheduling).

This is the url I am using to get provider scheduling.


Response JSON is missing Time Slot properties. It is sending bellow properties: private Date startDate; private Date endDate; private Provider provider; private Location location; private Set types;

Did you mean to use the “appointment” resource? That is what will have a time slot.

Can’t you trivially calculate the time slot just by doing end time minus start time?

You might also look at the appointmentblockwithtimeslot resource. I don’t know anything about this, but the java code behind it is here:

Hi @dkayiwa, I think it is appointmentblock resource. Time slot property is missing in creating block too.

@dkayiwa It seems like appointmentblockwithtimeslot is discontinued. It is not in documentation here: /openmrs/module/webservices/rest/apiDocs.htm

I found appointment block with time slot only in advanced administration, here: /openmrs/module/appointmentscheduling/appointmentBlockCalendar.list

and appointment block without time slot in here:

@jaks80 I suggest that you use your browser’s javascript console to inspect the REST calls being made from the current code. If those calls aren’t returning a time slot length, then maybe it’s being calculated from the start and end date.

One other thing: in the Appointment Scheduling module, appointment block and time slot are not the same thing. You can have multiple TimeSlot in one AppointmentBlock. I assume this is documented somewhere, at the very least in the design notes for when this module was built. I suggest you look for that documentation and make sure you’re doing the right thing, as the module expects it.

Hi @darius, Thank you for brief information. For Appointment scheduling with time slot this page is not using any rest api:


But This page is using rest api http://localhost:8080/openmrs/appointmentschedulingui/ It is using this rest url:


Both URL books provider schedule only difference is:

First URL books between date range and allow to split this range in Provider time slot(60 Minutes slot etc) and appointments for multiple patients can be booked in this time slot . Second one books only for one day and whole day is one Provider itime slot.

I am taking second approach as this is the only rest based service. That is why I was thinking first approach may have been deprecated. Regards

Have you find any solution for this how to create appointment time slot.I am facing the same issue.

Hi Naveed, I did not find a direct rest URL to create block appointment with time slot. There is another way to create provider schedule. I am using: http://localhost:8080/openmrs/ws/rest/v1/appointmentscheduling/appointmentblockwithtimeslot?v=full

	"location": "aff27d58-a15c-49a6-9beb-d30dcfc0c66e",
	"startDate": "2017-08-31T09:00:00.000+0100",
	"endDate": "2017-08-31T17:00:00.000+0100",
	"provider": "f4d6a64f-d996-4367-aa90-559c10db9b91",
	"types": [{
			"uuid": "7dd9ac8e-c436-11e4-a470-82b0ea87e2d8"

This JOSN creates a day long time slot. If you want hourly time slot just change time in startDate and endDate.

Thanks for your reply.Jaks it’s created the appointment block with time slot but not what we required.Actually we want that in one appointment block we have several appointment slots. For example if we have an appointment block between { //other inputs are assumed startDate:2017-08-24T12:00:00.000+0500, endDate:2017-08-25T12:00:00.000+0500 } what it does it just created one time slot from 12:00:00 to 12:00:00 but actually we want that between these Dates we want many timeslots of 20 minutes…For example if we want a timeslot of 20 minutes it will provider us startDate-EndDate/20=10 just for example So,we will have 10 timeslot between these dates of 20minutes.That what openmrs does on Demo application But I think this is not possible through Rest API?

Another problem with your solution is that,I am not able to create appointment with appoinmentblockwithtimeslot uuid.It’s say timeslot is empty.

Hi, Naveed, You are correct. I did not find it using rest api. The example I have shown in an work around I am using. I did not find any documentation how appointment scheduling suppose to work. If any one has any link of documentation pass it here please.

regards Yusuf

1 Like

Unfortunately, it’s not up-to-date, but there’s a youtube video here:

It uses the old user interface, but it explains the relationship between appointments, appointment blocks, and timeslots, and I believe that information is still fairly accurate.

Take care, Mark

I think there is an algorithm behind the scence that schedule the appointment slot.In rest API that’s why it’s not available for us.

After watching the video related to appointment Module.Things clear to me but problem remain unsolved. There are three main things in appointment Module. 1.Appointment Block (A provider scheduled block created between start and End Date) 2.Time Slot (A time slot length that will be created inside the Appointment Block for example 60) 3.duration(duration of appointment type for example neurology duration is 20) In appointment module actually happen is that duration is an input to scheduled algorithm on the basis of duration that many appointment is created in one slot.For example if we have a slot of 60minutes then there will be three appointment type of neurology (20minutes).If we try to created 4th one it’s not gonna create for us.But through API this is not working It seems scheduled algorithm is not working properly with Rest API?

Hi darius! I think it’s not calculated from start date minus date.There is an algorithm behind the scene which take duration as input and create that many appointment in any given slot.Does Rest API support the schedule algorithm or it does not?

Block booking slot does not save slots in database. What it does is breaks down dateFrom and dateTo and save it as multiple slots. For example: { startDate:2017-08-24T09:00:00.000 endDate:2017-08-25T17:00:00.000 } and If you specify 60 minute slot than backend will create 8 block appointments.

Yes thanks you are right.But when I try to used that slot for appointment it does not work.It show’s error that empty.timeslot.But it worked fine with interface. For example during appointment I pass these objects {

“appointmentType”: “3ebab8cb-5d67-49d2-830d-f979e30a61f4”, “timeSlot”: “6c3afe83-ce18-4a8f-be58-afebd5e00a7e”, “patient”: “dd662071-1691-11df-97a5-7038c432aabf”, “status”: “SCHEDULED” } It show this Error that timeslot.empty

Note I am providing timeslot uuid which I created from this JSON resouce http://localhost:8080/openmrs/ws/rest/v1/appointmentscheduling/appointmentblockwithtimeslot?v=full1

{ “location”: “aff27d58-a15c-49a6-9beb-d30dcfc0c66e”, “startDate”: “2017-08-31T09:00:00.000+0100”, “endDate”: “2017-08-31T17:00:00.000+0100”, “provider”: “f4d6a64f-d996-4367-aa90-559c10db9b91”, “types”: [{ “uuid”: “7dd9ac8e-c436-11e4-a470-82b0ea87e2d8” } ] }

> One thing more you said If you specify 60minute than backend will create 8 block appointments. My query is where I can specify timeslot in appointmentblock.I there is not supported property for timeslot while creating appointmentblockwithtimeslot.

This is the JSON working for me: { “timeSlot”: “ef467379-fd83-4c4e-b283-53fb90a75212”, “patient”: “1e9caea5-d31e-4436-80ec-2b10b88a5739”, “status”: “SCHEDULED”, “reason”: “”, “appointmentType”: “4da187c6-c436-11e4-a470-82b0ea87e2d8” } Change appointmentType json structure.

As we have been discussing there is no restAPI to specify time slot. I was talking about this URL: openmrs/module/appointmentscheduling/appointmentBlockForm.form?redirectedFrom=appointmentBlockList.list