use of org.hl7.fhir.r4b.model.DomainResource in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method transformReferenceToIdentifiable.
/**
* FHIR Reference -> XDS Identifiable
* Only for References to Patients or Encounters
* Identifier is extracted from contained resource or from Reference URL
* @param reference
* @param container
* @return
*/
public Identifiable transformReferenceToIdentifiable(Reference reference, DomainResource container) {
if (reference.hasReference()) {
String targetRef = reference.getReference();
List<Resource> resources = container.getContained();
for (Resource resource : resources) {
if (targetRef.equals(resource.getId())) {
if (resource instanceof Patient) {
return transform(((Patient) resource).getIdentifierFirstRep());
} else if (resource instanceof Encounter) {
return transform(((Encounter) resource).getIdentifierFirstRep());
}
}
}
Identifiable result = patientRefCreator.resolvePatientReference(reference.getReference());
if (result != null)
return result;
MultiValueMap<String, String> vals = UriComponentsBuilder.fromUriString(targetRef).build().getQueryParams();
if (vals.containsKey("identifier")) {
String ids = vals.getFirst("identifier");
if (ids == null)
return null;
String[] identifier = ids.split("\\|");
if (identifier.length == 2) {
return new Identifiable(identifier[1], new AssigningAuthority(noPrefix(identifier[0])));
}
}
} else if (reference.hasIdentifier()) {
return transform(reference.getIdentifier());
}
throw new InvalidRequestException("Cannot resolve reference to " + (reference.getReference() != null ? reference.getReference().toString() : ""));
}
use of org.hl7.fhir.r4b.model.DomainResource in project cqf-ruler by DBCG.
the class ExpressionEvaluationIT method testExpressionEvaluationANCIND01MeasureDomain.
@Test
public void testExpressionEvaluationANCIND01MeasureDomain() throws Exception {
DomainResource measure = (DomainResource) measures.get("ANCIND01");
// Patient First
uploadTests("test/measure/ANCIND01/charity-otala-1/Patient");
Map<String, IBaseResource> resources = uploadTests("test/measure/ANCIND01");
IBaseResource patient = resources.get("charity-otala-1");
Object ipResult = expressionEvaluation.evaluateInContext(measure, "ANCIND01.\"Initial Population\"", patient.getIdElement().getIdPart(), new SystemRequestDetails());
assertTrue(ipResult instanceof Boolean);
assertTrue(((Boolean) ipResult).booleanValue());
Object denomResult = expressionEvaluation.evaluateInContext(measure, "ANCIND01.Denominator", patient.getIdElement().getIdPart(), new SystemRequestDetails());
assertTrue(denomResult instanceof Boolean);
assertTrue(((Boolean) denomResult).booleanValue());
Object numerResult = expressionEvaluation.evaluateInContext(measure, "ANCIND01.Numerator", patient.getIdElement().getIdPart(), new SystemRequestDetails());
assertTrue(numerResult instanceof Boolean);
assertTrue(((Boolean) numerResult).booleanValue());
}
use of org.hl7.fhir.r4b.model.DomainResource in project cqf-ruler by DBCG.
the class ExpressionEvaluationIT method testExpressionEvaluationANCDT01PlanDefinitionDomain.
@Test
public void testExpressionEvaluationANCDT01PlanDefinitionDomain() throws Exception {
DomainResource planDefinition = (DomainResource) planDefinitions.get("lcs-cds-patient-view");
// Patient First
uploadTests("test/plandefinition/LungCancerScreening/Former-Smoker/Patient");
Map<String, IBaseResource> resources = uploadTests("test/plandefinition/LungCancerScreening/Former-Smoker");
IBaseResource patient = resources.get("Former-Smoker");
Object isFormerSmoker = expressionEvaluation.evaluateInContext(planDefinition, "Is former smoker who quit within past 15 years", patient.getIdElement().getIdPart(), true, new SystemRequestDetails());
assertTrue(isFormerSmoker instanceof Boolean);
assertTrue(((Boolean) isFormerSmoker).booleanValue());
Object isCurrentSmoker = expressionEvaluation.evaluateInContext(planDefinition, "Is current smoker", patient.getIdElement().getIdPart(), true, new SystemRequestDetails());
assertTrue(isCurrentSmoker instanceof Boolean);
assertTrue((!(Boolean) isCurrentSmoker));
}
use of org.hl7.fhir.r4b.model.DomainResource in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProviderIT method testActivityDefinitionApply.
@Test
public void testActivityDefinitionApply() throws Exception {
DomainResource activityDefinition = (DomainResource) activityDefinitions.get("opioidcds-risk-assessment-request");
// Patient First
Map<String, IBaseResource> resources = uploadTests("test/activitydefinition/Patient");
IBaseResource patient = resources.get("ExamplePatient");
Resource applyResult = activityDefinitionApplyProvider.apply(new SystemRequestDetails(), activityDefinition.getIdElement(), patient.getIdElement().getIdPart(), null, null, null, null, null, null, null, null);
assertTrue(applyResult instanceof ServiceRequest);
assertEquals("454281000124100", ((ServiceRequest) applyResult).getCode().getCoding().get(0).getCode());
}
use of org.hl7.fhir.r4b.model.DomainResource in project cqf-ruler by DBCG.
the class ExpressionEvaluation method getLibraryReferences.
private List<Reference> getLibraryReferences(DomainResource instance, JpaFhirDal jpaFhirDal, RequestDetails theRequest) {
List<Reference> references = new ArrayList<>();
if (instance.hasContained()) {
for (Resource resource : instance.getContained()) {
if (resource instanceof Library) {
resource.setId(resource.getIdElement().getIdPart().replace("#", ""));
jpaFhirDal.update((Library) resource);
// getLibraryLoader().putLibrary(resource.getIdElement().getIdPart(),
// getLibraryLoader().toElmLibrary((Library) resource));
}
}
}
if (instance instanceof ActivityDefinition) {
references.addAll(((ActivityDefinition) instance).getLibrary());
} else if (instance instanceof PlanDefinition) {
references.addAll(((PlanDefinition) instance).getLibrary());
} else if (instance instanceof Measure) {
references.addAll(((Measure) instance).getLibrary());
}
for (Extension extension : instance.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/cqif-library")) {
Type value = extension.getValue();
if (value instanceof Reference) {
references.add((Reference) value);
} else {
throw new RuntimeException("Library extension does not have a value of type reference");
}
}
return cleanReferences(references);
}
Aggregations