use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CodeResolveAndExportTest method verifyEncounterCodeStu3.
private void verifyEncounterCodeStu3() throws IOException {
InputStream inputStream = new FileInputStream(stu3OutputPath.toFile().getAbsolutePath());
Bundle bundle = (Bundle) FhirStu3.getContext().newJsonParser().parseResource(inputStream);
// Find encounter reason code.
Optional<BundleEntryComponent> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(ResourceType.Encounter)).findFirst();
assertTrue(maybeEncounterEntry.isPresent());
org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) maybeEncounterEntry.get().getResource();
assertEquals(encounterResource.getReason().size(), 1);
CodeableConcept encounterReason = encounterResource.getReason().get(0);
assertEquals(encounterReason.getCoding().size(), 1);
Coding reasonCoding = encounterReason.getCoding().get(0);
// Check encounter reason code.
assertEquals(SNOMED_URI, reasonCoding.getSystem());
assertEquals(EXPECTED_REASON_CODE, reasonCoding.getCode());
assertEquals(EXPECTED_REASON_DISPLAY, reasonCoding.getDisplay());
Optional<BundleEntryComponent> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(ResourceType.Observation)).findFirst();
assertTrue(maybeObservationEntry.isPresent());
// Find observation type code.
org.hl7.fhir.dstu3.model.Observation observationResource = (org.hl7.fhir.dstu3.model.Observation) maybeObservationEntry.get().getResource();
CodeableConcept observationType = observationResource.getCode();
assertNotNull(observationType);
assertEquals(observationType.getCoding().size(), 1);
Coding observationTypeCoding = observationType.getCoding().get(0);
// Check observation type code.
assertEquals(LOINC_URI, observationTypeCoding.getSystem());
assertEquals(OBSERVATION_CODE, observationTypeCoding.getCode());
assertEquals(OBSERVATION_DISPLAY, observationTypeCoding.getDisplay());
// Find observation value code.
CodeableConcept observationValue = observationResource.getValueCodeableConcept();
assertNotNull(observationValue);
assertEquals(observationValue.getCoding().size(), 1);
Coding observationValueCoding = observationValue.getCoding().get(0);
// Check observation value code.
assertEquals(LOINC_URI, observationValueCoding.getSystem());
assertEquals(EXPECTED_VALUE_CODE, observationValueCoding.getCode());
assertEquals(EXPECTED_VALUE_DISPLAY, observationValueCoding.getDisplay());
inputStream.close();
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CodeResolveAndExportTest method verifyEncounterCodeR4.
private void verifyEncounterCodeR4() throws IOException {
InputStream inputStream = new FileInputStream(r4OutputPath.toFile().getAbsolutePath());
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) FhirR4.getContext().newJsonParser().parseResource(inputStream);
// Find encounter reason code.
Optional<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(org.hl7.fhir.r4.model.ResourceType.Encounter)).findFirst();
assertTrue(maybeEncounterEntry.isPresent());
org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) maybeEncounterEntry.get().getResource();
assertEquals(encounterResource.getReasonCode().size(), 1);
org.hl7.fhir.r4.model.CodeableConcept encounterReason = encounterResource.getReasonCode().get(0);
assertEquals(encounterReason.getCoding().size(), 1);
org.hl7.fhir.r4.model.Coding reasonCoding = encounterReason.getCoding().get(0);
// Check encounter reason code.
assertEquals(SNOMED_URI, reasonCoding.getSystem());
assertEquals(EXPECTED_REASON_CODE, reasonCoding.getCode());
assertEquals(EXPECTED_REASON_DISPLAY, reasonCoding.getDisplay());
Optional<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(org.hl7.fhir.r4.model.ResourceType.Observation)).findFirst();
assertTrue(maybeObservationEntry.isPresent());
// Find observation type code.
org.hl7.fhir.r4.model.Observation observationResource = (org.hl7.fhir.r4.model.Observation) maybeObservationEntry.get().getResource();
org.hl7.fhir.r4.model.CodeableConcept observationType = observationResource.getCode();
assertNotNull(observationType);
assertEquals(observationType.getCoding().size(), 1);
org.hl7.fhir.r4.model.Coding observationTypeCoding = observationType.getCoding().get(0);
// Check observation type code.
assertEquals(LOINC_URI, observationTypeCoding.getSystem());
assertEquals(OBSERVATION_CODE, observationTypeCoding.getCode());
assertEquals(OBSERVATION_DISPLAY, observationTypeCoding.getDisplay());
// Find observation value code.
org.hl7.fhir.r4.model.CodeableConcept observationValue = observationResource.getValueCodeableConcept();
assertNotNull(observationValue);
assertEquals(observationValue.getCoding().size(), 1);
org.hl7.fhir.r4.model.Coding observationValueCoding = observationValue.getCoding().get(0);
// Check observation value code.
assertEquals(LOINC_URI, observationValueCoding.getSystem());
assertEquals(EXPECTED_VALUE_CODE, observationValueCoding.getCode());
assertEquals(EXPECTED_VALUE_DISPLAY, observationValueCoding.getDisplay());
inputStream.close();
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class ExporterTest method testExportFilterShouldKeepCareplanThatEndedDuringTarget.
@Test
public void testExportFilterShouldKeepCareplanThatEndedDuringTarget() {
record.encounterStart(time - years(10), EncounterType.WELLNESS);
record.careplanStart(time - years(10), "stop_smoking");
record.careplanEnd(time - years(1), "stop_smoking", DUMMY_CODE);
Person filtered = Exporter.filterForExport(patient, yearsToKeep, endTime);
Encounter encounter = filtered.record.currentEncounter(time);
assertEquals(1, encounter.careplans.size());
assertEquals("stop_smoking", encounter.careplans.get(0).type);
assertEquals(time - years(10), encounter.careplans.get(0).start);
assertEquals(time - years(1), encounter.careplans.get(0).stop);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class ExporterTest method testExportFilterShouldKeepMedicationThatEndedDuringTarget.
@Test
public void testExportFilterShouldKeepMedicationThatEndedDuringTarget() {
Code code = new Code("SNOMED-CT", "705129", "Fake Code");
record.encounterStart(time - years(10), EncounterType.AMBULATORY);
Medication med = record.medicationStart(time - years(10), "dimoxinil", false);
med.codes.add(code);
record.medicationEnd(time - years(9), "dimoxinil", DUMMY_CODE);
record.encounterStart(time - years(8), EncounterType.AMBULATORY);
med = record.medicationStart(time - years(8), "placebitol", true);
med.codes.add(code);
record.medicationEnd(time - years(4), "placebitol", DUMMY_CODE);
Person filtered = Exporter.filterForExport(patient, yearsToKeep, endTime);
Encounter encounter = filtered.record.currentEncounter(time);
assertEquals(1, encounter.medications.size());
assertEquals("placebitol", encounter.medications.get(0).type);
assertEquals(time - years(8), encounter.medications.get(0).start);
assertEquals(time - years(4), encounter.medications.get(0).stop);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class ExporterTest method testExportFilterShouldKeepConditionThatEndedDuringTarget.
@Test
public void testExportFilterShouldKeepConditionThatEndedDuringTarget() {
record.encounterStart(time - years(10), EncounterType.WELLNESS);
record.conditionStart(time - years(10), "boneitis");
record.conditionEnd(time - years(2), "boneitis");
record.encounterStart(time - years(10), EncounterType.WELLNESS);
record.conditionStart(time - years(10), "smallpox");
record.conditionEnd(time - years(9), "smallpox");
Person filtered = Exporter.filterForExport(patient, yearsToKeep, endTime);
Encounter encounter = filtered.record.currentEncounter(time);
assertEquals(1, encounter.conditions.size());
assertEquals("boneitis", encounter.conditions.get(0).type);
assertEquals(time - years(10), encounter.conditions.get(0).start);
}
Aggregations