|
|
|
@ -1,11 +1,15 @@ |
|
|
|
package com.ccsens.client.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.extra.pinyin.PinyinUtil; |
|
|
|
import cn.hutool.http.HttpRequest; |
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.ccsens.client.persist.dao.HisConnectionDao; |
|
|
|
import com.ccsens.client.service.ILtHisConnectionService; |
|
|
|
import com.ccsens.system.domain.po.PmsPatient; |
|
|
|
import com.ccsens.system.domain.vo.PmsPatientVo; |
|
|
|
@ -14,6 +18,9 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -27,11 +34,13 @@ import java.util.Map; |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private HisConnectionDao hisConnectionDao; |
|
|
|
/** |
|
|
|
* 前端调用查询列表接口,如果有数据则直接返回 |
|
|
|
* 如果没查到数据,使用searchValue(患者院内唯一标识cardNo)去his查询 |
|
|
|
* 如果his有数据,则插入一条基本信息pms_patient数据,将cardNo保存在patient_number字段上 |
|
|
|
* |
|
|
|
* --- |
|
|
|
* 前端在列表显示当前查找到的患者信息,点击患者准备测评时调用后台查询详情接口 |
|
|
|
* 详情接口根据id查找到患者信息,检查patient_number字段是否有值,如果有表示需要在院内his查找, |
|
|
|
* 通过patient_number在院内查找详细信息,查找完成后将详细信息保存在对应的表内, |
|
|
|
@ -39,15 +48,26 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
*/ |
|
|
|
|
|
|
|
private static final String URL_PREFIX = "http://200.1.8.36:7801/roc"; |
|
|
|
private static final String URL_SUFFIX_1_1_4 = "/patient-service/api/v1/patient/archives/get?cardNo="; |
|
|
|
|
|
|
|
//【RP1.1.4S054】查询患者档案信息
|
|
|
|
private static final String URL_SUFFIX_RP_1_1_4 = "/patient-service/api/v1/patient/archives/get?cardNo="; |
|
|
|
|
|
|
|
//【RP2.1.6S062】查询门诊患者挂号记录
|
|
|
|
private static final String URL_SUFFIX_RP_2_1_6 = "/patient-service/api/v1/register/patient/getFinOprRegList"; |
|
|
|
|
|
|
|
//【RP2.1.7S063】查询住院患者入院记录
|
|
|
|
private static final String URL_SUFFIX_RP_2_1_7 = "/patient-service/api/v1/patient/getFinIprList"; |
|
|
|
|
|
|
|
//【RE2.1.5S234】新 获取病案首页基本信息
|
|
|
|
private static final String URL_SUFFIX_RE_2_1_5 = "/patient-service/api/v1/patient/getFinOprRegList?inPatientNo="; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PmsPatientVo.PatientList getPatientByCardNo(String cardNo) { |
|
|
|
PmsPatientVo.PatientList patientVo = null; |
|
|
|
PmsPatientVo.PatientList patientVo; |
|
|
|
//调用"【RP1.1.4S054】查询患者档案信息"接口
|
|
|
|
String url = URL_PREFIX + URL_SUFFIX_1_1_4 + cardNo; |
|
|
|
|
|
|
|
HttpResponse response = getHttpResponse(cardNo, url); |
|
|
|
String url = URL_PREFIX + URL_SUFFIX_RP_1_1_4 + cardNo; |
|
|
|
HttpResponse response = getHttpResponse(url); |
|
|
|
String body; |
|
|
|
if (response.isOk()) { |
|
|
|
body = response.body(); |
|
|
|
@ -59,11 +79,14 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
try { |
|
|
|
JSONObject json = JSONUtil.parseObj(body); |
|
|
|
log.info("【RP1.1.4S054】查询患者档案信息接口-返回数据: {}", json); |
|
|
|
JSONObject data = json.getJSONObject("data"); |
|
|
|
if (data == null) { |
|
|
|
log.warn("查询患者档案信息接口返回data为空"); |
|
|
|
// 获取data数组
|
|
|
|
JSONArray dataArray = json.getJSONArray("data"); |
|
|
|
if (CollUtil.isEmpty(dataArray)) { |
|
|
|
log.warn("查询患者档案信息接口返回data为空或空数组"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
// 取第一个患者信息
|
|
|
|
JSONObject data = dataArray.getJSONObject(0); |
|
|
|
patientVo = new PmsPatientVo.PatientList(); |
|
|
|
patientVo.setPatientName(data.getStr("patientName")); |
|
|
|
String genderCode = data.getStr("genderCode"); |
|
|
|
@ -100,51 +123,110 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
patientInfo.setNameInitial(PinyinUtil.getFirstLetter(patientInfo.getName(), "")); |
|
|
|
patientInfo.setIdcard(patientVo.getIdCard()); |
|
|
|
patientInfo.setPatientNumber(cardNo); |
|
|
|
//TODO 添加数据库
|
|
|
|
|
|
|
|
return patientVo; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, List> getPatientOtherMsgByCardNo(String cardNo) { |
|
|
|
//病史信息对应数据库个人史 PmsPatientPersonal
|
|
|
|
//数据库视图view_lnpg_blxx 和
|
|
|
|
//是否吸烟 smokingHistory
|
|
|
|
//吸烟年限 smokingYear
|
|
|
|
//是否戒烟 smokingQuit
|
|
|
|
//戒烟年限 smokingQuitYear
|
|
|
|
//是否饮酒 drinkHistory
|
|
|
|
//饮酒年限 drinkYear
|
|
|
|
//是否戒酒 drinkQuit
|
|
|
|
//戒酒年限 drinkQuitYear
|
|
|
|
//数据库视图view_lnpg_gmxx
|
|
|
|
//过敏信息 allergyDrug
|
|
|
|
//1.查询所有需要的信息
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("cardNo", cardNo); |
|
|
|
//查门诊信息
|
|
|
|
String mzUrl = URL_PREFIX + URL_SUFFIX_RP_2_1_6; |
|
|
|
HttpResponse mzResponse = postHttpResponse(mzUrl, params); |
|
|
|
JSONObject mzData = getApiData(mzResponse, "【RP2.1.6S062】查询门诊患者挂号记录"); |
|
|
|
//查住院信息
|
|
|
|
String zyUrl = URL_PREFIX + URL_SUFFIX_RP_2_1_7; |
|
|
|
HttpResponse zyResponse = postHttpResponse(zyUrl, params); |
|
|
|
JSONObject zyData = getApiData(zyResponse, "【RP2.1.7S063】查询住院患者入院记录"); |
|
|
|
|
|
|
|
//查视图过敏信息
|
|
|
|
List<Object> gmxx = hisConnectionDao.getGmxx(cardNo); |
|
|
|
//查视图病历信息
|
|
|
|
List<Object> blxx = hisConnectionDao.getBlxx(cardNo); |
|
|
|
|
|
|
|
//构建返回信息
|
|
|
|
Map<String, List> result = new HashMap<>(); |
|
|
|
// 病史信息 - PmsPatientPersonal
|
|
|
|
List<Map<String, Object>> personalList = new ArrayList<>(); |
|
|
|
Map<String, Object> personal = new HashMap<>(); |
|
|
|
if (CollUtil.isNotEmpty(blxx)) { |
|
|
|
Object obj = blxx.get(0); |
|
|
|
if (obj instanceof Map) { |
|
|
|
Map<String, Object> item = (Map<String, Object>) obj; |
|
|
|
personal.put("smokingHistory", item.get("是否吸烟")); |
|
|
|
personal.put("smokingYear", item.get("吸烟年限")); |
|
|
|
personal.put("smokingQuit", item.get("是否戒烟")); |
|
|
|
personal.put("smokingQuitYear", item.get("戒烟年限")); |
|
|
|
personal.put("drinkHistory", item.get("是否饮酒")); |
|
|
|
personal.put("drinkYear", item.get("饮酒年限")); |
|
|
|
personal.put("drinkQuit", item.get("是否戒酒")); |
|
|
|
personal.put("drinkQuitYear", item.get("戒酒年限")); |
|
|
|
} |
|
|
|
} |
|
|
|
// 过敏信息 - 也放入PmsPatientPersonal
|
|
|
|
if (CollUtil.isNotEmpty(gmxx)) { |
|
|
|
Object obj = gmxx.get(0); |
|
|
|
if (obj instanceof Map) { |
|
|
|
Map<String, Object> item = (Map<String, Object>) obj; |
|
|
|
personal.put("allergyDrug", item.get("过敏信息")); |
|
|
|
} |
|
|
|
} |
|
|
|
personalList.add(personal); |
|
|
|
result.put("pmsPatientPersonal", personalList); |
|
|
|
|
|
|
|
//TODO "诊断用药(多个)对应数据库现病史 PmsPatientParentIllness" 暂无
|
|
|
|
|
|
|
|
//"就诊信息对应数据库病人基本信息表pmsPatientBody"
|
|
|
|
// 传入的cardNo,用户的唯一表示 cardNo outpatientNo 门诊/急诊/住院号
|
|
|
|
//"先查询【RP2.1.7S063】查询住院患者入院记录 如果没有住院 再查询【RP2.1.6S062】查询门诊患者挂号记录" age age 年龄
|
|
|
|
// deptName department 就诊科室
|
|
|
|
// "directorDocName(住院)docName(门诊)" doctor 就诊/主治医师
|
|
|
|
// "inDate(住院)receptDate(门诊)" admissionDate 就诊/入院日期
|
|
|
|
//【RP2.1.7S063】查询住院患者入院记录
|
|
|
|
// inTimes admissionCount 住院次数
|
|
|
|
// bedNo bedNumber 床位号
|
|
|
|
// outDate dischargeDate 出院日期
|
|
|
|
//【RE2.1.5S234】新 获取病案首页基本信息
|
|
|
|
// inWay admissionMethod 入院途径
|
|
|
|
// outType dischargeMethod 离院方式
|
|
|
|
//
|
|
|
|
//"检查信息对应数据库病人基本信息表pmsPatientBody"
|
|
|
|
//数据库视图view_lnpg_blxx
|
|
|
|
//身高 height 身高
|
|
|
|
//体重 weight 体重
|
|
|
|
//体温 temperature 体温
|
|
|
|
//血压 bloodPressureShrink 收缩压
|
|
|
|
//血压 bloodPressureDiastole 舒张压
|
|
|
|
//脉搏 pulse 脉搏
|
|
|
|
//肌酐 creatinine 肌酐
|
|
|
|
// 就诊信息和检查信息 - pmsPatientBody
|
|
|
|
List<Map<String, Object>> bodyList = new ArrayList<>(); |
|
|
|
Map<String, Object> bodyInfo = new HashMap<>(); |
|
|
|
// 基本信息
|
|
|
|
bodyInfo.put("outpatientNo", cardNo); |
|
|
|
if(ObjectUtil.isNotNull(zyData) && zyData != null){ |
|
|
|
bodyInfo.put("age", zyData.getStr("age")); |
|
|
|
bodyInfo.put("department", zyData.getStr("deptName")); |
|
|
|
bodyInfo.put("doctor", zyData.getStr("directorDocName")); |
|
|
|
bodyInfo.put("admissionDate", zyData.getStr("inDate")); |
|
|
|
bodyInfo.put("admissionCount", zyData.getStr("inTimes")); |
|
|
|
bodyInfo.put("bedNumber", zyData.getStr("bedNo")); |
|
|
|
bodyInfo.put("dischargeDate", zyData.getStr("outDate")); |
|
|
|
bodyInfo.put("diagnosisType","2"); |
|
|
|
bodyInfo.put("isMainDiagnosis","1"); |
|
|
|
bodyInfo.put("diagnosisName", zyData.getStr("ryDiagnose")); |
|
|
|
bodyInfo.put("diagnosisCode", zyData.getStr("ryDiagnoseCode")); |
|
|
|
bodyInfo.put("diagnosisDate", zyData.getStr("inDate")); |
|
|
|
|
|
|
|
//如果住院信息不为空,查病案首页信息
|
|
|
|
String baUrl = URL_PREFIX + URL_SUFFIX_RE_2_1_5 + zyData.getStr("inPatientNo"); |
|
|
|
HttpResponse baResponse = getHttpResponse(baUrl); |
|
|
|
JSONObject baData = getApiData(baResponse, "【RE2.1.5S234】新 获取病案首页基本信息"); |
|
|
|
if(ObjectUtil.isNotNull(baData) && baData != null){ |
|
|
|
bodyInfo.put("admissionMethod", baData.getStr("inWay")); |
|
|
|
bodyInfo.put("dischargeMethod", baData.getStr("outType")); |
|
|
|
} |
|
|
|
}else if(ObjectUtil.isNotNull(mzData) && mzData != null){ |
|
|
|
bodyInfo.put("age", mzData.getStr("age")); |
|
|
|
bodyInfo.put("department", mzData.getStr("deptName")); |
|
|
|
bodyInfo.put("doctor", mzData.getStr("docName")); |
|
|
|
bodyInfo.put("admissionDate", mzData.getStr("receptDate")); |
|
|
|
} |
|
|
|
if (CollUtil.isNotEmpty(blxx)) { |
|
|
|
Object obj = blxx.get(0); |
|
|
|
if (obj instanceof Map) { |
|
|
|
Map<String, Object> item = (Map<String, Object>) obj; |
|
|
|
bodyInfo.put("height", item.get("身高")); |
|
|
|
bodyInfo.put("weight", item.get("体重")); |
|
|
|
bodyInfo.put("temperature", item.get("体温")); |
|
|
|
//TODO 血压需要处理
|
|
|
|
bodyInfo.put("bloodPressureShrink", item.get("血压")); |
|
|
|
bodyInfo.put("bloodPressureDiastole", item.get("血压")); |
|
|
|
bodyInfo.put("pulse", item.get("脉搏")); |
|
|
|
bodyInfo.put("creatinine", item.get("肌酐")); |
|
|
|
} |
|
|
|
} |
|
|
|
bodyList.add(bodyInfo); |
|
|
|
result.put("pmsPatientBody", bodyList); |
|
|
|
|
|
|
|
//TODO 暂无 tz T值
|
|
|
|
// oxygenSaturation 血氧饱和度
|
|
|
|
@ -154,24 +236,46 @@ public class LtHisConnectionServiceImpl implements ILtHisConnectionService { |
|
|
|
// hematocrit 凝血酶原时间
|
|
|
|
// dimer D-二聚体
|
|
|
|
|
|
|
|
//"诊断信息对应数据库病人基本信息表pmsPatientBody"
|
|
|
|
// 【RP2.1.7S063】查询住院患者入院记录
|
|
|
|
//查询入院患者的诊断 diagnosisType 诊断类型
|
|
|
|
//默认主诊断 isMainDiagnosis 是否主要诊断
|
|
|
|
//ryDiagnose diagnosisName 诊断名称
|
|
|
|
//ryDiagnoseCode diagnosisCode 诊断编码
|
|
|
|
//同入院日期 diagnosisDate 诊断日期
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
private JSONObject getApiData(HttpResponse response, String errorString) { |
|
|
|
JSONObject mzData = null; |
|
|
|
if (response.isOk()) { |
|
|
|
String mzBody = response.body(); |
|
|
|
try { |
|
|
|
JSONObject json = JSONUtil.parseObj(mzBody); |
|
|
|
JSONArray dataArray = json.getJSONArray("data"); |
|
|
|
if (CollUtil.isEmpty(dataArray)) { |
|
|
|
log.warn(errorString + "接口返回data为空或空数组"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
mzData = dataArray.getJSONObject(0); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error(errorString + "接口-请求失败: {}", response.getStatus()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
log.error(errorString + "接口-请求失败: {}", response.getStatus()); |
|
|
|
} |
|
|
|
return mzData; |
|
|
|
} |
|
|
|
|
|
|
|
private HttpResponse getHttpResponse(String cardNo, String url) { |
|
|
|
private HttpResponse getHttpResponse(String url) { |
|
|
|
return HttpRequest.get(url) |
|
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
|
.header("Domain", "LNPG") |
|
|
|
.header("Key", "9d36990a-7154-41e3-bba5-e0d4f7b952e7") |
|
|
|
.form("cardNo", cardNo) // 使用 form 方法添加参数
|
|
|
|
.timeout(5000) // 设置超时时间
|
|
|
|
.execute(); |
|
|
|
} |
|
|
|
|
|
|
|
private HttpResponse postHttpResponse(String url, Map<String, Object> params) { |
|
|
|
return HttpRequest.post(url) |
|
|
|
.header("Content-Type", "application/json;charset=utf-8") |
|
|
|
.header("Domain", "LNPG") |
|
|
|
.header("Key", "9d36990a-7154-41e3-bba5-e0d4f7b952e7") |
|
|
|
.form(params) |
|
|
|
.timeout(5000) |
|
|
|
.execute(); |
|
|
|
} |
|
|
|
} |
|
|
|
|