利用函数的执行顺序,先正遍历树,再反遍历树

2017-12-10  本文已影响0人  SEkin

条件:过滤树里面所需要的数据,并且空的目录也不要显示,这里@kpi_type-{指标:1,目录:0}。
@kpi_souce :{"统计指标":1 或 -10 (默认-10),“考评指标”:2,“计算指标”:3;},
(注意:有目录指标,即有子节点,但是kpi_type为1)

目的:找出树里面所有的统计指标,树为无限极没限制。并且不显示空的目录

var   testJson={  kpi_id: 100000000, kpi_name: '日常统计学评价', par_kpi_id: -2, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101000000, kpi_name: '医院运行基本监测指标', par_kpi_id: 100000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101010000, kpi_name: '资源配置', par_kpi_id: 101000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101010100, kpi_name: '实际开放床位', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '2', children: []}, { kpi_id: 101010200, kpi_name: '重症医学科床位数', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010300, kpi_name: '急诊留观床位数', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010400, kpi_name: '应急用床位', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010500, kpi_name: '全院职工总数', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010600, kpi_name: '卫生技术人员数', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101010601, kpi_name: '医师数', par_kpi_id: 101010600, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010602, kpi_name: '护理人员数', par_kpi_id: 101010600, disp_order: 11, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101010603, kpi_name: '医技人员数', par_kpi_id: 101010600, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101010700, kpi_name: '医院医用建筑面积', par_kpi_id: 101010000, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101020000, kpi_name: '工作负荷', par_kpi_id: 101000000, disp_order: 14, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101020100, kpi_name: '门急诊', par_kpi_id: 101020000, disp_order: 15, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101020101, kpi_name: '年门诊人次', par_kpi_id: 101020100, disp_order: 16, kpi_type: 1, kpi_source: '3',  children: []}, { kpi_id: 101020102, kpi_name: '年健康体检人次', par_kpi_id: 101020100, disp_order: 17, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101020103, kpi_name: '年急诊人次', par_kpi_id: 101020100, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101020104, kpi_name: '年急诊留观人次', par_kpi_id: 101020100, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101020200, kpi_name: '住院', par_kpi_id: 101020000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101020201, kpi_name: '年住院患者入院例数', par_kpi_id: 101020200, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101020202, kpi_name: '年出院例数', par_kpi_id: 101020200, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101020203, kpi_name: '出院患者实际占用总床日数', par_kpi_id: 101020200, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101020300, kpi_name: '手术工作量', par_kpi_id: 101020000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101020301, kpi_name: '年住院手术例数', par_kpi_id: 101020300, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101020302, kpi_name: '年门诊手术例数', par_kpi_id: 101020300, kpi_type: 1, kpi_source: '3', children: []},]},]}, { kpi_id: 101030000, kpi_name: '医疗质量', par_kpi_id: 101000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101030300, kpi_name: '住院患者死亡例数', par_kpi_id: 101030000, disp_order: 54, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030400, kpi_name: '住院患者自动出院例数', par_kpi_id: 101030000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030500, kpi_name: '住院手术例数', par_kpi_id: 101030000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101030501, kpi_name: '住院手术死亡例数', par_kpi_id: 101030500, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101030600, kpi_name: '住院危重抢救例数', par_kpi_id: 101030000, kpi_type: 1, kpi_source: '1', children: [{ kpi_id: 101030601, kpi_name: '住院危重抢救死亡例数', par_kpi_id: 101030600, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 101030700, kpi_name: '急诊科危重患者抢救例数', par_kpi_id: 101030000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101030701, kpi_name: '急诊科危重患者抢救死亡例数', par_kpi_id: 101030700, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101030100, kpi_name: '手术冰冻与石蜡诊断', par_kpi_id: 101030000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101030101, kpi_name: '手术冰冻与石蜡诊断人数', par_kpi_id: 101030100, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030102, kpi_name: '手术冰冻与石蜡诊断符合例数', par_kpi_id: 101030100, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030103, kpi_name: '手术冰冻与石蜡诊断符合率', par_kpi_id: 101030100, kpi_type: 1, kpi_source: '2', children: []},]}, { kpi_id: 101030200, kpi_name: '恶性肿瘤患者手术前后病理诊断', par_kpi_id: 101030000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101030201, kpi_name: '恶性肿瘤患者手术前后病理诊断人数', par_kpi_id: 101030200, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030202, par_kpi_id: 101030200, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101030203, kpi_name: '恶性肿瘤患者手术前后病理诊断符合率', par_kpi_id: 101030200, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101030800, kpi_name: '新生儿患者住院死亡率', par_kpi_id: 101030000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101030801, kpi_name: '新生儿患者住院例数', par_kpi_id: 101030800, disp_order: 101030801, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101030802, kpi_name: '新生儿患者住院死亡例数', par_kpi_id: 101030801, kpi_type: 1, kpi_source: '3', children: []},]},]},]}, { kpi_id: 101040000, kpi_name: '工作效率', par_kpi_id: 101000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101040100, kpi_name: '出院患者平均住院日', par_kpi_id: 101040000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101040200, kpi_name: '平均每张床工作日', par_kpi_id: 101040000, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101040300, kpi_name: '床位使用率(%)', par_kpi_id: 101040000, kpi_type: 1, kpi_source: '2', children: []}, { kpi_id: 101040400, kpi_name: '床位周转次数', par_kpi_id: 101040000, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101050000, kpi_name: '患者负担', par_kpi_id: 101000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101050100, kpi_name: '每门诊人次费用', par_kpi_id: 101050000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101050101, kpi_name: '每门诊人次药费', par_kpi_id: 101050100, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101050200, kpi_name: '每住院人次费用', par_kpi_id: 101050000, disp_order: 91, kpi_type: 1, kpi_source: '3',   children: [{ kpi_id: 101050201, kpi_name: '每住院人次药费', par_kpi_id: 101050200, disp_order: 92, kpi_type: 1, kpi_source: '3',   children: []},]},]}, { kpi_id: 101060000, kpi_name: '资产运营', par_kpi_id: 101000000, disp_order: 93, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101060100, kpi_name: '流动比率(%)', par_kpi_id: 101060000, disp_order: 94, kpi_type: 1, kpi_source: '3',children: []}, { kpi_id: 101060200, kpi_name: '速动比率(%)', par_kpi_id: 101060000, disp_order: 95, kpi_type: 1, kpi_source: '3',   children: []}, { kpi_id: 101060300, kpi_name: '医疗收入/百元固定资产', par_kpi_id: 101060000, disp_order: 96, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101060400, kpi_name: '业务支出/百元业务收入', par_kpi_id: 101060000, disp_order: 97, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101060500, kpi_name: '资产负债率(%)', par_kpi_id: 101060000, disp_order: 98, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101060600, kpi_name: '固定资产总值(万元)', par_kpi_id: 101060000, disp_order: 99, kpi_type: 1, kpi_source: '3',   children: []}, { kpi_id: 101060700, kpi_name: '医疗收入(万元)', par_kpi_id: 101060000, disp_order: 100, kpi_type: 1, kpi_source: '3',   children: []}, { kpi_id: 101060800, kpi_name: '医疗收入中药品收入比率(%)', par_kpi_id: 101060000, disp_order: 101, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101060900, kpi_name: '医疗收入中医用材料收入比率(%)', par_kpi_id: 101060000, disp_order: 102, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101070000, kpi_name: '科研成果', par_kpi_id: 101000000, disp_order: 103, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 101070100, kpi_name: '国内论文数ISSN', par_kpi_id: 101070000, disp_order: 104, kpi_type: 1, kpi_source: '3',  children: []}, { kpi_id: 101070200, kpi_name: '国内论文数及被引用数次(以中国科技核心期刊发布信息为准)', par_kpi_id: 101070000, disp_order: 105, kpi_type: 1, kpi_source: '3', children: []}, { kpi_id: 101070300, kpi_name: 'SCI收录论文数', par_kpi_id: 101070000, disp_order: 106, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101070301, kpi_name: 'SCI论文数/每百张开放床位', par_kpi_id: 101070300, disp_order: 101070301, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101070400, kpi_name: '承担与完成国家级科研课题数', par_kpi_id: 101070000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101070401, kpi_name: '国家级科研课题数/每百张开放床位', par_kpi_id: 101070400, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101070500, kpi_name: '承担与完成省级科研课题数', par_kpi_id: 101070000, disp_order: 108, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101070501, kpi_name: '省级科研基金额度/每百张开放床位', par_kpi_id: 101070500, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101070600, kpi_name: '承担国家级科研基金额度(万元)', par_kpi_id: 101070000, kpi_type: 1, kpi_source: '3', children: [{ kpi_id: 101070601, kpi_name: '国家级科研基金额度/每百张开放床位', par_kpi_id: 101070600, kpi_type: 1, kpi_source: '3', children: []},]}, { kpi_id: 101070700, kpi_name: '承担省级科研基金额度(万元)', par_kpi_id: 101070000, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 101070701, kpi_name: '省级科研基金额度/每百张开放床位', par_kpi_id: 101070700, kpi_type: 1, kpi_source: '3', children: []},]},]},]}, { kpi_id: 114, kpi_name: '医疗质量与安全监测指标', par_kpi_id: 100000000, disp_order: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 115, kpi_name: '住院重点疾病', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 116, kpi_name: '住院重点疾病总例数', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 117, kpi_name: '住院重点疾病死亡例数', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 118, kpi_name: '住院重点疾病二周内再住院例数', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 119, kpi_name: '住院重点疾病一月内再住院例数', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 123, kpi_name: '住院重点疾病平均住院日', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 124, kpi_name: '住院重点疾病平均住院费用', par_kpi_id: 115, kpi_type: 1, kpi_source: '-10',   children: []},]}, { kpi_id: 141, kpi_name: '住院重点手术', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 142, kpi_name: '住院重点手术总例数', par_kpi_id: 141, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 143, kpi_name: '住院重点手术死亡例数', par_kpi_id: 141, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 148, kpi_name: '住院重点手术再手术例数', par_kpi_id: 141, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 151, kpi_name: '住院重点手术平均住院日', par_kpi_id: 141, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 152, kpi_name: '住院重点手术平均住院费用', par_kpi_id: 141, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 153, kpi_name: '麻醉', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 154, kpi_name: '麻醉总例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 155, kpi_name: '全身麻醉例数', par_kpi_id: 154, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 156, kpi_name: '全身麻醉体外循环例数', par_kpi_id: 155, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 157, kpi_name: '脊髓麻醉例数', par_kpi_id: 154, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 158, kpi_name: '其他类麻醉例数', par_kpi_id: 154, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 159, kpi_name: '由麻醉医师实施镇痛治疗例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 160, kpi_name: '门诊患者镇痛治疗例数', par_kpi_id: 159, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 161, kpi_name: '住院患者镇痛治疗例数', par_kpi_id: 159, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 162, kpi_name: '住院患者镇痛治疗手术后阵痛例数', par_kpi_id: 161, kpi_type: 1, kpi_source: '-10', children: []},]},]}, { kpi_id: 163, kpi_name: '由麻醉医师实施心肺复苏治疗例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 164, kpi_name: '心肺复苏治疗复苏成功例数', par_kpi_id: 163, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 165, kpi_name: '麻醉复苏(Steward 苏醒评分)管理例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 166, kpi_name: '进入麻醉复苏室例数', par_kpi_id: 165, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 167, kpi_name: '麻醉复苏离室时 Steward 评分≥4 分例数', par_kpi_id: 165, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 168, kpi_name: '麻醉非预期的相关事件例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 169, kpi_name: '麻醉中发生未预期的意识障碍例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 170, kpi_name: '麻醉中出现氧饱和度重度降低例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 171, kpi_name: '全身麻醉结束时使用催醒药物例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 172, kpi_name: '麻醉中因误咽误吸引发呼吸道梗阻例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 173, kpi_name: '麻醉意外死亡例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 174, kpi_name: '其他麻醉非预期的相关事件例数', par_kpi_id: 168, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 175, kpi_name: '麻醉分级(ASA病情分级)管理例数', par_kpi_id: 153, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 176, kpi_name: 'ASA-Ⅰ级例数', par_kpi_id: 175, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 177, kpi_name: 'ASA-Ⅰ级术后死亡例数', par_kpi_id: 176, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 178, kpi_name: 'ASA-Ⅱ级例数', par_kpi_id: 175, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 179, kpi_name: 'ASA-Ⅱ级术后死亡例数', par_kpi_id: 178, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 180, kpi_name: 'ASA-Ⅲ级例数', par_kpi_id: 175, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 181, kpi_name: 'ASA-Ⅲ级术后死亡例数', par_kpi_id: 180, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 182, kpi_name: 'ASA-Ⅳ级例数', par_kpi_id: 175, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 183, kpi_name: 'ASA-Ⅳ级术后死亡例数', par_kpi_id: 182, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 184, kpi_name: 'ASA-Ⅴ级例数', par_kpi_id: 175, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 185, kpi_name: 'ASA-Ⅴ级术后死亡例数', par_kpi_id: 184, kpi_type: 1, kpi_source: '-10', children: []},]},]},]}, { kpi_id: 187, kpi_name: '住院患者压疮', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 188, kpi_name: '患者入院前已有压疮率', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 189, kpi_name: '患者入院前已有一级压疮率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 190, kpi_name: '患者入院前已有二级压疮率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 191, kpi_name: '患者入院前已有三级压疮率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 192, kpi_name: '患者入院前已有四级压疮率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 193, kpi_name: '自家庭入住时有压疮的患者率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 194, kpi_name: '自养老院入住时有压疮的患者率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 195, kpi_name: '自其他医院转入时有压疮的患者率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 196, kpi_name: '自其他来源入住时有压疮的病人率', par_kpi_id: 188, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 303, kpi_name: '住院期间发生压疮例次', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 197, kpi_name: '住院期间发生压疮率', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 198, kpi_name: '住院期间发生一级压疮率', par_kpi_id: 197, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 199, kpi_name: '住院期间发生二级压疮率', par_kpi_id: 197, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 200, kpi_name: '住院期间发生三级压疮率', par_kpi_id: 197, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 201, kpi_name: '住院期间发生四级压疮率', par_kpi_id: 197, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 202, kpi_name: '住院期间压疮发生率', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 203, kpi_name: '骶尾椎骨处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 204, kpi_name: '坐骨处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 205, kpi_name: '股骨粗隆处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 206, kpi_name: '跟骨处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 207, kpi_name: '足踝处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 208, kpi_name: '肩胛骨处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 209, kpi_name: '枕骨处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 210, kpi_name: '其他部位压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 211, kpi_name: '多处压疮发生率', par_kpi_id: 202, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 304, kpi_name: '住院期间发生一级压疮人次', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 305, kpi_name: '住院期间发生二级压疮人次', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 306, kpi_name: '住院期间发生三级压疮人次', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 307, kpi_name: '住院期间发生四级压疮人次', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 308, kpi_name: '住院期间压疮发生率', par_kpi_id: 187, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 212, kpi_name: '医院内跌倒/坠床', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 213, kpi_name: '医院内住院患者的跌倒与原因', par_kpi_id: 212, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 214, kpi_name: '医院内因患者健康状况而造成跌倒比率', par_kpi_id: 213, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 215, kpi_name: '医院内因治疗、药物和(或)麻醉反应而造成跌倒比率', par_kpi_id: 213, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 216, kpi_name: '医院内因环境中危险因子而造成跌倒比率', par_kpi_id: 213, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 217, kpi_name: '医院内因其他因素而造成跌倒比率', par_kpi_id: 213, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 309, kpi_name: '患者跌倒例数', par_kpi_id: 213, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 218, kpi_name: '医院内跌倒造成伤害程度', par_kpi_id: 212, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 219, kpi_name: '医院内跌倒伤害严重度1级比率', par_kpi_id: 218, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 220, kpi_name: '医院内跌倒伤害严重度2级比率', par_kpi_id: 218, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 221, kpi_name: '医院内跌倒伤害严重度3级比率', par_kpi_id: 218, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 222, kpi_name: '医院内再次发生跌倒比率', par_kpi_id: 212, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 223, kpi_name: '择期手术后并发症', par_kpi_id: 114, kpi_type: 0, kpi_source: '-10', last_change_time: '2017/08/10 06:06:02', children: [{ kpi_id: 224, kpi_name: '择期手术后并发症发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '1', children: [{ kpi_id: 235, kpi_name: '手术并发症(严重但可治疗)导致的死亡', par_kpi_id: 224, kpi_type: 1, kpi_source: '1', children: []}, {kpi_id: 236, kpi_name: '手术后伤口裂开', par_kpi_id: 224, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 237, kpi_name: '手术后肺栓塞或深静脉血栓', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 238, kpi_name: '手术后出血或血肿', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 239, kpi_name: '手术后髋关节骨折', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 240, kpi_name: '手术后生理与代谢紊乱', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 241, kpi_name: '手术后呼吸衰竭', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 242, kpi_name: '手术后败血症', par_kpi_id: 224, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 247, kpi_name: '因用药错误导致患者死亡发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 248, kpi_name: '输血反应发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 249, kpi_name: '输液反应发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 250, kpi_name: '手术过程中异物遗留发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 251, kpi_name: '医源性气胸发生率', par_kpi_id: 223, kpi_type: 1, kpi_source: '-10', children: []}]}]}, { kpi_id: 255, kpi_name: '单病种质量指标', par_kpi_id: 100000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 254, kpi_name: '效率指标', par_kpi_id: 255, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 253, kpi_name: '病案中总例数', par_kpi_id: 254, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 256, kpi_name: 'KW总例数', par_kpi_id: 254, kpi_type: 1, kpi_source: '-10', children: []},]},]}, { kpi_id: 263, kpi_name: '重症医学(ICU)质量监测指标', par_kpi_id: 100000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 264, kpi_name: '非预期的24/48小时重返重症医学科率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 265, kpi_name: '呼吸机相关肺炎(VAP)的预防率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 266, kpi_name: '呼吸机相关肺炎(VAP)发病率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 267, kpi_name: '中心静脉置管相关血流感染发生率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 268, kpi_name: '留置导尿管相关泌尿系感染发病率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 269, kpi_name: '重症患者死亡率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 270, kpi_name: 'APACHEⅡ评15分以上的患者死亡率', par_kpi_id: 269, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 271, kpi_name: 'APACHEⅡ评15分以下的患者死亡率', par_kpi_id: 269, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 272, kpi_name: '重症患者压疮发生率', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: [{ kpi_id: 273, kpi_name: 'APACHEⅡ评15分以上的患者压疮发生率', par_kpi_id: 272, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 274, kpi_name: 'APACHEⅡ评15分以下的患者压疮发生率', par_kpi_id: 272, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 275, kpi_name: '人工气道脱出例数', par_kpi_id: 263, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 288, kpi_name: '合理用药监测指标', par_kpi_id: 100000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 289, kpi_name: '抗生素处方数/每百张门诊处方(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 290, kpi_name: '注射剂处方数/每百张门诊处方(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 291, kpi_name: '药费收入占医疗总收入比重(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 292, kpi_name: '抗菌药物占西药出库总金额比重(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 293, kpi_name: '常用抗菌药物种类与可提供药敏试验种类比例(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 8002, kpi_name: '抗菌药物占西药出库总金额比重(门诊部)(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 8003, kpi_name: '抗菌药物占西药出库总金额比重(住院部)(%)', par_kpi_id: 288, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 298, kpi_name: '医院感染控制质量监测指标', par_kpi_id: 100000000, kpi_type: 0, kpi_source: '-10', children: [{ kpi_id: 299, kpi_name: '呼吸机相关肺炎发病率', par_kpi_id: 298, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 300, kpi_name: '留置导尿管相关泌尿系感染发病率', par_kpi_id: 298, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 301, kpi_name: '血管导管相关血流感染率', par_kpi_id: 298, kpi_type: 1, kpi_source: '-10', children: []}, { kpi_id: 302, kpi_name: '不同感染风险指数手术部位感染发病率', par_kpi_id: 298, kpi_type: 1, kpi_source: '-10', children: []},]}, { kpi_id: 200000100, kpi_name: '高水平医院指标监测', par_kpi_id: 100000000, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000201, kpi_name: '住院死亡类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000200, kpi_name: '住院总死亡患者人数', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []}, {kpi_id: 200000204, kpi_name: '同期出院患者总人次', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000205, kpi_name: '新生儿患者住院死亡人数', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1',   children: []}, { kpi_id: 200000206, kpi_name: '同期新生儿患者出院人次', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000207, kpi_name: '手术患者住院死亡人数', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000208, kpi_name: '同期手术患者出院人次', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000209, kpi_name: '手术患者围手术期住院死亡人数', par_kpi_id: 200000201, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 200000202, kpi_name: '住院重返类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000210, kpi_name: '出院当天再住院患者人次', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000211, kpi_name: '同期出院患者总人次(除死亡患者外)', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000212, kpi_name: '出院2-31天内再住院患者人次', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000213, kpi_name: '重返手术室再次手术例数', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000214, kpi_name: '同期出院患者手术例数', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000215, kpi_name: '转出ICU后重返ICU患者人次', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000216, kpi_name: '同期转出ICU患者人次(除ICU中死亡情况)', par_kpi_id: 200000202, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 200000217, kpi_name: '手术并发症类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000218, kpi_name: '手术患者并发症发生例数', par_kpi_id: 200000217, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000219, kpi_name: '手术患者手术后肺栓塞发生例数', par_kpi_id: 200000217, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000220, kpi_name: '手术患者手术后深静脉血栓发生例数', par_kpi_id: 200000217, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000221, kpi_name: '手术患者手术后败血症发生例数', par_kpi_id: 200000217, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000240, kpi_name: '手术患者手术后伤口裂开发生例数', par_kpi_id: 200000217, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 200000222, kpi_name: '患者安全类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000223, kpi_name: '发生压疮的出院患者人次', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000224, kpi_name: '同期出院患者人次', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000225, kpi_name: '发生产伤的新生儿出院患者人次', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000226, kpi_name: '同期活产儿人数', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000227, kpi_name: '发生产伤的阴道分娩出院产妇人数', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000228, kpi_name: '同期阴道分娩出院产妇人数', par_kpi_id: 200000222, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 200000229, kpi_name: '重点病种质量类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000231, kpi_name: '同期重点病种患者出院人次', par_kpi_id: 200000229, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000232, kpi_name: '重点病种患者住院死亡人数', par_kpi_id: 200000229, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000233, kpi_name: '同期重点病种患者出院人次(除死亡患者外)', par_kpi_id: 200000229, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000234, kpi_name: '重点病种出院当天内再住院人次', par_kpi_id: 200000229, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000235, kpi_name: '重点病种出院2-31天内再住院人次', par_kpi_id: 200000229, kpi_type: 1, kpi_source: '1', children: []},]}, { kpi_id: 200000230, kpi_name: '重点手术质量类指标', par_kpi_id: 200000100, kpi_type: 0, kpi_source: 'null', children: [{ kpi_id: 200000236, kpi_name: '同期接受重点手术后出院患者人次', par_kpi_id: 200000230, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000237, kpi_name: '重点手术后死亡的住院患者人数', par_kpi_id: 200000230, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000238, kpi_name: '重点手术例数', par_kpi_id: 200000230, kpi_type: 1, kpi_source: '1', children: []}, { kpi_id: 200000239, kpi_name: '重点手术后重返手术室再次手术例数', par_kpi_id: 200000230, kpi_type: 1, kpi_source: '1', children: []},]},]},] }
mapJson1(json.children);
 function mapJson1(arr) {
  // 正遍历
             arr.map(function (val, index) {
            if (val.kpi_type == 1 && (val.kpi_source == 2 || val.kpi_source == 3)) {
                arr[index] = null;   
            } else {
                if (val.children.length) {
                    mapJson1(val.children);
                }
            }
         
        })  
// 反遍历tree ,过滤出空的节点和空的目录
        for (var i = 0; i < arr.length;) {
            var obj = arr[i];
            if (obj) {
                if (obj.kpi_type == 0 && !obj.children.length) {
                    arr.splice(i, 1);
                } else {
                    i++;
                }
            } else {
                arr.splice(i, 1);
            }
        }
    }


    console.log(testJson.children[0].children);

上一篇下一篇

猜你喜欢

热点阅读