|
@ -49,6 +49,7 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.QrcodeUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import com.ylzinfo.ehc.EhcHandler;
|
|
@ -143,6 +144,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
private PatientRegisterDao patientRegisterDao;
|
|
|
@Autowired
|
|
|
private PrescriptionLogService prescriptionLogService;
|
|
|
@Autowired
|
|
|
private WlyyInspectionDao wlyyInspectionDao;
|
|
|
|
|
|
|
|
|
@Value("${demo.flag}")
|
|
@ -348,6 +351,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
List<WlyyPrescriptionInfoVO> infoVOs = new ArrayList<>();
|
|
|
vo.setInfoVOs(convertToModels(prescriptionInfoDao.findByPrescriptionId(vo.getId()),infoVOs,WlyyPrescriptionInfoVO.class));
|
|
|
|
|
|
//检查检验信息
|
|
|
List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
|
|
|
vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId()),inspectionVOs,WlyyInspectionVO.class));
|
|
|
}
|
|
|
}
|
|
|
rs.put("prescriptions",prescriptionVOs);
|
|
@ -1154,7 +1160,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getInspectionDictionary(String pyKey,String winNo)throws Exception{
|
|
|
return entranceService.MS25002(pyKey,winNo,demoFlag);
|
|
|
JSONArray rs = entranceService.MS25002(pyKey,winNo,demoFlag);
|
|
|
if(rs!=null&&rs.size()>0){
|
|
|
|
|
|
//设置科室翻译名称字典,减少循环层级降低循环次数
|
|
|
List<DictHospitalDeptDO> depts =dictHospitalDeptDao.findByOrgCode("350211A1002");
|
|
|
Map<String,String> deptDictMap = new HashedMap();
|
|
|
for(DictHospitalDeptDO dp:depts){
|
|
|
deptDictMap.put(dp.getCode(),dp.getName());
|
|
|
}
|
|
|
|
|
|
//翻译执行科室
|
|
|
for(int i=0;i<rs.size();i++){
|
|
|
JSONObject dict = (JSONObject)rs.get(i);
|
|
|
String dept = dict.getString("exec_unit");
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
String deptName = deptDictMap.get(dept);
|
|
|
if(StringUtils.isNotBlank(deptName)){
|
|
|
dict.put("exec_unit_name",deptName);
|
|
|
}else{
|
|
|
dict.put("exec_unit_name","");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -1166,7 +1196,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
* @param diagnosisJson
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson)throws Exception{
|
|
|
public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson,String inspectionJson)throws Exception{
|
|
|
|
|
|
Map<String,Object> result = new HashedMap();
|
|
|
|
|
@ -1222,7 +1252,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
outpatientDO.setIcd10Name(Icd10Name);
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
|
|
//判断是否需药品,有药品到his开处方,没有药品直接下诊断开方
|
|
|
//判断是否有检查检验或药品开方
|
|
|
if("1".equals(type)){
|
|
|
|
|
|
//doctor转换为his医生
|
|
@ -1237,102 +1267,45 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
prescriptionInfoDao.delete(oldInfos);
|
|
|
}
|
|
|
|
|
|
//his处方拼接开方条件
|
|
|
com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
|
|
|
|
|
|
//存储药品,构建his开方入参
|
|
|
if(StringUtils.isNotBlank(infoJsons)){
|
|
|
//药品
|
|
|
List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
|
|
|
//his处方拼接开方条件
|
|
|
com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
|
|
|
for(WlyyPrescriptionInfoDO info:infoDOs){
|
|
|
|
|
|
info.setDel(1);
|
|
|
info.setPrescriptionId(prescription.getId());
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
json.put("cardNo",outpatientDO.getCardNo());
|
|
|
json.put("doctor",doctorMappingDO.getMappingCode());
|
|
|
json.put("dept",outpatientDO.getDept());
|
|
|
json.put("chargeCode",info.getDrugNo());
|
|
|
json.put("winNo",outpatientDO.getWinNo());
|
|
|
json.put("chargeFlag",1); //项目类别-必输 1-药品 2检验检查
|
|
|
json.put("quantity",info.getQuantity()); //数量-必输
|
|
|
json.put("serialNo",outpatientDO.getRegisterNo()); //挂号流水号-必输
|
|
|
json.put("groupNo",info.getGroupNo());//库房号-必输
|
|
|
json.put("serial",info.getSerial()); //药品序列号-必输
|
|
|
String Icd10s[] = Icd10.split(",");
|
|
|
for(int i=0;i<Icd10s.length;i++){
|
|
|
if(i==0){
|
|
|
json.put("icdCode",Icd10s[i]);
|
|
|
}else if(i==1){
|
|
|
json.put("diagTwo",Icd10s[i]);
|
|
|
}else if(i==2){
|
|
|
json.put("diagThree",Icd10s[i]);
|
|
|
}else if(i==3){
|
|
|
json.put("diagFour",Icd10s[i]);
|
|
|
}else if(i==4){
|
|
|
json.put("diagFive",Icd10s[i]);
|
|
|
}
|
|
|
}
|
|
|
json.put("dosage",info.getDosage());
|
|
|
json.put("unit",info.getUnit());
|
|
|
json.put("usage",info.getUsageCode());
|
|
|
json.put("supplyCode",info.getSupplyCode());
|
|
|
json.put("days",info.getDays());
|
|
|
json.put("frequency",info.getFrequency());
|
|
|
jsonData.add(json);
|
|
|
logger.info("json:" +json.toString());
|
|
|
//设置his药品查询条件
|
|
|
setInfoJsonParam(jsonData,doctorMappingDO,outpatientDO,info,Icd10);
|
|
|
}
|
|
|
//保存处方
|
|
|
prescriptionInfoDao.save(infoDOs);
|
|
|
|
|
|
//调用his开方接口
|
|
|
net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
|
|
|
logger.info("调用his开方接口: "+jsonObject.toString());
|
|
|
//判断返回结果
|
|
|
String rs = jsonObject.getString("@RESULT");
|
|
|
|
|
|
//保存日志
|
|
|
WlyyHttpLogDO log = new WlyyHttpLogDO();
|
|
|
log.setCode("makeDiagnosis");
|
|
|
log.setName("下诊断");
|
|
|
log.setPatient(outpatientDO.getPatient());
|
|
|
log.setDoctor(outpatientDO.getDoctor());
|
|
|
log.setResponse(jsonObject.toString());
|
|
|
log.setRequest(jsonData.toJSONString());
|
|
|
log.setStatus(rs);
|
|
|
log.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(log);
|
|
|
|
|
|
if("0".equals(rs)){
|
|
|
String admNo = jsonObject.getString("@ADM_NO");
|
|
|
String realOrder = jsonObject.getString("@real_order");
|
|
|
|
|
|
prescription.setAdmNo(admNo);
|
|
|
prescription.setRealOrder(realOrder);
|
|
|
prescriptionDao.save(prescription);
|
|
|
outpatientDO.setAdmNo(admNo);
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
|
|
result.put("code",1);
|
|
|
result.put("mes","开方提交成功");
|
|
|
|
|
|
return result;
|
|
|
}else{
|
|
|
//开方失败
|
|
|
prescription.setStatus(13);
|
|
|
prescriptionDao.save(prescription);
|
|
|
result.put("code",-1);
|
|
|
result.put("mes","开方提交失败");
|
|
|
}
|
|
|
|
|
|
prescriptionLogService.addPrescriptionLog(prescription.getId(),13,2,outpatientDO.getDoctor(),outpatientDO.getDoctorName(),"",new Date());
|
|
|
//删除之前检查检验
|
|
|
List<WlyyInspectionDO> inspectionDels = wlyyInspectionDao.findByOutpatientId(outPatientId);
|
|
|
if(inspectionDels!=null&&inspectionDels.size()>0){
|
|
|
wlyyInspectionDao.delete(inspectionDels);
|
|
|
}
|
|
|
//存储检查检验,构建his开方入参
|
|
|
if(StringUtils.isNotBlank(inspectionJson)){
|
|
|
List<WlyyInspectionDO> inspections = (List<WlyyInspectionDO>) com.alibaba.fastjson.JSONArray.parseArray(inspectionJson, WlyyInspectionDO.class);
|
|
|
for(WlyyInspectionDO ins:inspections){
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
ins.setCreateTime(new Date());
|
|
|
ins.setPrescriptionId(prescription.getId());
|
|
|
ins.setOutpatientId(outPatientId);
|
|
|
|
|
|
}else{
|
|
|
result.put("code",-2);
|
|
|
result.put("mes","参数错误,药品参数错误");
|
|
|
return result;
|
|
|
//设置his药品查询条件
|
|
|
setInspectionParam(jsonData,doctorMappingDO,outpatientDO,ins,Icd10);
|
|
|
}
|
|
|
}
|
|
|
//上传his开方
|
|
|
return sendHisDiagnosis(jsonData,outpatientDO,prescription);
|
|
|
|
|
|
}else{
|
|
|
//
|
|
@ -1345,6 +1318,172 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 上传his开方
|
|
|
* @param jsonData
|
|
|
* @param outpatientDO
|
|
|
* @param prescription
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Map<String,Object> sendHisDiagnosis(com.alibaba.fastjson.JSONArray jsonData,WlyyOutpatientDO outpatientDO,WlyyPrescriptionDO prescription)throws Exception{
|
|
|
Map<String,Object> result = new HashedMap();
|
|
|
//调用his开方接口
|
|
|
net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
|
|
|
logger.info("调用his开方接口: "+jsonObject.toString());
|
|
|
//判断返回结果
|
|
|
String rs = jsonObject.getString("@RESULT");
|
|
|
|
|
|
//保存日志
|
|
|
WlyyHttpLogDO log = new WlyyHttpLogDO();
|
|
|
log.setCode("makeDiagnosis");
|
|
|
log.setName("下诊断");
|
|
|
log.setPatient(outpatientDO.getPatient());
|
|
|
log.setDoctor(outpatientDO.getDoctor());
|
|
|
log.setResponse(jsonObject.toString());
|
|
|
log.setRequest(jsonData.toJSONString());
|
|
|
log.setStatus(rs);
|
|
|
log.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(log);
|
|
|
|
|
|
if("0".equals(rs)){
|
|
|
String admNo = jsonObject.getString("@ADM_NO");
|
|
|
String realOrder = jsonObject.getString("@real_order");
|
|
|
|
|
|
prescription.setAdmNo(admNo);
|
|
|
prescription.setRealOrder(realOrder);
|
|
|
prescriptionDao.save(prescription);
|
|
|
outpatientDO.setAdmNo(admNo);
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
|
|
result.put("code",1);
|
|
|
result.put("mes","开方提交成功");
|
|
|
|
|
|
return result;
|
|
|
}else{
|
|
|
//开方失败
|
|
|
prescription.setStatus(13);
|
|
|
prescriptionDao.save(prescription);
|
|
|
result.put("code",-1);
|
|
|
result.put("mes","开方提交失败");
|
|
|
|
|
|
//记录开发失败日志
|
|
|
prescriptionLogService.addPrescriptionLog(prescription.getId(),13,2,outpatientDO.getDoctor(),outpatientDO.getDoctorName(),"",new Date());
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置检查检验his入参
|
|
|
* @param jsonData
|
|
|
* @param doctorMappingDO
|
|
|
* @param outpatientDO
|
|
|
* @param inspectionDO
|
|
|
* @param Icd10
|
|
|
*/
|
|
|
public void setInspectionParam(com.alibaba.fastjson.JSONArray jsonData,DoctorMappingDO doctorMappingDO,WlyyOutpatientDO outpatientDO,WlyyInspectionDO inspectionDO,String Icd10){
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
json.put("cardNo",outpatientDO.getCardNo());
|
|
|
json.put("doctor",doctorMappingDO.getMappingCode());
|
|
|
json.put("dept",inspectionDO.getDept());
|
|
|
|
|
|
json.put("frequency",inspectionDO.getFrequency()); //组号
|
|
|
json.put("quantity",inspectionDO.getQuantity()); //数量
|
|
|
|
|
|
json.put("winNo",outpatientDO.getWinNo());
|
|
|
json.put("chargeFlag",2); //项目类别-必输 1-药品 2检验检查
|
|
|
/**
|
|
|
* code;//项目编码',
|
|
|
* name;//(检查方法)',
|
|
|
* information;//病史与体征',
|
|
|
* checkEquip;//类别',
|
|
|
* checkPart;//部位',
|
|
|
* adresult;//辅助检查治疗',
|
|
|
* goal;//检查目的',
|
|
|
* opview;//手术所见-病理申请单必填',
|
|
|
* specimenName;//标本名称-病理申请单必填',
|
|
|
* specimenNum;//标本数量-病理申请单必填',
|
|
|
* ywjcResult;//以往检查结果-病理申请单选填',
|
|
|
* ywjcDate;//以往检查时间-病理申请单选填 格式:yyyy-mm-dd',
|
|
|
* blzd;//病理诊断-病理申请单选填',
|
|
|
* fixationfluid;//固定液
|
|
|
*/
|
|
|
json.put("code",inspectionDO.getCode()); //项目编码
|
|
|
json.put("name",inspectionDO.getName()); //挂号流水号-必输
|
|
|
json.put("information",inspectionDO.getInformation());//库房号-必输
|
|
|
json.put("checkEquip",inspectionDO.getCheckEquip()); //药品序列号-必输
|
|
|
json.put("checkPart",inspectionDO.getCheckPart());
|
|
|
json.put("adresult",inspectionDO.getAdresult());
|
|
|
json.put("goal",inspectionDO.getGoal());
|
|
|
json.put("opview",inspectionDO.getOpview());
|
|
|
json.put("specimenName",inspectionDO.getSpecimenName());
|
|
|
json.put("specimenNum",inspectionDO.getSpecimenNum());
|
|
|
json.put("ywjcResult",inspectionDO.getYwjcResult());
|
|
|
json.put("ywjcDate",inspectionDO.getYwjcDate());
|
|
|
json.put("blzd",inspectionDO.getBlzd());
|
|
|
json.put("fixationfluid",inspectionDO.getFixationfluid());
|
|
|
//设置诊断
|
|
|
setIcd10(json,Icd10);
|
|
|
jsonData.add(json);
|
|
|
logger.info("json:" +json.toString());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置药品his入参
|
|
|
* @param jsonData
|
|
|
* @param doctorMappingDO
|
|
|
* @param outpatientDO
|
|
|
* @param info
|
|
|
* @param Icd10
|
|
|
*/
|
|
|
public void setInfoJsonParam(com.alibaba.fastjson.JSONArray jsonData,DoctorMappingDO doctorMappingDO,WlyyOutpatientDO outpatientDO,WlyyPrescriptionInfoDO info,String Icd10){
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
|
json.put("cardNo",outpatientDO.getCardNo());
|
|
|
json.put("doctor",doctorMappingDO.getMappingCode());
|
|
|
json.put("dept",outpatientDO.getDept());
|
|
|
json.put("chargeCode",info.getDrugNo());
|
|
|
json.put("winNo",outpatientDO.getWinNo());
|
|
|
json.put("chargeFlag",1); //项目类别-必输 1-药品 2检验检查
|
|
|
json.put("quantity",info.getQuantity()); //数量-必输
|
|
|
json.put("serialNo",outpatientDO.getRegisterNo()); //挂号流水号-必输
|
|
|
json.put("groupNo",info.getGroupNo());//库房号-必输
|
|
|
json.put("serial",info.getSerial()); //药品序列号-必输
|
|
|
|
|
|
json.put("dosage",info.getDosage());
|
|
|
json.put("unit",info.getUnit());
|
|
|
json.put("usage",info.getUsageCode());
|
|
|
json.put("supplyCode",info.getSupplyCode());
|
|
|
json.put("days",info.getDays());
|
|
|
json.put("frequency",info.getFrequency());
|
|
|
|
|
|
//设置诊断
|
|
|
setIcd10(json,Icd10);
|
|
|
|
|
|
jsonData.add(json);
|
|
|
logger.info("json:" +json.toString());
|
|
|
}
|
|
|
|
|
|
public void setIcd10(com.alibaba.fastjson.JSONObject json,String Icd10){
|
|
|
String Icd10s[] = Icd10.split(",");
|
|
|
for(int i=0;i<Icd10s.length;i++){
|
|
|
if(i==0){
|
|
|
json.put("icdCode",Icd10s[i]);
|
|
|
}else if(i==1){
|
|
|
json.put("diagTwo",Icd10s[i]);
|
|
|
}else if(i==2){
|
|
|
json.put("diagThree",Icd10s[i]);
|
|
|
}else if(i==3){
|
|
|
json.put("diagFour",Icd10s[i]);
|
|
|
}else if(i==4){
|
|
|
json.put("diagFive",Icd10s[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订单查询
|