use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testDevice.
@Test
public void testDevice() 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));
Encounter encounter = person.getCurrentEncounter(module);
List<HealthRecord.Device> devices = encounter.devices;
assertNotNull(devices);
assertEquals(1, devices.size());
HealthRecord.Device device = devices.get(0);
assertEquals("13459008", device.type);
assertEquals("SynCardia", device.manufacturer);
assertEquals("Total Artificial Heart", device.model);
assertEquals(0L, device.stop);
HealthRecord.Device attribute = (HealthRecord.Device) person.attributes.get("artificial_heart");
assertNotNull(attribute);
// we want reference equality, it should be the same object
assertTrue(attribute == device);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method condition_onset_diagnosed_by_target_encounter.
@Test
public void condition_onset_diagnosed_by_target_encounter() throws Exception {
Module module = TestHelper.getFixture("condition_onset.json");
State condition = module.getState("Diabetes");
// Should pass through this state immediately without calling the record
person.history.add(0, condition);
assertTrue(condition.process(person, time));
// The encounter comes next (and add it to history);
State encounter = module.getState("ED_Visit");
// states are added to history before being processed
person.history.add(0, encounter);
assertTrue(encounter.process(person, time));
assertEquals(1, person.record.encounters.size());
Encounter enc = person.record.encounters.get(0);
Code code = enc.codes.get(0);
assertEquals("50849002", code.code);
assertEquals("Emergency Room Admission", code.display);
assertEquals(1, enc.conditions.size());
code = enc.conditions.get(0).codes.get(0);
assertEquals("73211009", code.code);
assertEquals("Diabetes mellitus", code.display);
Long onsetTime = person.getOnsetConditionRecord().getConditionLastOnsetTimeFromModule(module.name, code.display);
assertTrue(onsetTime != null);
assertEquals(time, onsetTime.longValue());
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method condition_onset_during_encounter.
@Test
public void condition_onset_during_encounter() throws Exception {
Module module = TestHelper.getFixture("condition_onset.json");
// The encounter comes first (and add it to history);
State encounter = module.getState("ED_Visit");
assertTrue(encounter.process(person, time));
person.history.add(0, encounter);
// Then appendicitis is diagnosed
State appendicitis = module.getState("Appendicitis");
assertTrue(appendicitis.process(person, time));
assertEquals(1, person.record.encounters.size());
Encounter enc = person.record.encounters.get(0);
Code code = enc.codes.get(0);
assertEquals("50849002", code.code);
assertEquals("Emergency Room Admission", code.display);
assertEquals(1, enc.conditions.size());
code = enc.conditions.get(0).codes.get(0);
assertEquals("47693006", code.code);
assertEquals("Rupture of appendix", code.display);
Long onsetTime = person.getOnsetConditionRecord().getConditionLastOnsetTimeFromModule(module.name, code.display);
assertTrue(onsetTime != null);
assertNotNull(person.attributes.get("Most Recent ED Visit"));
assertEquals(time, onsetTime.longValue());
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class StateTest method testDeviceEndByState.
@Test
public void testDeviceEndByState() 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_State");
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 testSupplyList.
@Test
public void testSupplyList() throws Exception {
Module module = TestHelper.getFixture("artificial_heart_device.json");
State encounterState = module.getState("Encounter");
assertTrue(encounterState.process(person, time));
State supplyListState = module.getState("Necessary_Supplies");
assertTrue(supplyListState.process(person, time));
Encounter encounter = person.getCurrentEncounter(module);
List<HealthRecord.Supply> supplies = encounter.supplies;
assertNotNull(supplies);
assertEquals(4, supplies.size());
String[] expectedCodes = { "52291003", "468159004", "39802000", "788177008" };
String[] expectedDisplays = { "Glove, device (physical object)", "Cotton ball (physical object)", "Tongue blade, device (physical object)", "Examination gown, single-use (physical object)" };
int[] expectedQuantities = { 10_000, 3_000, 98765, 1 };
for (int i = 0; i < 4; i++) {
HealthRecord.Supply supply = supplies.get(i);
Code code = supply.codes.get(0);
assertEquals(expectedCodes[i], code.code);
assertEquals(expectedDisplays[i], code.display);
assertEquals(expectedQuantities[i], supply.quantity);
}
}
Aggregations