segment2.0
beeajax 2 years ago
parent 9420b2fc97
commit da9c63579a

@ -1,191 +1,213 @@
package com.docus.server.collect.basic.ws; package com.docus.server.collect.basic.ws;
import com.docus.core.util.Func; import com.docus.core.util.DateUtil;
import com.docus.core.util.XmlUtil;
import com.docus.server.collect.infrastructure.dao.FlagEnum;
import com.docus.server.record.pojo.dto.TBasicDTO; import com.docus.server.record.pojo.dto.TBasicDTO;
import com.docus.server.tool.ParamsUtils;
import com.docus.server.ws.convert.IConverter; import com.docus.server.ws.convert.IConverter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.w3c.dom.Node;
@Component("tBasicConverter") @Component("tBasicConverter")
public class TBasicConverter implements IConverter<TBasicDTO> { public class TBasicConverter implements IConverter<TBasicDTO> {
@Override @Override
public TBasicDTO convert(String message, String methodName) { public TBasicDTO convert(String message, String methodName) {
XmlUtil xml = XmlUtil.of(message); // XmlUtil xml = XmlUtil.of(message);
//id-消息流水号 // //id-消息流水号
String serialId = null; // String serialId = null;
Node serialIdNode = FlagEnum.INSERT.equals(methodName) ? // Node serialIdNode = FlagEnum.INSERT.equals(methodName) ?
xml.getNode("/PRPA_HIP0032/id/@extension") : xml.getNode("/PRPA_HIP0033/id/@extension"); // xml.getNode("/PRPA_HIP0032/id/@extension") : xml.getNode("/PRPA_HIP0033/id/@extension");
if (Func.isNotEmpty(serialIdNode)) { // if (Func.isNotEmpty(serialIdNode)) {
serialId = serialIdNode.getNodeValue(); // serialId = serialIdNode.getNodeValue();
} // }
//接受方 // //接受方
String receive = null; // String receive = null;
Node receiveNode = FlagEnum.INSERT.equals(methodName) ? // Node receiveNode = FlagEnum.INSERT.equals(methodName) ?
xml.getNode("/PRPA_HIP0032/receiver/device/id/item/@extension") : xml.getNode("/PRPA_HIP0033/receiver/device/id/item/@extension"); // xml.getNode("/PRPA_HIP0032/receiver/device/id/item/@extension") : xml.getNode("/PRPA_HIP0033/receiver/device/id/item/@extension");
if (Func.isNotEmpty(receiveNode)) { // if (Func.isNotEmpty(receiveNode)) {
receive = receiveNode.getNodeValue(); // receive = receiveNode.getNodeValue();
} // }
//发送方 // //发送方
String send = null; // String send = null;
Node sendNode = xml.getNode("/PRPA_HIP0032/sender/device/id/item/@extension"); // Node sendNode = xml.getNode("/PRPA_HIP0032/sender/device/id/item/@extension");
if (Func.isNotEmpty(sendNode)) { // if (Func.isNotEmpty(sendNode)) {
send = sendNode.getNodeValue(); // send = sendNode.getNodeValue();
} // }
//住院流水号 // //住院流水号
String jzh = null; // String jzh = null;
Node jzhNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/item/@extension"); // Node jzhNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/item/@extension");
if (Func.isNotEmpty(jzhNode)) { // if (Func.isNotEmpty(jzhNode)) {
jzh = jzhNode.getNodeValue(); // jzh = jzhNode.getNodeValue();
} // }
//住院号标识 // //住院号标识
String inpatientNo = null; // String inpatientNo = null;
Node inpatientNoNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/id/item/@extension"); // Node inpatientNoNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/id/item/@extension");
if (Func.isNotEmpty(inpatientNoNode)) { // if (Func.isNotEmpty(inpatientNoNode)) {
inpatientNo = inpatientNoNode.getNodeValue(); // inpatientNo = inpatientNoNode.getNodeValue();
} // }
//住院次数[] // //住院次数[]
String admissTimes = null; // String admissTimes = null;
Node admissTimesNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='次']/@value"); // Node admissTimesNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='次']/@value");
if (Func.isNotEmpty(admissTimesNode)) { // if (Func.isNotEmpty(admissTimesNode)) {
admissTimes = admissTimesNode.getNodeValue(); // admissTimes = admissTimesNode.getNodeValue();
} // }
//姓名 // //姓名
String name = null; // String name = null;
Node nameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/name/item/part/@value"); // Node nameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/name/item/part/@value");
if (Func.isNotEmpty(nameNode)) { // if (Func.isNotEmpty(nameNode)) {
name = nameNode.getNodeValue(); // name = nameNode.getNodeValue();
} // }
//入院日期时间 // //入院日期时间
String admissDate = null; // String admissDate = null;
Node admissDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/low/@value"); // Node admissDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/low/@value");
if (Func.isNotEmpty(admissDateNode)) { // if (Func.isNotEmpty(admissDateNode)) {
admissDate = admissDateNode.getNodeValue(); // admissDate = admissDateNode.getNodeValue();
} // }
//出院日期时间 // //出院日期时间
String disDate = null; // String disDate = null;
Node disDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/high/@value"); // Node disDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/high/@value");
if (Func.isNotEmpty(disDateNode)) { // if (Func.isNotEmpty(disDateNode)) {
disDate = disDateNode.getNodeValue(); // disDate = disDateNode.getNodeValue();
} // }
//入院诊断科室名称[] // //入院诊断科室名称[]
String admissDeptName = null; // String admissDeptName = null;
Node admissDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='入院诊断']/section/entry[@displayName='入院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name"); // Node admissDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='入院诊断']/section/entry[@displayName='入院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
if (Func.isNotEmpty(admissDeptNameNode)) { // if (Func.isNotEmpty(admissDeptNameNode)) {
admissDeptNameNode.getTextContent(); // admissDeptNameNode.getTextContent();
} // }
//出院诊断科室名称[] // //出院诊断科室名称[]
String disDeptName = null; // String disDeptName = null;
Node disDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name"); // Node disDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
if (Func.isNotEmpty(disDeptNameNode)) { // if (Func.isNotEmpty(disDeptNameNode)) {
disDeptName = disDeptNameNode.getTextContent(); // disDeptName = disDeptNameNode.getTextContent();
} // }
//主治医师[] // //主治医师[]
String attendingName = null; // String attendingName = null;
Node attendingNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/authenticator[@displayName='主治医师']/assignedEntity/assignedPerson/name"); // Node attendingNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/authenticator[@displayName='主治医师']/assignedEntity/assignedPerson/name");
if (Func.isNotEmpty(attendingNameNode)) { // if (Func.isNotEmpty(attendingNameNode)) {
attendingName = attendingNameNode.getTextContent(); // attendingName = attendingNameNode.getTextContent();
} // }
//年龄 // //年龄
String age = null; // String age = null;
Node ageNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/age[@unit='岁']/@value"); // Node ageNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/age[@unit='岁']/@value");
if (Func.isNotEmpty(ageNode)) { // if (Func.isNotEmpty(ageNode)) {
age = ageNode.getNodeValue(); // age = ageNode.getNodeValue();
} // }
//性别 // //性别
String sex = null; // String sex = null;
Node sexNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/administrativeGenderCode/@code"); // Node sexNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/administrativeGenderCode/@code");
if (Func.isNotEmpty(sexNode)) { // if (Func.isNotEmpty(sexNode)) {
sex = sexNode.getNodeValue(); // sex = sexNode.getNodeValue();
} // }
//身份证号 // //身份证号
String idCard = null; // String idCard = null;
Node idCardNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/id/item/@extension"); // Node idCardNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/id/item/@extension");
if (Func.isNotEmpty(idCardNode)) { // if (Func.isNotEmpty(idCardNode)) {
idCard = idCardNode.getNodeValue(); // idCard = idCardNode.getNodeValue();
} // }
//出院科室 // //出院科室
String disDept = null; // String disDept = null;
Node disDeptCardNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/id/@extension"); // Node disDeptCardNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/id/@extension");
if (Func.isNotEmpty(disDeptCardNode)) { // if (Func.isNotEmpty(disDeptCardNode)) {
disDept = disDeptCardNode.getNodeValue(); // disDept = disDeptCardNode.getNodeValue();
} // }
//性别名称 // //性别名称
String sexName = null; // String sexName = null;
Node sexNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/administrativeGenderCode/@displayName"); // Node sexNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/administrativeGenderCode/@displayName");
if (Func.isNotEmpty(sexNameNode)) { // if (Func.isNotEmpty(sexNameNode)) {
sexName = sexNameNode.getNodeValue(); // sexName = sexNameNode.getNodeValue();
} // }
//床位号 // //床位号
String bedNum = null; // String bedNum = null;
Node bedNumNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/id/@extension"); // Node bedNumNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/id/@extension");
if (Func.isNotEmpty(bedNumNode)) { // if (Func.isNotEmpty(bedNumNode)) {
bedNum = bedNumNode.getNodeValue(); // bedNum = bedNumNode.getNodeValue();
} // }
//住院天数数[] // //住院天数数[]
String admissDays = null; // String admissDays = null;
Node admissDaysNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='天']/@value"); // Node admissDaysNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='天']/@value");
if (Func.isNotEmpty(admissDaysNode)) { // if (Func.isNotEmpty(admissDaysNode)) {
admissDays = admissDaysNode.getNodeValue(); // admissDays = admissDaysNode.getNodeValue();
} // }
//是否死亡[] // //是否死亡[]
String isDead = null; // String isDead = null;
Node isDeadNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院情况']/observation/value"); // Node isDeadNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院情况']/observation/value");
if (Func.isNotEmpty(isDeadNode)) { // if (Func.isNotEmpty(isDeadNode)) {
isDead = isDeadNode.getTextContent(); // isDead = isDeadNode.getTextContent();
} // }
//病区编号 // //病区编号
String wardCode = null; // String wardCode = null;
Node wardCodeNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/id/@extension"); // Node wardCodeNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/id/@extension");
if (Func.isNotEmpty(wardCodeNode)) { // if (Func.isNotEmpty(wardCodeNode)) {
wardCode = wardCodeNode.getNodeValue(); // wardCode = wardCodeNode.getNodeValue();
} // }
//病区名称 // //病区名称
String wardName = null; // String wardName = null;
Node wardNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/name"); // Node wardNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/componentOf/encompassingEncounter/location/healthCareFacility/serviceProviderOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/asOrganizationPartOf/wholeOrganization/name");
if (Func.isNotEmpty(wardNameNode)) { // if (Func.isNotEmpty(wardNameNode)) {
wardName = wardNameNode.getTextContent(); // wardName = wardNameNode.getTextContent();
} // }
//顺德人医第三方索引 // //顺德人医第三方索引
String sdryIndex = null; // String sdryIndex = null;
Node sdryIndexNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/id/item/@extension"); // Node sdryIndexNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/id/item/@extension");
if (Func.isNotEmpty(sdryIndexNode)) { // if (Func.isNotEmpty(sdryIndexNode)) {
sdryIndex = sdryIndexNode.getNodeValue(); // sdryIndex = sdryIndexNode.getNodeValue();
} // }
//
// //设置dto
// TBasicDTO dto = new TBasicDTO();
// dto.setSerialId(serialId);
// dto.setSend(send);
// dto.setReceive(receive);
// dto.setInpatientNo(inpatientNo);
// dto.setName(name);
// dto.setJzh(jzh);
// dto.setAdmissDeptName(admissDeptName);
// dto.setDisDeptName(disDeptName);
// dto.setAdmissDate(admissDate);
// dto.setDisDate(disDate);
// dto.setAdmissTimes(admissTimes);
// dto.setAttendingName(attendingName);
// dto.setAge(age);
// dto.setSex(sex);
// dto.setIdCard(idCard);
// dto.setDisDept(disDept);
// dto.setSexName(sexName);
// dto.setBedNum(bedNum);
// dto.setIsDead(isDead);
// dto.setAdmissDays(admissDays);
// dto.setWardCode(wardCode);
// dto.setWardName(wardName);
// dto.setSdryIndex(sdryIndex);
//
// dto.setParams(ParamsUtils.addParam("serialId", dto.getSerialId())
// .addParam("receive", dto.getReceive())
// .addParam("send", dto.getSend())
// .param());
//设置dto
TBasicDTO dto = new TBasicDTO();
dto.setSerialId(serialId);
dto.setSend(send);
dto.setReceive(receive);
dto.setInpatientNo(inpatientNo);
dto.setName(name);
dto.setJzh(jzh);
dto.setAdmissDeptName(admissDeptName);
dto.setDisDeptName(disDeptName);
dto.setAdmissDate(admissDate);
dto.setDisDate(disDate);
dto.setAdmissTimes(admissTimes);
dto.setAttendingName(attendingName);
dto.setAge(age);
dto.setSex(sex);
dto.setIdCard(idCard);
dto.setDisDept(disDept);
dto.setSexName(sexName);
dto.setBedNum(bedNum);
dto.setIsDead(isDead);
dto.setAdmissDays(admissDays);
dto.setWardCode(wardCode);
dto.setWardName(wardName);
dto.setSdryIndex(sdryIndex);
dto.setParams(ParamsUtils.addParam("serialId", dto.getSerialId()) TBasicDTO dto = new TBasicDTO();
.addParam("receive", dto.getReceive()) dto.setSerialId("1212");
.addParam("send", dto.getSend()) dto.setSend("1");
.param()); dto.setReceive("1");
dto.setInpatientNo("334");
dto.setName("1");
dto.setJzh("565");
dto.setAdmissDeptName("1");
dto.setDisDeptName("1");
dto.setAdmissDate(DateUtil.formatDateTime(DateUtil.now()));
dto.setDisDate(DateUtil.formatDateTime(DateUtil.now()));
dto.setAdmissTimes("3");
dto.setAttendingName("1");
dto.setAge("1");
dto.setSex("1");
dto.setIdCard("1");
dto.setDisDept("1");
dto.setSexName("1");
dto.setBedNum("1");
dto.setIsDead("1");
dto.setAdmissDays("1");
dto.setWardCode("1");
dto.setWardName("1");
dto.setSdryIndex("1");
return dto; return dto;
} }
} }

