|
@ -1,21 +1,35 @@
|
|
package com.yihu.jw.healthCare.service;
|
|
package com.yihu.jw.healthCare.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
|
|
import com.yihu.jw.entity.hospital.httplog.YlzHttpLogDO;
|
|
|
|
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
|
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
|
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
|
|
import com.yihu.jw.healthCare.utils.AES;
|
|
import com.yihu.jw.healthCare.utils.AES;
|
|
import com.yihu.jw.healthCare.utils.MD5;
|
|
import com.yihu.jw.healthCare.utils.MD5;
|
|
import com.yihu.jw.healthCare.utils.SafeUtil;
|
|
import com.yihu.jw.healthCare.utils.SafeUtil;
|
|
import com.yihu.jw.healthCare.utils.StringUtils;
|
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
|
|
import com.yihu.jw.hospital.httplog.dao.YlzHttpLogDao;
|
|
|
|
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
|
|
|
|
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
|
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
|
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
|
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import com.yihu.jw.utils.StringUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
import javax.xml.ws.Response;
|
|
import javax.xml.ws.Response;
|
|
@ -38,6 +52,18 @@ public class HealthCareService {
|
|
private HttpClientUtil httpClientUtil;
|
|
private HttpClientUtil httpClientUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private YlzHttpLogDao ylzHttpLogDao;
|
|
private YlzHttpLogDao ylzHttpLogDao;
|
|
|
|
@Autowired
|
|
|
|
private BasePatientDao patientDao;
|
|
|
|
@Autowired
|
|
|
|
private PatientMappingDao patientMappingDao;
|
|
|
|
@Autowired
|
|
|
|
private OutpatientDao outpatientDao;
|
|
|
|
@Autowired
|
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
|
@Autowired
|
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
|
|
|
private String ylzConfigUrl;
|
|
private String ylzConfigUrl;
|
|
private String ylzConfigAppid;
|
|
private String ylzConfigAppid;
|
|
@ -45,6 +71,7 @@ public class HealthCareService {
|
|
private String ylzConfigEncryptKey;
|
|
private String ylzConfigEncryptKey;
|
|
private String ylzConfigSignKey;
|
|
private String ylzConfigSignKey;
|
|
private String ylzConfigOrgCode;
|
|
private String ylzConfigOrgCode;
|
|
|
|
|
|
|
|
|
|
public void initConfig() throws Exception{
|
|
public void initConfig() throws Exception{
|
|
logger.info("初始话参数!");
|
|
logger.info("初始话参数!");
|
|
@ -75,6 +102,14 @@ public class HealthCareService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 医保统一调用接口
|
|
|
|
* @param data
|
|
|
|
* @param funid
|
|
|
|
* @param name
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
public String requestYlz(JSONObject data,String funid,String name) throws Exception {
|
|
public String requestYlz(JSONObject data,String funid,String name) throws Exception {
|
|
YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
|
|
YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
|
|
initConfig();
|
|
initConfig();
|
|
@ -119,6 +154,11 @@ public class HealthCareService {
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取token
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
public String getYlzToken() throws Exception {
|
|
public String getYlzToken() throws Exception {
|
|
YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
|
|
YlzHttpLogDO ylzHttpLogDO = new YlzHttpLogDO();
|
|
String token = null;
|
|
String token = null;
|
|
@ -146,10 +186,12 @@ public class HealthCareService {
|
|
JSONObject result = JSONObject.parseObject(response);
|
|
JSONObject result = JSONObject.parseObject(response);
|
|
if (result.getString("flag").equalsIgnoreCase("1")){
|
|
if (result.getString("flag").equalsIgnoreCase("1")){
|
|
String dataResult = result.getString("encrypt_data");
|
|
String dataResult = result.getString("encrypt_data");
|
|
|
|
result.remove("encrypt_data");
|
|
if (dataResult!=null&&dataResult!=""){
|
|
if (dataResult!=null&&dataResult!=""){
|
|
String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
|
|
String decryptResult = AES.aesDecrypt(dataResult,ylzConfigEncryptKey);
|
|
JSONObject dataObject = JSONObject.parseObject(decryptResult);
|
|
JSONObject dataObject = JSONObject.parseObject(decryptResult);
|
|
response = dataResult.toString();
|
|
|
|
|
|
result.put("encrypt_data",dataObject);
|
|
|
|
response = result.toString();
|
|
token = dataObject.getString("access_token");
|
|
token = dataObject.getString("access_token");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -165,4 +207,237 @@ public class HealthCareService {
|
|
return token;
|
|
return token;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2.2.1渠道应用是否已授权(N20.17.01.01)
|
|
|
|
*
|
|
|
|
* @param patient
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String authorized(String patient) throws Exception{
|
|
|
|
String funid = "N20.17.01.01";
|
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
|
if (patientDO==null){
|
|
|
|
throw new Exception("患者信息不存在");
|
|
|
|
}
|
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
|
|
|
|
if (patientMappingDO==null){
|
|
|
|
throw new Exception("患者his信息不存在");
|
|
|
|
}
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
data.put("service_id","N20.17.01.01");
|
|
|
|
data.put("name",patientDO.getName());
|
|
|
|
data.put("idcard",patientDO.getIdcard());
|
|
|
|
data.put("cert_type","01");//TODO
|
|
|
|
data.put("phone",patientDO.getMobile());
|
|
|
|
data.put("user_id",patientMappingDO.getMappingCode());
|
|
|
|
String result = requestYlz(data,funid,"渠道应用是否已授权");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2.2.2医保在线服务授权表单(H5表单/小程序)(N20.17.01.02)
|
|
|
|
*
|
|
|
|
* @param patient
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String medicareOnline(String patient) throws Exception{
|
|
|
|
String funid = "N20.17.01.02";
|
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("ylzConfigRedirectUrl");
|
|
|
|
if (hospitalSysDictDO==null){
|
|
|
|
throw new Exception("回调地址为空!");
|
|
|
|
}
|
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
|
if (patientDO==null){
|
|
|
|
throw new Exception("患者信息不存在");
|
|
|
|
}
|
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
|
|
|
|
if (patientMappingDO==null){
|
|
|
|
throw new Exception("患者his信息不存在");
|
|
|
|
}
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
data.put("service_id","N20.17.01.01");
|
|
|
|
data.put("name",patientDO.getName());
|
|
|
|
data.put("idcard",patientDO.getIdcard());
|
|
|
|
data.put("cert_type","01");//TODO
|
|
|
|
data.put("phone",patientDO.getMobile());
|
|
|
|
data.put("user_id",patientMappingDO.getMappingCode());
|
|
|
|
data.put("redirect_url",hospitalSysDictDO.getDictValue());
|
|
|
|
String result = requestYlz(data,funid,"医保在线服务授权表单");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2.5.1医保挂号(N20.17.04.01)
|
|
|
|
*
|
|
|
|
* 返回值
|
|
|
|
*
|
|
|
|
* @param outpatientId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String register(String outpatientId) throws Exception{
|
|
|
|
String funid = "N20.17.04.01";
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
|
|
|
|
if (outpatientDO==null){
|
|
|
|
throw new Exception("上传医保失败:门诊为空!");
|
|
|
|
}
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
data.put("region_code","");//参保地区划代码
|
|
|
|
data.put("idcard",outpatientDO.getIdcard());//证件号码
|
|
|
|
data.put("name",outpatientDO.getPatientName());//姓名
|
|
|
|
data.put("cert_type","01");//证件类型
|
|
|
|
data.put("medical_mode","");//医疗就诊方式
|
|
|
|
data.put("medical_type","");//医疗类别
|
|
|
|
data.put("his_serial",outpatientDO.getRegisterNo());//his流水号
|
|
|
|
data.put("his_dept_code",outpatientDO.getDept());//his内部科室编码
|
|
|
|
data.put("his_dept_name",outpatientDO.getDeptName());//his内部科室名称
|
|
|
|
data.put("emergency_sign",0);//急诊标志0 否,1 是
|
|
|
|
data.put("trauma_sign",0);//外伤标志0 否,1 是
|
|
|
|
data.put("date", DateUtil.dateToStrLong(outpatientDO.getAdmDate()));//实际门诊/入院日期 若为空,默认取系统时间
|
|
|
|
data.put("data_source","");//数据来源
|
|
|
|
String result = requestYlz(data,funid,"医保挂号");
|
|
|
|
if (result==null){
|
|
|
|
throw new Exception("上传医保挂号失败!");
|
|
|
|
}
|
|
|
|
JSONObject object = JSONObject.parseObject(result);
|
|
|
|
if (object.getString("flag").equalsIgnoreCase("1")){
|
|
|
|
JSONObject encryptData = object.getJSONObject("encrypt_data");
|
|
|
|
String insuranceSerial = encryptData.getString("insurance_serial");
|
|
|
|
outpatientDO.setInsuranceSerial(insuranceSerial);
|
|
|
|
outpatientDO.setMedicalStatus(1);
|
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
logger.info("医保挂号流水号保存成功");
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2.5.2医保挂号冲销(N20.17.04.02)
|
|
|
|
*
|
|
|
|
* 返回值
|
|
|
|
*
|
|
|
|
* @param outpatientId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String registerBack(String outpatientId) throws Exception{
|
|
|
|
String funid = "N20.17.04.02";
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
|
|
|
|
if (outpatientDO==null){
|
|
|
|
throw new Exception("上传医保失败:门诊为空!");
|
|
|
|
}
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
data.put("region_code","");//参保地区划代码
|
|
|
|
data.put("idcard",outpatientDO.getIdcard());//证件号码
|
|
|
|
data.put("name",outpatientDO.getPatientName());//姓名
|
|
|
|
data.put("cert_type","01");//证件类型
|
|
|
|
data.put("medical_mode","");//医疗就诊方式
|
|
|
|
data.put("medical_type","");//医疗类别
|
|
|
|
data.put("his_serial",outpatientDO.getRegisterNo());//his流水号
|
|
|
|
data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保流水号
|
|
|
|
data.put("data_source","");//数据来源
|
|
|
|
String result = requestYlz(data,funid,"医保挂号冲销");
|
|
|
|
if (result==null){
|
|
|
|
throw new Exception("上传医保挂号冲销失败!");
|
|
|
|
}
|
|
|
|
JSONObject object = JSONObject.parseObject(result);
|
|
|
|
if (object.getString("flag").equalsIgnoreCase("1")){
|
|
|
|
JSONObject encryptData = object.getJSONObject("encrypt_data");
|
|
|
|
String invalidSerial = encryptData.getString("refund_serial");
|
|
|
|
outpatientDO.setInvalidSerial(invalidSerial);
|
|
|
|
outpatientDO.setMedicalStatus(0);
|
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
logger.info("医保挂号冲销流水号保存成功");
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 2.5.3医保费用明细上传(N20.17.04.03)
|
|
|
|
*
|
|
|
|
* @param outpatientId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String feeDetailUpload(String outpatientId) throws Exception{
|
|
|
|
String funid = "N20.17.04.03";
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
|
|
|
|
if (outpatientDO==null){
|
|
|
|
throw new Exception("上传医保费用明细失败:门诊信息为空!");
|
|
|
|
}
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
|
|
|
|
if (doctorDO==null){
|
|
|
|
throw new Exception("上传医保费用明细失败:医生信息为空!");
|
|
|
|
}
|
|
|
|
Double register = outpatientDO.getFee();
|
|
|
|
Double drugFee= 0.0;
|
|
|
|
List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(outpatientId);
|
|
|
|
for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS){
|
|
|
|
drugFee +=wlyyPrescriptionDO.getDrugFee();
|
|
|
|
}
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
data.put("region_code","");//参保地区划代码
|
|
|
|
data.put("name",outpatientDO.getPatientName());//姓名
|
|
|
|
data.put("idcard",outpatientDO.getIdcard());//证件号码
|
|
|
|
data.put("cert_type","01");//证件类型 TODO
|
|
|
|
data.put("medical_mode","");//医疗就诊方式
|
|
|
|
data.put("insurance_serial",outpatientDO.getInsuranceSerial());//医保流水号
|
|
|
|
data.put("his_serial",outpatientDO.getRegisterNo());//his流水号
|
|
|
|
data.put("item_count",2);//明细项目数量
|
|
|
|
data.put("total_amount",drugFee+register);//医疗费总金额
|
|
|
|
data.put("data_source","");//数据来源
|
|
|
|
String icd10 = outpatientDO.getIcd10();
|
|
|
|
String icd10Name = outpatientDO.getIcd10Name();
|
|
|
|
String icd[] = icd10.split(",");
|
|
|
|
String icdName[] = icd10Name.split(",");
|
|
|
|
JSONArray icdArray = new JSONArray();
|
|
|
|
for (int i=0;i<icd.length;i++){
|
|
|
|
JSONObject icdObj = new JSONObject();
|
|
|
|
icdObj.put("disease_code_icd10","");//诊断或症状编码
|
|
|
|
icdObj.put("disease_name_icd10","");//诊断或症状名称
|
|
|
|
icdObj.put("disease_type","");//诊断或症状类型
|
|
|
|
icdObj.put("disease_order","");//诊断或症状序号
|
|
|
|
icdArray.add(icdObj);
|
|
|
|
}
|
|
|
|
data.put("zdlist",icdArray);
|
|
|
|
JSONArray infoArray = new JSONArray();
|
|
|
|
for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS){
|
|
|
|
List<WlyyPrescriptionInfoDO> prescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId());
|
|
|
|
for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:prescriptionInfoDOS){
|
|
|
|
JSONObject infoObj = new JSONObject();
|
|
|
|
infoObj.put("prescription_code",wlyyPrescriptionDO.getRealOrder());//医院处方编号
|
|
|
|
infoObj.put("his_detail_sn","");//his处方明细流水号
|
|
|
|
infoObj.put("item_name","");//医保项目名称
|
|
|
|
infoObj.put("item_code","");//医保项目编码
|
|
|
|
infoObj.put("specification_type",wlyyPrescriptionInfoDO.getSpecification());//规格型号
|
|
|
|
infoObj.put("dosage_form",wlyyPrescriptionInfoDO.getDosage());//剂型
|
|
|
|
infoObj.put("charge_unit","");//单位
|
|
|
|
infoObj.put("price",wlyyPrescriptionInfoDO.getPackRetprice());//单价
|
|
|
|
infoObj.put("amount",wlyyPrescriptionInfoDO.getQuantity());//数量
|
|
|
|
infoObj.put("total_money",wlyyPrescriptionInfoDO.getPackRetprice()*Integer.parseInt(wlyyPrescriptionInfoDO.getQuantity()));//金额
|
|
|
|
infoObj.put("prescription_date", DateUtil.dateToStrLong(wlyyPrescriptionDO.getCreateTime()));//处方日期
|
|
|
|
infoObj.put("his_dept_code",wlyyPrescriptionDO.getDept());//his内部科室编码
|
|
|
|
infoObj.put("his_dept_name",wlyyPrescriptionDO.getDeptName());//his内部科室名称
|
|
|
|
infoObj.put("medical_per_name",wlyyPrescriptionDO.getDoctorName());//医疗服务人员姓名
|
|
|
|
infoObj.put("medical_per_id",doctorDO.getIdcard());//医疗服务人员证件号码
|
|
|
|
infoObj.put("limit_type","");//限制范围类别
|
|
|
|
infoObj.put("actg_date","");//记帐日期
|
|
|
|
infoObj.put("his_item_name",wlyyPrescriptionInfoDO.getDrugName());//HIS院内项目名称
|
|
|
|
infoObj.put("his_item_code",wlyyPrescriptionInfoDO.getDrugNo());//HIS院内项目编码
|
|
|
|
infoObj.put("clerk_days","");//记帐日期
|
|
|
|
infoObj.put("people_type","");//医保服务人员类别
|
|
|
|
infoArray.add(infoObj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String result = requestYlz(data,funid,"医保费用明细上传");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|