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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
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.model.doc.CriticallyIllNoticeDoc;
import com.lantone.qc.pub.model.doc.DifficultCaseDiscussDoc;
import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : THR0603
 * @Description : 对危重疑难病人的上级医师查房记录未精确到时分
 * @Author : 胡敬
 * @Date: 2020-03-30 14:13
 */
@Component
public class THR0603 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        List<CriticallyIllNoticeDoc> criticallyIllNoticeDocs = inputInfo.getCriticallyIllNoticeDocs();
        List<DifficultCaseDiscussDoc> difficultCaseDiscussDocs = inputInfo.getDifficultCaseDiscussDocs();
        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
        if (ListUtil.isEmpty(criticallyIllNoticeDocs) && ListUtil.isEmpty(difficultCaseDiscussDocs) || ListUtil.isEmpty(threeLevelWardDocs)) {
            return;
        }
        List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
        String wardRecordDateStr;
        for (ThreeLevelWardDoc threeLevelWardDoc : allDoctorWradDocs) {
            Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
            wardRecordDateStr = rescueStructureMap.get("查房日期");
            Date wardRecordDate = StringUtil.parseDateTime(wardRecordDateStr
                    , CatalogueUtil.processDateFormat(Content.dateFormats));
            if (null == wardRecordDate) {
                status.set("-1");
                return;
            }
        }
    }
}