Online Booking API - creat booking response

OpenBookingAPI/resource_BookingService.html#resource_BookingService_create_POST

The api reports that this returns the reference number as a json object.  I assume that means we end up with :- 

{reference:12345}

 

The api page is actually incorrect in this case as it reports: 

Response
 
HTTP/1.1 201 Created
Content-Type: application/json
...
 
ie there is no reported body. although they api states it returns a JSONOBJECT.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Online Booking API - creat booking response

The content type is incorrect. It should be text/plain.

It will return a string like: 921:dcfde1f4-d336-11e7-8830-4fcefa1c2d1c

Re: Online Booking API - creat booking response

By that you mean the Return type is a String?

...and if so is that string the booking reference?  the example you posted has a colon in it which seems odd for a GUID or reference

 

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

So we should update our submitted headers to be :

 

Accept: text/plain
Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

Yes, the returned string is the booking reference. The content of the string doesn't really matter from a client perspective, and the format could change over time. You just need to submit it when retrieving or cancelling bookings.

Re: Online Booking API - creat booking response

Yes I think there is actually a bug here...when you submit the booking post if you include the header 

Accept: plain/text

 

then you will get automatic failure as the interface specifies:

```

@Path("bookings")
public interface BookingService {

    /**
     * Creates a new appointment from a booking request.
     *
     * @param booking the booking
     * @return the appointment reference
     */
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    Response create(Booking booking, @Context UriInfo uriInfo);```

 

 

soo we have to use 

```accept: application/json```

however you have stated it returns `plain/text`

The real issue comes in handling the response...because if I do something like :

$response = $this->decode($output,$info['content_type'],$asArray);

as you can see the response would be null ...because I the returned header will tell me its actually application/json not plain/text... but it wont decode as json and hence will be null.

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

Finally it might be wise to add an option to disable anonymous bookings ...ie those that dont resolve to a known customer...

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

Anonymous bookings are required as external services don't have access to the customer or patient list. If a customer is new, or their details have changed, they should still be able to make an appointment.

Re: Online Booking API - creat booking response

I disagree - it would be quite easy to have a feature that just declines an appointment if the system could not match to an existing client.  I am not suggesting anonymous shouldnt be possible just that it should be configurable

I wouldnt want my book filled with random appointments from people who are not clients.  Obviously the front end can reduced spam etc using captcha tech and the like but I would suggest that the api should have some sort of safegaurd as well

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

The API is designed to allow new customers to make appointments, as well as existing customers whose details may have changed.

If you reject making an appointment after they have entered all their details, it will probably just annoy people.

If you want to restrict it to existing customers with valid data, you could:

1. create a customer portal that only allows appointments for registered customers

2. perform validation yourself by querying the database for the supplied customer details

Re: Online Booking API - creat booking response

Yes, its a bug. It should be @Produces(MediaType.TEXT_PLAIN)

Can you not just use $output directly?

 

Re: Online Booking API - creat booking response

Of course, however  given I have written an library that handles all the endpoints using generic decoding function that accept the content type as a parameter...it makes it hard when you return an incorrect type from an endpoint

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

Also additionally I just wonder if its possible to have an endpoint that returns the version of the rest interface (currently v1) to make sure any external interface is up to date.

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: benjicharlton[at]gmail[dot]com

Re: Online Booking API - creat booking response

The version is encoded in the URL. If new features need to be added that would break existing clients, a new version URL will be used, but the original version will continue to be supported.

Syndicate content