use of org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent in project synthea by synthetichealth.
the class FhirStu3 method encounterClaim.
/**
* Create an entry for the given Claim, associated to an Encounter.
*
* @param rand Source of randomness to use when generating ids etc
* @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(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Claim claim) {
org.hl7.fhir.dstu3.model.Claim claimResource = new org.hl7.fhir.dstu3.model.Claim();
org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) encounterEntry.getResource();
claimResource.setStatus(ClaimStatus.ACTIVE);
claimResource.setUse(org.hl7.fhir.dstu3.model.Claim.Use.COMPLETE);
// duration of encounter
claimResource.setBillablePeriod(encounterResource.getPeriod());
claimResource.setPatient(new Reference(personEntry.getFullUrl()));
claimResource.setOrganization(encounterResource.getServiceProvider());
// add item for encounter
claimResource.addItem(new ItemComponent(new PositiveIntType(1)).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
ItemComponent claimItem = new ItemComponent(new PositiveIntType(itemSequence));
Code primaryCode = item.codes.get(0);
String system = ExportHelper.getSystemURI(primaryCode.system);
CodeableConcept serviceProvided = new CodeableConcept().addCoding(new Coding().setCode(primaryCode.code).setVersion("v1").setSystem(system));
claimItem.setService(serviceProvided);
// calculate the cost of the procedure
Money moneyResource = new Money();
moneyResource.setCode("USD");
moneyResource.setSystem("urn:iso:std:iso:4217");
moneyResource.setValue(item.getCost());
claimItem.setNet(moneyResource);
if (item instanceof HealthRecord.Procedure) {
Type procedureReference = new Reference(item.fullUrl);
ProcedureComponent claimProcedure = new ProcedureComponent(new PositiveIntType(procedureSequence), procedureReference);
claimResource.addProcedure(claimProcedure);
claimItem.addProcedureLinkId(procedureSequence);
procedureSequence++;
} else {
Reference informationReference = new Reference(item.fullUrl);
SpecialConditionComponent informationComponent = new SpecialConditionComponent();
informationComponent.setSequence(informationSequence);
informationComponent.setValue(informationReference);
CodeableConcept category = new CodeableConcept();
category.getCodingFirstRep().setSystem("http://hl7.org/fhir/claiminformationcategory").setCode("info");
informationComponent.setCategory(category);
claimResource.addInformation(informationComponent);
claimItem.addInformationLinkId(informationSequence);
claimItem.setService(claimResource.getType());
informationSequence++;
}
claimResource.addItem(claimItem);
} else {
// assume it's a Condition, we don't have a Condition class specifically
// add diagnosisComponent to claim
Reference diagnosisReference = new Reference(item.fullUrl);
org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent diagnosisComponent = new org.hl7.fhir.dstu3.model.Claim.DiagnosisComponent(new PositiveIntType(conditionSequence), diagnosisReference);
claimResource.addDiagnosis(diagnosisComponent);
// update claimItems with diagnosis
ItemComponent diagnosisItem = new ItemComponent(new PositiveIntType(itemSequence));
diagnosisItem.addDiagnosisLinkId(conditionSequence);
claimResource.addItem(diagnosisItem);
conditionSequence++;
}
itemSequence++;
}
Money moneyResource = new Money();
moneyResource.setCode("USD");
moneyResource.setSystem("urn:iso:std:iso:4217");
moneyResource.setValue(claim.getTotalClaimCost());
claimResource.setTotal(moneyResource);
return newEntry(rand, bundle, claimResource);
}
Aggregations