How to create custom REST API on hapi fhir

Hi,

I’m currently working on hapi fhir using eclipse IDE. and I want to add in my own REST APIs.
I would like to ask where should I place the REST API that I will be making? I wanted it to coexist with the /create, /update etc. that hapi fhir is using for the JSON files.

Thank you in advance for the help!

1 Like

Can you explain what you mean by “your own REST APIs”? Are you talking about FHIR-conformant custom operations or something completely outside the FHIR spec? (Note that FHIR doesn’t use /create or /update in its URL conventions.)

1 Like

Hi Sir Lloyd,

I was thinking of making a separate API that has it’s own JSON format that saves the data it gets to a database. I was under the impression that the /create, /update etc in the Controller.Java in the hapi fhir main library are APIs.

@Edward_Pimentel I think this is difficult but keep on you will get solution of your problem of IDE. :slightly_smiling_face:

If you’re defining custom JSON, then you’re outside the FHIR standard and outside what HAPI is set up to support directly. You’re of course free to create whatever APIs you like, but you can’t call them “FHIR” unless they use the FHIR syntax (and you can’t call them RESTful FHIR unless they use the FHIR URI syntax).

Ok but if I’m going to add custom API to the hapi fhir. where do you recommend I start?

The same place you’d start writing a custom API? You might be able to leverage a tiny bit of HAPI’s code, but most of it will be custom. I guess part of the question is - why do you want to use HAPI to write a custom API?

Hi,

This is for getting a summary of the identifiers of the records being submitted.

If you’re submitting a batch or transaction, you’ll already get the identifiers back

Also is it possible to make changes on the JSON format that hapi fhir is using?

Not if you want your system to be FHIR conformant. (And if you don’t, it’s not clear why you’d be using HAPI…)