def is_there_ocl_code_on_same_trip(code1: str) -> Predicate[ClaimLineFocus]:
    return Predicate(
        "Does the claim have a different claim line with a procedure code " +
        code1 +
        " with a matching date of service from AND matching modifiers (any combination, all for modifier fields)?",
        lambda clf: any(ocl for ocl in other_lines(clf)
                        if code(ocl) == code1 and is_same_trip(clf, ocl)),
    )
コード例 #2
0
def node1400() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "1400",
        Predicate(
            "Does the claim line have a Modifer (in any modifier position) equal to ET?",
            lambda clf: "ET" in modifiers(clf.claim_line)),
        node1600(),
        node1700(),
    )
コード例 #3
0
def node1100() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "1100",
        Predicate(
            "Does the claim line have a procedure code in the Extra Attendant Code List?",
            lambda clf: code(clf) == extra_attendant_code),
        node1400(),
        node1500(),
    )
コード例 #4
0
def node800() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "800",
        Predicate(
            "Does the claim line have a procedure code in the Oxygen Supplies Code List?",
            lambda clf: code(clf) == oxygen_supplies_code),
        node1000(),
        node1100(),
    )
コード例 #5
0
def node600() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "600",
        Predicate(
            "Does the claim line have a procedure code in the Disposable Supplies Code List?",
            lambda cl: code(cl) in disposable_supplies_code_list),
        node700(),
        node800(),
    )
コード例 #6
0
def node500() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "500",
        Predicate("Does the claim line have the procedure code 92950?",
                  lambda cl: code(cl) == "92950"),
        insight_deny_claim_line(
            "Cardiopulmonary Resuscitation (CPR) is not separately payable and is included in ambulance transport fees"
        ),
        node600(),
    )
コード例 #7
0
def node400() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "400",
        Predicate(
            "Does the claim line have a valid CMS-1500 Place of Service Code?",
            has_valid_pos),
        node500(),
        insight_deny_claim(
            "Invalid Place of Service for claim type CMS-1500 (paper claim)"),
    )
コード例 #8
0
def node1500() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "1500",
        Predicate(
            "Do all claim lines include modifier code = ET?", lambda clf: all([
                "ET" in modifiers(acl.claim_line)
                for acl in all_lines(clf.request)
            ])),
        node1800(),
        node1900(),
    )
def is_there_ocl_code_in_codeset_on_same_trip(
        code_set: CodeSet) -> Predicate[ClaimLineFocus]:
    if len(code_set.codes) == 1:
        return is_there_ocl_code_on_same_trip(list(code_set.codes)[0])
    else:
        return Predicate(
            "Does the claim have a different claim line with a procedure code from "
            + code_set.name + " code list for the same trip?",
            lambda clf: any(ocl for ocl in other_lines(clf)
                            if code(ocl) in code_set.codes and is_same_trip(
                                clf, ocl)),
        )
コード例 #10
0
def node200() -> TreeNode[InsightEngineRequest, SimpleInsight]:
    return DecisionTreeNode[InsightEngineRequest, SimpleInsight](
        "200",
        Predicate(
            "codes(request) have intersection with ground_and_air_transport_code_set",
            lambda request: len(
                codes(request).intersection(ground_and_air_transport_code_set.
                                            codes)) > 0),
        node300(),
        insight_deny_claim(
            "TMHP does not reimburse ambulance claims if a valid transport code is not present on the claim (if a client has not been transported)"
        ),
    )
コード例 #11
0
def node700() -> TreeNode[ClaimLineFocus, SimpleInsight]:
    return DecisionTreeNode[ClaimLineFocus, SimpleInsight](
        "700",
        Predicate(
            "Does the claim have a different claim line with a procedure code A0434 with a matching date of service from AND matching modifiers (any combination, all for modifier fields)?",
            lambda clf: any([
                code(olf) == specialty_care_transport_code and is_same_trip(
                    clf, olf) for olf in other_lines(clf)
            ])),
        insight_deny_claim_line(
            "Disposable Supplies are not Separately Payable when used during Specialty Care Transport"
        ),
        node900(),
    )
