package com.lantone.qc.kernel.catalogue.firstpagerecord;

import com.google.common.collect.Lists;
import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.Content;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.util.ListUtil;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : FIRP03046
 * @Description : 主要诊断与主要手术/操作不匹配
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class FIRP03046 extends QCCatalogue {

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getFirstPageRecordDoc() == null || inputInfo.getFirstPageRecordDoc().getStructureExtMap() == null) {
            return;
        }
        Map<String, Object> structureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
        List<Map<String, String>> diags = (List) structureExtMap.get(Content.dischargeDiag);
        List<Map<String, String>> opers = (List) structureExtMap.get(Content.operative_information);
        if (ListUtil.isEmpty(diags) || ListUtil.isEmpty(opers)) {
            return;
        }
        String diagName = diags.get(0).get("诊断名称");
        String operName = opers.get(0).get("手术名称");
        diagOperList.forEach(i -> {
            String[] diagOperArry = i.split("=");
            if (diagOperArry[0].indexOf(diagName) > -1 && diagOperArry[1].indexOf(operName) > -1) {
                status.set("-1");
                return;
            }
        });
    }

    private List<String> diagOperList = Lists.newArrayList(
            "诊断名称=手术名称",
            "冠状动脉粥样硬化性心脏病=体内埋藏式自动除颤起搏器植入",
            "感染性休克(好转）=鼻内镜鼻腔鼻窦手术",
            "发热=手术名称 : 非血管介入: 经皮肝穿刺活检术,非血管介入: 各个部位脓肿、囊肿穿刺引流术",
            "胆囊占位性病变=经皮冠脉造影术",
            "肝癌=心电监护下左眼白内障超声乳化囊外摘除联合人工晶体植入/房角粘连分离/胬肉切除术/自体结膜移植术",
            "低钠血症=神经导航下复发颅咽管瘤囊腔Ommaya泵置入",
            "甲状腺结节=右侧甲状腺癌根治(右侧甲状腺叶切除；峡部切除；右侧气食管沟清扫)",
            "急性胆管炎=左输尿管镜探查",
            "冠状动脉粥样硬化性心脏病=主动脉、颈动脉造影术；",
            "肝功能异常=骨髓穿刺",
            "休克=胸椎后路T5/6骨折复位、椎管减压、植骨融合、椎弓根钉棒系统内固定术；",
            "慢性便秘=腹腔镜辅助下全结肠切除",
            "膀胱肿瘤=冠状动脉药物涂层支架置入术",
            "子宫多发肌瘤=取环",
            "腰椎管狭窄=尿道狭窄扩张",
            "病态窦房结综合征=脑血管造影",
            "颈部皮肤肿物=头皮肿物切除术",
            "妊娠期糖尿病=子宫下段剖宫产术",
            "宫颈管息肉=宫颈粘连分离",
            "盆腔炎性疾病后遗症=腹腔镜左侧输卵管切除术",
            "颈椎间盘突出=后路腰4/5经右侧椎间孔减压、椎体间融合、钉棒系统内固定术",
            "左半侧颜面萎缩=腹部吸脂",
            "妊娠期高血压=急诊子宫下段剖宫产",
            "左侧股骨远端骨折术后=左膝关节松解",
            "轻度认知障碍=腰椎穿刺术",
            "风湿性瓣膜性联合性心脏病=经皮心房颤动射频消融术",
            "惊恐障碍=无痛肠镜",
            "取卵术后=（住院）超声科B超引导下腹腔积液置管引流",
            "后循环脑血管缺血=无痛肠镜申请单(和爽)(西甲硅油)|经肠镜结直肠息肉摘除术",
            "左侧卵巢囊肿蒂扭转=腹腔镜下双侧附件切除",
            "左侧股骨转子间骨折=左髋关节滑膜切除",
            "病态窦房结综合征=用两根导管的冠状动脉造影术",
            "肋软骨痛=无痛肠镜申请单(和爽)(西甲硅油)|经肠镜结直肠息肉摘除术",
            "心律失常=用两根导管的冠状动脉造影术",
            "病态窦房结综合征=用两根导管的冠状动脉造影术"
    );

}