Stef Heyenrath
Stef Heyenrath

Reputation: 9830

HL7-Fhir : when posting a resource, is it allowed to reference to another resources by search criteria?

Creating a new resource (patient) can be done by a POST to the server.

Example 1]
Create a new Patient 'a' which is linked to Organization with id = 1) :

{
  "resourceType": "Patient",
  "name": "a",
  "birthDate": "1974-12-25",
  "organization": {
    "reference": "Organization/1"
  }
}

However, I was wondering if it's also allowed to create a new Patient with a link to an Organization based on a search field?

Example 2]
Create a new Patient 'b' which is linked to an Organization with name = orgname.

{
  "resourceType": "Patient",
  "name": "b",
  "birthDate": "1974-12-25",
  "organization": {
    "reference": "Organization?name=orgname"
  }
}

Upvotes: 1

Views: 822

Answers (1)

Lloyd McKenzie
Lloyd McKenzie

Reputation: 6793

A reference must point to a specific resource. So what you've shown isn't allowed. However, if you were to post a bundle, your Patient resource could point to an Organization resource within the Bundle and the Bundle could have a conditional create (using If-None-Exist) based on the absence of any resource that has a specified name. But we haven't actually defined what happens to references in this circumstance. (If you wouldn't mind, it'd be good to submit a change request on this.)

Upvotes: 1

Related Questions