@ -14,42 +14,42 @@ public class WsBasicResultImpl implements IWsResult {
@Override @Override
public String ok(Map<String, Object> params) { public String ok(Map<String, Object> params) {
return null; return "hello";
} }
@Override @Override
public String fail(Map<String, Object> params) { public String fail(Map<String, Object> params) {
String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI); String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
return "<MCCI_IN000002UV01 xmlns=\"urn:hl7-org:v3\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ITSVersion=\"XML_1.0\" xsi:schemaLocation=\"urn:hl7-org:v3 file:///E:/hl7/HL7/v3ballot_fullsite_2011MAY/v3ballot/html/processable/multicacheschemas/MCCI_IN000002UV01.xsd\"> \n" + return "<MCCI_IN000002UV01 xmlns=\"urn:hl7-org:v3\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ITSVersion=\"XML_1.0\" xsi:schemaLocation=\"urn:hl7-org:v3 file:///E:/hl7/HL7/v3ballot_fullsite_2011MAY/v3ballot/html/processable/multicacheschemas/MCCI_IN000002UV01.xsd\"> \n" +
" <id extension=\"" + Func.randomUUID() + "\"/> \n" + " <id extension=\"" + Func.randomUUID() + "\"/> \n" +
" <creationTime value=\"" + createTime + "\"/> \n" + " <creationTime value=\"" + createTime + "\"/> \n" +
" <interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/> \n" + " <interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/> \n" +
" <processingCode code=\"P\"/> \n" + " <processingCode code=\"P\"/> \n" +
" <processingModeCode/> \n" + " <processingModeCode/> \n" +
" <acceptAckCode code=\"AL\"/> \n" + " <acceptAckCode code=\"AL\"/> \n" +
" <receiver typeCode=\"RCV\"> \n" + " <receiver typeCode=\"RCV\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" + " <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" + " <id> \n" +
" <item extension=\"" + params.get("receive") + "\"/> \n" + " <item extension=\"" + params.get("receive") + "\"/> \n" +
" </id> \n" + " </id> \n" +
" </device> \n" + " </device> \n" +
" </receiver> \n" + " </receiver> \n" +
" <sender typeCode=\"SND\"> \n" + " <sender typeCode=\"SND\"> \n" +
" <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" + " <device classCode=\"DEV\" determinerCode=\"INSTANCE\"> \n" +
" <id> \n" + " <id> \n" +
" <item extension=\"" + params.get("send") + "\"/> \n" + " <item extension=\"" + params.get("send") + "\"/> \n" +
" </id> \n" + " </id> \n" +
" </device> \n" + " </device> \n" +
" </sender> \n" + " </sender> \n" +
" <acknowledgement typeCode=\"AE\"> \n" + " <acknowledgement typeCode=\"AE\"> \n" +
" <!--请求消息ID--> \n" + " <!--请求消息ID--> \n" +
" <targetMessage> \n" + " <targetMessage> \n" +
" <id extension=\"" + params.get("serialId") + "\"/> \n" + " <id extension=\"" + params.get("serialId") + "\"/> \n" +
" </targetMessage> \n" + " </targetMessage> \n" +
" <acknowledgementDetail> \n" + " <acknowledgementDetail> \n" +
" <text value=\"" + params.get("msg") + "\"/> \n" + " <text value=\"" + params.get("msg") + "\"/> \n" +
" </acknowledgementDetail> \n" + " </acknowledgementDetail> \n" +
" </acknowledgement> \n" + " </acknowledgement> \n" +
"</MCCI_IN000002UV01>\n"; "</MCCI_IN000002UV01>\n";
} }
} }

