use of org.hl7.fhir.dstu3.model.ProcedureRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ProcedureRequestMapperTest method mapProcedureRequestWithNoReferencedEncounter.
@Test
public void mapProcedureRequestWithNoReferencedEncounter() {
var ehrExtract = unmarshallCodeElement("no_referenced_encounter_example.xml");
var planStatement = getPlanStatement(ehrExtract);
ProcedureRequest procedureRequest = procedureRequestMapper.mapToProcedureRequest(ehrExtract, getEhrComposition(ehrExtract), planStatement, SUBJECT, ENCOUNTERS, PRACTISE_CODE);
assertThat(procedureRequest.getContext().getResource()).isNull();
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ProcedureRequestMapperTest method mapProcedureRequestWithPrfParticipant.
@Test
public void mapProcedureRequestWithPrfParticipant() {
var ehrExtract = unmarshallCodeElement("prf_participant_example.xml");
var planStatement = getPlanStatement(ehrExtract);
setUpCodeableConceptMock();
ProcedureRequest procedureRequest = procedureRequestMapper.mapToProcedureRequest(ehrExtract, getEhrComposition(ehrExtract), planStatement, SUBJECT, ENCOUNTERS, PRACTISE_CODE);
assertFixedValues(planStatement, procedureRequest);
assertThat(procedureRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo(planStatement.getCode().getDisplayName());
assertThat(procedureRequest.getRequester().getAgent().getReference()).isEqualTo("Practitioner/9C1610C2-5E48-4ED5-882B-5A4A172AFA35");
assertThat(procedureRequest.getContext().getResource().getIdElement().getValue()).isEqualTo(ENCOUNTER_ID);
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveProcedureRequest.
private ProcedureRequest resolveProcedureRequest(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId) throws ActivityDefinitionApplyException {
// status, intent, code, and subject are required
ProcedureRequest procedureRequest = new ProcedureRequest();
procedureRequest.setStatus(ProcedureRequest.ProcedureRequestStatus.DRAFT);
procedureRequest.setIntent(ProcedureRequest.ProcedureRequestIntent.PROPOSAL);
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(new ProcedureRequest.ProcedureRequestRequesterComponent().setAgent(new Reference(practitionerId)));
} else if (organizationId != null) {
procedureRequest.setRequester(new ProcedureRequest.ProcedureRequestRequesterComponent().setAgent(new Reference(organizationId)));
}
if (activityDefinition.hasExtension()) {
procedureRequest.setExtension(activityDefinition.getExtension());
}
if (activityDefinition.hasCode()) {
procedureRequest.setCode(activityDefinition.getCode());
} else // code can be set as a dynamicValue
if (!activityDefinition.hasCode() && !activityDefinition.hasDynamicValue()) {
throw new ActivityDefinitionApplyException("Missing required code property");
}
if (activityDefinition.hasBodySite()) {
procedureRequest.setBodySite(activityDefinition.getBodySite());
}
if (activityDefinition.hasProduct()) {
throw new ActivityDefinitionApplyException("Product does not map to " + activityDefinition.getKind());
}
if (activityDefinition.hasDosage()) {
throw new ActivityDefinitionApplyException("Dosage does not map to " + activityDefinition.getKind());
}
return procedureRequest;
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProvider method resolveActivityDefinition.
// For library use
public Resource resolveActivityDefinition(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId, RequestDetails theRequest) throws FHIRException {
Resource result = newResource(activityDefinition.getKind().toCode());
switch(result.fhirType()) {
case "ProcedureRequest":
result = resolveProcedureRequest(activityDefinition, patientId, practitionerId, organizationId);
break;
case "MedicationRequest":
result = resolveMedicationRequest(activityDefinition, patientId);
break;
case "SupplyRequest":
result = resolveSupplyRequest(activityDefinition, practitionerId, organizationId);
break;
case "Procedure":
result = resolveProcedure(activityDefinition, patientId);
break;
case "DiagnosticReport":
result = resolveDiagnosticReport(activityDefinition, patientId);
break;
case "Communication":
result = resolveCommunication(activityDefinition, patientId);
break;
case "CommunicationRequest":
result = resolveCommunicationRequest(activityDefinition, patientId);
break;
}
for (ActivityDefinition.ActivityDefinitionDynamicValueComponent dynamicValue : activityDefinition.getDynamicValue()) {
if (dynamicValue.getExpression() != null) {
Boolean aliasedExpression = null;
if (dynamicValue.hasLanguage()) {
String language = dynamicValue.getLanguage();
if (language.equals("text/cql.identifier") || language.equals("text/cql-identifier") || language.equals("text/cql.name") || language.equals("text/cql-name")) {
aliasedExpression = true;
} else {
aliasedExpression = false;
}
} else {
aliasedExpression = false;
}
/*
* TODO: Passing the activityDefinition as context here because that's what will
* have the libraries, but perhaps the "context" here should be the result
* resource?
*/
Object value = expressionEvaluation.evaluateInContext(activityDefinition, dynamicValue.getExpression(), aliasedExpression, patientId, theRequest);
// TODO need to verify type... yay
if (value instanceof Boolean) {
value = new BooleanType((Boolean) value);
}
this.modelResolver.setValue(result, dynamicValue.getPath(), value);
}
}
return result;
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project BridgeServer2 by Sage-Bionetworks.
the class CRCControllerTest method procedureMissingIdentifiers.
@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Could not find Bridge user ID.")
public void procedureMissingIdentifiers() throws Exception {
when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
when(mockAccountService.authenticate(any(), any())).thenReturn(account);
when(mockAccountService.getAccount(ACCOUNT_ID)).thenReturn(Optional.of(account));
ProcedureRequest procedure = new ProcedureRequest();
String json = FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
mockRequestBody(mockRequest, json);
controller.postProcedureRequest();
}
Aggregations