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

Replacement of temporary UUIDs in uri in transaction not working #854

Closed
t4deon opened this Issue Feb 20, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@t4deon

t4deon commented Feb 20, 2018

I'm trying to post a Binary along with a DiagnosticResource (DR) in a transaction. In the DR, I reference the Binary in DR.presentedForm[0].uri with an UUID before posting (this is not a reference, just an uri). According to the spec, this UUID should be replaced with the ID of the Binary given by the server. Right now, the UUID is not replaced in DR.presentedForm[0].uri.

Here is some example code for testing:

Binary binary = new Binary();
binary.setId(IdType.newRandomUuid());
binary.setContent(bytes);
binary.setContentType("application/pdf");

DiagnosticReport dr = new DiagnosticReport();
dr.setId(IdDt.newRandomUuid());
Attachment attachment = new Attachment();
attachment.setContentType("application/pdf");
attachment.setUrl(binary.getId());
dr.setPresentedForm(Collections.singletonList(attachment));
dr.setSubject(new Reference().setIdentifier(patient.getIdentifierFirstRep()));

Bundle transactionBundle = new Bundle();
transactionBundle.setType(Bundle.BundleType.BATCH);

Bundle.BundleEntryComponent binaryEntry = new Bundle.BundleEntryComponent();   
binaryEntry.setResource(binary).setFullUrl(binary.getId()).getRequest().setUrl("Binary").setMethod(Bundle.HTTPVerb.POST);       
transactionBundle.addEntry(binaryEntry);

Bundle.BundleEntryComponent drEntry = new Bundle.BundleEntryComponent();     
drEntry.setResource(dr).setFullUrl(dr.getId()).getRequest().setUrl("DiagnosticReport").setMethod(Bundle.HTTPVerb.POST);         
transactionBundle.addEntry(drEntry);

FhirContext.forDstu3().newRestfulGenericClient(fhirBase).transaction().withBundle(transactionBundle).execute();

Versions tried:
Hapi Client: 3.2.0
Hapi Server: 3.2.0

@t4deon t4deon changed the title from Replacement of temporary UUIDs in transaction not working to Replacement of temporary UUIDs in uri in transaction not working Feb 20, 2018

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Feb 20, 2018

Note that you have transactionBundle.setType(Bundle.BundleType.BATCH) set. You'd definitely need to change it to transactionBundle.setType(Bundle.BundleType.TRANSACTION) for transaction processing rules to apply.

It still doesn't work in my unit test with that change, so that's not a fix, but it's a factor.

@jamesagnew

This comment has been minimized.

Owner

jamesagnew commented Feb 20, 2018

Alright, fix coming up. Thanks for supplying a testcase, that makes this very easy to fix.

@t4deon

This comment has been minimized.

t4deon commented Feb 20, 2018

Note that you have transactionBundle.setType(Bundle.BundleType.BATCH) set. You'd definitely need to change it to transactionBundle.setType(Bundle.BundleType.TRANSACTION) for transaction processing rules to @apply.

Yes that's right. Thanks for the fix James :-)

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