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

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName : BEH0495
 * @Description : 入院记录由非执业医师书写,执业医师未在24小时内
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0495 extends QCCatalogue {

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }

        Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        String qmPerson = structureMap.get("签名");
        if (StringUtil.isBlank(qmPerson) || CatalogueUtil.isOccup(qmPerson)) {
            return;
        }

        String shPerson = structureMap.get("审核人");
        String jlDate = structureMap.get("记录日期");
        String shDate = structureMap.get("审核日期");
        /*boolean before = StringUtil.parseDateTime(shDate).before(StringUtil.parseDateTime(jlDate));
        if(before){
            status.set("-1");
            return;
        }*/
        if (!CatalogueUtil.isOccup(shPerson) || CatalogueUtil.compareTime(StringUtil.parseDateTime(jlDate), StringUtil.parseDateTime(shDate), 24 * 60L)) {
            status.set("-1");
        }
    }

}