Search in sources :

Example 6 with DiagnosisComponent

use of org.hl7.fhir.r4.model.Claim.DiagnosisComponent in project beneficiary-fhir-data by CMSgov.

the class DiagnosisUtilV2 method addDiagnosisCode.

/**
 * @param eob the {@link ExplanationOfBenefit} to (possibly) modify
 * @param diagnosis the {@link Diagnosis} to add, if it's not already present
 * @return the {@link DiagnosisComponent#getSequence()} of the existing or newly-added entry
 */
static int addDiagnosisCode(ExplanationOfBenefit eob, Diagnosis diagnosis, ClaimTypeV2 claimType) {
    // Filter out if the diagnosis is already contained in the document
    Optional<DiagnosisComponent> existingDiagnosis = eob.getDiagnosis().stream().filter(d -> d.getDiagnosis() instanceof CodeableConcept).filter(d -> containedIn(diagnosis, (CodeableConcept) d.getDiagnosis())).findAny();
    // If we already have a match, we are done
    if (existingDiagnosis.isPresent()) {
        return existingDiagnosis.get().getSequenceElement().getValue();
    }
    // Set diagnosisCodeableConcept
    DiagnosisComponent diagnosisComponent = new DiagnosisComponent().setSequence(eob.getDiagnosis().size() + 1);
    diagnosisComponent.setDiagnosis(toCodeableConcept(diagnosis));
    // Set Type
    diagnosisComponent.addType(translateLabels(diagnosis.getLabels(), claimType));
    if (diagnosis.getPresentOnAdmission().isPresent() && diagnosis.getPresentOnAdmissionCode().isPresent()) {
        diagnosisComponent.addExtension(TransformerUtilsV2.createExtensionCoding(eob, diagnosis.getPresentOnAdmissionCode().get(), diagnosis.getPresentOnAdmission()));
    }
    eob.getDiagnosis().add(diagnosisComponent);
    return diagnosisComponent.getSequenceElement().getValue();
}
Also used : IntStream(java.util.stream.IntStream) CcwCodebookInterface(gov.cms.bfd.model.codebook.model.CcwCodebookInterface) LoggerFactory(org.slf4j.LoggerFactory) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) HashMap(java.util.HashMap) C4BBClaimProfessionalAndNonClinicianDiagnosisType(gov.cms.bfd.server.war.commons.carin.C4BBClaimProfessionalAndNonClinicianDiagnosisType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.ItemComponent) ExDiagnosistype(org.hl7.fhir.r4.model.codesystems.ExDiagnosistype) CcwCodebookVariable(gov.cms.bfd.model.codebook.data.CcwCodebookVariable) Map(java.util.Map) Diagnosis(gov.cms.bfd.server.war.commons.Diagnosis) ReflectionUtils(gov.cms.bfd.server.war.commons.ReflectionUtils) Logger(org.slf4j.Logger) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) Set(java.util.Set) IOException(java.io.IOException) C4BBClaimInpatientInstitutionalDiagnosisType(gov.cms.bfd.server.war.commons.carin.C4BBClaimInpatientInstitutionalDiagnosisType) C4BBClaimOutpatientInstitutionalDiagnosisType(gov.cms.bfd.server.war.commons.carin.C4BBClaimOutpatientInstitutionalDiagnosisType) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) DiagnosisLabel(gov.cms.bfd.server.war.commons.Diagnosis.DiagnosisLabel) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) Coding(org.hl7.fhir.r4.model.Coding) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Optional(java.util.Optional) BufferedReader(java.io.BufferedReader) DiagnosisComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.DiagnosisComponent) InputStream(java.io.InputStream) DiagnosisComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.DiagnosisComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 7 with DiagnosisComponent

use of org.hl7.fhir.r4.model.Claim.DiagnosisComponent in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherR4FromClaimTransformerV2Test method verifySamhsaMatcherForDiagnosisIcd.

