use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testMultiObservation.
@Test
public void testMultiObservation() throws Exception {
// Birth makes the blood pump :-)
LifecycleModule.birth(person, (long) person.attributes.get(Person.BIRTHDATE));
Module module = TestHelper.getFixture("observation_groups.json");
State condition = module.getState("Record_BP");
assertTrue(condition.process(person, time));
// for a MultiObservation, we expect only the MultiObs to be added to the record,
// not the child observations, which get added as components of the parent observation
Encounter e = person.record.encounters.get(0);
assertEquals(1, e.observations.size());
HealthRecord.Observation o = e.observations.get(0);
assertEquals("55284-4", o.codes.get(0).code);
assertEquals(2, o.observations.size());
// diastolic
assertEquals("8462-4", o.observations.get(0).codes.get(0).code);
// systolic
assertEquals("8480-6", o.observations.get(1).codes.get(0).code);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testDeviceEndByAttribute.
@Test
public void testDeviceEndByAttribute() throws Exception {
Module module = TestHelper.getFixture("artificial_heart_device.json");
State encounterState = module.getState("Encounter");
assertTrue(encounterState.process(person, time));
State deviceState = module.getState("Artificial_Heart");
assertTrue(deviceState.process(person, time));
State deviceEndState = module.getState("Remove_Device_By_Attribute");
assertTrue(deviceEndState.process(person, time));
Encounter encounter = person.getCurrentEncounter(module);
List<HealthRecord.Device> devices = encounter.devices;
HealthRecord.Device device = devices.get(0);
assertEquals(time, device.stop);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testVaccine.
@Test
public void testVaccine() throws Exception {
Module module = TestHelper.getFixture("vaccine.json");
State encounterState = module.getState("Encounter");
assertTrue(encounterState.process(person, time));
State supplyListState = module.getState("Vaccine");
assertTrue(supplyListState.process(person, time));
Encounter encounter = person.getCurrentEncounter(module);
List<HealthRecord.Immunization> vaccines = encounter.immunizations;
assertNotNull(vaccines);
assertEquals(1, vaccines.size());
String[] expectedCodes = { "123" };
String[] expectedDisplays = { "CVX Vaccine Code" };
for (int i = 0; i < vaccines.size(); i++) {
HealthRecord.Immunization vaccine = vaccines.get(i);
Code code = vaccine.codes.get(0);
assertEquals(expectedCodes[i], code.code);
assertEquals(expectedDisplays[i], code.display);
}
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class CodeResolveAndExportTest method verifyEncounterCodeDstu2.
private void verifyEncounterCodeDstu2() throws IOException {
InputStream inputStream = new FileInputStream(dstu2OutputPath.toFile().getAbsolutePath());
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) FhirDstu2.getContext().newJsonParser().parseResource(inputStream);
// Find encounter reason code.
Optional<Entry> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceName().equals(org.hl7.fhir.dstu2.model.ResourceType.Encounter.name())).findFirst();
assertTrue(maybeEncounterEntry.isPresent());
ca.uhn.fhir.model.dstu2.resource.Encounter encounterResource = (ca.uhn.fhir.model.dstu2.resource.Encounter) maybeEncounterEntry.get().getResource();
assertEquals(encounterResource.getReason().size(), 1);
CodeableConceptDt encounterReason = encounterResource.getReason().get(0);
assertEquals(encounterReason.getCoding().size(), 1);
CodingDt 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<Entry> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceName().equals(org.hl7.fhir.dstu2.model.ResourceType.Observation.name())).findFirst();
assertTrue(maybeObservationEntry.isPresent());
// Find observation type code.
ca.uhn.fhir.model.dstu2.resource.Observation observationResource = (ca.uhn.fhir.model.dstu2.resource.Observation) maybeObservationEntry.get().getResource();
CodeableConceptDt observationType = observationResource.getCode();
assertNotNull(observationType);
assertEquals(observationType.getCoding().size(), 1);
CodingDt 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.
CodeableConceptDt observationValue = (CodeableConceptDt) observationResource.getValue();
assertNotNull(observationValue);
assertEquals(observationValue.getCoding().size(), 1);
CodingDt 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 testExportFilterShouldKeepOldActiveConditions.
@Test
public void testExportFilterShouldKeepOldActiveConditions() {
record.encounterStart(time - years(10), EncounterType.WELLNESS);
record.conditionStart(time - years(10), "fakitis");
record.conditionEnd(time - years(8), "fakitis");
record.encounterStart(time - years(10), EncounterType.WELLNESS);
record.conditionStart(time - years(10), "fakosis");
Person filtered = Exporter.filterForExport(patient, yearsToKeep, endTime);
Encounter encounter = filtered.record.currentEncounter(time);
assertEquals(1, encounter.conditions.size());
assertEquals("fakosis", encounter.conditions.get(0).type);
assertEquals(time - years(10), encounter.conditions.get(0).start);
}
Aggregations