--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/c5fa7344-3a14-4929-8fb9-1fdcc4cbfe30%40googlegroups.com.
Hi Rob,For lists of resources, having your FHIR service return a "plain JSON list" isn't really a FHIR way of doing it, but there are a few acceptable ways of doing do. You can certainly return a bundle, and that's how most FHIR operations work. For something like a current allergy list, you're probably actually looking for the List resource.There's some discussion here: http://hl7-fhir.github.io/lifecycle.html#current and some examples of this here: http://hl7-fhir.github.io/list-examples.htmlWe don't currently have any examples on the site of how to implement this particular pattern (contributions welcome of course :) ) but it could be done as a standard search method in HAPI server like any other.Cheers,James
On Tue, Oct 11, 2016 at 3:06 PM, <resend...@gmail.com> wrote:
After posting this I realized dstu3.model.Bundle i just an IBaseResource, so the "String encodeResourceToString(IBaseResource ibr)" signature should work fine. I'm still not totally sure whether it is correct to return a Bundle object or a simple JSON array. The SMART on FHIR endpoints seem to return bundle objects, as do the hapi demo endpoints.
On Tuesday, October 11, 2016 at 1:51:27 PM UTC-5, resend...@gmail.com wrote:I've produced a list of entries, List<AllergyIntolerance> allergyList. I was wanting to serialize them as json array eg: [ {a1}, {a2}, ... ]With the goal of having an endpoint that returns a list of allergies for a given patient. My initial approach was something like "gson.toJson(allergyList)".. but the output was really noisy.
I found that I should be using FhirContext.forDstu3().newJsonParser().I'm having trouble finding an ideal method signature to use. I see a signature for encoding a model.api.Bundle to String, but way to encode a dstu3.model.Bundle to String. I see that I can encode an IBaseResource to String, which is what I want to do; but, I have to loop through each item individually and append to my own StringBuilder (I couldn't find any obvious way to make model.api.Bundle objects accept entries that are IBaseResource implementors... only IResource implementors).
Thanks,Rob
--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.