/**
 * Verify SAMHSA matcher for ICD item with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForDiagnosisIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codingList.add(new Coding().setSystem(system).setCode(code));
        codeableConcept.setCoding(codingList);
        diagnosisComponent.setPackageCode(null);
    }
    // Set procedure to empty so we dont check it for matches
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getProductOrService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcherV2.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 8 with DiagnosisComponent

use of org.hl7.fhir.r4.model.Claim.DiagnosisComponent in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherR4FromClaimTransformerV2Test method verifySamhsaMatcherForProcedureIcd.

/**
 * Verify SAMHSA matcher for ICD item with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForProcedureIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis to empty so we dont check it for matches
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codeableConcept.setCoding(codingList);
        diagnosisComponent.setPackageCode(null);
    }
    // Set procedure
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codingList.add(new Coding().setSystem(system).setCode(code));
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getProductOrService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcherV2.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 9 with DiagnosisComponent

use of org.hl7.fhir.r4.model.Claim.DiagnosisComponent in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherFromClaimTransformerTest method verifySamhsaMatcherForProcedureIcd.

/**
 * Verify SAMHSA matcher for ICD item with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForProcedureIcd(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis to empty so we dont check it for matches
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        CodeableConcept codeableConcept = diagnosisComponent.getDiagnosisCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        if (codeableConcept != null) {
            codeableConcept.setCoding(codingList);
            diagnosisComponent.setPackageCode(null);
        }
    }
    // Set procedure
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codingList.add(new Coding().setSystem(system).setCode(code));
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcher.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 10 with DiagnosisComponent

use of org.hl7.fhir.r4.model.Claim.DiagnosisComponent in project beneficiary-fhir-data by CMSgov.

the class SamhsaMatcherFromClaimTransformerTest method verifySamhsaMatcherForDiagnosisPackage.

/**
 * Verify SAMHSA matcher for package with the given system, code and if the expectation is that
 * there should be a match for this combination.
 *
 * @param system the system value
 * @param code the code
 * @param shouldMatch if the matcher should match on this combination
 */
private void verifySamhsaMatcherForDiagnosisPackage(String system, String code, boolean shouldMatch, ExplanationOfBenefit explanationOfBenefit) {
    ExplanationOfBenefit modifiedEob = explanationOfBenefit.copy();
    // Set diagnosis DRG
    for (ExplanationOfBenefit.DiagnosisComponent diagnosisComponent : modifiedEob.getDiagnosis()) {
        if (diagnosisComponent.getDiagnosisCodeableConcept() != null) {
            diagnosisComponent.getDiagnosisCodeableConcept().setCoding(new ArrayList<>());
        }
        CodeableConcept codeableConcept = new CodeableConcept();
        Coding coding = new Coding(system, code, null);
        codeableConcept.setCoding(Collections.singletonList(coding));
        diagnosisComponent.setPackageCode(codeableConcept);
    }
    // Set procedure to empty so we dont check it for matches
    for (ExplanationOfBenefit.ProcedureComponent diagnosisComponent : modifiedEob.getProcedure()) {
        CodeableConcept codeableConcept = diagnosisComponent.getProcedureCodeableConcept();
        ArrayList<Coding> codingList = new ArrayList<>();
        codeableConcept.setCoding(codingList);
    }
    // Set item coding to non-SAMHSA so we dont check it for matches
    List<Coding> codings = new ArrayList<>();
    Coding coding = new Coding();
    coding.setSystem(TransformerConstants.CODING_SYSTEM_HCPCS);
    coding.setCode(NON_SAMHSA_HCPCS_CODE);
    codings.add(coding);
    modifiedEob.getItem().get(0).getService().setCoding(codings);
    assertEquals(shouldMatch, samhsaMatcher.test(modifiedEob));
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) ArrayList(java.util.ArrayList) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

ArrayList (java.util.ArrayList)15 Coding (org.hl7.fhir.r4.model.Coding)14 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)9 Coding (org.hl7.fhir.dstu3.model.Coding)8 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)8 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)8 ExplanationOfBenefit (org.hl7.fhir.r4.model.ExplanationOfBenefit)8 DiagnosisComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.DiagnosisComponent)8 Test (org.junit.jupiter.api.Test)7 Reference (org.hl7.fhir.dstu3.model.Reference)4 Claim (org.mitre.synthea.world.concepts.Claim)4 DateType (org.hl7.fhir.dstu3.model.DateType)3 Money (org.hl7.fhir.dstu3.model.Money)3 Period (org.hl7.fhir.dstu3.model.Period)3 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)2 CcwCodebookInterface (gov.cms.bfd.model.codebook.model.CcwCodebookInterface)2 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)2 DiagnosisLabel (gov.cms.bfd.server.war.commons.Diagnosis.DiagnosisLabel)2 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)2 BufferedReader (java.io.BufferedReader)2