From e8ac24b4dfd643818c043eb1514117b86d2f851c Mon Sep 17 00:00:00 2001 From: Kevin Hartmann Date: Fri, 30 Apr 2021 15:17:22 -0400 Subject: [PATCH] Test now passes. --- .../fhir/jpa/packages/PackageInstallerSvcImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java index 7c044f667db..67f3c1727e2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/PackageInstallerSvcImpl.java @@ -52,6 +52,7 @@ import com.google.gson.JsonElement; import org.apache.commons.lang3.Validate; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.utilities.npm.IPackageCacheManager; @@ -329,8 +330,16 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc { ourLog.info("Creating new resource matching {}", map.toNormalizedQueryString(myFhirContext)); theOutcome.incrementResourcesInstalled(myFhirContext.getResourceType(theResource)); - createResource(dao, theResource); + IIdType id = theResource.getIdElement(); + + if (id.isEmpty()) { + createResource(dao, theResource); + ourLog.info("Created resource with new id"); + } else { + updateResource(dao, theResource); + ourLog.info("Created resource with existing id"); + } } else { ourLog.info("Updating existing resource matching {}", map.toNormalizedQueryString(myFhirContext));