|
@@ -1,5 +1,7 @@
|
|
|
package thyyxxk.webserver.service.inpatient;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -14,18 +16,20 @@ import thyyxxk.webserver.dao.his.inpatient.Routines;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.YiZhuLuRuDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.dictionary.CodeName;
|
|
|
+import thyyxxk.webserver.entity.drg.BaseInfo;
|
|
|
+import thyyxxk.webserver.entity.drg.DiseInfoList;
|
|
|
+import thyyxxk.webserver.entity.drg.OprtInfoList;
|
|
|
import thyyxxk.webserver.entity.inpatient.dismiss.ZyDisYbDiag;
|
|
|
import thyyxxk.webserver.entity.inpatient.patient.*;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.HuanZheFeiYong;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
|
|
|
+import thyyxxk.webserver.service.externalhttp.DrgWebServices;
|
|
|
import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
+import thyyxxk.webserver.service.zhuyuanyisheng.EmrServer;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author dj
|
|
@@ -38,13 +42,18 @@ public class PatientService {
|
|
|
private final Routines routines;
|
|
|
private final YiZhuLuRuDao yiZhuLuRuDao;
|
|
|
private final RedisLikeService redis;
|
|
|
+ private final EmrServer emrServer;
|
|
|
+ private final DrgWebServices drgHttp;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
- public PatientService(PatientDao dao, Routines routines, YiZhuLuRuDao yiZhuLuRuDao, RedisLikeService redis) {
|
|
|
+ public PatientService(PatientDao dao, Routines routines, YiZhuLuRuDao yiZhuLuRuDao, RedisLikeService redis, EmrServer emrServer, DrgWebServices drgHttp) {
|
|
|
this.dao = dao;
|
|
|
this.routines = routines;
|
|
|
this.yiZhuLuRuDao = yiZhuLuRuDao;
|
|
|
this.redis = redis;
|
|
|
+ this.emrServer = emrServer;
|
|
|
+ this.drgHttp = drgHttp;
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<Overview>> getOverView(String ward, Boolean viewBabies) {
|
|
@@ -62,9 +71,105 @@ public class PatientService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有住院号【" + inpatientNo + "】的在院业务!");
|
|
|
}
|
|
|
setExpenseInformation(data);
|
|
|
+ // todo 要查看患者预分组
|
|
|
+ setDrgPatInfo(data);
|
|
|
return ResultVoUtil.success(data);
|
|
|
}
|
|
|
|
|
|
+ private void setDrgPatInfo(Patient p) {
|
|
|
+ BaseInfo bf = new BaseInfo();
|
|
|
+ bf.setVisitId(p.getInpatientNo() + "_" + p.getAdmissTimes() + "_" + p.getLedgerSn())
|
|
|
+ .setGend(p.getSex().toString())
|
|
|
+ .setBrdy(p.getBirthDate())
|
|
|
+ .setAge(p.getAge().toString())
|
|
|
+ .setNwbAge("")
|
|
|
+ .setNwbBirWt("")
|
|
|
+ .setNwbAdmWt("")
|
|
|
+ .setAdmTime(p.getAdmissDate())
|
|
|
+ .setActIptDays(String.valueOf(DateUtil.daysBetween(new Date(), p.getAdmissDate())))
|
|
|
+ .setTotalFee(p.getTotalCharge())
|
|
|
+ .setCdntnPay("")
|
|
|
+ .setIllPay("");
|
|
|
+ JSONObject upload = new JSONObject();
|
|
|
+ upload.put("base_info", bf);
|
|
|
+ upload.put("dise_info_list", setDrgDisList(p));
|
|
|
+ upload.put("oprt_info_list", setOprtInfoList(p));
|
|
|
+ JSONObject res = drgHttp.getDrgCaseQualityControlGroup(upload);
|
|
|
+ if (res.getInteger("code") == 0) {
|
|
|
+ if (res.getJSONObject("result") != null) {
|
|
|
+ JSONArray groupInfo = res.getJSONObject("result").getJSONArray("group_info");
|
|
|
+ if (groupInfo != null) {
|
|
|
+ JSONObject item = groupInfo.getJSONObject(0);
|
|
|
+ p.setGroupInfoName(item.getString("name"));
|
|
|
+ p.setGroupInfoWeight(item.getString("weight"));
|
|
|
+ p.setGroupInfoBl(item.getString("bl"));
|
|
|
+ p.setGroupInfoProfit(item.getString("profit"));
|
|
|
+ p.setGroupInfoFeeStand(item.getString("fee_stand"));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("上传数据:{}", upload);
|
|
|
+ log.info("res:{}", res);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DiseInfoList> setDrgDisList(Patient p) {
|
|
|
+ List<DiseInfoList> list = new ArrayList<>();
|
|
|
+ JSONObject emrJs = emrServer.getEmrPatientData(p.getInpatientNo(), p.getAdmissTimes());
|
|
|
+ String id = p.getInpatientNo() + "_" + p.getAdmissTimes() + "_" + p.getLedgerSn();
|
|
|
+ try {
|
|
|
+ JSONArray disList = emrJs.getJSONArray("入院诊断");
|
|
|
+ for (int i = 0; i < disList.size(); i++) {
|
|
|
+ DiseInfoList temp = new DiseInfoList();
|
|
|
+ JSONObject item = disList.getJSONObject(i);
|
|
|
+ try {
|
|
|
+ temp.setVisitId(id)
|
|
|
+ .setDiagCode(item.getString("code"))
|
|
|
+ .setDiagName(item.getString("name"))
|
|
|
+ .setMaindiagFlag(i == 0 ? "1" : "0")
|
|
|
+ .setSortNo(String.valueOf(i + 1));
|
|
|
+ list.add(temp);
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<OprtInfoList> setOprtInfoList(Patient p) {
|
|
|
+ String id = p.getInpatientNo() + "_" + p.getAdmissTimes() + "_" + p.getLedgerSn();
|
|
|
+ List<OprtInfoList> list = new ArrayList<>();
|
|
|
+ JSONArray emrList = emrServer.getPatientSurgery(p.getInpatientNo(), p.getAdmissTimes());
|
|
|
+ for (int i = 0; i < emrList.size(); i++) {
|
|
|
+ JSONObject item = emrList.getJSONObject(i);
|
|
|
+ JSONObject oprtName;
|
|
|
+ try {
|
|
|
+ oprtName = item.getJSONObject("手术名称");
|
|
|
+ } catch (Exception e) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JSONArray oprtNameVals = oprtName.getJSONArray("value");
|
|
|
+ if (null == oprtNameVals) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (int j = 0; j < oprtNameVals.size(); j++) {
|
|
|
+ JSONObject opList = oprtNameVals.getJSONObject(j);
|
|
|
+ OprtInfoList op = new OprtInfoList();
|
|
|
+ op.setVisitId(id)
|
|
|
+ .setOprnOprtType((i + j) == 0 ? "1" : "2")
|
|
|
+ .setOprnOprtCode(opList.getString("code"))
|
|
|
+ .setOprnOprtName(opList.getString("name"))
|
|
|
+ .setSortNo(String.valueOf((i + j) + 1));
|
|
|
+ list.add(op);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public ResultVo<Patient> getDisPatient(String inpatientNo, Integer times) {
|
|
|
Patient data = dao.getPatientInfo(inpatientNo, "zy_inactpatient", times);
|