|
@ -69,6 +69,7 @@ import com.yihu.jw.restmodel.hospital.consult.WlyyHospitalSysDictVO;
|
|
|
import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
@ -107,6 +108,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.checkerframework.checker.units.qual.MixedUnits;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@ -272,6 +274,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private YxTokenMappingDao yxTokenMappingDao;
|
|
|
@Autowired
|
|
|
private BaseNatAppointmentDao baseNatAppointmentDao;
|
|
|
|
|
|
|
|
|
|
|
@ -4682,6 +4686,42 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
//核算检测预约模板消息
|
|
|
public void sendNatWxTemplat(String name,String idcard,String mobile,String time,String orderNo,String relationName){
|
|
|
String first = "";
|
|
|
String contentMsg = "";
|
|
|
String msgUrl="";
|
|
|
String remark="";
|
|
|
String responseMsg="";
|
|
|
if ("natAppointmentRemind".equalsIgnoreCase(relationName)){
|
|
|
first = "尊敬的用户"+name+",您已完成线上自助核酸检测开单预约";
|
|
|
contentMsg = "申请人:"+name+";预约时间:"+time+";发票流水号:"+orderNo;
|
|
|
remark="请您持核酸开单预约信息和结算发票号、医保卡、就诊卡、电子健康卡,提前15分钟至我院五号楼北侧(急诊部后侧)核酸检测点2号窗口绑定检测。";
|
|
|
}
|
|
|
if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)) {
|
|
|
String prefix = "https://hlwyy.xmzsh.com";
|
|
|
responseMsg = entranceService.ehospitalNotice(
|
|
|
name,
|
|
|
idcard,
|
|
|
mobile,
|
|
|
first,
|
|
|
prefix + msgUrl,
|
|
|
contentMsg,
|
|
|
remark);
|
|
|
logger.info("中山发送模板消息返回结果="+responseMsg);
|
|
|
System.out.println("结束发送模板消息");
|
|
|
}
|
|
|
//保存发送模板记录,
|
|
|
WxPushLogDO wxPushLogDO = new WxPushLogDO();
|
|
|
wxPushLogDO.setCreateTime(new Date());
|
|
|
wxPushLogDO.setWechatId(wechatId);
|
|
|
wxPushLogDO.setReceiverName(name);
|
|
|
wxPushLogDO.setRequest(first+contentMsg+msgUrl);
|
|
|
wxPushLogDO.setResponse(responseMsg);
|
|
|
wxPushLogDO.setTempName("核算检测预约模板消息");
|
|
|
wxPushLogDao.save(wxPushLogDO);
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<WlyyHospitalSysDictDO> findCancelReasonList() {
|
|
@ -10337,5 +10377,215 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
}
|
|
|
return doorServiceCount;
|
|
|
}
|
|
|
public MixEnvelop findJobCategory(){
|
|
|
String sqlPid = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category where pid = 0 and del = 1";
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sqlPid);
|
|
|
if (list.size()>0){
|
|
|
for (Map<String,Object> map:list){
|
|
|
String child = "select id as \"id\",name as \"name\",pid as \"pid\" from base_job_category where del = 1";
|
|
|
String pid = map.get("id").toString();
|
|
|
child+=" and pid = "+pid;
|
|
|
List<Map<String,Object>> childList = hibenateUtils.createSQLQuery(child);
|
|
|
map.put("childList",childList);
|
|
|
}
|
|
|
}
|
|
|
MixEnvelop envelop = new MixEnvelop();
|
|
|
envelop.setDetailModelList(list);
|
|
|
return envelop;
|
|
|
}
|
|
|
public Map<String,Object> findRandomDoctor(){
|
|
|
String sql = "select t.id as \"id\"," +
|
|
|
"t.doctor_mapping_code as \"doctorMappingCode\"," +
|
|
|
"t.doctor_code as \"doctorCode\"," +
|
|
|
"t.dept_code as \"deptCode\"," +
|
|
|
"t.start_time as \"startTime\"," +
|
|
|
"t.end_time as \"endTime\"," +
|
|
|
"t.doctor_name as \"doctorName\"," +
|
|
|
"t.dept_name as \"deptName\" from base_doctor_time_mapping t where 1=1 ";
|
|
|
if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
sql+=" order by dbms_random.value";
|
|
|
}else {
|
|
|
sql+=" ORDER BY RAND() ";
|
|
|
}
|
|
|
List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
|
|
|
if (list!=null&&list.size()>0){
|
|
|
return list.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
public void saveNatAppointment(String mediaCard,String patientId,String name,String cardNo,String cardType,String mobile,
|
|
|
String firstJobCode,String firstJobName,String secondJobCode,String secondJobName,String natTime,String address,
|
|
|
String province,String provinceName,String city,String cityName,String town,String townName,String street,String streetName){
|
|
|
BaseNatAppointmentDO baseNatAppointmentDO= new BaseNatAppointmentDO();
|
|
|
net.sf.json.JSONObject jsondate = new JSONObject();
|
|
|
jsondate.put("checkPart","鼻/咽拭子");
|
|
|
jsondate.put("cardNo",mediaCard);
|
|
|
jsondate.put("chargeFlag","2");
|
|
|
jsondate.put("chargeCode","361322");
|
|
|
jsondate.put("icdCode","Z00.000");
|
|
|
jsondate.put("socialNo",cardNo);
|
|
|
jsondate.put("tellPhone",mobile);
|
|
|
jsondate.put("address1",province);
|
|
|
jsondate.put("address2",city);
|
|
|
jsondate.put("address3",town);
|
|
|
jsondate.put("address4",street);
|
|
|
jsondate.put("address5",2);
|
|
|
jsondate.put("area",address);
|
|
|
jsondate.put("target",2);
|
|
|
Map<String,Object> map = findRandomDoctor();
|
|
|
net.sf.json.JSONObject rs = new JSONObject();
|
|
|
if (map!=null){
|
|
|
try {
|
|
|
rs = entranceService.BS10111(cardNo, map.get("doctorMappingCode").toString(), map.get("deptCode").toString(), "31", "6", demoFlag);
|
|
|
net.sf.json.JSONObject res = rs.getJSONObject("resquest");
|
|
|
logger.info("挂号结果 res: " + res.toString());
|
|
|
String rsCode = res.getString("@RESULT");
|
|
|
if ("0".equals(rsCode)) {
|
|
|
//存储挂号号
|
|
|
// {"resquest":{"@RESULT":"0","@MSG":"完成","@serial_no":"47770476","@times":"28"}}
|
|
|
String serialNo = (String) res.get("@serial_no");
|
|
|
String conNo = (String) res.get("@times");
|
|
|
String xtgzh = (String) res.get("@xtgzh");
|
|
|
String realOrder = (String) res.get("@real_order");
|
|
|
logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
|
|
|
jsondate.put("serialNo",serialNo);
|
|
|
jsondate.put("dept",map.get("deptCode").toString());
|
|
|
jsondate.put("doctor",map.get("doctorMappingCode").toString());
|
|
|
//存储就诊记录
|
|
|
WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
|
|
|
// 存储挂号医生与挂号科室
|
|
|
registerDO.setDoctor(map.get("doctorCode").toString());
|
|
|
registerDO.setDoctorName(map.get("doctorName").toString());
|
|
|
registerDO.setDept(map.get("deptCode").toString());
|
|
|
registerDO.setDeptName(map.get("deptName").toString());
|
|
|
registerDO.setRealOrder(realOrder);
|
|
|
registerDO.setXtgzh(xtgzh);
|
|
|
registerDO.setPatient(patientId);
|
|
|
registerDO.setPatientName(name);
|
|
|
//挂号流水号与挂号次数
|
|
|
registerDO.setRegisterNo(serialNo);
|
|
|
registerDO.setConNo(conNo);
|
|
|
registerDO.setCreateTime(new Date());
|
|
|
registerDO.setDel(1);
|
|
|
registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
patientRegisterDao.save(registerDO);
|
|
|
|
|
|
} else if ("-2".equals(rsCode)) {
|
|
|
String serialNo = (String) res.get("@serial_no");
|
|
|
String xtgzh = (String) res.get("@xtgzh");
|
|
|
String realOrder = (String) res.get("@real_order");
|
|
|
String conNo = (String) res.get("@times");
|
|
|
jsondate.put("serialNo",serialNo);
|
|
|
jsondate.put("dept",map.get("deptCode").toString());
|
|
|
jsondate.put("doctor",map.get("doctorMappingCode").toString());
|
|
|
logger.info("挂号流水 @serial_no: " + serialNo + " @times: " + conNo);
|
|
|
//存储就诊记录
|
|
|
WlyyPatientRegisterDO registerDO = new WlyyPatientRegisterDO();
|
|
|
registerDO.setDoctor(map.get("doctorCode").toString());
|
|
|
registerDO.setDoctorName(map.get("doctorName").toString());
|
|
|
registerDO.setDept(map.get("deptCode").toString());
|
|
|
registerDO.setDeptName(map.get("deptName").toString());
|
|
|
registerDO.setRealOrder(realOrder);
|
|
|
registerDO.setXtgzh(xtgzh);
|
|
|
registerDO.setPatient(patientId);
|
|
|
registerDO.setPatientName(name);
|
|
|
registerDO.setRegisterNo(serialNo);
|
|
|
registerDO.setConNo(conNo);
|
|
|
registerDO.setCreateTime(new Date());
|
|
|
registerDO.setDate(DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
|
|
|
patientRegisterDao.save(registerDO);
|
|
|
}
|
|
|
//保存日志
|
|
|
WlyyHttpLogDO log = new WlyyHttpLogDO();
|
|
|
log.setCode("registerOutPatient");
|
|
|
log.setName("挂号");
|
|
|
log.setPatient(patientId);
|
|
|
log.setDoctor(map.get("doctorCode").toString());
|
|
|
log.setResponse(rs.toString());
|
|
|
log.setStatus(rsCode);
|
|
|
log.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(log);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
logger.info("saveNatAppointment params:"+jsondate.toString());
|
|
|
try {
|
|
|
JSONObject jsonObject = entranceService.BS10112(jsondate.toString(),flag);
|
|
|
//判断返回结果
|
|
|
String prers = jsonObject.getString("@RESULT");
|
|
|
//保存日志
|
|
|
WlyyHttpLogDO log = new WlyyHttpLogDO();
|
|
|
log.setCode("saveNatAppointment");
|
|
|
log.setName("核酸检测开方");
|
|
|
log.setPatient(patientId);
|
|
|
log.setDoctor(map.get("doctorCode").toString());
|
|
|
log.setResponse(jsonObject.toString());
|
|
|
log.setRequest(jsondate.toString());
|
|
|
log.setCreateTime(new Date());
|
|
|
wlyyHttpLogDao.save(log);
|
|
|
if ("0".equals(prers)) {
|
|
|
String realOrder = jsonObject.getString("@real_order");
|
|
|
baseNatAppointmentDO.setRealOrder(realOrder);
|
|
|
//成功后发送模板消息
|
|
|
sendNatWxTemplat(name,cardNo,mobile,natTime,realOrder,"natAppointmentRemind");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
baseNatAppointmentDO.setMedicard(mediaCard);
|
|
|
baseNatAppointmentDO.setName(name);
|
|
|
baseNatAppointmentDO.setCardNo(cardNo);
|
|
|
baseNatAppointmentDO.setCardType(cardType);
|
|
|
baseNatAppointmentDO.setAddress(address);
|
|
|
baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDate(natTime,"yyyy-MM-dd hh:mm:ss"));
|
|
|
baseNatAppointmentDO.setCity(city);
|
|
|
baseNatAppointmentDO.setCityName(cityName);
|
|
|
baseNatAppointmentDO.setFirstJobCode(firstJobCode);
|
|
|
baseNatAppointmentDO.setFirstJobName(firstJobName);
|
|
|
baseNatAppointmentDO.setSecondJobCode(secondJobCode);
|
|
|
baseNatAppointmentDO.setSecondJobName(secondJobName);
|
|
|
baseNatAppointmentDO.setProvince(province);
|
|
|
baseNatAppointmentDO.setProvinceName(provinceName);
|
|
|
baseNatAppointmentDO.setTown(town);
|
|
|
baseNatAppointmentDO.setTownName(townName);
|
|
|
baseNatAppointmentDO.setStreet(street);
|
|
|
baseNatAppointmentDO.setStreet(streetName);
|
|
|
baseNatAppointmentDO.setPatientId(patientId);
|
|
|
baseNatAppointmentDO.setIsSuccess("0");
|
|
|
baseNatAppointmentDO.setPayStatus("0");
|
|
|
baseNatAppointmentDO.setCreateTime(new Date());
|
|
|
baseNatAppointmentDO.setMobile(mobile);
|
|
|
baseNatAppointmentDao.save(baseNatAppointmentDO);
|
|
|
}
|
|
|
public MixEnvelop getNatRecords(String patientId,Integer page ,Integer pageSize){
|
|
|
String sql = "select t.name as \"name\"," +
|
|
|
"t.card_no as \"cardNo\"," +
|
|
|
"t.card_type as \"cardType\"," +
|
|
|
"t.mobile as \"mobile\"," +
|
|
|
"t.inspection_name as \"inspectionName\"," +
|
|
|
"t.real_order as \"realOrder\"," +
|
|
|
"t.real_order as \"realOrder\"," +
|
|
|
"t.is_success as \"isSuccess\"," +
|
|
|
"t.create_time as \"createTime\"," +
|
|
|
"t.appointment_time as \"appointmentTime\" " +
|
|
|
" from base_nat_appointment t where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(patientId)){
|
|
|
sql+=" and t.patient_id ='"+patientId+"'";
|
|
|
}
|
|
|
List<Map<String ,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
|
|
|
List<Map<String ,Object>> listCount = hibenateUtils.createSQLQuery(sql);
|
|
|
MixEnvelop mixnvelop = new MixEnvelop();
|
|
|
if (listCount!=null&&listCount.size()>0){
|
|
|
mixnvelop.setCurrPage(page);
|
|
|
mixnvelop.setPageSize(pageSize);
|
|
|
mixnvelop.setTotalCount(listCount.size());
|
|
|
mixnvelop.setDetailModelList(list);
|
|
|
|
|
|
}
|
|
|
return mixnvelop;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|