microsoft / fhir-server

A service that implements the FHIR standard
MIT License
1.21k stars 518 forks source link

Transaction broken reference #1174

Closed yochail closed 4 years ago

yochail commented 4 years ago

Describe the bug I’m trying to use FHIR Bundle transaction to write multiple co-referenced resources to the server at once. The challenge is that any of those resources may or may not already be on the server. To address that I’m using “Conditional Create” and “Condition update” with “Conditional References” features. The bundle have entries as follows: “Organization” resource – create if none exist “Location” resource” – create if none exist “ResearchStudy” resource that contains a “Conditional References” to the organization and location resources – Update\Update as Create(if none exist)

This setup works for the first time creation, but if the Organization/Location are already created (same bundle, second call), the transaction will succeed, but the condition reference in the research study will be translated to reference GUID that doesn’t exist.

Example: (full bundle attached) First call: Organization?name:exact=Janssen Sciences Ireland UC Returning bundle: Organization resource url: Organization/ ResearchStudy organization reference: Organization/

Second call: Organization?name:exact=Janssen Sciences Ireland UC Returning bundle: Organization resource: success 200 (no returning url, because the resource already exists) ResearchStudy organization reference: Organization/

To Reproduce Steps to reproduce the behavior:

  1. use the file attached to post to fhir server TWICE
  2. check the resource references for location/organization returning inside the research study object in the second call
    • they are broken

Expected behavior the resources inner reference should be pointing to the resources created in the first call

Actual behavior the resources inner references are broken

Transaction body: FHIRbug-post.txt

yochail commented 4 years ago

Sounds like the issue in #1044 solves this bug as well