sotn
sotn

Reputation: 2101

HAPI FHIR custom search response

I am building a restful FHIR search API which requires a custom response. This is different from a custom resource. The API must return all Patients as follows:

{
   "Patients":[
          {
           "patientid": "pat1",
           "gender": "male",
           "birthDate": "1924-10-10",
           "deceasedBoolean": true
          },
         {
          "patientid": "pat2",
           "gender": "female",
           "birthDate": "1957-10-10",
           "deceasedBoolean": false
         }

]
}

So, thats an object with an array of objects. How can I return this instead of a Bundle?

Upvotes: 0

Views: 445

Answers (1)

Lloyd McKenzie
Lloyd McKenzie

Reputation: 6793

If you return that, you don't have a FHIR API. You have a custom API. FHIR defines what the results of a search look like. If you don't align with those requirements, you're not conformant with the standard.

The whole point of a standard API like FHIR is that search results look the same regardless of what system is returning them - so that clients only have to be coded to a single interface instead of a distinct interface for every server.

The data you're trying to expose could be exposed as a proper searchset response Bundle containing valid FHIR-formatted resources. If you do that, you would be conformant and able to claim that you've implemented FHIR.

However, if you insist on exposing your data in the format you've described above, you will not be able to claim FHIR conformance and no FHIR-conformant clients or libraries will work with your system without customization. (And unless you have regulatory power or significant money to spend, the odds of clients performing such customization is pretty slim.)

Upvotes: 3

Related Questions