use of gov.cms.bfd.model.rda.PreAdjFissClaim in project beneficiary-fhir-data by CMSgov.
the class R4ClaimSamhsaMatcherTransformerTest method fissTest.
/**
* These tests check if the transformed FISS claims result in the expected SAMHSA filtering
* outcomes.
*/
@ParameterizedTest(name = "{index}: {0}")
@MethodSource
public void fissTest(String testName, LocalDate toDate, List<String> diagCodes, List<String> procCodes, boolean expectedResult, String errorMessagePostFix) {
PreAdjFissClaim entity = new PreAdjFissClaim();
String principalDxCode = diagCodes.get(0);
String admittingDxCode = diagCodes.get(1);
entity.setLastUpdated(Instant.ofEpochMilli(1));
entity.setStmtCovToDate(toDate);
entity.setPrincipleDiag(principalDxCode);
entity.setAdmitDiagCode(admittingDxCode);
Set<PreAdjFissDiagnosisCode> diagnoses = IntStream.range(0, diagCodes.size()).mapToObj(i -> {
PreAdjFissDiagnosisCode diagCode = new PreAdjFissDiagnosisCode();
diagCode.setPriority((short) i);
diagCode.setDiagCd2(diagCodes.get(i));
return diagCode;
}).collect(Collectors.toSet());
entity.setDiagCodes(diagnoses);
Set<PreAdjFissProcCode> procedures = IntStream.range(0, procCodes.size()).mapToObj(i -> {
PreAdjFissProcCode procCode = new PreAdjFissProcCode();
procCode.setProcDate(LocalDate.EPOCH);
procCode.setPriority((short) i);
procCode.setProcCode(procCodes.get(i));
return procCode;
}).collect(Collectors.toSet());
entity.setProcCodes(procedures);
Claim claim = FissClaimTransformerV2.transform(new MetricRegistry(), entity);
R4ClaimSamhsaMatcher matcher = new R4ClaimSamhsaMatcher();
assertEquals(expectedResult, matcher.test(claim), testName + " " + errorMessagePostFix);
}
use of gov.cms.bfd.model.rda.PreAdjFissClaim in project beneficiary-fhir-data by CMSgov.
the class FissClaimResponseTransformerV2 method getContainedPatient.
private static Resource getContainedPatient(PreAdjFissClaim claimGroup) {
Optional<PreAdjFissPayer> optional = claimGroup.getPayers().stream().filter(p -> p.getPayerType() == PreAdjFissPayer.PayerType.BeneZ).findFirst();
Patient patient;
if (optional.isPresent()) {
PreAdjFissPayer benePayer = optional.get();
patient = getContainedPatient(claimGroup.getMbi(), new PatientInfo(benePayer.getBeneFirstName(), benePayer.getBeneLastName(), ifNotNull(benePayer.getBeneMidInit(), s -> s.charAt(0) + "."), benePayer.getBeneDob(), benePayer.getBeneSex()));
} else {
patient = getContainedPatient(claimGroup.getMbi(), null);
}
return patient;
}
use of gov.cms.bfd.model.rda.PreAdjFissClaim in project beneficiary-fhir-data by CMSgov.
the class FissClaimTransformerV2 method getContainedPatient.
private static Resource getContainedPatient(PreAdjFissClaim claimGroup) {
Optional<PreAdjFissPayer> optional = claimGroup.getPayers().stream().filter(p -> p.getPayerType() == PreAdjFissPayer.PayerType.BeneZ).findFirst();
Patient patient;
if (optional.isPresent()) {
PreAdjFissPayer benePayer = optional.get();
patient = getContainedPatient(claimGroup.getMbi(), new PatientInfo(benePayer.getBeneFirstName(), benePayer.getBeneLastName(), ifNotNull(benePayer.getBeneMidInit(), s -> s.charAt(0) + "."), benePayer.getBeneDob(), benePayer.getBeneSex()));
} else {
patient = getContainedPatient(claimGroup.getMbi(), null);
}
return patient;
}
use of gov.cms.bfd.model.rda.PreAdjFissClaim in project beneficiary-fhir-data by CMSgov.
the class FissClaimTransformer method transformMessageImpl.
private PreAdjFissClaim transformMessageImpl(FissClaim from, DataTransformer transformer, Instant now, String namePrefix) {
final PreAdjFissClaim to = new PreAdjFissClaim();
transformer.copyString(namePrefix + PreAdjFissClaim.Fields.dcn, false, 1, 23, from.getDcn(), to::setDcn);
transformer.copyString(namePrefix + PreAdjFissClaim.Fields.hicNo, false, 1, 12, from.getHicNo(), to::setHicNo);
transformer.copyEnumAsCharacter(namePrefix + PreAdjFissClaim.Fields.currStatus, PreAdjFissClaim_currStatus_Extractor.getEnumString(from), to::setCurrStatus);
transformer.copyEnumAsCharacter(namePrefix + PreAdjFissClaim.Fields.currLoc1, PreAdjFissClaim_currLoc1_Extractor.getEnumString(from), to::setCurrLoc1);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.currLoc2, false, 5, PreAdjFissClaim_currLoc2_Extractor.getEnumString(from), to::setCurrLoc2);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.medaProvId, 1, 13, from::hasMedaProvId, from::getMedaProvId, to::setMedaProvId);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.medaProv_6, 1, 6, from::hasMedaProv6, from::getMedaProv6, to::setMedaProv_6);
transformer.copyOptionalAmount(namePrefix + PreAdjFissClaim.Fields.totalChargeAmount, from::hasTotalChargeAmount, from::getTotalChargeAmount, to::setTotalChargeAmount);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.receivedDate, from::hasRecdDtCymd, from::getRecdDtCymd, to::setReceivedDate);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.currTranDate, from::hasCurrTranDtCymd, from::getCurrTranDtCymd, to::setCurrTranDate);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.admitDiagCode, 1, 7, from::hasAdmDiagCode, from::getAdmDiagCode, to::setAdmitDiagCode);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.principleDiag, 1, 7, from::hasPrincipleDiag, from::getPrincipleDiag, to::setPrincipleDiag);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.npiNumber, 1, 10, from::hasNpiNumber, from::getNpiNumber, to::setNpiNumber);
if (from.hasMbi()) {
final var mbi = from.getMbi();
if (transformer.validateString(namePrefix + PreAdjFissClaim.Fields.mbi, false, 1, 11, mbi)) {
to.setMbiRecord(mbiCache.lookupMbi(mbi));
}
}
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.fedTaxNumber, 1, 10, from::hasFedTaxNb, from::getFedTaxNb, to::setFedTaxNumber);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.pracLocAddr1, 1, 2147483647, from::hasPracLocAddr1, from::getPracLocAddr1, to::setPracLocAddr1);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.pracLocAddr2, 1, 2147483647, from::hasPracLocAddr2, from::getPracLocAddr2, to::setPracLocAddr2);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.pracLocCity, 1, 2147483647, from::hasPracLocCity, from::getPracLocCity, to::setPracLocCity);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.pracLocState, 1, 2, from::hasPracLocState, from::getPracLocState, to::setPracLocState);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.pracLocZip, 1, 15, from::hasPracLocZip, from::getPracLocZip, to::setPracLocZip);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.stmtCovFromDate, from::hasStmtCovFromCymd, from::getStmtCovFromCymd, to::setStmtCovFromDate);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.stmtCovToDate, from::hasStmtCovToCymd, from::getStmtCovToCymd, to::setStmtCovToDate);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.lobCd, true, 1, PreAdjFissClaim_lobCd_Extractor.getEnumString(from), to::setLobCd);
if (from.hasServTypeCdEnum()) {
to.setServTypeCdMapping(PreAdjFissClaim.ServTypeCdMapping.Normal);
}
if (from.hasServTypeCdForClinicsEnum()) {
to.setServTypeCdMapping(PreAdjFissClaim.ServTypeCdMapping.Clinic);
}
if (from.hasServTypeCdForSpecialFacilitiesEnum()) {
to.setServTypeCdMapping(PreAdjFissClaim.ServTypeCdMapping.SpecialFacility);
}
if (from.hasServTypCdUnrecognized()) {
to.setServTypeCdMapping(PreAdjFissClaim.ServTypeCdMapping.Unrecognized);
}
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.servTypeCd, true, 1, PreAdjFissClaim_servTypeCd_Extractor.getEnumString(from), to::setServTypeCd);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.servTypeCd, true, 1, PreAdjFissClaim_servTypeCdForClinics_Extractor.getEnumString(from), to::setServTypeCd);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.servTypeCd, true, 1, PreAdjFissClaim_servTypeCdForSpecialFacilities_Extractor.getEnumString(from), to::setServTypeCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.servTypeCd, 1, 1, from::hasServTypCdUnrecognized, from::getServTypCdUnrecognized, to::setServTypeCd);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.freqCd, true, 1, PreAdjFissClaim_freqCd_Extractor.getEnumString(from), to::setFreqCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.billTypCd, 1, 3, from::hasBillTypCd, from::getBillTypCd, to::setBillTypCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.rejectCd, 1, 5, from::hasRejectCd, from::getRejectCd, to::setRejectCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.fullPartDenInd, 1, 1, from::hasFullPartDenInd, from::getFullPartDenInd, to::setFullPartDenInd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.nonPayInd, 1, 2, from::hasNonPayInd, from::getNonPayInd, to::setNonPayInd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.xrefDcnNbr, 1, 23, from::hasXrefDcnNbr, from::getXrefDcnNbr, to::setXrefDcnNbr);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.adjReqCd, true, 1, PreAdjFissClaim_adjReqCd_Extractor.getEnumString(from), to::setAdjReqCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.adjReasCd, 1, 2, from::hasAdjReasCd, from::getAdjReasCd, to::setAdjReasCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.cancelXrefDcn, 1, 23, from::hasCancelXrefDcn, from::getCancelXrefDcn, to::setCancelXrefDcn);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.cancelDate, from::hasCancelDateCymd, from::getCancelDateCymd, to::setCancelDate);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.cancAdjCd, true, 1, PreAdjFissClaim_cancAdjCd_Extractor.getEnumString(from), to::setCancAdjCd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.originalXrefDcn, 1, 23, from::hasOriginalXrefDcn, from::getOriginalXrefDcn, to::setOriginalXrefDcn);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.paidDt, from::hasPaidDtCymd, from::getPaidDtCymd, to::setPaidDt);
transformer.copyOptionalDate(namePrefix + PreAdjFissClaim.Fields.admDate, from::hasAdmDateCymd, from::getAdmDateCymd, to::setAdmDate);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.admSource, true, 1, PreAdjFissClaim_admSource_Extractor.getEnumString(from), to::setAdmSource);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.primaryPayerCode, true, 1, PreAdjFissClaim_primaryPayerCode_Extractor.getEnumString(from), to::setPrimaryPayerCode);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.attendPhysId, 1, 16, from::hasAttendPhysId, from::getAttendPhysId, to::setAttendPhysId);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.attendPhysLname, 1, 17, from::hasAttendPhysLname, from::getAttendPhysLname, to::setAttendPhysLname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.attendPhysFname, 1, 18, from::hasAttendPhysFname, from::getAttendPhysFname, to::setAttendPhysFname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.attendPhysMint, 1, 1, from::hasAttendPhysMint, from::getAttendPhysMint, to::setAttendPhysMint);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.attendPhysFlag, true, 1, PreAdjFissClaim_attendPhysFlag_Extractor.getEnumString(from), to::setAttendPhysFlag);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.operatingPhysId, 1, 16, from::hasOperatingPhysId, from::getOperatingPhysId, to::setOperatingPhysId);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.operPhysLname, 1, 17, from::hasOperPhysLname, from::getOperPhysLname, to::setOperPhysLname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.operPhysFname, 1, 18, from::hasOperPhysFname, from::getOperPhysFname, to::setOperPhysFname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.operPhysMint, 1, 1, from::hasOperPhysMint, from::getOperPhysMint, to::setOperPhysMint);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.operPhysFlag, true, 1, PreAdjFissClaim_operPhysFlag_Extractor.getEnumString(from), to::setOperPhysFlag);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.othPhysId, 1, 16, from::hasOthPhysId, from::getOthPhysId, to::setOthPhysId);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.othPhysLname, 1, 17, from::hasOthPhysLname, from::getOthPhysLname, to::setOthPhysLname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.othPhysFname, 1, 18, from::hasOthPhysFname, from::getOthPhysFname, to::setOthPhysFname);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.othPhysMint, 1, 1, from::hasOthPhysMint, from::getOthPhysMint, to::setOthPhysMint);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.othPhysFlag, true, 1, PreAdjFissClaim_othPhysFlag_Extractor.getEnumString(from), to::setOthPhysFlag);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.xrefHicNbr, 1, 12, from::hasXrefHicNbr, from::getXrefHicNbr, to::setXrefHicNbr);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.procNewHicInd, true, 1, PreAdjFissClaim_procNewHicInd_Extractor.getEnumString(from), to::setProcNewHicInd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.newHic, 1, 12, from::hasNewHic, from::getNewHic, to::setNewHic);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.reposInd, true, 1, PreAdjFissClaim_reposInd_Extractor.getEnumString(from), to::setReposInd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.reposHic, 1, 12, from::hasReposHic, from::getReposHic, to::setReposHic);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.mbiSubmBeneInd, true, 1, PreAdjFissClaim_mbiSubmBeneInd_Extractor.getEnumString(from), to::setMbiSubmBeneInd);
transformer.copyEnumAsString(namePrefix + PreAdjFissClaim.Fields.adjMbiInd, true, 1, PreAdjFissClaim_adjMbiInd_Extractor.getEnumString(from), to::setAdjMbiInd);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.adjMbi, 1, 11, from::hasAdjMbi, from::getAdjMbi, to::setAdjMbi);
transformer.copyOptionalString(namePrefix + PreAdjFissClaim.Fields.medicalRecordNo, 1, 17, from::hasMedicalRecordNo, from::getMedicalRecordNo, to::setMedicalRecordNo);
to.setLastUpdated(now);
return to;
}
use of gov.cms.bfd.model.rda.PreAdjFissClaim in project beneficiary-fhir-data by CMSgov.
the class FissClaimRdaSinkIT method fissClaim.
@Test
public void fissClaim() throws Exception {
RdaPipelineTestUtils.runTestWithTemporaryDb(FissClaimRdaSinkIT.class, Clock.systemUTC(), (appState, entityManager) -> {
final LocalDate today = LocalDate.of(2022, 1, 3);
final Instant now = today.atStartOfDay().toInstant(ZoneOffset.UTC);
final Clock clock = Clock.fixed(now, ZoneOffset.UTC);
final PreAdjFissClaim claim = new PreAdjFissClaim();
claim.setSequenceNumber(3L);
claim.setDcn("1");
claim.setHicNo("h1");
claim.setCurrStatus('T');
claim.setCurrLoc1('A');
claim.setCurrLoc2("1A");
claim.setPracLocCity("city name can be very long indeed");
claim.setMbiRecord(new Mbi(1L, "12345678901", "hash-of-12345678901"));
final PreAdjFissProcCode procCode0 = new PreAdjFissProcCode();
procCode0.setDcn(claim.getDcn());
procCode0.setPriority((short) 0);
procCode0.setProcCode("P");
procCode0.setProcFlag("F");
procCode0.setProcDate(today);
claim.getProcCodes().add(procCode0);
final PreAdjFissDiagnosisCode diagCode0 = new PreAdjFissDiagnosisCode();
diagCode0.setDcn(claim.getDcn());
diagCode0.setPriority((short) 0);
diagCode0.setDiagCd2("cd2");
diagCode0.setDiagPoaInd("Q");
claim.getDiagCodes().add(diagCode0);
final FissProcedureCode procCodeMessage = FissProcedureCode.newBuilder().setProcCd("P").setProcFlag("F").setProcDt("2022-01-03").build();
final FissDiagnosisCode diagCodeMessage = FissDiagnosisCode.newBuilder().setDiagCd2("cd2").setDiagPoaIndUnrecognized("Q").build();
final FissClaim claimMessage = FissClaim.newBuilder().setDcn(claim.getDcn()).setHicNo(claim.getHicNo()).setCurrStatusEnum(FissClaimStatus.CLAIM_STATUS_RTP).setCurrLoc1Unrecognized(String.valueOf(claim.getCurrLoc1())).setCurrLoc2Unrecognized(claim.getCurrLoc2()).setPracLocCity("city name can be very long indeed").addFissProcCodes(0, procCodeMessage).addFissDiagCodes(0, diagCodeMessage).setMbi(claim.getMbi()).build();
final FissClaimChange message = FissClaimChange.newBuilder().setSeq(claim.getSequenceNumber()).setDcn(claim.getDcn()).setClaim(claimMessage).build();
final IdHasher defaultIdHasher = new IdHasher(new IdHasher.Config(1, "notarealpepper"));
final FissClaimTransformer transformer = new FissClaimTransformer(clock, MbiCache.computedCache(defaultIdHasher.getConfig()));
final FissClaimRdaSink sink = new FissClaimRdaSink(appState, transformer, true);
final String expectedMbiHash = defaultIdHasher.computeIdentifierHash(claim.getMbi());
assertEquals(Optional.empty(), sink.readMaxExistingSequenceNumber());
int count = sink.writeMessage("version", message);
assertEquals(1, count);
List<PreAdjFissClaim> claims = entityManager.createQuery("select c from PreAdjFissClaim c", PreAdjFissClaim.class).getResultList();
assertEquals(1, claims.size());
PreAdjFissClaim resultClaim = claims.get(0);
assertEquals(Long.valueOf(3), resultClaim.getSequenceNumber());
assertEquals(claim.getHicNo(), resultClaim.getHicNo());
assertEquals(claim.getPracLocCity(), resultClaim.getPracLocCity());
assertEquals(claim.getMbi(), resultClaim.getMbi());
assertEquals(expectedMbiHash, resultClaim.getMbiHash());
assertEquals(claim.getProcCodes().size(), resultClaim.getProcCodes().size());
assertEquals(claim.getDiagCodes().size(), resultClaim.getDiagCodes().size());
assertEquals(Optional.of(claim.getSequenceNumber()), sink.readMaxExistingSequenceNumber());
Mbi databaseMbiEntity = RdaPipelineTestUtils.lookupCachedMbi(entityManager, claimMessage.getMbi());
assertNotNull(databaseMbiEntity);
assertEquals(claim.getMbi(), databaseMbiEntity.getMbi());
assertEquals(expectedMbiHash, databaseMbiEntity.getHash());
});
}
Aggregations