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.model.entity.Clinical;
import com.lantone.qc.pub.model.entity.PD;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;


/**
 * @ClassName : BEH0005
 * @Description :主诉症状时间描述前后不合理
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH0005 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        if(inputInfo.getBeHospitalizedDoc() == null){
            status.set("0");
            return;
        }
        List<Integer> time_index = new ArrayList<>();
        String chief_text = inputInfo.getBeHospitalizedDoc().getChiefLabel().getText();
        if(chief_text.contains("检查") || chief_text.contains("术后") || chief_text.contains("药物")){
            status.set("0");
        }else {
            int year = chief_text.indexOf("年");
            if (year != -1) {
                time_index.add(year);
            }
            int month = chief_text.indexOf("月");
            if (month != -1) {
                time_index.add(month);
            }
            int week = chief_text.indexOf("周");
            if (week != -1) {
                time_index.add(week);
            }
            int day = chief_text.indexOf("天");
            if (day != -1) {
                time_index.add(day);
            }
            int ri = chief_text.indexOf("日");
            if (ri != -1) {
                time_index.add(ri);
            }
            int hour = chief_text.indexOf("时");
            if (hour != -1) {
                time_index.add(hour);
            }
        }
        if(time_index.size()>0){
            int min = time_index.get(0);
            for (Integer data:time_index) {
                if(data<min){
                    min = data;
                }
            }
            if(min == time_index.get(0)){
                status.set("0");
            }
        }
    }
}