RESTful API error

This forum is for programmers who have questions about the source code.
Post Reply
bravegag
Posts: 49
Joined: Fri May 24, 2019 3:37 pm

RESTful API error

Post by bravegag » Wed Jun 05, 2019 3:31 pm

Hello,

I got a developer's key and I think I have everything setup to develop on top of the FHIR RESTful API. I'm new to using OpenDental (OD) and to the FHIR model. I'm using this doc as reference: https://www.opendental.com/resources/Op ... -1Spec.pdf

My code is written in Scala so I do as described in that doc:

Code: Select all

//val url = "https://api.opendental.com/fhir/organization?name=Relaxation%20Dental"
val url = "https://api.opendental.com/fhir/capabilitystatement"

val fhirRequest: WSRequest = ws.url(url)
  .withHttpHeaders(
     "Content-Type" -> "application/json",
     "Authorization" -> "FHIRAPIKey=%s".format(config.get[String]("fhir.api.key")),
     "Accept" -> "application/json"
  )
  .withRequestTimeout(10000.millis)

val futureResponse = fhirRequest.get()
futureResponse.map { response => 
  Ok(response.json)
}
This request seems correct, for example, if I remove the key then the FHIR RESTful API test server will complain that the authorization key is invalid etc.

For every valid request I get back the following:

Code: Select all

{"issue":[{"severity":"error","code":"exception","details":{"text":"The server has encountered an error."}}]}
Is this an issue on the test server or am I doing something wrong? maybe some misconfiguration in my test OD installation?

TIA,
Best regards,
Giovanni

bravegag
Posts: 49
Joined: Fri May 24, 2019 3:37 pm

Re: RESTful API error

Post by bravegag » Wed Jun 05, 2019 3:32 pm

Ah and btw is this "Relaxation Dental" the default demo database organization name? I found this clinic name somewhere in the OD coming from the demo DB.

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: RESTful API error

Post by cmcgehee » Wed Jun 05, 2019 3:46 pm

Giovanni,

I think I've found your account, and it looks like you're on version 18.3 of Open Dental. To access the API via https://api.opendental.com/ you need to be on at least 18.4. We added some new resources in 19.1 so if you have a test database, you might want to update to that version.

I think "Relaxation Dental" is the practice name in the database that comes bundled with the trial installer of Open Dental.
Chris McGehee
Open Dental Software
http://www.opendental.com

bravegag
Posts: 49
Joined: Fri May 24, 2019 3:37 pm

Re: RESTful API error

Post by bravegag » Thu Jun 06, 2019 2:27 am

Hi Chris,

Thank you for your help, makes sense and it works now after upgrading to 18.4.51.0. I was on 18.3.x to match the exact same version as the dental practice I'm working with I guess we'll trigger a OD software update on the practice side too.

Is there a way to automatically find the practice associated with an API key or do we need to know this. The idea would be to avoid hardcoding this info in an application but rather get it from the DB.

Best regards,
Giovanni

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: RESTful API error

Post by cmcgehee » Thu Jun 06, 2019 8:13 am

Yes, you can find that in the capability statement: https://api.opendental.com/fhir/capabilitystatement. There is a software.version field that will tell you the version of Open Dental. This capability statement will tell you information specific for the office linked to the API key you include.
Chris McGehee
Open Dental Software
http://www.opendental.com

bravegag
Posts: 49
Joined: Fri May 24, 2019 3:37 pm

Re: RESTful API error

Post by bravegag » Thu Jun 06, 2019 10:29 am

Hi Chris,

Thanks again! could you please point me to a doc or samples on how to interpret the capability statement? I reviewed the documentation under https://www.hl7.org/fhir/capabilitystatement.html but it is a bit dry and I still don't get how to make a request for the described capabilities. A wild guess from what I understood from the capability statement JSON is that I can query the practice name by doing something like (I haven't tried these):

Code: Select all

https://api.opendental.com/fhir/read/location/name
or

Code: Select all

https://api.opendental.com/fhir/location/name/read
TIA,
Best regards,
Giovanni

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: RESTful API error

Post by cmcgehee » Thu Jun 06, 2019 10:53 am

The link you mentioned is the best documentation I know of for the capability statement. If you're looking for the practice name, use:

Code: Select all

https://api.opendental.com/fhir/organization/0
We've decided to represent clinics as Organization resources and we represent the practice as an Organization with an id of 0.
Chris McGehee
Open Dental Software
http://www.opendental.com

Post Reply