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

Ensure the Patient resource type prefix in ProcedureRequest's subject… #309

Merged
merged 3 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable, but what about if patientId is a contained reference? (e.g. #1234). And it should probably also account for the possibility that the reference is an absolute URL (e.g. http://blah-be-de-blah... and uuid:oid:XXX...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used URI class to account for absoluteUrl and references to contained resources (indicated by presence of a fragment).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but it does still need to check for the case that the input is relative, but already starts with Patient/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored that check and also updated R4 with these same changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

}
procedureRequest.setSubject(new Reference(patientReferenceString));

if (practitionerId != null) {
procedureRequest.setRequester(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
Expand Down