package com.lantone.qc.trans.shaoyf;

import com.google.common.collect.Lists;
import com.lantone.qc.dbanaly.facade.shaoyf.ShaoyfXmlUtil;
import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
import com.lantone.qc.pub.model.vo.MedrecVo;
import com.lantone.qc.trans.ModelDocTrans;
import com.lantone.qc.trans.comsis.OrdinaryAssistant;
import com.lantone.qc.trans.shaoyf.util.ShaoyfOrdinaryAssistant;

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

/**
 * @Description: 出院小结文档生成
 * @author: rengb
 * @time: 2020/3/17 13:25
 */
public class ShaoyfLeaveHospitalDocTrans extends ModelDocTrans {

    @Override
    public LeaveHospitalDoc extract(MedrecVo medrecVo) {
        Map<String, Object> contentMap = ((List<Map>) medrecVo.getContent().get("content")).get(0);
        String content = contentMap.get("xmlText").toString();

        Map<String, String> sourceMap = ShaoyfXmlUtil.getXmlToMap(content);
        sourceMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
        sourceMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
        structureMap.put("入院情况", structureMap.get("入院病情"));
        structureMap.put("出院时间", structureMap.get("出院日期"));
        ShaoyfOrdinaryAssistant.techTitleDocRemove(structureMap, "医师签名");
        ShaoyfOrdinaryAssistant.techTitleDocRemove(structureMap, "审核人");
        LeaveHospitalDoc leaveHospitalDoc = new LeaveHospitalDoc();
        leaveHospitalDoc.setStructureMap(structureMap);
        leaveHospitalDoc.setPageData((Map) structureMap);

        return leaveHospitalDoc;
    }

    private List<String> keyContrasts = Lists.newArrayList(
            "本人姓名=姓名",
            "入院日期=入院时间",
            "实际住院天数=住院天数",
            "出院时情况=出院情况",
            //            "注意事项=健康教育",
            "复诊时间=随访计划",
            "出院指导=健康教育",
            "医生=医师签名",
            "病历日期=签名时间",
            "体温(耳)=体温耳"
    );

}