|
@ -27,6 +27,7 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.util.network.HttpResponse;
|
|
@ -72,6 +73,14 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
private PatientRegisterDao patientRegisterDao;
|
|
|
@Autowired
|
|
|
private WlyyHttpLogDao wlyyHttpLogDao;
|
|
|
@Autowired
|
|
|
private PrescriptionEmrDao prescriptionEmrDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
@Autowired
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
|
|
|
//请求内网服务
|
|
|
public static String entranceUrl = "http://192.168.101.2:10024/dsyy/";
|
|
@ -394,7 +403,7 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
* @param ApplyDept 执行科室
|
|
|
* @param ApplyDoctor 开单医生
|
|
|
* @param ExecuteDept 执行科室(药房)
|
|
|
* @param infoJson 药品列表
|
|
|
* @param wlyyPrescriptionInfoDOS 药品列表
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
@ -521,6 +530,158 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 数据哈希计算接口
|
|
|
*
|
|
|
* @param contentJson
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject computeDigestForAlg(String contentJson) throws Exception {
|
|
|
String url = entranceUrl +"computeDigestForAlg";
|
|
|
JSONObject object = new JSONObject();
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("content",contentJson);
|
|
|
HttpResponse response = HttpUtils.doPost(url,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if (status==200){
|
|
|
object = rs.getJSONObject("obj");
|
|
|
}
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 数据签名接口
|
|
|
* @param templateId 模板ID签名数据摘要数据类型
|
|
|
* @param urId 签名流水ID
|
|
|
* @param patientName 患者姓名
|
|
|
* @param patientAge 患者年龄
|
|
|
* @param patientSex 患者性别
|
|
|
* @param patientCardType 证件类型
|
|
|
* @param recipeTime 开具时间
|
|
|
* @param hashValue Hash原文(从签名指纹接口结果中得到的)
|
|
|
* @param hashType Hash算法(从签名指纹接口结果中得到的)
|
|
|
*/
|
|
|
public JSONObject synRecipeInfo(String templateId,String urId,String patientName,String patientAge,
|
|
|
String patientSex,String patientCardType,String recipeTime,
|
|
|
String hashValue,String hashType,String openId,String patientCard) throws Exception {
|
|
|
String url = entranceUrl +"synRecipeInfo";
|
|
|
JSONObject object = new JSONObject();
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("templateId",templateId);
|
|
|
params.put("urId",urId);
|
|
|
params.put("patientName",patientName);
|
|
|
params.put("patientAge",patientAge);
|
|
|
params.put("patientSex",patientSex);
|
|
|
params.put("patientCardType",patientCardType);
|
|
|
params.put("recipeTime",recipeTime);
|
|
|
params.put("hashValue",hashValue);
|
|
|
params.put("hashType",hashType);
|
|
|
params.put("openId",openId);
|
|
|
params.put("patientCard",patientCard);
|
|
|
HttpResponse response = HttpUtils.doPost(url,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if (status==200){
|
|
|
object = rs.getJSONObject("obj");
|
|
|
}
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处方签名
|
|
|
* @param prescriptionDO
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String SOF_SignDataWithExtraInfo(WlyyPrescriptionDO prescriptionDO) throws Exception {
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()).orElse(null);
|
|
|
List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionDO.getId(), 1);
|
|
|
List<WlyyPrescriptionDiagnosisDO> diagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
|
|
|
JSONObject object = new JSONObject();
|
|
|
String baseSign="";
|
|
|
object.put("infos",infoDOS);
|
|
|
object.put("registerSn",outpatientDO.getRegisterNo());
|
|
|
object.put("diagnosiss",diagnosisDOS);
|
|
|
JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
|
|
|
String hashValue = null;
|
|
|
String hashType = null;
|
|
|
if (jsonObject.getString("status").equalsIgnoreCase("0")){
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
hashValue= data.getString("hashValue");
|
|
|
hashType = data.getString("hashType");
|
|
|
}
|
|
|
|
|
|
BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).orElse(null);
|
|
|
BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
|
|
|
if (patientDO!=null&&doctorDO!=null){
|
|
|
String patientName = patientDO.getName();
|
|
|
Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
|
|
|
String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
|
|
|
String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
|
|
|
String openId = doctorDO.getOpenid();
|
|
|
String idcard = patientDO.getIdcard();
|
|
|
if (hashType!=null&&hashValue!=null){
|
|
|
JSONObject object1 = synRecipeInfo("hash_004",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
|
|
|
if (object1.getString("status").equalsIgnoreCase("0")){
|
|
|
logger.info("西药处方签名成功"+object1);
|
|
|
JSONObject jsonObject1 = JSONObject.parseObject(object1.getString("data"));
|
|
|
if (jsonObject1!=null){
|
|
|
baseSign=jsonObject1.getString("stamp");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return baseSign;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 病历签名
|
|
|
* @param prescriptionDO
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionDO prescriptionDO) throws Exception {
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId()).orElse(null);
|
|
|
WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionDO.getId());
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("emr",prescriptionEmrDO);
|
|
|
object.put("registerSn",outpatientDO.getRegisterNo());
|
|
|
object.put("doctorName",outpatientDO.getDoctorName());
|
|
|
object.put("patientName",outpatientDO.getPatientName());
|
|
|
JSONObject jsonObject = computeDigestForAlg(object.toJSONString());
|
|
|
String hashValue = null;
|
|
|
String hashType = null;
|
|
|
if (jsonObject.getString("status").equalsIgnoreCase("0")){
|
|
|
JSONObject data = jsonObject.getJSONObject("data");
|
|
|
hashValue= data.getString("hashValue");
|
|
|
hashType = data.getString("hashType");
|
|
|
}
|
|
|
|
|
|
BasePatientDO patientDO = patientDao.findById(outpatientDO.getPatient()).orElse(null);
|
|
|
BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(outpatientDO.getDoctor());
|
|
|
if (patientDO!=null&&doctorDO!=null){
|
|
|
String patientName = patientDO.getName();
|
|
|
Integer patientAge = IdCardUtil.getAgeForIdcard(patientDO.getIdcard());
|
|
|
String patientSex = IdCardUtil.getSexForIdcard(patientDO.getIdcard());
|
|
|
String recipeTime = DateUtil.dateToStrLong(prescriptionDO.getCreateTime());
|
|
|
String openId = doctorDO.getOpenid();
|
|
|
String idcard = patientDO.getIdcard();
|
|
|
if (hashType!=null&&hashValue!=null){
|
|
|
JSONObject object1 = synRecipeInfo("hash_002",getCode(),patientName,patientAge.toString(),patientSex,"SF",recipeTime,hashValue,hashType,openId,idcard);
|
|
|
if (object1.getString("status").equalsIgnoreCase("0")){
|
|
|
logger.info("门诊病历签名成功"+object1);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//========================调用内网服务结束===================
|
|
|
|
|
|
//============================业务服务调用================================
|