Knockout - 根据选择菜单将子json加载为复选框

时间:2016-06-23 20:27:02

标签: jquery json knockout.js

我正在尝试根据用户在选择菜单中选择的内容加载子对象作为复选框。有人可以解释我做错了吗?

选择菜单按预期工作,但未加载复选框。

以下是我尝试做的一个例子: https://jsfiddle.net/mujaji/Lsa5mgb2/3/

的Javascript

function DefectTypeVM(defectTypeItems) {
var self = this;

self.defecttypes = ko.observableArray(defectTypeItems);
self.selectedTriage = ko.observable();
self.selectedActions = ko.observable();
self.selectedDefectType = ko.observable("1");
self.selectedSubCategory = ko.observable("08");

function getById(defectTypeItems, value) {
    if(!value) {
        return [];
    }

    var result = ko.utils.arrayFirst(defectTypeItems, function(item) {
        return item.value === value;
        return item.triage === triage;
        return item.actions === actions;
    });

    return result && result.childItems || [];
}

self.defectsubcategory = ko.computed(function(){
    var defectTypeItems = self.defecttypes();
    var id = self.selectedDefectType()
    return getById(defectTypeItems, id);
}, self);

}

var defectTypeItems = [

{text: "Denial", value: "1", triage: [], actions: [], childItems: [
    {text: 'Authorization', value: '01', triage: [
        {text: 'Check Applicable Systems to Verify if Auth Info was Obtained for All Services Provided', value: '01'},
        {text: 'Verify Auth is on Claim', value: '02'},
        {text: 'Verify Auth is Required for Service(s)', value: '03'},
        {text: 'Verify Auth Obtained for Diff Proc/Service/CPT/PT', value: '04'},
        {text: 'Verify Auth Obtained for Incorrect Dates of Services', value: '05'}
    ], actions: [
        {text: 'Initiated Handoff', value: '01'},
        {text: 'Obtained Retro-Auth', value: '02'},
        {text: 'Called Payer to Resolve Auth Denial', value: '03'},
        {text: 'Applied Contractual/Adjustment', value: '04'},
        {text: 'Rebilled Claim with Added Auth #', value: '05'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '06'},
        {text: 'Referred Encounter to Denials Team', value: '07'},
        {text: 'Referred to Other Dept to Resolve Claim', value: '08'},
        {text: 'Confirmed Payment is Promised', value: '09'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '10'},
        {text: 'Submitted Appeal', value: '11'},
        {text: 'Submitted Write-Off Request', value: '12'},
        {text: 'Other Action', value: '13'}
]},
    {text: 'Benefits Exhausted', value: '02', triage: [
        {text: 'Check Applicable Systems to Verify Auth Info was Obtained for All Services Provided', value: '001'},
        {text: 'Verify Benefits are Exhausted in Application Systems', value: '002'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Applied Contractual/Adjustment', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Flipped Bal to Next Payer', value: '0015'},
        {text: 'Updated Financial Class and Rebill in Host', value: '0016'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0017'},
        {text: 'Referred Encounter to Denials Team', value: '0018'},
        {text: 'Referred to Other Dept to Resolve Claim', value: '0019'},
        {text: 'Sent to Coding for Review', value: '0020'},
        {text: 'Sent Medical Records to Payer', value: '0021'},
        {text: 'Confirmed Payment is Promised', value: '0022'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0023'},
        {text: 'Submitted Appeal', value: '0024'},
        {text: 'Submitted Write-Off Request', value: '0025'},
        {text: 'Other Action', value: '0026'}
]},
    {text: 'Technical Claim', value: '03', triage: [
        {text: 'Verify Dates of Service', value: '001'},
        {text: 'Verify Incorrect Bill Type Billed', value: '002'},
        {text: 'Verify Primary EOB Info is Correct', value: '003'},
        {text: 'Verify Provider Number', value: '004'},
        {text: 'Verify Other Bill Info', value: '005'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Billing Denial', value: '0013'},
        {text: 'Applied Contractual/Adjustment', value: '0014'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Referred Encounter to Denials Team', value: '0017'},
        {text: 'Referred to Other Dept for Review', value: '0018'},
        {text: 'Sent to Coding for Review', value: '0019'},
        {text: 'Confirmed Claim is Still Pending with Payer', value: '0020'},
        {text: 'Confirmed Payment is Promised', value: '0021'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0022'},
        {text: 'Submitted Appeal', value: '0023'},
        {text: 'Submitted Write-Off Request', value: '0024'},
        {text: 'Other Action', value: '0024'}
]},
    {text: 'Clinical Non-Covered', value: '04', triage: [
        {text: 'Verify Charge(s) in Question', value: '001'},
        {text: 'Verify if Denial is Benefits Related (Member Policy Issue)', value: '002'},
        {text: 'Verify if Denial is Related to Services Provided', value: '003'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Billing Denial', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Submitted Request for Medical Records', value: '0016'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0017'},
        {text: 'Provided Additional Information to Payer', value: '0018'},
        {text: 'Referred Encounter to Denials Team', value: '0019'},
        {text: 'Referred to Other Dept for Review', value: '0020'},
        {text: 'Sent to Coding for Review', value: '0021'},
        {text: 'Confirmed Payment is Promised', value: '0022'},
        {text: 'Submitted Write-Off Request', value: '0023'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0024'},
        {text: 'Submitted Appeal', value: '0025'},
        {text: 'Submitted Write-Off Request', value: '0026'},
        {text: 'Other Action', value: '0027'}
]},
    {text: 'Coding', value: '04', triage: [
        {text: 'Verify Claim Submitted Correctly', value: '001'},
        {text: 'Verify Coding Information in Question', value: '002'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Verify Coding Info in Question', value: '0013'},
        {text: 'Applied Contractual/Adjustment', value: '0014'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Referred Encounter to Denials Team', value: '0017'},
        {text: 'Referred to Other Dept to Review', value: '0018'},
        {text: 'Sent to Coding for Review', value: '0019'},
        {text: 'Confirmed Payment is Promised', value: '0020'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0021'},
        {text: 'Submitted Appeal', value: '0022'},
        {text: 'Submitted Write-Off Request', value: '0023'},
        {text: 'Other Action', value: '0024'}
]},
    {text: 'Coordination of Benefits', value: '05', triage: [
        {text: 'Check Recent Accounts for Payment/Other Coverage', value: '001'},
        {text: 'Review Patient Coverage via Applicable System and Identify if Patient Has Other Coverage', value: '002'},
        {text: 'Verify COB Order is Correct', value: '003'},
        {text: 'Verify if Auto or WC Related', value: '004'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Verify COB Issue', value: '0012'},
        {text: 'Called Payer to Resolve', value: '0013'},
        {text: 'Sent Letter to Patient', value: '0014'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0015'},
        {text: 'Applied Contractual/Adjustment', value: '0016'},
        {text: 'Updated COB and Rebilled Claim', value: '0017'},
        {text: 'Contacted Payer to Resolve COB Denial', value: '0018'},
        {text: 'Referred Encounter to Denials Team', value: '0019'},
        {text: 'Confirmed Payment is Promised', value: '0020'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0021'},
        {text: 'Submitted Appeal', value: '0022'},
        {text: 'Submitted Write-Off Request', value: '0023'},
        {text: 'Other Action', value: '0024'}
]},
    {text: 'Duplicate', value: '06', triage: [
        {text: 'Confirm Claim is a Duplicate', value: '001'},
        {text: 'Review for Encounters with Same Dates of Service', value: '002'},
        {text: 'Verify Bill Type', value: '003'},
        {text: 'Verify Claim Billed with Correct ICN', value: '004'}
    ], actions: [
        {text: 'Combined Encounters', value: '001'},
        {text: 'Cancelled Previous Claim(s)', value: '002'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '003'},
        {text: 'Applied Contractual/Adjustment', value: '004'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '005'},
        {text: 'Referred to Other Dept to Review', value: '006'},
        {text: 'Other Action', value: '007'}
]},
    {text: 'Eligibility', value: '07', triage: [
        {text: 'Check Related Visits', value: '001'},
        {text: 'Review Patient Coverage via Applicable System and Identify if Patient Has Other Coverage', value: '002'},
        {text: 'Verify Insurance/Patient Name/Subscriber is Accurate', value: '003'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Eligibility Denial', value: '0013'},
        {text: 'Updated Insurance Info', value: '0014'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0015'},
        {text: 'Applied Contractual/Adjustment', value: '0016'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0017'},
        {text: 'Referred Encounter to Denials Team', value: '0018'},
        {text: 'Confirmed Payment is Promised', value: '0019'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0020'},
        {text: 'Submitted Appeal', value: '0021'},
        {text: 'Submitted Write-Off Request', value: '0022'},
        {text: 'Other Action', value: '0023'}
    ]},
    {text: 'Lacks Information/Med Records', value: '08', triage: [
        {text: 'Verify Info Needed from Payer', value: '001'},
        {text: 'Verify Whether Information has Previously Been Provided', value: '002'},
        {text: 'Verify Insurance/Patient Name/Subscriber is Accurate', value: '003'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Missing Info', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Submitted Request for Medical Records', value: '0016'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0017'},
        {text: 'Itemized Statement Sent to Payer', value: '0018'},
        {text: 'Sent Letter to Patient', value: '0019'},
        {text: 'Sent Medical Records to Payer', value: '0020'},
        {text: 'Referred Encounter to Denials Team', value: '0021'},
        {text: 'Referred to Other Dept to Review', value: '0022'},
        {text: 'Confirmed Payment is Promised', value: '0023'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0024'},
        {text: 'Submitted Appeal', value: '0025'},
        {text: 'Submitted Other Form', value: '0026'},
        {text: 'Submitted Write-Off Request', value: '0027'},
        {text: 'Other Action', value: '0028'}
    ]},
    {text: 'Payer', value: '09', triage: [
        {text: 'Verfiy With Payer for Additional Information', value: '001'},
        {text: 'Verify Claim Billed With Correct Facility NPI', value: '002'},
        {text: 'Verify Payer is Contracted with Rendering Facility', value: '003'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Claim', value: '0013'},
        {text: 'Contacted Payer to Resolve Claim', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Referred Encounter to Contract Management', value: '0017'},
        {text: 'Referred Encounter to Denials Team', value: '0018'},
        {text: 'Referred to Other Dept to Resolve Claim', value: '0019'},
        {text: 'Sent to Coding for Review', value: '0020'},
        {text: 'Confirmed Payment is Promised', value: '0021'},
        {text: 'Submitted Write-Off Request', value: '0022'},
        {text: 'Other Action', value: '0023'}
    ]},
    {text: 'Provider', value: '10', triage: [
        {text: 'Verify Claim Submitted Correctly', value: '001'},
        {text: 'Verify Correct NPI in Applicable Systems', value: '002'},
        {text: 'Verify Provider is Credentialed with Payer', value: '003'},
        {text: 'Verify with Payer Info Needed to Resolve', value: '004'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Credentialing Issue', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Referred Encounter to Denials Team', value: '0017'},
        {text: 'Referred to Other Dept to Resolve Claim', value: '0018'},
        {text: 'Confirmed Payment is Promised', value: '0019'},
        {text: 'Submitted Write-Off Request', value: '0020'},
        {text: 'Other Action', value: '0021'}
    ]},
    {text: 'Technical Non-Covered', value: '11', triage: [
        {text: 'Verify Charge(s) in Question', value: '001'},
        {text: 'Verify if Denial is Benefits Related (Member Policy Issue)', value: '002'},
        {text: 'Verify if Denial is Related to Services Provided', value: '003'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Identify/Discuss Reasoning for Non-Covered Item', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Provided Additional Information to Payer', value: '0017'},
        {text: 'Submitted Request for Medical Records', value: '0018'},
        {text: 'Referred Encounter to Denials Team', value: '0019'},
        {text: 'Referred to Other Dept for Review', value: '0020'},
        {text: 'Sent to Coding for Review', value: '0021'},
        {text: 'Confirmed Payment is Promised', value: '0022'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0023'},
        {text: 'Submitted Appeal', value: '0024'},
        {text: 'Submitted Write-Off Request', value: '0025'},
        {text: 'Other Action', value: '0026'}
    ]},
    {text: 'Timely Filing', value: '12', triage: [
        {text: 'Verify Appeal/Documentation Submitted within Filing Limits', value: '001'},
        {text: 'Verify Claim Submitted within Filing Limits', value: '002'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve/Prove Filing Limit Met', value: '0013'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0014'},
        {text: 'Applied Contractual/Adjustment', value: '0015'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0016'},
        {text: 'Referred Encounter to Denials Team', value: '0019'},
        {text: 'Confirmed Payment is Promised', value: '0022'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0023'},
        {text: 'Submitted Appeal', value: '0024'},
        {text: 'Submitted Write-Off Request', value: '0025'},
        {text: 'Other Action', value: '0026'}
    ]},
    {text: 'Clinical Medical Necessity', value: '13', triage: [
        {text: 'Review Charge(s) in Question', value: '001'},
        {text: 'Verify With Payer to Determine Root Cause', value: '002'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Called Patient to Resolve', value: '0012'},
        {text: 'Called Payer to Resolve Claim', value: '0013'},
        {text: 'Applied Contractual/Adjustment', value: '0014'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value: '0015'},
        {text: 'Submitted Request for Medical Records', value: '0016'},
        {text: 'Made Corrections to Claim(s) and Resubmitted', value: '0017'},
        {text: 'Provided Requested Info to Payer', value: '0018'},
        {text: 'Referred Encounter to Appropriate Dept for Review', value: '0019'},
        {text: 'Referred Encounter to Denials Team', value: '0020'},
        {text: 'Sent to Coding for Review', value: '0021'},
        {text: 'Confirmed Payment is Promised', value: '0022'},
        {text: 'Confirmed Appeal is Still Pending with Payer', value: '0023'},
        {text: 'Submitted Appeal', value: '0024'},
        {text: 'Submitted Write-Off Request', value: '0025'},
        {text: 'Other Action', value: '0026'}
    ]},
    {text: 'Skilled Nursing Facility', value: '14', triage: [
        {text: 'Confirm SNF Denial', value: '001'}
    ], actions: [
        {text: 'Initiated Handoff', value: '0011'},
        {text: 'Rebilled SNF Facility', value: '0012'},
        {text: 'Called SNF Facility', value: '0013'},
        {text: 'Confirmed Payment is Promised', value: '0014'},
        {text: 'Other Action', value: '0015'}
    ]}
]},
{text: "Credit Defect", value: "3", triage: [], actions: [], childItems: [
    {text: 'Credit', value: '01', triage: [
        {text: 'Review All Charges/Corrections', value: '01'},
        {text: 'Review EOB for Duplicate Payments', value: '02'},
        {text: 'Review EOR for Contractual Errors', value: '03'},
        {text: 'Verify to Whom Refund Needs to be Applied', value: '04'}
    ], actions: [
        {text: 'Called Patient to Resolve', value: '01'},
        {text: 'Submitted Write-Off Request', value: '02'},
        {text: 'Transferred or Adjusted Bal', value: '03'},
        {text: 'Referred to Other Dept to Resolve Claim', value: '04'},
        {text: 'Refund Provided to Patient', value: '05'},
        {text: 'Refund Provided to Payer', value: '06'},
        {text: 'Made Correction to Claim', value: '07'},
        {text: 'Awaiting/Pending Recoupment', value: '08'},
        {text: 'Other Action', value: '09'}
    ]}
]},
{text: "Uncategorized Defect", value: "4", triage: [], actions: [], childItems: [
    {text: 'Potential Defect', value: '01', triage: [
        {text: 'Verify Claim Was Submitted to Payer', value: '01'},
        {text: 'Verify if More Specific Category Applies', value: '02'},
        {text: 'Verify Payer Received Claim', value: '03'}
    ], actions: [
        {text: 'Overrode Defect Category', value:'01'},
        {text: 'Initiated Handoff', value:'02'},
        {text: 'Called Patient to Resolve', value:'03'},
        {text: 'Contacted Payer to Resolve Claim', value:'04'},
        {text: 'Transferred Bal to Patient Per Hospital Guidelines', value:'05'},
        {text: 'Applied Contractual/Adjustment', value:'06'},
        {text: 'Bill/Rebilled Claim', value:'07'},
        {text: 'Confirmed Claim is Still Pending with Payer', value:'08'},
        {text: 'Confirmed Payment is Promised', value:'09'},
        {text: 'Confirmed Claim was Recently Billed', value:'10'},
        {text: 'Submitted Write-Off Request', value:'11'},
        {text: 'Other Action', value:'12'}
    ]},
    {text: 'Supervisor Approved Exceptions', value: '02', triage: [
        {text: 'Verify Exception with Supervisor', value: '01'},
        {text: 'Confirm Follow Up Date with Supervisor', value: '02'},
        {text: 'Request Proper Notation from Supervisor', value: '03'}
    ], actions: [
        {text: 'Next Action Date (30 Days)', value:'01'},
        {text: 'Next Action Date (60 Days)', value:'02'},
        {text: 'Next Action Date (90 Days)', value:'03'}
    ]}
]}
];

var defecttypeModule = {};

defecttypeModule.defecttypeVM = new DefectTypeVM(defectTypeItems);

ko.applyBindings(defecttypeModule.defecttypeVM, document.getElementById("overrideStep"));

由于

1 个答案:

答案 0 :(得分:0)

您正在使用data-bind="foreach: selectedTriage",但尚未填充selectTriage观察点。 实际上,您可能希望在您的getById函数中填充一个可观察数组,或者将其设置为计算数据,例如您已经拥有的defectsubcategory

哦,顺便说一句,我会避免以下代码:

    return item.value === value;
    return item.triage === triage;
    return item.actions === actions;

因为只有第一行被执行而且它只是误导!

希望输入有帮助