|
|
@ -2,6 +2,7 @@ package com.ccsens.client.service.impl; |
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.extra.pinyin.PinyinUtil; |
|
|
import cn.hutool.extra.pinyin.PinyinUtil; |
|
|
import cn.hutool.http.HttpRequest; |
|
|
import cn.hutool.http.HttpRequest; |
|
|
@ -10,10 +11,17 @@ import cn.hutool.json.JSONArray; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.ccsens.client.persist.dao.HisConnectionDao; |
|
|
import com.ccsens.client.persist.dao.HisConnectionDao; |
|
|
|
|
|
import com.ccsens.client.persist.dao.PmsPatientDao; |
|
|
import com.ccsens.client.service.ILtHisConnectionService; |
|
|
import com.ccsens.client.service.ILtHisConnectionService; |
|
|
|
|
|
import com.ccsens.client.service.IPmsPatientService; |
|
|
|
|
|
import com.ccsens.common.core.domain.model.LoginUser; |
|
|
|
|
|
import com.ccsens.common.utils.IDGenerator; |
|
|
|
|
|
import com.ccsens.system.domain.dto.PmsPatientDto; |
|
|
import com.ccsens.system.domain.po.PmsPatient; |
|
|
import com.ccsens.system.domain.po.PmsPatient; |
|
|
|
|
|
import com.ccsens.system.domain.po.PmsPatientExample; |
|
|
import com.ccsens.system.domain.vo.PmsPatientVo; |
|
|
import com.ccsens.system.domain.vo.PmsPatientVo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -24,6 +32,8 @@ import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import static com.ccsens.common.utils.SecurityUtils.getLoginUser; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author zy |
|
|
* @author zy |
|
|
@ -31,11 +41,15 @@ import java.util.Map; |
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Service |
|
|
@Service |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
|
|
public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private HisConnectionDao hisConnectionDao; |
|
|
private HisConnectionDao hisConnectionDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private IPmsPatientService patientService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private PmsPatientDao patientDao; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 前端调用查询列表接口,如果有数据则直接返回 |
|
|
* 前端调用查询列表接口,如果有数据则直接返回 |
|
|
* 如果没查到数据,使用searchValue(患者院内唯一标识cardNo)去his查询 |
|
|
* 如果没查到数据,使用searchValue(患者院内唯一标识cardNo)去his查询 |
|
|
@ -62,6 +76,72 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
private static final String URL_SUFFIX_RE_2_1_5 = "/patient-service/api/v1/patient/getFinOprRegList?inPatientNo="; |
|
|
private static final String URL_SUFFIX_RE_2_1_5 = "/patient-service/api/v1/patient/getFinOprRegList?inPatientNo="; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<PmsPatientVo.PatientList> queryHisPatient(String cardNo) { |
|
|
|
|
|
LoginUser loginUser = null; |
|
|
|
|
|
try { |
|
|
|
|
|
loginUser = getLoginUser(); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
PmsPatientVo.PatientList patientByCardNo = getPatientByCardNo(cardNo); |
|
|
|
|
|
if (ObjectUtil.isNotNull(patientByCardNo)) { |
|
|
|
|
|
//检查当前患者信息是否在系统内已存在
|
|
|
|
|
|
PmsPatient pmsPatient; |
|
|
|
|
|
PmsPatientExample example = new PmsPatientExample(); |
|
|
|
|
|
example.createCriteria().andIdcardEqualTo(patientByCardNo.getIdCardEncrypt()).andDelFlagEqualTo((byte) 0); |
|
|
|
|
|
List<PmsPatient> pmsPatients = patientDao.selectByExample(example); |
|
|
|
|
|
if (CollUtil.isEmpty(pmsPatients)) { |
|
|
|
|
|
pmsPatient = new PmsPatient(); |
|
|
|
|
|
}else { |
|
|
|
|
|
pmsPatient = pmsPatients.get(0); |
|
|
|
|
|
} |
|
|
|
|
|
//查找到患者信息,先添加基本信息
|
|
|
|
|
|
BeanUtil.copyProperties(patientByCardNo, pmsPatient); |
|
|
|
|
|
pmsPatient.setName(patientByCardNo.getPatientName()); |
|
|
|
|
|
pmsPatient.setIdcard(patientByCardNo.getIdCardEncrypt()); |
|
|
|
|
|
pmsPatient.setHospitalId(ObjectUtil.isNull(loginUser) ? 176 : loginUser.getHospitalId()); |
|
|
|
|
|
pmsPatient.setNameFull(PinyinUtil.getPinyin(pmsPatient.getName(), "")); |
|
|
|
|
|
pmsPatient.setNameInitial(PinyinUtil.getFirstLetter(pmsPatient.getName(), "")); |
|
|
|
|
|
pmsPatient.setPatientNumber(cardNo); |
|
|
|
|
|
|
|
|
|
|
|
PmsPatientVo.PatientInfo pmsPatientVo = patientService.editPatient(pmsPatient); |
|
|
|
|
|
//保存id
|
|
|
|
|
|
patientByCardNo.setPatientId(pmsPatientVo.getId()); |
|
|
|
|
|
//根据cardNo查询其他信息
|
|
|
|
|
|
try { |
|
|
|
|
|
Map<String, List<Map<String, Object>>> patientOtherMsgByCardNo = getPatientOtherMsgByCardNo(cardNo); |
|
|
|
|
|
if(CollUtil.isNotEmpty(patientOtherMsgByCardNo)){ |
|
|
|
|
|
//不为空则添加其他信息
|
|
|
|
|
|
patientOtherMsgByCardNo.forEach((key, valueList) -> { |
|
|
|
|
|
if(CollUtil.isNotEmpty(valueList)){ |
|
|
|
|
|
valueList.forEach(value -> { |
|
|
|
|
|
com.alibaba.fastjson2.JSONObject valueJson = com.alibaba.fastjson2.JSONObject.parseObject(JSONUtil.toJsonStr(value)); |
|
|
|
|
|
valueJson.put("patientId", patientByCardNo.getPatientId()); |
|
|
|
|
|
PmsPatientDto.EditOtherMsg param = new PmsPatientDto.EditOtherMsg(); |
|
|
|
|
|
param.setEditType(key); |
|
|
|
|
|
param.setModel(valueJson); |
|
|
|
|
|
patientService.editPatientOtherMsg(param); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
log.error("获取患者其他信息失败", e); |
|
|
|
|
|
} |
|
|
|
|
|
List<PmsPatientVo.PatientList> list = new ArrayList<>(); |
|
|
|
|
|
list.add(patientByCardNo); |
|
|
|
|
|
return list; |
|
|
|
|
|
}else { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
log.error("查询患者失败", e); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PmsPatientVo.PatientList getPatientByCardNo(String cardNo) { |
|
|
public PmsPatientVo.PatientList getPatientByCardNo(String cardNo) { |
|
|
PmsPatientVo.PatientList patientVo; |
|
|
PmsPatientVo.PatientList patientVo; |
|
|
@ -78,15 +158,16 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
JSONObject json = JSONUtil.parseObj(body); |
|
|
JSONObject json = JSONUtil.parseObj(body); |
|
|
|
|
|
// String localJsonStr = FileUtil.readUtf8String("C:\\Users\\dou\\Desktop\\柳铁部署\\lthis.json");
|
|
|
|
|
|
// JSONObject json = JSONUtil.parseObj(localJsonStr);
|
|
|
log.info("【RP1.1.4S054】查询患者档案信息接口-返回数据: {}", json); |
|
|
log.info("【RP1.1.4S054】查询患者档案信息接口-返回数据: {}", json); |
|
|
// 获取data数组
|
|
|
// 获取data数组
|
|
|
JSONArray dataArray = json.getJSONArray("data"); |
|
|
JSONObject data = json.getJSONObject("data"); |
|
|
if (CollUtil.isEmpty(dataArray)) { |
|
|
if (CollUtil.isEmpty(data)) { |
|
|
log.warn("查询患者档案信息接口返回data为空或空数组"); |
|
|
log.warn("查询患者档案信息接口返回data为空"); |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
// 取第一个患者信息
|
|
|
// 取第一个患者信息
|
|
|
JSONObject data = dataArray.getJSONObject(0); |
|
|
|
|
|
patientVo = new PmsPatientVo.PatientList(); |
|
|
patientVo = new PmsPatientVo.PatientList(); |
|
|
patientVo.setPatientName(data.getStr("patientName")); |
|
|
patientVo.setPatientName(data.getStr("patientName")); |
|
|
String genderCode = data.getStr("genderCode"); |
|
|
String genderCode = data.getStr("genderCode"); |
|
|
@ -106,29 +187,21 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
patientVo.setContactMobile(data.getStr("linkmanTel")); |
|
|
patientVo.setContactMobile(data.getStr("linkmanTel")); |
|
|
patientVo.setIdCardType(data.getStr("idCardType")); |
|
|
patientVo.setIdCardType(data.getStr("idCardType")); |
|
|
patientVo.setIdCard(data.getStr("idCardNumber")); |
|
|
patientVo.setIdCard(data.getStr("idCardNumber")); |
|
|
|
|
|
patientVo.setIdCardEncrypt(data.getStr("idCardNumber")); |
|
|
patientVo.setAboBloodType(data.getStr("bloodCode")); |
|
|
patientVo.setAboBloodType(data.getStr("bloodCode")); |
|
|
//TODO 职业和婚姻状况待定
|
|
|
//TODO 职业和婚姻状况待定
|
|
|
// patient.setMaritalStatus(data.getStr("mari"));
|
|
|
patientVo.setMaritalStatus(Byte.valueOf(data.getStr("mari"))); |
|
|
// patient.setCareer(data.getStr("profCode"));
|
|
|
patientVo.setCareer(Byte.valueOf(data.getStr("profCode"))); |
|
|
log.info("处理后的patient信息: {}", patientVo); |
|
|
log.info("处理后的patient信息: {}", patientVo); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("查询患者档案信息异常", e); |
|
|
log.error("查询患者档案信息异常", e); |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
//根据查找到的信息,添加pms_patient数据
|
|
|
|
|
|
PmsPatient patientInfo = new PmsPatient(); |
|
|
|
|
|
BeanUtil.copyProperties(patientVo, patientInfo); |
|
|
|
|
|
patientInfo.setName(patientVo.getPatientName()); |
|
|
|
|
|
patientInfo.setNameFull(PinyinUtil.getPinyin(patientInfo.getName(), "")); |
|
|
|
|
|
patientInfo.setNameInitial(PinyinUtil.getFirstLetter(patientInfo.getName(), "")); |
|
|
|
|
|
patientInfo.setIdcard(patientVo.getIdCard()); |
|
|
|
|
|
patientInfo.setPatientNumber(cardNo); |
|
|
|
|
|
|
|
|
|
|
|
return patientVo; |
|
|
return patientVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Map<String, List> getPatientOtherMsgByCardNo(String cardNo) { |
|
|
public Map<String, List<Map<String, Object>>> getPatientOtherMsgByCardNo(String cardNo) { |
|
|
//1.查询所有需要的信息
|
|
|
//1.查询所有需要的信息
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
params.put("cardNo", cardNo); |
|
|
params.put("cardNo", cardNo); |
|
|
@ -142,12 +215,24 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
JSONObject zyData = getApiData(zyResponse, "【RP2.1.7S063】查询住院患者入院记录"); |
|
|
JSONObject zyData = getApiData(zyResponse, "【RP2.1.7S063】查询住院患者入院记录"); |
|
|
|
|
|
|
|
|
//查视图过敏信息
|
|
|
//查视图过敏信息
|
|
|
List<Object> gmxx = hisConnectionDao.getGmxx(cardNo); |
|
|
List<Object> gmxx = new ArrayList<>(); |
|
|
|
|
|
try { |
|
|
|
|
|
gmxx = hisConnectionDao.getGmxx(cardNo); |
|
|
|
|
|
log.info("查询视图gmxx成功:{}", gmxx); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
log.error("查询视图gmxx异常", e); |
|
|
|
|
|
} |
|
|
//查视图病历信息
|
|
|
//查视图病历信息
|
|
|
List<Object> blxx = hisConnectionDao.getBlxx(cardNo); |
|
|
List<Object> blxx = new ArrayList<>(); |
|
|
|
|
|
try { |
|
|
|
|
|
blxx = hisConnectionDao.getBlxx(cardNo); |
|
|
|
|
|
log.info("查询视图blxx成功:{}", blxx); |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
log.error("查询视图blxx异常", e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//构建返回信息
|
|
|
//构建返回信息
|
|
|
Map<String, List> result = new HashMap<>(); |
|
|
Map<String, List<Map<String, Object>>> result = new HashMap<>(); |
|
|
// 病史信息 - PmsPatientPersonal
|
|
|
// 病史信息 - PmsPatientPersonal
|
|
|
List<Map<String, Object>> personalList = new ArrayList<>(); |
|
|
List<Map<String, Object>> personalList = new ArrayList<>(); |
|
|
Map<String, Object> personal = new HashMap<>(); |
|
|
Map<String, Object> personal = new HashMap<>(); |
|
|
@ -174,7 +259,9 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
personalList.add(personal); |
|
|
personalList.add(personal); |
|
|
result.put("pmsPatientPersonal", personalList); |
|
|
if(CollUtil.isNotEmpty(personalList)){ |
|
|
|
|
|
result.put("pmsPatientPersonal", personalList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//TODO "诊断用药(多个)对应数据库现病史 PmsPatientParentIllness" 暂无
|
|
|
//TODO "诊断用药(多个)对应数据库现病史 PmsPatientParentIllness" 暂无
|
|
|
|
|
|
|
|
|
@ -226,7 +313,9 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
bodyList.add(bodyInfo); |
|
|
bodyList.add(bodyInfo); |
|
|
result.put("pmsPatientBody", bodyList); |
|
|
if(CollUtil.isNotEmpty(bodyList)){ |
|
|
|
|
|
result.put("pmsPatientBody", bodyList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//TODO 暂无 tz T值
|
|
|
//TODO 暂无 tz T值
|
|
|
// oxygenSaturation 血氧饱和度
|
|
|
// oxygenSaturation 血氧饱和度
|
|
|
@ -239,18 +328,21 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject getApiData(HttpResponse response, String errorString) { |
|
|
private JSONObject getApiData(HttpResponse response, String errorString) { |
|
|
JSONObject mzData = null; |
|
|
JSONObject mzData = null; |
|
|
if (response.isOk()) { |
|
|
if (response.isOk()) { |
|
|
String mzBody = response.body(); |
|
|
String mzBody = response.body(); |
|
|
try { |
|
|
try { |
|
|
JSONObject json = JSONUtil.parseObj(mzBody); |
|
|
JSONObject json = JSONUtil.parseObj(mzBody); |
|
|
JSONArray dataArray = json.getJSONArray("data"); |
|
|
JSONObject dataArray = json.getJSONObject("data"); |
|
|
|
|
|
// JSONArray dataArray = json.getJSONArray("data");
|
|
|
if (CollUtil.isEmpty(dataArray)) { |
|
|
if (CollUtil.isEmpty(dataArray)) { |
|
|
log.warn(errorString + "接口返回data为空或空数组"); |
|
|
log.warn(errorString + "接口返回data为空或空数组"); |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
mzData = dataArray.getJSONObject(0); |
|
|
mzData = dataArray; |
|
|
}catch (Exception e){ |
|
|
}catch (Exception e){ |
|
|
log.error(errorString + "接口-请求失败: {}", response.getStatus()); |
|
|
log.error(errorString + "接口-请求失败: {}", response.getStatus()); |
|
|
} |
|
|
} |
|
|
@ -261,6 +353,7 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private HttpResponse getHttpResponse(String url) { |
|
|
private HttpResponse getHttpResponse(String url) { |
|
|
|
|
|
log.info("调用接口:{}", url); |
|
|
return HttpRequest.get(url) |
|
|
return HttpRequest.get(url) |
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
.header("Domain", "LNPG") |
|
|
.header("Domain", "LNPG") |
|
|
@ -270,6 +363,7 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private HttpResponse postHttpResponse(String url, Map<String, Object> params) { |
|
|
private HttpResponse postHttpResponse(String url, Map<String, Object> params) { |
|
|
|
|
|
log.info("调用接口:{}--参数:{}", url, params); |
|
|
return HttpRequest.post(url) |
|
|
return HttpRequest.post(url) |
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
.header("Domain", "LNPG") |
|
|
.header("Domain", "LNPG") |
|
|
|