use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method confirmCanFindEventWithExistenceOfThirdEvent.
@Test
public void confirmCanFindEventWithExistenceOfThirdEvent() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
Observation observation = new Observation();
DateTimeType observationEffective = new DateTimeType(new Date());
observationEffective.setYear(2015);
observationEffective.setMonth(0);
observationEffective.setDay(5);
observation.setEffective(observationEffective);
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), ENCOUNTER_1, fhirConfig);
mockFhirResourceRetrieval("/Observation?subject=Patient%2F123&_format=json", getFhirParser(), observation, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "ObservationWithin30DaysOfCondition";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test2", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, true);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method anEventDoesFollow.
@Test
public void anEventDoesFollow() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), ENCOUNTER_1, fhirConfig);
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "NotFollowedByCondition";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test4", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, false);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method getEncounter.
public Encounter getEncounter(int year, int month, int day) {
Encounter encounter = new Encounter();
Period encounterPeriod = new Period();
Calendar c = Calendar.getInstance();
c.set(year, month - 1, day);
Date encounterDate = c.getTime();
encounterPeriod.setStart(encounterDate);
encounterPeriod.setEnd(encounterDate);
encounter.setPeriod(encounterPeriod);
return encounter;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project summary-care-record-api by NHSDigital.
the class ParticipantAgentMapper method mapInformant.
public static Participant.Informant mapInformant(Bundle bundle, EncounterParticipantComponent encounterParticipant) {
var informant = new Participant.Informant();
informant.setTime(formatDateToHl7(encounterParticipant.getPeriod().getStartElement()));
var participantType = encounterParticipant.getIndividual().getReference().split("/")[0];
if (PractitionerRole.class.getSimpleName().equals(participantType)) {
setParticipantAgents(bundle, encounterParticipant.getIndividual(), informant);
} else if (RelatedPerson.class.getSimpleName().equals(participantType)) {
var relatedPerson = getResourceByReference(bundle, encounterParticipant.getIndividual().getReference(), RelatedPerson.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is missing RelatedPerson %s that is linked to Encounter", encounterParticipant.getIndividual().getReference())));
var participantNonAgentRole = new NonAgentRole("participantNonAgentRole");
setRelationship(relatedPerson, participantNonAgentRole);
setRelatedPersonName(relatedPerson, participantNonAgentRole);
informant.setParticipantNonAgentRole(participantNonAgentRole);
} else {
throw new FhirValidationException(String.format("Invalid Encounter participant type %s", participantType));
}
return informant;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project summary-care-record-api by NHSDigital.
the class DiagnosisMapper method mapAuthor.
private void mapAuthor(List<Resource> resources, Encounter encounter, Node author) {
DateTimeType time = parseDate(xmlUtils.getValueByXPath(author, DIAGNOSIS_PARTICIPANT_TIME_XPATH), DateTimeType.class);
participantMapper.map(author).stream().peek(it -> resources.add(it)).filter(it -> it instanceof PractitionerRole).forEach(it -> encounter.addParticipant(new EncounterParticipantComponent().setPeriod(new Period().setStartElement(time)).addType(getParticipationType("AUT", "author")).setIndividual(new Reference(it))));
}
Aggregations