Full references from getId()

226 views
Skip to first unread message

Kevin Mayfield

unread,
Jul 19, 2016, 11:17:25 AM7/19/16
to HAPI FHIR
Have a bit of code that looks like this:

                                                Reference ref = new Reference();
Organization organisation = (Organization) bundle.getEntry().get(0).getResource();
ref.setReference("Organization/"+organisation.getId());
patient.setManagingOrganization(ref);

Originally this would create a reference like:

 <managingOrganization>
      <reference value="Organization/32859"/>
   </managingOrganization>

But now it's returning this (when converted to XML)

 <managingOrganization>
   </managingOrganization>

Is this new behaviour?? I'm still investigating but the getId() appears to return the correct resource Id, so I'd suspect it's something to do with setting the reference.

Server is not configured to use external references.

"issue": [
    {
      "severity": "error",
      "code": "processing",
      "diagnostics": "Resource contains external reference to URL \"Patient/http://localhost:8080/hapi-fhir-jpaserver/baseStu3/Patient/169333\" but this server is not configured to allow external references"
    }
  ]

Kevin Mayfield

unread,
Jul 19, 2016, 11:19:43 AM7/19/16
to HAPI FHIR
Code to convert to String (xml)

String Response = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);

Wonder if I'm missing a setting here???

James Agnew

unread,
Jul 19, 2016, 11:44:33 AM7/19/16
to Kevin Mayfield, HAPI FHIR
Hmm.. 

I'm not sure what might have changed to cause this, I guess it depends on the context of how this is being called.. but FWIW this would fix it:

ref.setReference("Organization/"+organisation.getIdElement().getIdPart());

Cheers,
James

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/9cf5867a-2281-4cb5-ab2a-71be9fcf2f6b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kevin Mayfield

unread,
Jul 20, 2016, 1:33:59 AM7/20/16
to HAPI FHIR
Thanks, I'll have a look at using that.

Kevin Mayfield

unread,
Jul 20, 2016, 6:14:24 AM7/20/16
to HAPI FHIR

That's resolved it.

Behaviour seems to have changed from either the 1.4->1.6 move or DSTU2->STU3. Anyway working now :)

Reply all
Reply to author
Forward
0 new messages