コード例 #12
0
def does_cl_contain_value_in_information_segment_for_same_trip(
) -> Predicate[ClaimLineFocus]:
    def f(clf: ClaimLineFocus) -> bool:
        supportingInfo = claim(clf.request).supportingInfo
        return supportingInfo is not None and any(
            (cast(Period,
                  cast(ClaimSupportingInfo, si).timingPeriod).start == cast(
                      Period, clf.claim_line.servicedPeriod).start)
            and cast(ClaimSupportingInfo, si).valueString != ""
            for si in supportingInfo)

    return Predicate(
        "Does the claim line contain any value in the Information Segment for the Same Trip?",
        f,
    )
コード例 #13
0
def node300() -> TreeNode[InsightEngineRequest, SimpleInsight]:
    return DecisionTreeNode[InsightEngineRequest, SimpleInsight](
        "300",
        Predicate(
            "Does the claim have a valid Origin-Destination Modifier (in any modifier position) on every Claim Line?",
            lambda request: all([
                len([
                    m for m in modifiers(cl) if isOriginDestinationModifier(m)
                ]) > 0 for cl in claimLines(request)
            ])),
        stub("300:Yes"),
        insight_deny_claim(
            "TMHP does not reimburse ambulance claims if a valid origin-destination modifier is not present on every claim line"
        ),
    )
コード例 #14
0
def does_cl_have_units_less_than(amount: int) -> Predicate[ClaimLineFocus]:
    return Predicate("Does the claim line have units less than " + str(amount),
                     lambda clf: units(clf) < amount)
コード例 #15
0
def does_acl_code_have_units_greater(code1: str,
                                     amount: int) -> Predicate[ClaimLineFocus]:
    return Predicate(
        "Does the procedure code " + code1 + " have units greater than " +
        str(amount), lambda clf: units_of_code(clf.request, code1) > amount)
コード例 #16
0
def is_clf_code_equal_to(code1: str) -> Predicate[ClaimLineFocus]:
    return Predicate(
        "Does the claim line have procedure code = " + code1 + "?",
        lambda clf: code(clf) == code1)
コード例 #17
0
def is_clf_code_in_set(codeSet: CodeSet) -> Predicate[ClaimLineFocus]:
    return Predicate(
        "Does the claim line have a procedure code listed in the " +
        codeSet.name + " Code List?", lambda clf: code(clf) in codeSet.codes)
コード例 #18
0
from engine.dsl import *
from engine.tree_node import TreeNode
from engine.tree_node import DecisionTreeNode
from engine.tree_node import ResultTreeNode
from fhir.resources.claim import Claim, ClaimItem, ClaimInsurance, ClaimSupportingInfo
from fhir.resources.codeableconcept import CodeableConcept
from fhir.resources.coding import Coding
from fhir.resources.period import Period
from fhir.resources.address import Address
from fhir.resources.organization import Organization

from schema.insight_engine_response import InsightEngineResponse, Insight, Defense, MessageBundle, TranslatedMessage
from schema.insight_engine_request import InsightEngineRequest
import json

alwaysTrue = Predicate("true", bool_always(True))

units_gt_1 = Predicate[ClaimLineFocus](
    "Does the claim line have units greater than 1?",
    lambda clf: units(clf) > 1)

exist_other_line_with_ET_and_same_trip_origin_destination = Predicate[
    ClaimLineFocus](
        "Does at least one claim line include modifier code = ET for the same date start and origin-destination modifier?",
        lambda clf: any([
            "ET" in modifiers(ocl.claim_line) and
            is_same_trip_based_on_origin_destination(clf, ocl)
            for ocl in other_lines(clf)
        ]))

is_there_pan = Predicate[ClaimLineFocus](