-
Notifications
You must be signed in to change notification settings - Fork 61
FHIR Client API Design Ideas
A lot of our current code centers around the idea of fetching data about a particular patient. Our FHIR-request wrapping code has encapsulated this nicely already, and as we're looking at using fhir_client
, we're realizing it doesn't support most of this.
For example, what if we want to get all observations related to a patient from the past week? Currently, with fhir_client
, we might have to do something like this:
patient_response = client.read(FHIR::Patient, fhir_patient_id)
patient = patient_response.resource
observation_response = client.search(FHIR::Observation, search: {
parameters: {
patient: patient.id,
date: ">#{1.week.ago.to_date}"
}
})
observations = observation_response.resource.entry.map(&:resource)
However, following the pattern of libraries like ActiveRecord, it would be nice to be able to do something like this:
patient = client.find(FHIR::Patient, fhir_patient_id)
observations = patient.observations(date: ">#{1.week.ago.to_date}")
Where the FHIR::Patient
instance could remember the client it was fetched from, and could also be aware of associations and use that client to fetch them.
Or -- we could take the ActiveRecord analogy further, and do something like this:
FHIR::Base.client = client
patient = FHIR::Patient.find(fhir_patient_id)
observations = patient.observations(date: ">#{1.week.ago.to_date}")
conditions = patient.conditions
- Getting Started
- Configuration
-
Searching
- History
- CRUD
- Transactions
- Validation
-
Operations
$everything
$validate