diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/ActivityDefinitionApplyProvider.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/ActivityDefinitionApplyProvider.java index f4b2b7416..302b05c60 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/ActivityDefinitionApplyProvider.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/ActivityDefinitionApplyProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.dstu3.providers; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -147,7 +148,15 @@ private ProcedureRequest resolveProcedureRequest(ActivityDefinition activityDefi ProcedureRequest procedureRequest = new ProcedureRequest(); procedureRequest.setStatus(ProcedureRequest.ProcedureRequestStatus.DRAFT); procedureRequest.setIntent(ProcedureRequest.ProcedureRequestIntent.ORDER); - procedureRequest.setSubject(new Reference(patientId)); + String patientReferenceString = patientId; + URI patientIdAsUri = URI.create(patientReferenceString); + + if (!patientIdAsUri.isAbsolute() + && patientIdAsUri.getFragment() == null + && !patientReferenceString.startsWith("Patient/")) { + patientReferenceString = "Patient/" + patientId; + } + procedureRequest.setSubject(new Reference(patientReferenceString)); if (practitionerId != null) { procedureRequest.setRequester( diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/ActivityDefinitionApplyProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/ActivityDefinitionApplyProvider.java index 9115197dd..799a33a94 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/ActivityDefinitionApplyProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/ActivityDefinitionApplyProvider.java @@ -1,5 +1,6 @@ package org.opencds.cqf.r4.providers; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -189,7 +190,15 @@ private ServiceRequest resolveServiceRequest(ActivityDefinition activityDefiniti ServiceRequest serviceRequest = new ServiceRequest(); serviceRequest.setStatus(ServiceRequest.ServiceRequestStatus.DRAFT); serviceRequest.setIntent(ServiceRequest.ServiceRequestIntent.ORDER); - serviceRequest.setSubject(new Reference(patientId)); + String patientReferenceString = patientId; + URI patientIdAsUri = URI.create(patientReferenceString); + + if (!patientIdAsUri.isAbsolute() + && patientIdAsUri.getFragment() == null + && !patientReferenceString.startsWith("Patient/")) { + patientReferenceString = "Patient/" + patientId; + } + serviceRequest.setSubject(new Reference(patientReferenceString)); if (practitionerId != null) { serviceRequest.setRequester(new Reference(practitionerId));