New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.getResource() not populated for references parsed out of json DSTU2 bundle #143

Closed
nrpeterson opened this Issue Apr 1, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@nrpeterson
Contributor

nrpeterson commented Apr 1, 2015

I am receiving a DSTU2 bundle resource in JSON format. Using the 1.0-SNAPSHOT build, I make a FhirContext, instantiate a JsonParser, and parse the bundle with jsonParser.parseResource(...).

The bundle contains a Medication resource, and a MedicationPrescription resource that references it. On the Medication, I see

"id":"71cc85b0-368d-471f-a234-398ea938f553",

and on the MedicationPrescription

"medication":{
    "reference":"Medication/71cc85b0-368d-471f-a234-398ea938f553"
}

But, doing medScrip.getMedication().getResource() yields a null. Are the DSTU2 bundles able to create these links? The documentation implies this is possible for bundles, but I wasn't sure if that referred to DSTU1 bundles instead.

Thank you!

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Apr 2, 2015

Hi @nrpeterson - Would you be able to provide a sample bundle that exhibits this issue?

We do have one unit test that seems to show that what you're describing works correctly- The bundle is found here: https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-structures-dstu2/src/test/resources/bundle-example.json
..and the unit test can be found in the method testParseAndEncodeBundle here: https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java#L472

I'm guessing there's some nuance to your case that isn't being recreated in this bundle.

@nrpeterson

This comment has been minimized.

Contributor

nrpeterson commented Apr 3, 2015

Hey, @jamesagnew - thanks for your response.

It seems to be a difference of method here. I was concerned that the jsonParser.parseBundle method returned ca.uhn.fhir.model.api.Bundle instead of ca.uhn.fhir.model.dstu2.Bundle, and so I was using jsonParser.parseResource instead. When I switch it to parseBundle (and switch out bundle.getEntry() for bundle.getEntries(), it definitely works as expected.

This will definitely serve my purpose. Thank you!

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Apr 3, 2015

Aha! You are right, when I switch to using the new bundle style I see it too. Thanks for figuring out what I was missing! :)

Solution should be coming up shortly.

@nrpeterson

This comment has been minimized.

Contributor

nrpeterson commented Apr 3, 2015

:-) Awesome. Thank you so much! All of your work is greatly appreciated, sir.

@jamesagnew jamesagnew closed this in 461fdb5 Apr 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment