package com.docus.server.synclis.converter;

import com.docus.core.util.Func;
import com.docus.server.archive.entity.AfCollectTask;
import com.docus.server.archive.entity.TBasic;
import com.docus.server.archive.enums.SysFlagType;
import com.docus.server.synclis.entity.LisView;

import java.util.Date;


/**
 * @author YongBin Wen
 * @date 2025/1/16 14:33
 */
public class LisViewConverter {
    public static AfCollectTask convertTask(LisView view, TBasic basic) {
        if (view == null) {
            return null;
        }
        AfCollectTask task = new AfCollectTask();
        task.setPatientId(basic.getPatientId());
        task.setSysflag(SysFlagType.LIS.getType());
        task.setSyncTime(new Date());
        task.setState("0");
        task.setPresult("");
        task.setC1(view.getPatientId());
        task.setC2(view.getLabNum());
        task.setC3(view.getName());
        task.setC4(view.getLabNum());
        task.setC5(basic.getJzh());
        task.setC6(view.getCheckName());
        task.setC7(view.getPatSource());
        String pattern1 = "yyyy-MM-dd";
        String pattern2 = "yyyy-MM-dd HH:mm:ss";
        task.setT1(pattern1.length() == view.getReqDate().length() ? Func.parseDate(view.getAuditTime(), pattern1) : Func.parseDate(view.getAuditTime(), pattern2));
        task.setT2(Func.parseDate(view.getAuditTime(), pattern2));
        return task;
    }
}
