use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class HealthRecordTest method testReportSomeObs.
@Test
public void testReportSomeObs() {
Person person = new Person(0L);
person.coverage.setPayerAtTime(time, noInsurance);
HealthRecord record = new HealthRecord(person);
Encounter encounter = record.encounterStart(time, EncounterType.WELLNESS);
record.observation(time, "A", "A");
record.observation(time, "B", "B");
record.observation(time, "C", "C");
Report report = record.report(time, "R", 2);
Assert.assertEquals(3, encounter.observations.size());
Assert.assertEquals(2, report.observations.size());
Assert.assertEquals("B", report.observations.get(0).value);
Assert.assertEquals("C", report.observations.get(1).value);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class HealthRecordTest method testReportTooManyObs.
@Test
public void testReportTooManyObs() {
Person person = new Person(0L);
person.coverage.setPayerAtTime(time, noInsurance);
HealthRecord record = new HealthRecord(person);
Encounter encounter = record.encounterStart(time, EncounterType.WELLNESS);
record.observation(time, "A", "A");
record.observation(time, "B", "B");
record.observation(time, "C", "C");
Report report = record.report(time, "R", 4);
Assert.assertEquals(3, encounter.observations.size());
Assert.assertEquals(3, report.observations.size());
Assert.assertEquals("A", report.observations.get(0).value);
Assert.assertEquals("B", report.observations.get(1).value);
Assert.assertEquals("C", report.observations.get(2).value);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class LossOfCareHealthRecordTest method personRunsOutOfCurrentYearIncomeThenNextYearBegins.
@Test
public void personRunsOutOfCurrentYearIncomeThenNextYearBegins() {
Person person = new Person(0L);
person.coverage.setPayerAtTime(time, Payer.noInsurance);
person.setProvider(EncounterType.WELLNESS, new Provider());
Code code = new Code("SNOMED-CT", "705129", "Fake Code");
// Set person's income to be $1 lower than the cost of an encounter.
person.attributes.put(Person.INCOME, (int) defaultEncounterCost - 1);
// Set person's birthdate
person.attributes.put(Person.BIRTHDATE, time);
// First encounter of current year is uncovered but affordable.
Encounter coveredEncounterYearOne = person.encounterStart(time, EncounterType.WELLNESS);
coveredEncounterYearOne.codes.add(code);
coveredEncounterYearOne.provider = new Provider();
person.record.encounterEnd(time, EncounterType.WELLNESS);
// Person is in debt $1. They should not receive any more care.
assertTrue(person.defaultRecord.encounters.contains(coveredEncounterYearOne));
assertFalse(person.lossOfCareRecord.encounters.contains(coveredEncounterYearOne));
// Second encounter of current year is uncovered and not affordable.
Encounter uncoveredEncounterYearOne = person.encounterStart(time, EncounterType.WELLNESS);
uncoveredEncounterYearOne.codes.add(code);
uncoveredEncounterYearOne.provider = new Provider();
person.record.encounterEnd(time, EncounterType.WELLNESS);
// Person should have this encounter in the uncoveredHealthRecord.
assertFalse(person.defaultRecord.encounters.contains(uncoveredEncounterYearOne));
assertTrue(person.lossOfCareRecord.encounters.contains(uncoveredEncounterYearOne));
// Next year begins. Person should enough income to cover one encounter for the year.
long oneYear = Utilities.convertTime("years", 1) + 1;
person.coverage.setPayerAtTime(time + oneYear, Payer.noInsurance);
// First encounter of next year is uncovered but affordable.
Encounter coveredEncounterYearTwo = person.encounterStart(time + oneYear, EncounterType.WELLNESS);
coveredEncounterYearTwo.codes.add(code);
coveredEncounterYearTwo.provider = new Provider();
person.record.encounterEnd(time + oneYear, EncounterType.WELLNESS);
// Person is in debt $1. They should not receive any more care.
assertTrue(person.defaultRecord.encounters.contains(coveredEncounterYearTwo));
assertFalse(person.lossOfCareRecord.encounters.contains(coveredEncounterYearTwo));
// Second encounter of next year is uncovered and not affordable.
Encounter uncoveredEncounterYearTwo = person.encounterStart(time + oneYear, EncounterType.WELLNESS);
uncoveredEncounterYearTwo.codes.add(code);
uncoveredEncounterYearTwo.provider = new Provider();
person.record.encounterEnd(time + oneYear, EncounterType.WELLNESS);
// Person should have this encounter in the uncoveredHealthRecord.
assertFalse(person.defaultRecord.encounters.contains(uncoveredEncounterYearTwo));
assertTrue(person.lossOfCareRecord.encounters.contains(uncoveredEncounterYearTwo));
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class EncounterModuleTest method testEncounterHasClinician.
@Test
public void testEncounterHasClinician() {
module.process(person, System.currentTimeMillis());
assertNotNull(person.record);
assertFalse(person.record.encounters.isEmpty());
int last = person.record.encounters.size() - 1;
Encounter encounter = person.record.encounters.get(last);
assertNotNull("Encounter must have clinician", encounter.clinician);
assertNotNull("Encounter must have provider organization", encounter.provider);
}
use of org.mitre.synthea.world.concepts.HealthRecord.Encounter in project synthea by synthetichealth.
the class FhirR4 method encounterClaim.
/**
* Create an entry for the given Claim, associated to an Encounter.
*
* @param person The patient having the encounter.
* @param personEntry Entry for the person
* @param bundle The Bundle to add to
* @param encounterEntry The current Encounter
* @param claim the Claim object
* @return the added Entry
*/
private static BundleEntryComponent encounterClaim(Person person, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim) {
org.hl7.fhir.r4.model.Claim claimResource = new org.hl7.fhir.r4.model.Claim();
org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
claimResource.setStatus(ClaimStatus.ACTIVE);
CodeableConcept type = new CodeableConcept();
type.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/claim-type").setCode("institutional");
claimResource.setType(type);
claimResource.setUse(org.hl7.fhir.r4.model.Claim.Use.CLAIM);
InsuranceComponent insuranceComponent = new InsuranceComponent();
insuranceComponent.setSequence(1);
insuranceComponent.setFocal(true);
insuranceComponent.setCoverage(new Reference().setDisplay(claim.payer.getName()));
claimResource.addInsurance(insuranceComponent);
// duration of encounter
claimResource.setBillablePeriod(encounterResource.getPeriod());
claimResource.setCreated(encounterResource.getPeriod().getEnd());
claimResource.setPatient(new Reference().setReference(personEntry.getFullUrl()).setDisplay((String) person.attributes.get(Person.NAME)));
claimResource.setProvider(encounterResource.getServiceProvider());
if (USE_US_CORE_IG) {
claimResource.setFacility(encounterResource.getLocationFirstRep().getLocation());
}
// set the required priority
CodeableConcept priority = new CodeableConcept();
priority.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/processpriority").setCode("normal");
claimResource.setPriority(priority);
// add item for encounter
claimResource.addItem(new ItemComponent(new PositiveIntType(1), encounterResource.getTypeFirstRep()).addEncounter(new Reference(encounterEntry.getFullUrl())));
int itemSequence = 2;
int conditionSequence = 1;
int procedureSequence = 1;
int informationSequence = 1;
for (Claim.ClaimEntry claimEntry : claim.items) {
HealthRecord.Entry item = claimEntry.entry;
if (Costs.hasCost(item)) {
// update claimItems list
Code primaryCode = item.codes.get(0);
String system = ExportHelper.getSystemURI(primaryCode.system);
ItemComponent claimItem = new ItemComponent(new PositiveIntType(itemSequence), mapCodeToCodeableConcept(primaryCode, system));
// calculate the cost of the procedure
Money moneyResource = new Money();
moneyResource.setCurrency("USD");
moneyResource.setValue(item.getCost());
claimItem.setNet(moneyResource);
claimResource.addItem(claimItem);
if (item instanceof Procedure) {
Type procedureReference = new Reference(item.fullUrl);
ProcedureComponent claimProcedure = new ProcedureComponent(new PositiveIntType(procedureSequence), procedureReference);
claimResource.addProcedure(claimProcedure);
claimItem.addProcedureSequence(procedureSequence);
procedureSequence++;
} else {
Reference informationReference = new Reference(item.fullUrl);
SupportingInformationComponent informationComponent = new SupportingInformationComponent();
informationComponent.setSequence(informationSequence);
informationComponent.setValue(informationReference);
CodeableConcept category = new CodeableConcept();
category.getCodingFirstRep().setSystem("http://terminology.hl7.org/CodeSystem/claiminformationcategory").setCode("info");
informationComponent.setCategory(category);
claimResource.addSupportingInfo(informationComponent);
claimItem.addInformationSequence(informationSequence);
informationSequence++;
}
} else {
// assume it's a Condition, we don't have a Condition class specifically
// add diagnosisComponent to claim
Reference diagnosisReference = new Reference(item.fullUrl);
DiagnosisComponent diagnosisComponent = new DiagnosisComponent(new PositiveIntType(conditionSequence), diagnosisReference);
claimResource.addDiagnosis(diagnosisComponent);
// update claimItems with diagnosis
ItemComponent diagnosisItem = new ItemComponent(new PositiveIntType(itemSequence), mapCodeToCodeableConcept(item.codes.get(0), SNOMED_URI));
diagnosisItem.addDiagnosisSequence(conditionSequence);
claimResource.addItem(diagnosisItem);
conditionSequence++;
}
itemSequence++;
}
Money moneyResource = new Money();
moneyResource.setCurrency("USD");
moneyResource.setValue(claim.getTotalClaimCost());
claimResource.setTotal(moneyResource);
return newEntry(person, bundle, claimResource);
}
Aggregations