@ -1,42 +1,52 @@
package com.docus.server.collect.dept.ws; package com.docus.server.collect.dept.ws;
import com.docus.core.util.XmlUtil;
import com.docus.server.sys.common.pojo.dto.DeptDTO; import com.docus.server.sys.common.pojo.dto.DeptDTO;
import com.docus.server.tool.ParamsUtils;
import com.docus.server.ws.convert.IConverter; import com.docus.server.ws.convert.IConverter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.w3c.dom.Node;
import java.util.UUID;
@Component("powerDeptConverter") @Component("powerDeptConverter")
public class PowerDeptConverter implements IConverter { public class PowerDeptConverter implements IConverter {
@Override @Override
public DeptDTO convert(String message,String methodName) { public DeptDTO convert(String message, String methodName) {
//TODO 根据协议进行解析。 //TODO 根据协议进行解析。
XmlUtil xmlParseUtil = XmlUtil.of(message); // XmlUtil xmlParseUtil = XmlUtil.of(message);
Node msgIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/id/@extension"); // Node msgIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/id/@extension");
Node receiverNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/receiver/device/id/item/@extension"); // Node receiverNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/receiver/device/id/item/@extension");
Node operateTypeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/@operateType"); // Node operateTypeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/@operateType");
Node deptCodeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/DEPT_CODE/@value"); // Node deptCodeNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/DEPT_CODE/@value");
Node deptNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/DEPT_NAME/@value"); // Node deptNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/subject1/valueSet/valueSetItems/DEPT_NAME/@value");
Node authorIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/id/item/@extension"); // Node authorIdNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/id/item/@extension");
Node authorNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/assignedPerson/name/item/part/@value"); // Node authorNameNode = xmlParseUtil.getNode("/PRVS_IN000002UV01/controlActProcess/subject/registrationRequest/author/assignedEntity/assignedPerson/name/item/part/@value");
//
// DeptDTO deptDto = new DeptDTO();
// deptDto.setMessageId(msgIdNode.getNodeValue());
// deptDto.setReceiver(receiverNode.getNodeValue());
// deptDto.setOperateType(operateTypeNode.getNodeValue());
// deptDto.setDeptCode(deptCodeNode.getNodeValue());
// deptDto.setDeptName(deptNameNode.getNodeValue());
// deptDto.setAuthorId(authorIdNode.getNodeValue());
// deptDto.setAuthorName(authorNameNode.getNodeValue());
// deptDto.setSource(message);//原始xml报文
//
// deptDto.setParams(ParamsUtils.addParam("msg", "操作成功!")
// .addParam("msgId", deptDto.getMessageId())
// .addParam("receiver", deptDto.getReceiver())
// .param());
DeptDTO deptDto = new DeptDTO(); DeptDTO deptDto = new DeptDTO();
deptDto.setMessageId(msgIdNode.getNodeValue()); deptDto.setMessageId(UUID.randomUUID().toString());
deptDto.setReceiver(receiverNode.getNodeValue()); deptDto.setReceiver("1");
deptDto.setOperateType(operateTypeNode.getNodeValue()); deptDto.setOperateType("2");
deptDto.setDeptCode(deptCodeNode.getNodeValue()); deptDto.setDeptCode("3");
deptDto.setDeptName(deptNameNode.getNodeValue()); deptDto.setDeptName("4");
deptDto.setAuthorId(authorIdNode.getNodeValue()); deptDto.setAuthorId("5");
deptDto.setAuthorName(authorNameNode.getNodeValue()); deptDto.setAuthorName("6");
deptDto.setSource(message);//原始xml报文 deptDto.setSource(message);//原始xml报文
deptDto.setParams(ParamsUtils.addParam("msg", "操作成功!")
.addParam("msgId", deptDto.getMessageId())
.addParam("receiver", deptDto.getReceiver())
.param());
return deptDto; return deptDto;
} }
} }

@ -40,7 +40,7 @@ public class WsDeptResultImpl implements IWsResult {
"\t</sender>\n" + "\t</sender>\n" +
"\t<acknowledgement typeCode=\"AA\">\n" + "\t<acknowledgement typeCode=\"AA\">\n" +
"\t\t<targetMessage>\n" + "\t\t<targetMessage>\n" +
"\t\t\t<id extension=\"" + params.get("msgId") + "\"/>\n" + "\t\t\t<id extension=\"" + params.get("messageId") + "\"/>\n" +
"\t\t</targetMessage>\n" + "\t\t</targetMessage>\n" +
"\t\t<acknowledgementDetail>\n" + "\t\t<acknowledgementDetail>\n" +
"\t\t\t<text value=\"" + params.get("msg") + "\"/>\n" + "\t\t\t<text value=\"" + params.get("msg") + "\"/>\n" +

@ -5,10 +5,8 @@ import com.docus.server.sys.common.pojo.dto.UserDTO;
import com.docus.server.sys.service.IPowerDeptService; import com.docus.server.sys.service.IPowerDeptService;
import com.docus.server.sys.service.IPowerUserService; import com.docus.server.sys.service.IPowerUserService;
import com.docus.server.ws.impl.BaseCollectService; import com.docus.server.ws.impl.BaseCollectService;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -22,9 +20,10 @@ public class CollectService extends BaseCollectService {
/** /**
* 3 * 3
*/ */
@Async("recordMessage") /*@Async("recordMessage")
@Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 2000L, multiplier = 1.5)) @Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 2000L, multiplier = 1.5))*/
public void toInsertOrUpdateDept(DeptDTO deptDTO) { @Transactional
public void insertOrUpdateDept(DeptDTO deptDTO) {
//异步写入归档系统,失败自动重试。 //异步写入归档系统,失败自动重试。
if (checkType(deptDTO.getOperateType(), delType)) { if (checkType(deptDTO.getOperateType(), delType)) {
deptService.delDeptByDeptCode(deptDTO.getDeptCode()); deptService.delDeptByDeptCode(deptDTO.getDeptCode());
@ -33,15 +32,13 @@ public class CollectService extends BaseCollectService {
} }
} }
// @Async("recordMessage") @Transactional
// @Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 2000L, multiplier = 1.5)) public void insertOrUpdateUser(UserDTO userDTO) {
public void toInsertOrUpdateUser(UserDTO userDTO) {
// 判断操作类型 // 判断操作类型
if (super.checkType(userDTO.getOperateType(), delType)) { if (super.checkType(userDTO.getOperateType(), delType)) {
userService.delUserByUserName(userDTO.getUserName()); userService.delUserByUserName(userDTO.getUserName());
} else { } else {
userService.saveOrUpdatePowerUser(userDTO); userService.saveOrUpdatePowerUser(userDTO);
} }
} }
} }

@ -40,8 +40,11 @@ public class VisitorProcessor extends AbstractProcessor {
@Override @Override
public Object beforeProcess(TrackContext context) { public Object beforeProcess(TrackContext context) {
log.debug("=== AOP 前置通知 ==="); log.debug("=== AOP 前置通知 ===");
String message = (String) context.getArgs()[0];
initBeans(context.getBeanNames()); initBeans(context.getBeanNames());
String message = (String) context.getArgs()[0];
if (Func.isEmpty(message)) {
throw new RuntimeException("参数为空");
}
Object dto = converter.convert(message, context.getMethodName()); Object dto = converter.convert(message, context.getMethodName());
String jsonStr = JSON.toJSON(dto); String jsonStr = JSON.toJSON(dto);
SpringUtils.invokeMethod(context.getClassType(), "setProperty", new Object[]{jsonStr}); SpringUtils.invokeMethod(context.getClassType(), "setProperty", new Object[]{jsonStr});

@ -1,20 +1,16 @@
package com.docus.server.ws.impl; package com.docus.server.ws.impl;
import com.docus.core.util.Func;
import com.docus.core.util.json.JSON; import com.docus.core.util.json.JSON;
import com.docus.server.collect.infrastructure.dao.CollectTypeEnum; import com.docus.log.annotation.TrackGroup;
import com.docus.server.collect.infrastructure.dao.FlagEnum;
import com.docus.server.record.pojo.dto.TBasicDTO; import com.docus.server.record.pojo.dto.TBasicDTO;
import com.docus.server.record.service.ITBasicService; import com.docus.server.record.service.ITBasicService;
import com.docus.server.tool.ParamsUtils; import com.docus.server.visitor.VisitorProcessor;
import com.docus.server.ws.IBasicService; import com.docus.server.ws.IBasicService;
import com.docus.server.ws.ITaskOriginalMessageService;
import com.docus.server.ws.IWsResult;
import com.docus.server.ws.convert.IConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @BelongsProject: docus-webservice-sdry * @BelongsProject: docus-webservice-sdry
@ -27,67 +23,45 @@ import javax.annotation.Resource;
@Service @Service
@Slf4j @Slf4j
public class BasicServiceImpl implements IBasicService { public class BasicServiceImpl implements IBasicService {
@Resource(name = "wsDeptResultImpl")
private IWsResult wsResult;
@Resource(name = "tBasicConverter")
private IConverter converter;
@Resource @Resource
private ITBasicService tBasicService; private ITBasicService tBasicService;
@Resource private AtomicReference<TBasicDTO> atomicReference = new AtomicReference<>();
private ITaskOriginalMessageService taskOriginalMessageService;
/**
* @param message
* @see com.docus.server.ws.convert.IConverter
* @see com.docus.server.ws.IWsResult
* @see VisitorProcessor aop
*/
@Override @Override
@TrackGroup(group = "WEBSERVICE_XML_BASIC",
beanNames = {"tBasicConverter", "wsBasicResultImpl"}, processor = VisitorProcessor.class)
public String setTBasic(String message) { public String setTBasic(String message) {
log.info("新增基础数据:{}", message); log.info("新增基础数据:{}", message);
tBasicService.insertTBasic(getTBasicDTO());
if (Func.isEmpty(message)) { return null;
return toFail();
}
//此处需要存储原xml内容。
TBasicDTO tBasicDTO = new TBasicDTO();
long id = 0;
try {
tBasicDTO = (TBasicDTO) converter.convert(message, FlagEnum.INSERT.name());
id = taskOriginalMessageService.insertTaskOriginalMessage(JSON.toJSON(tBasicDTO), message, CollectTypeEnum.WEBSERVICE_XML_BASIC);
tBasicService.insertTBasic(tBasicDTO);
return wsResult.ok(tBasicDTO.getParams());
} catch (Exception e) {
log.error(e.getMessage(), e);
// taskOriginalMessageService.updateTaskOriginalMessage(id);
tBasicDTO.getParams().put("msg", e.getMessage());
return wsResult.fail(tBasicDTO.getParams());
}
} }
/**
* @param message
* @see com.docus.server.ws.convert.IConverter
* @see com.docus.server.ws.IWsResult
* @see VisitorProcessor aop
*/
@Override @Override
@TrackGroup(group = "WEBSERVICE_XML_BASIC",
beanNames = {"tBasicConverter", "wsBasicResultImpl"}, processor = VisitorProcessor.class)
public String updateTBasic(String message) { public String updateTBasic(String message) {
log.info("修改基础数据:{}", message); tBasicService.updateTBasic(getTBasicDTO());
return null;
if (Func.isEmpty(message)) { }
return toFail();
}
TBasicDTO tBasicDTO = new TBasicDTO(); public void setProperty(String json) {
long id = 0; this.atomicReference.set(JSON.fromJSON(json, TBasicDTO.class));
try {
tBasicDTO = (TBasicDTO) converter.convert(message, FlagEnum.UPDATE.name());
id = taskOriginalMessageService.insertTaskOriginalMessage(JSON.toJSON(tBasicDTO), message, CollectTypeEnum.WEBSERVICE_XML_BASIC);
tBasicService.updateTBasic(tBasicDTO);
return wsResult.ok(tBasicDTO.getParams());
} catch (Exception e) {
log.error(e.getMessage(), e);
// taskOriginalMessageService.updateTaskOriginalMessage(id);
tBasicDTO.getParams().put("msg", e.getMessage());
return wsResult.fail(tBasicDTO.getParams());
}
} }
private String toFail() { public TBasicDTO getTBasicDTO() {
return wsResult.fail(ParamsUtils.addParam("serialId", null) return atomicReference.get();
.addParam("msg", "参数为空")
.addParam("receive", null)
.addParam("send", null).param());
} }
} }

@ -1,18 +1,16 @@
package com.docus.server.ws.impl; package com.docus.server.ws.impl;
import com.docus.core.util.json.JSON; import com.docus.core.util.json.JSON;
import com.docus.server.collect.infrastructure.dao.CollectTypeEnum; import com.docus.log.annotation.TrackGroup;
import com.docus.server.collect.infrastructure.dao.FlagEnum;
import com.docus.server.collect.service.CollectService; import com.docus.server.collect.service.CollectService;
import com.docus.server.sys.common.pojo.dto.DeptDTO; import com.docus.server.sys.common.pojo.dto.DeptDTO;
import com.docus.server.visitor.VisitorProcessor;
import com.docus.server.ws.IDeptServer; import com.docus.server.ws.IDeptServer;
import com.docus.server.ws.ITaskOriginalMessageService;
import com.docus.server.ws.IWsResult;
import com.docus.server.ws.convert.IConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @author wen yongbin * @author wen yongbin
@ -21,34 +19,32 @@ import javax.annotation.Resource;
@Service @Service
@Slf4j @Slf4j
public class DeptServerImpl implements IDeptServer { public class DeptServerImpl implements IDeptServer {
@Resource(name = "wsBasicResultImpl")
private IWsResult wsResult;
@Resource(name = "powerDeptConverter")
private IConverter converter;
@Resource @Resource
private CollectService collectService; private CollectService collectService;
@Resource private AtomicReference<DeptDTO> atomicReference = new AtomicReference<>();
private ITaskOriginalMessageService taskOriginalMessageService;
/**
* @param message
* @see com.docus.server.ws.convert.IConverter
* @see com.docus.server.ws.IWsResult
* @see VisitorProcessor aop
*/
@Override @Override
@TrackGroup(group = "WEBSERVICE_XML_DEPT",
beanNames = {"powerDeptConverter", "wsDeptResultImpl"}, processor = VisitorProcessor.class)
public String deptModify(String message) { public String deptModify(String message) {
log.info("新增/修改科室数据:{}", message); log.info("新增/修改科室数据:{}", message);
collectService.insertOrUpdateDept(getDeptDTO());
return null;
}
DeptDTO deptDTO = new DeptDTO(); public void setProperty(String json) {
Long id = null; DeptDTO deptDTO = JSON.fromJSON(json, DeptDTO.class);
this.atomicReference.set(deptDTO);
}
try { public DeptDTO getDeptDTO() {
//此处需要存储原xml内容。 return this.atomicReference.get();
deptDTO = (DeptDTO) converter.convert(message, FlagEnum.INSERT.name());
id = taskOriginalMessageService.insertTaskOriginalMessage(JSON.toJSON(deptDTO), message, CollectTypeEnum.WEBSERVICE_XML_DEPT);
collectService.toInsertOrUpdateDept(deptDTO);
return wsResult.ok(deptDTO.getParams());
} catch (Exception e) {
log.error(e.getMessage(), e);
// taskOriginalMessageService.updateTaskOriginalMessage(id);
deptDTO.getParams().put("msg", e.getMessage());
return wsResult.fail(deptDTO.getParams());
}
} }
} }

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @author wen yongbin * @author wen yongbin
@ -18,43 +19,31 @@ import javax.annotation.Resource;
@Service @Service
@Slf4j @Slf4j
public class UserServerImpl implements IUserServer { public class UserServerImpl implements IUserServer {
// @Resource(name = "wsUserResultImpl")
// private IWsResult wsResult;
// @Resource(name = "powerUserConverter")
// private IConverter converter;
@Resource @Resource
private CollectService collectService; private CollectService collectService;
private UserDTO userDTO; private AtomicReference<UserDTO> atomicReference = new AtomicReference<>();
// @Resource /**
// private ITaskOriginalMessageService taskOriginalMessageService; * @param message
* @see com.docus.server.ws.convert.IConverter
* @see com.docus.server.ws.IWsResult
* @see VisitorProcessor aop
*/
@Override @Override
@TrackGroup(group = "WEBSERVICE_XML_USER", @TrackGroup(group = "WEBSERVICE_XML_USER",
beanNames = {"powerUserConverter", "wsUserResultImpl"}, processor = VisitorProcessor.class) beanNames = {"powerUserConverter", "wsUserResultImpl"}, processor = VisitorProcessor.class)
public String userModify(String message) { public String userModify(String message) {
log.debug("新增/修改用户数据:{}", message); log.debug("新增/修改用户数据:{}", message);
// UserDTO userDTO = (UserDTO) converter.convert(message, FlagEnum.INSERT); collectService.insertOrUpdateUser(getUserDTO());
collectService.toInsertOrUpdateUser(userDTO);
// return JSON.toJSON(userDTO);
// UserDTO userDTO = new UserDTO();
// long id = 0;
// try {
// UserDTO userDTO = (UserDTO) converter.convert(message, FlagEnum.INSERT);
// id = taskOriginalMessageService.insertTaskOriginalMessage(JSON.toJSON(userDTO), message, CollectTypeEnum.WEBSERVICE_XML_USER);
// collectService.toInsertOrUpdateUser(userDTO);
// return wsResult.ok(userDTO.getParams());
// return JSON.toJSON(userDTO);
// } catch (Exception e) {
// userDTO.getParams().put("msg", e.getMessage());
// taskOriginalMessageService.updateTaskOriginalMessage(id);
// return wsResult.fail(userDTO.getParams());
// }
return null; return null;
} }
public void setProperty(String json) { public void setProperty(String json) {
this.userDTO = JSON.fromJSON(json, UserDTO.class); this.atomicReference.set(JSON.fromJSON(json, UserDTO.class));
}
public UserDTO getUserDTO() {
return atomicReference.get();
} }
} }

@ -12,7 +12,7 @@ public interface ITBasicService {
* @param dto * @param dto
* @throws Exception * @throws Exception
*/ */
void insertTBasic(TBasicDTO dto) throws Exception; void insertTBasic(TBasicDTO dto);
/** /**
* *
@ -20,7 +20,7 @@ public interface ITBasicService {
* @param dto * @param dto
* @throws Exception * @throws Exception
*/ */
void updateTBasic(TBasicDTO dto) throws Exception; void updateTBasic(TBasicDTO dto);
/** /**
* *

@ -96,11 +96,11 @@
</update> </update>
<select id="selectOne" resultType="java.lang.Integer"> <select id="selectOne" resultType="java.lang.Integer">
select count(patient_id) from t_basic where jzh=#{jzh} select count(patient_id) from `docus_medicalrecord`.`t_basic` where jzh=#{jzh}
</select> </select>
<select id="getPatientId" resultType="java.lang.String"> <select id="getPatientId" resultType="java.lang.String">
select patient_id from t_basic where jzh=#{jzh} select patient_id from `docus_medicalrecord`.`t_basic` where jzh=#{jzh}
</select> </select>
<select id="selectBasicListByAdmissDate" resultType="com.docus.server.record.pojo.entity.TBasic"> <select id="selectBasicListByAdmissDate" resultType="com.docus.server.record.pojo.entity.TBasic">
select * select *

Loading…
Cancel
Save