|
@@ -20,6 +20,7 @@ import thyyxxk.wxservice_server.entity.inspections.QueryReportDetail;
|
|
|
import thyyxxk.wxservice_server.entity.inspections.detail.*;
|
|
|
import thyyxxk.wxservice_server.utils.*;
|
|
|
|
|
|
+import java.awt.geom.RectangularShape;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -41,108 +42,100 @@ public class InspectionsService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<ExamIndexResult>> getExamIndex(CheckExamParam param) {
|
|
|
- String sendHead0 = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + param.getPatientId() + "</PTNT_NO>";
|
|
|
- String sendHead1 = null;
|
|
|
- String sendHead2 = null;
|
|
|
- String sendHead3 = null;
|
|
|
+ String firstHead = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + param.getPatientId() + "</PTNT_NO>";
|
|
|
+ String[] sendHeads = new String[]{firstHead, null, null, null};
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String url = hrgApiUrl + "/getParentIdByPatientId?patientId=" + param.getPatientId();
|
|
|
HrgCommonResponse response = restTemplate.getForObject(url, HrgCommonResponse.class);
|
|
|
if (null != response && response.getCode() == 0) {
|
|
|
List<Map<String, String>> list = CastUtil.cast(response.getData());
|
|
|
- sendHead1 = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + list.get(0).get("parentPatientId") + "</PTNT_NO>";
|
|
|
+ sendHeads[1] = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + list.get(0).get("parentPatientId") + "</PTNT_NO>";
|
|
|
}
|
|
|
final String tjNo = dao.selectTjNo(param.getPatientId());
|
|
|
final String inpatientNo = dao.selectInpatientNo(param.getPatientId());
|
|
|
if (StringUtil.notBlank(tjNo)) {
|
|
|
- sendHead2 = "<message><PTNT_NO>" + tjNo + "</PTNT_NO>";
|
|
|
+ sendHeads[2] = "<message><PTNT_NO>" + tjNo + "</PTNT_NO>";
|
|
|
}
|
|
|
if (StringUtil.notBlank(inpatientNo)) {
|
|
|
- sendHead3 = "<message><PATIENT_TYPE>1</PATIENT_TYPE><PTNT_NO>" + inpatientNo + "</PTNT_NO>";
|
|
|
+ sendHeads[3] = "<message><PATIENT_TYPE>1</PATIENT_TYPE><PTNT_NO>" + inpatientNo + "</PTNT_NO>";
|
|
|
}
|
|
|
String sendEnd = "<START_TIME>" + param.getStart() + "</START_TIME><END_TIME>" + param.getEnd() + "</END_TIME></message>";
|
|
|
- String send0 = sendHead0 + sendEnd;
|
|
|
- String xml0 = invokeService.invokeRemoteMethod("GetLabReportIndex", send0);
|
|
|
- List<ExamIndexResult> list0 = invokeService.analyzeExamIndex(xml0);
|
|
|
- if (null != sendHead1) {
|
|
|
- String send1 = sendHead1 + sendEnd;
|
|
|
- String xml1 = invokeService.invokeRemoteMethod("GetLabReportIndex", send1);
|
|
|
- List<ExamIndexResult> list1 = invokeService.analyzeExamIndex(xml1);
|
|
|
- list0.addAll(list1);
|
|
|
- }
|
|
|
- if (null != sendHead2) {
|
|
|
- String send2 = sendHead2 + sendEnd;
|
|
|
- String xml2 = invokeService.invokeRemoteMethod("GetLabReportIndex", send2);
|
|
|
- List<ExamIndexResult> list2 = invokeService.analyzeExamIndex(xml2);
|
|
|
- list0.addAll(list2);
|
|
|
- }
|
|
|
- if (null != sendHead3) {
|
|
|
- String send3 = sendHead3 + sendEnd;
|
|
|
- String xml3 = invokeService.invokeRemoteMethod("GetLabReportIndex", send3);
|
|
|
- List<ExamIndexResult> list3 = invokeService.analyzeExamIndex(xml3);
|
|
|
- list0.addAll(list3);
|
|
|
+ List<ExamIndexResult> list = new ArrayList<>();
|
|
|
+ for (String sendHead : sendHeads) {
|
|
|
+ if (null != sendHead) {
|
|
|
+ String sendXml = sendHead + sendEnd;
|
|
|
+ String resXml = invokeService.invokeRemoteMethod("GetLabReportIndex", sendXml);
|
|
|
+ list.addAll(invokeService.analyzeExamIndex(resXml));
|
|
|
+ }
|
|
|
}
|
|
|
- return ResultVoUtil.success(list0);
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<ExamIndexResult>> checkCovidExamIndexBySocialNo(String socialNo) {
|
|
|
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date date = new Date();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String start = df.format(date.getTime() - 15L * 24 * 60 * 60 * 1000);
|
|
|
String end = df.format(date);
|
|
|
String xmlEnd = "<START_TIME>" + start + "</START_TIME><END_TIME>" + end + "</END_TIME></message>";
|
|
|
List<String> mzNos = dao.selectMzNos(socialNo);
|
|
|
- List<HshjPatient> hshjNos = null;
|
|
|
- if (null != mzNos && mzNos.size() > 0) {
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- hshjNos = new ArrayList<>();
|
|
|
- for (String mzNo : mzNos) {
|
|
|
- String url = hrgApiUrl + "/getParentIdByPatientId?patientId=" + mzNo;
|
|
|
- HrgCommonResponse response = restTemplate.getForObject(url, HrgCommonResponse.class);
|
|
|
- if (null != response && response.getCode() == 0) {
|
|
|
- String patName = dao.selectPatName(mzNo);
|
|
|
- List<Map<String, String>> list = CastUtil.cast(response.getData());
|
|
|
- for (Map<String, String> item : list) {
|
|
|
- Date startDate = DateUtil.parseDatetime(start + " 00:00:00");
|
|
|
- Date itemDate = DateUtil.parseDatetime(item.get("createDate"));
|
|
|
- if (null != startDate && null != itemDate) {
|
|
|
- if (startDate.before(itemDate)) {
|
|
|
- hshjNos.add(new HshjPatient(patName, mzNo, item.get("parentPatientId")));
|
|
|
- }
|
|
|
- }
|
|
|
+ List<HshjPatient> hshjNos = getCovidMultipleExamNo(mzNos, start);
|
|
|
+ List<ExamIndexResult> results = getSingleCovidExamResult(mzNos, xmlEnd);
|
|
|
+ results.addAll(getMultipleExamResult(hshjNos, xmlEnd));
|
|
|
+ return ResultVoUtil.success(results);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<HshjPatient> getCovidMultipleExamNo(List<String> mzNos, String start) {
|
|
|
+ List<HshjPatient> hshjNos = new ArrayList<>();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ for (String mzNo : mzNos) {
|
|
|
+ String url = hrgApiUrl + "/getParentIdByPatientId?patientId=" + mzNo;
|
|
|
+ HrgCommonResponse response = restTemplate.getForObject(url, HrgCommonResponse.class);
|
|
|
+ if (null != response && response.getCode() == 0) {
|
|
|
+ String patName = dao.selectPatName(mzNo);
|
|
|
+ List<Map<String, String>> list = CastUtil.cast(response.getData());
|
|
|
+ for (Map<String, String> item : list) {
|
|
|
+ Date startDate = DateUtil.parseDatetime(start + " 00:00:00");
|
|
|
+ Date itemDate = DateUtil.parseDatetime(item.get("createDate"));
|
|
|
+ if (null != startDate && null != itemDate && startDate.before(itemDate)) {
|
|
|
+ hshjNos.add(new HshjPatient(patName, mzNo, item.get("parentPatientId")));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ return hshjNos;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamIndexResult> getSingleCovidExamResult(List<String> mzNos, String xmlEnd) {
|
|
|
List<ExamIndexResult> results = new ArrayList<>();
|
|
|
- if (null != mzNos && mzNos.size() > 0) {
|
|
|
- for (String mzNo : mzNos) {
|
|
|
- String mzHead = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + mzNo + "</PTNT_NO>";
|
|
|
- String xml = invokeService.invokeRemoteMethod("GetLabReportIndex", mzHead+xmlEnd);
|
|
|
- List<ExamIndexResult> list = invokeService.analyzeExamIndex(xml);
|
|
|
- for (ExamIndexResult index : list) {
|
|
|
- if (BooleanUtil.isCovidExam(index.getAPLY_CTNT())) {
|
|
|
- results.add(index);
|
|
|
- }
|
|
|
+ for (String mzNo : mzNos) {
|
|
|
+ String mzHead = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + mzNo + "</PTNT_NO>";
|
|
|
+ String xml = invokeService.invokeRemoteMethod("GetLabReportIndex", mzHead+xmlEnd);
|
|
|
+ List<ExamIndexResult> list = invokeService.analyzeExamIndex(xml);
|
|
|
+ for (ExamIndexResult index : list) {
|
|
|
+ if (BooleanUtil.isCovidExam(index.getAPLY_CTNT())) {
|
|
|
+ results.add(index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (null != hshjNos && hshjNos.size() > 0) {
|
|
|
- for (HshjPatient hshj : hshjNos) {
|
|
|
- String hshjHead = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + hshj.getParentId() + "</PTNT_NO>";
|
|
|
- String xml = invokeService.invokeRemoteMethod("GetLabReportIndex", hshjHead+xmlEnd);
|
|
|
- List<ExamIndexResult> list = invokeService.analyzeExamIndex(xml);
|
|
|
- for (ExamIndexResult index : list) {
|
|
|
- if (BooleanUtil.isCovidExam(index.getAPLY_CTNT())) {
|
|
|
- index.setPTNT_ID(hshj.getPatientId());
|
|
|
- index.setIC_CARD(hshj.getPatientId());
|
|
|
- index.setPTNT_NAME(hshj.getName());
|
|
|
- results.add(index);
|
|
|
- }
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ExamIndexResult> getMultipleExamResult(List<HshjPatient> hshjNos, String xmlEnd) {
|
|
|
+ List<ExamIndexResult> results = new ArrayList<>();
|
|
|
+ for (HshjPatient hshj : hshjNos) {
|
|
|
+ String hshjHead = "<message><PATIENT_TYPE>0</PATIENT_TYPE><PTNT_NO>" + hshj.getParentId() + "</PTNT_NO>";
|
|
|
+ String xml = invokeService.invokeRemoteMethod("GetLabReportIndex", hshjHead+xmlEnd);
|
|
|
+ List<ExamIndexResult> list = invokeService.analyzeExamIndex(xml);
|
|
|
+ for (ExamIndexResult index : list) {
|
|
|
+ if (BooleanUtil.isCovidExam(index.getAPLY_CTNT())) {
|
|
|
+ index.setPTNT_ID(hshj.getPatientId());
|
|
|
+ index.setIC_CARD(hshj.getPatientId());
|
|
|
+ index.setPTNT_NAME(hshj.getName());
|
|
|
+ results.add(index);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return ResultVoUtil.success(results);
|
|
|
+ return results;
|
|
|
}
|
|
|
|
|
|
public ResultVo<ExamDetailResult> checkExamDetail(QueryReportDetail param) {
|
|
@@ -151,15 +144,8 @@ public class InspectionsService {
|
|
|
}
|
|
|
String send = "<message><ORDR_ID>" + param.getOrderId() + "</ORDR_ID></message>";
|
|
|
String xml = invokeService.invokeRemoteMethod("GetLabReport", send);
|
|
|
- Element retEle = null;
|
|
|
- try {
|
|
|
- Document document = DocumentHelper.parseText(xml);
|
|
|
- Element root = document.getRootElement();
|
|
|
- retEle = root.element("return");
|
|
|
- } catch (DocumentException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (retEle == null) {
|
|
|
+ Element retEle = getResultElement(xml);
|
|
|
+ if (null == retEle) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "结果集为空!");
|
|
|
}
|
|
|
ExamDetailResult detail = new ExamDetailResult();
|
|
@@ -211,5 +197,14 @@ public class InspectionsService {
|
|
|
return ResultVoUtil.success(detail);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private Element getResultElement(String xml) {
|
|
|
+ try {
|
|
|
+ Document document = DocumentHelper.parseText(xml);
|
|
|
+ Element root = document.getRootElement();
|
|
|
+ return root.element("return");
|
|
|
+ } catch (DocumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|