package com.docus.server.message.converters;

import com.docus.core.util.DateUtil;
import com.docus.server.message.controller.vo.PushInfoVo;
import com.docus.server.message.dto.FsRecordSubmitDTO;
import com.docus.server.message.dto.TbasicQrPreciseCondition;
import com.docus.server.message.feign.vo.ArchiveAndRecallPushVo;



import java.util.UUID;

public class FsWsRecordSubmitMessageConvert {
    public static FsRecordSubmitDTO convert(PushInfoVo pushInfoVo) {
        String jzh = null;
        String inpatientNo = null;
        String name = null;
        Integer admissTimes = null;
        String submitNo=null;
        String submitName=null;
        String submitDate = null;


        jzh = pushInfoVo.getInhospNo();

        inpatientNo = pushInfoVo.getInpNo();

        admissTimes = Integer.parseInt(pushInfoVo.getVisitId());

        name = pushInfoVo.getName();

        submitNo = pushInfoVo.getSubmitCode();

        submitName = pushInfoVo.getSubmitNameString();

        submitDate = pushInfoVo.getSubmitTime();


        FsRecordSubmitDTO recordSubmitDTO = new FsRecordSubmitDTO();
        recordSubmitDTO.setJzh(jzh);
        recordSubmitDTO.setInpatientNo(inpatientNo);
        recordSubmitDTO.setAdmissTimes(admissTimes);
        recordSubmitDTO.setName(name);
        recordSubmitDTO.setSubmitNo(submitNo);
        recordSubmitDTO.setSubmitName(submitName);
        recordSubmitDTO.setSubmitDate(submitDate);
        return recordSubmitDTO;
    }

    public static TbasicQrPreciseCondition convert(FsRecordSubmitDTO dto) {
        if (dto == null) {
            return null;
        }
        TbasicQrPreciseCondition condition = new TbasicQrPreciseCondition();

        condition.setInpatientNo(dto.getInpatientNo());
        condition.setAdmissTimes(dto.getAdmissTimes());
        condition.setName(dto.getName());
        return condition;
    }
    public static String getPushXml(ArchiveAndRecallPushVo vo) {
        String result = "<Msg>\n" +
                "\t<!--归档/解档ID-->\n" +
                "\t<Id>"+ UUID.randomUUID()+"</Id>\n" +
                "\t<!--住院号-->\n" +
                "\t<inHospIndexNo>"+vo.getInpatientNo()+"</inHospIndexNo>\n" +
                "\t<!--住院次数-->\n" +
                "\t<visitNo>"+vo.getAdmissTimes()+"</visitNo>\n" +
                "\t<!--患者姓名-->\n" +
                "\t<patientName>"+vo.getName()+"</patientName>\n" +
                "\t<!--住院就诊流水号-->\n" +
                "\t<inHospNo>"+vo.getExternalId()+"</inHospNo>\n" +
                "\t<!--入院时间yyyy-MM-dd HH:mm:ss-->\n" +
                "\t<admitTime>"+ DateUtil.format(vo.getAdmissDate(),DateUtil.PATTERN_DATETIME)+"</admitTime>\n" +
                "\t<!--出院时间yyyy-MM-dd HH:mm:ss-->\n" +
                "\t<disTime>"+DateUtil.format(vo.getDisDate(),DateUtil.PATTERN_DATETIME)+"</disTime>\n" +
                "\t<!--归档时间yyyy-MM-dd HH:mm:ss-->\n" +
                "\t<archiveTime>"+vo.getArchiveTime()+"</archiveTime>\n" +
                "\t<!--解档时间yyyy-MM-dd HH:mm:ss-->\n" +
                "\t<unarchiveTime></unarchiveTime>\n" +
                "\t<!--出院科室代码-->\n" +
                "\t<dischargeDeptCode>"+vo.getDisDept()+"</dischargeDeptCode>\n" +
                "\t<!--出院科室-->\n" +
                "\t<dischargeDeptName>"+vo.getDisDeptName()+"</dischargeDeptName>\n" +
                "\t<!--操作人工号-->\n" +
                "\t<controlUserName>"+vo.getControlUserName()+"</controlUserName>\n" +
                "\t<!--操作人姓名-->\n" +
                "\t<controlName>"+vo.getControlName()+"</controlName>\n" +
                "\t<!--解档/归档状态 0:解档 1:归档-->\n" +
                "\t<archiveState>"+vo.getIsArchive()+"</archiveState>\n" +
                "</Msg>";
        return result;
    }
}
