Skip to content
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

ConditionalCreate accidentally making contained resources. #2868

Closed
tadgh opened this issue Aug 5, 2021 · 1 comment
Closed

ConditionalCreate accidentally making contained resources. #2868

tadgh opened this issue Aug 5, 2021 · 1 comment

Comments

@tadgh
Copy link
Collaborator

tadgh commented Aug 5, 2021

When using a conditionalCreate with an ifNoneExist, if the resource already exists, and a bundle contains a reference to the existing resource described by a URN, the target resource will become contained in the referring resource, instead of the search resolving, and substituting the reference with the found PID from the database.

Exanple:

  1. Create patient
{
"resourceType": "Patient",
"identifier": [
	{
		"system": "https://example.com/fhir/memberuniqueidentifier",
		"value": "123"
	}
]
}
  1. Create a bundle with 2 entries:
  • One, a conditional POST on that same patient, with a full URL described by a URN.
  • Next, a conditional PUT on another resource, (e.g. Task), with a reference to the patient, defined by the fullUrl URN.
{
	"resourceType": "Bundle",
	"type": "transaction",
	"entry": [
		{
			"fullUrl": "urn:uuid:b348d0ca-337e-4554-8189-4d89386d67d3",
			"resource": {
				"resourceType": "Task",
				"language": "en-US",
				"identifier": [
					{
						"system": "https://example.com/fhir/taskidentifier",
						"value": "10100"
					}
				],
				"basedOn": [
					{
						"reference": "urn:uuid:9ffec273-d2c6-4b39-a23e-bd31f94afe32"
					}
				]
			},
			"request": {
				"method": "PUT",
				"url": "/Task?identifier=https%3A%2F%2Fexample.com%2Ffhir%2Ftaskidentifier|10100"
			}
		},
		{
			"fullUrl": "urn:uuid:9ffec273-d2c6-4b39-a23e-bd31f94afe32",
			"resource": {
				"resourceType": "Patient",
				"identifier": [
					{
                                               "system": "https://example.com/fhir/memberuniqueidentifier",
						"value": "123"
					}
				]
			},
			"request": {
				"method": "POST",
				"url": "/Patient",
				"ifNoneExist": "Patient?identifier=https%3A%2F%example.com%2Ffhir%2Fmemberuniqueidentifier|123"
			}
		}
	]
}

Expected behavior
When the Task is created, it should refer to the original Patient created, like so:

{
        "resourceType": "Task",
        "id": "1626",
        "meta": {
          "versionId": "1",
          "lastUpdated": "2021-08-05T05:22:25.353-07:00",
          "source": "#EBtcLOmk4oSFIRvb"
        },
        "language": "en-US",
        "identifier": [
          {
            "system": "https://example.com/fhir/taskidentifier",
            "value": "10100"
          }
        ],
        "basedOn": [
          {
            "reference": "Patient/1625"
          }
        ]
      }

Instead, it becomes a contained resource in the task, like so:


        "resourceType": "Task",
        "id": "1627",
        "meta": {
          "versionId": "1",
          "lastUpdated": "2021-08-05T05:22:47.759-07:00",
          "source": "#fMMdRu1IMywTlQdK"
        },
        "language": "en-US",
        "contained": [
          {
            "resourceType": "Patient",
            "id": "1",
            "identifier": [
              {
                "system": "https://example.com/fhir/memberuniqueidentifier",
                "value": "123"
              }
            ]
          }
        ],
        "identifier": [
          {
            "system": "https://example.com/fhir/taskidentifier",
            "value": "101019"
          }
        ],
        "basedOn": [
          {
            "reference": "#1"
          }
        ]
      },

Note the `"reference": "#1"``

@tadgh
Copy link
Collaborator Author

tadgh commented Aug 18, 2021

Closed by #2880

@tadgh tadgh closed this as completed Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant