|
@@ -1,5 +1,7 @@
|
|
|
package thyyxxk.webserver.service.examinations;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.text.StringEscapeUtils;
|
|
|
import org.dom4j.Document;
|
|
@@ -8,6 +10,7 @@ import org.dom4j.DocumentHelper;
|
|
|
import org.dom4j.Element;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.webserver.config.exception.BizException;
|
|
|
import thyyxxk.webserver.entity.examinations.adicon.AdiconInquiry;
|
|
|
import thyyxxk.webserver.entity.examinations.adicon.BarcodeType;
|
|
@@ -15,6 +18,7 @@ import thyyxxk.webserver.entity.examinations.adicon.ListTableItem;
|
|
|
import thyyxxk.webserver.entity.examinations.adicon.ReportDetail;
|
|
|
import thyyxxk.webserver.service.externalhttp.AdiconHttpSrvc;
|
|
|
import thyyxxk.webserver.utils.FilterUtil;
|
|
|
+import thyyxxk.webserver.utils.StringUtil;
|
|
|
|
|
|
import javax.xml.bind.JAXBContext;
|
|
|
import javax.xml.bind.Unmarshaller;
|
|
@@ -44,6 +48,7 @@ public class AdiconService {
|
|
|
}
|
|
|
|
|
|
public List<ListTableItem> getReportList(AdiconInquiry inquiry) throws Exception {
|
|
|
+ List<String> barcodesList = getPatientBarcodeList(inquiry);
|
|
|
String key = URLEncoder.encode(inquiry.getKey(), StandardCharsets.UTF_8.name());
|
|
|
String xmlString = adiconHttpSrvc.getReportList(key, inquiry.getBegin(), inquiry.getEnd());
|
|
|
List<ListTableItem> result = new ArrayList<>();
|
|
@@ -56,9 +61,13 @@ public class AdiconService {
|
|
|
ListTableItem listTable = (ListTableItem) unmarshaller.unmarshal(reader);
|
|
|
if (inquiry.getReportType().equals("全部") ||
|
|
|
inquiry.getReportType().equals(listTable.getReportType())) {
|
|
|
- result.add(listTable);
|
|
|
+ if (barcodesList.isEmpty() || barcodesList.contains(listTable.getCustomerBarcode())) {
|
|
|
+ result.add(listTable);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ if (result.isEmpty() && !barcodesList.isEmpty()) {
|
|
|
+ throw new BizException("没有找到此患者已发布的外送报告。");
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -105,6 +114,29 @@ public class AdiconService {
|
|
|
return root.getText();
|
|
|
}
|
|
|
|
|
|
+ private List<String> getPatientBarcodeList(AdiconInquiry inquiry) {
|
|
|
+ List<String> barcodesList = new ArrayList<>();
|
|
|
+ if (StringUtil.notBlank(inquiry.getPatNo())) {
|
|
|
+ String url = "http://172.16.32.167:9206/thyy/api/public/lis/bar_code";
|
|
|
+ JSONObject obj = new RestTemplate().postForObject(url, inquiry, JSONObject.class);
|
|
|
+ if (null == obj) {
|
|
|
+ throw new BizException("没有找到此患者已发布的外送报告。");
|
|
|
+ }
|
|
|
+ if (obj.getIntValue("code") != 1) {
|
|
|
+ throw new BizException(obj.getString("message"));
|
|
|
+ }
|
|
|
+ JSONArray data = obj.getJSONArray("data");
|
|
|
+ if (data.isEmpty()) {
|
|
|
+ throw new BizException("没有找到此患者已发布的外送报告。");
|
|
|
+ }
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject item = data.getJSONObject(i);
|
|
|
+ barcodesList.add(item.getString("barCode"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return barcodesList;
|
|
|
+ }
|
|
|
+
|
|
|
private Element getRootElement(String xmlString) throws DocumentException {
|
|
|
String xmlWithoutDeclaration = removeXmlDeclaration(xmlString);
|
|
|
String standardXml = StringEscapeUtils.unescapeXml(xmlWithoutDeclaration);
|