createResourceIfNoneExist bug?
# support
m
Hi there, I have used
createResourceIfNoneExist
as below and it kept returning the error.
Copy code
const practitionerResource = await medplum.createResourceIfNoneExist(
    practitioner,
    `identifier=https://example.com/practitioner|${uuid}`,
  );

d: Invalid uri format (Practitioner.qualification[0].identifier[0].system)
I have tried to find a regular identifier, not the one in the qualification field, however, the function was only looking for the qualification one. To confirm the bug, I use the
search
function to see if
identifier
is a valid parameter.
Copy code
const searchResult = await medplum.search("Practitioner", {
    _count: 1,
    identifier: `https://example.com/practitioner|0dd84b13-1008-4e9a-b0cd-4957f016359c`,
  });

  console.log(JSON.stringify(searchResult, null, 2));
Received the response as below.
Copy code
{
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "fullUrl": "http://localhost:8103/fhir/R4/Practitioner/019545cb-8b40-71be-b534-ca9034d03997",
      "search": {
        "mode": "match"
      },
      "resource": {
        "resourceType": "Practitioner",
        "identifier": [
          {
            "system": "https://example.com/practitioner",
            "value": "0dd84b13-1008-4e9a-b0cd-4957f016359c"
          }
        ],
        "id": "019545cb-8b40-71be-b534-ca9034d03997",
        ...
        }
      }
    }
  ],
Is this a bug? or if I use the function the wrong way, please let me know. Thank you very much in advance! cc @two4zero_63114
n
Possible that the error is due to the resource you're trying to create instead of the search param? From your first code snippet, what's the value of the
practitioner
variable? Perhaps its
qualification[0].identifier[0].system
is invalid
m
@nathan-watkins-unityai Yes, you were right nathan. I had an error in
qualification[0].identifier[0].system
field so that
createResourceIfNoneExist
didn't work. I have done fixing this. Sorry for late reply. Thanks a lot!
188 Views