package com.docus.server.collect.dept.ws;

import com.docus.core.util.DateUtil;
import com.docus.core.util.Func;
import com.docus.server.collect.IWsResult;
import com.docus.server.common.util.IdUtil;
import org.springframework.stereotype.Component;

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

@Component("wsDeptResultImpl")
public class WsDeptResultImpl implements IWsResult {

    @Override
    public String ok(Map<String, Object> params) {
        String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
        return "<MCCI_IN000002UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\" xsi:schemaLocation=\"urn:hl7-org:v3\n" +
            "file:///E:/hl7/HL7/v3ballot_fullsite_2011MAY/v3ballot/html/processable/multicacheschemas/MCCI\n" +
            "_IN000002UV01.xsd\">\n" +
            "\t<id extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
            "\t<creationTime value=\"" + createTime + "\"/>\n" +
            "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\"/>\n" +
            "\t<processingCode code=\"P\"/>\n" +
            "\t<processingModeCode/>\n" +
            "\t<acceptAckCode code=\"AL\"/>\n" +
            "\t<receiver typeCode=\"RCV\">\n" +
            "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
            "\t\t\t<id>\n" +
            "\t\t\t\t<item extension=\"MDM\"/>\n" +
            "\t\t\t</id>\n" +
            "\t\t</device>\n" +
            "\t</receiver>\n" +
            "\t<sender typeCode=\"SND\">\n" +
            "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
            "\t\t\t<id>\n" +
            "\t\t\t\t<item extension=\"" + params.get("receiver") + "\"/>\n" +
            "\t\t\t</id>\n" +
            "\t\t</device>\n" +
            "\t</sender>\n" +
            "\t<acknowledgement typeCode=\"AA\">\n" +
            "\t\t<targetMessage>\n" +
            "\t\t\t<id extension=\"" + params.get("messageId") + "\"/>\n" +
            "\t\t</targetMessage>\n" +
            "\t\t<acknowledgementDetail>\n" +
            "\t\t\t<text value=\"" + params.get("msg") + "\"/>\n" +
            "\t\t</acknowledgementDetail>\n" +
            "\t</acknowledgement>\n" +
            "</MCCI_IN000002UV01>";
    }

    @Override
    public String fail(Map<String, Object> params) {
        String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
        return "<RCMR_IN000030UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\" xsi:schemaLocation=\"urn:hl7-org:v3\n" +
            "file:///E:/hl7/HL7/v3ballot_fullsite_2011MAY/v3ballot/html/processable/multicacheschemas/RCMR\n" +
            "_IN000030UV01.xsd\">\n" +
            "\t<id extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
            "\t<creationTime value=\"" + createTime + "\"/>\n" +
            "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"RCMR_IN000030UV01\"/>\n" +
            "\t<processingCode code=\"P\"/>\n" +
            "\t<processingModeCode/>\n" +
            "\t<acceptAckCode code=\"AL\"/>\n" +
            "\t<receiver typeCode=\"RCV\">\n" +
            "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
            "\t\t\t<id>\n" +
            "\t\t\t\t<item extension=\"MDM\"/>\n" +
            "\t\t\t</id>\n" +
            "\t\t</device>\n" +
            "\t</receiver>\n" +
            "\t<sender typeCode=\"SND\">\n" +
            "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
            "\t\t\t<id>\n" +
            "\t\t\t\t<item extension=\"" + params.get("receiver") + "\"/>\n" +
            "\t\t\t</id>\n" +
            "\t\t</device>\n" +
            "\t</sender>\n" +
            "\t<acknowledgement typeCode=\"AE\">\n" +
            "\t\t<targetMessage>\n" +
            "\t\t\t<id extension=\"" + params.get("msgId") + "\"/>\n" +
            "\t\t</targetMessage>\n" +
            "\t\t<acknowledgementDetail>\n" +
            "\t\t\t<text value=\"" + params.get("msg") + "\"/>\n" +
            "\t\t</acknowledgementDetail>\n" +
            "\t</acknowledgement>\n" +
            "</RCMR_IN000030UV01>\n";
    }

}
