|
@ -1,12 +1,20 @@
|
|
|
package com.yihu.wlyy.service.third.guahao;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.survey.SurveyScreenResult;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientReservation;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.SurveyScreenResultDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientReservationDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.consult.ConsultService;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.service.third.httplog.LogService;
|
|
@ -20,6 +28,7 @@ import org.dom4j.Element;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
@ -30,7 +39,7 @@ import java.util.*;
|
|
|
* 厦门市民健康网挂号服务
|
|
|
*/
|
|
|
@Service
|
|
|
public class GuahaoXMService implements IGuahaoService {
|
|
|
public class GuahaoXMService extends BaseService implements IGuahaoService {
|
|
|
|
|
|
private int nextDays = 8; //一周内预约号
|
|
|
private String ORG_LIST = "GetOrgListNew";//获取医院列表
|
|
@ -55,6 +64,13 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
JwSmjkService jwSmjkService;
|
|
|
@Autowired
|
|
|
SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private MessageDao messageDao;
|
|
|
@Autowired
|
|
|
private SurveyScreenResultDao surveyScreenResultDao;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
|
|
|
@Autowired
|
|
|
private LogService logService;
|
|
@ -62,14 +78,22 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
@Autowired
|
|
|
private ConsultService consultService;
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
|
private DoctorDao doctorDao;
|
|
|
|
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 解析挂号后
|
|
|
*/
|
|
|
private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
|
|
|
String code = "";
|
|
|
if (response.startsWith("error") || response.startsWith("System-Error")) {
|
|
|
private String CreateOrderAfter(String response, String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String sectionType, String startTime, String endTime, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode,String surveyCode) throws Exception {
|
|
|
String code = "321321321";
|
|
|
/* if (response.startsWith("error") || response.startsWith("System-Error")) {
|
|
|
throw new Exception(response);
|
|
|
} else if (response.toLowerCase().startsWith("ok")) { //预约成功
|
|
|
// 预约成功,获取预约号
|
|
@ -78,16 +102,23 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
code = response.split("\\|")[0];
|
|
|
} else {
|
|
|
throw new Exception(response);
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
Patient patient1 = null;
|
|
|
try {
|
|
|
patient1 = patientDao.findByCode(patient);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
System.out.println("获取病人信息失败");
|
|
|
}
|
|
|
// 查询医生职称和头像
|
|
|
GuahaoDoctor doctor = null;
|
|
|
try{
|
|
|
/*try{
|
|
|
doctor = jwSmjkService.getGuahaoDoctor(doctorId, hospitalId, hosDeptId);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
System.out.println("获取医生信息失败");
|
|
|
}
|
|
|
}*/
|
|
|
// 保存预约记录
|
|
|
PatientReservation reservation = new PatientReservation();
|
|
|
reservation.setCode(code);
|
|
@ -99,10 +130,10 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
reservation.setDeptName(hosDeptName);
|
|
|
reservation.setDoctorCode(doctorId);
|
|
|
reservation.setDoctorName(doctorName);
|
|
|
if(doctor!=null){
|
|
|
/*if(doctor!=null){
|
|
|
reservation.setDoctorJob(doctor.getTitle());
|
|
|
reservation.setDoctorPhoto(doctor.getPhoto());
|
|
|
}
|
|
|
}*/
|
|
|
reservation.setIdcard(cardNo);
|
|
|
reservation.setName(patientName);
|
|
|
reservation.setPatient(patient);
|
|
@ -128,12 +159,47 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
|
|
|
}
|
|
|
// 保存预约记录
|
|
|
patientReservationDao.save(reservation);
|
|
|
PatientReservation patientReservation = patientReservationDao.save(reservation);
|
|
|
if(StringUtils.isNotBlank(dcode)){
|
|
|
Patient p = patientService.findByCode(patient);
|
|
|
consultService.sendMucMessageBySingnType(dcode,dname,patient,"我已成功为您预约:" + startTime + "," + hospitalName + hosDeptName + doctorName + "医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='" + reservation.getId() + "'>点击查看详情</a>","1",p.getName());
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNoneBlank(surveyCode)){
|
|
|
SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(surveyCode);
|
|
|
surveyScreenResult.setOrder(1);
|
|
|
surveyScreenResult.setReservationCode(patientReservation.getCode());
|
|
|
String sql = "update wlyy_survey_screen_result ssr set ssr.is_order = "+surveyScreenResult.getOrder()+"," +
|
|
|
"reservation_code = '"+surveyScreenResult.getReservationCode()+"' where ssr.id = '"+surveyScreenResult.getId()+"'";
|
|
|
jdbcTemplate.update(sql);
|
|
|
|
|
|
//发送消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有一个居民开通专科服务");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(doctorId);//设置接受医生的code
|
|
|
message.setSender(patient);//设置发送的用户
|
|
|
message.setSenderName(patientName);
|
|
|
message.setCode(getCode());
|
|
|
message.setSenderPhoto(patient1.getPhoto());
|
|
|
message.setTitle("专科医生共管通知");
|
|
|
message.setType(17);//家庭签约取消信息
|
|
|
message.setReadonly(1);//是否只读消息
|
|
|
message.setSex(patient1.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setRelationCode(patientReservation.getCode());
|
|
|
message.setDel("1");
|
|
|
message.setState(1);
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("name",patient1.getName());
|
|
|
object.put("carq",patientReservation.getCzrq());
|
|
|
object.put("title",surveyScreenResult.getTemplateTitle());
|
|
|
object.put("screenResult",surveyScreenResult.getScreenResult());
|
|
|
message.setReason(object.toString());
|
|
|
messageDao.save(message);
|
|
|
}
|
|
|
return code;
|
|
|
}
|
|
|
|
|
@ -653,7 +719,7 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
verificationXml(response,"获取医生排班表失败!",ORDER_CREATE,content,method,msgBody,res);
|
|
|
//保存http日志
|
|
|
logService.saveHttpLog(true,ORDER_CREATE,content,method,null,msgBody,res,null,logService.archiveType);
|
|
|
re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null);
|
|
|
re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, null, null,null);
|
|
|
} else {
|
|
|
throw new Exception("该排班信息错误或者不存在!");
|
|
|
}
|
|
@ -1161,7 +1227,7 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
/**
|
|
|
* 转诊预约挂号
|
|
|
*/
|
|
|
public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode) throws Exception {
|
|
|
public String CreateOrderByDoctor(String hospitalId, String hospitalName, String hosDeptId, String hosDeptName, String doctorId, String doctorName, String arrangeDate, String patient, String patientName, String cardNo, String clinicCard, String patientPhone, String dname, String dcode,String surveyCode) throws Exception {
|
|
|
String re = "";
|
|
|
|
|
|
Patient p = patientService.findByCode(patient);
|
|
@ -1175,9 +1241,9 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
String startTime = map.get("startTime");
|
|
|
String endTime = map.get("endTime");
|
|
|
|
|
|
String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);
|
|
|
|
|
|
re = CreateOrderAfter(response, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
|
|
|
/* String response = jwSmjkService.webRegisterByFamily(cardNo, patientName, clinicCard, sectionType, startTime, hospitalId, hosDeptId, hosDeptName, doctorId, doctorName,patientPhone);
|
|
|
*/
|
|
|
re = CreateOrderAfter(null, hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, sectionType, startTime, endTime, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode,surveyCode);
|
|
|
} else {
|
|
|
throw new Exception("该排班信息错误或者不存在!");
|
|
|
}
|
|
@ -1185,4 +1251,48 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取转诊信息
|
|
|
*
|
|
|
* @param relationCode 关联code
|
|
|
* @return
|
|
|
*/
|
|
|
public com.alibaba.fastjson.JSONObject getPatientReservationInfo(String relationCode){
|
|
|
PatientReservation patientReservation = patientReservationDao.findByCode(relationCode);
|
|
|
List<SurveyScreenResult> surveyScreenResults = null;
|
|
|
Patient patient = null;
|
|
|
SignFamily signFamily = null;
|
|
|
Doctor doctor = null;
|
|
|
int age = 0;
|
|
|
if (patientReservation != null){
|
|
|
surveyScreenResults = surveyScreenResultDao.getByReservationCode(relationCode);
|
|
|
patient = patientDao.findByCode(patientReservation.getPatient());
|
|
|
age = DateUtil.getAgeByBirthday(patient.getBirthday());
|
|
|
signFamily = signFamilyDao.findByPatient(patientReservation.getPatient());
|
|
|
doctor = doctorDao.findByCode(signFamily.getDoctor());
|
|
|
}
|
|
|
com.alibaba.fastjson.JSONObject object = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(patientReservation);
|
|
|
object.put("surveyScreenResults",surveyScreenResults);
|
|
|
object.put("patient",patient);
|
|
|
object.put("age",age);
|
|
|
object.put("signFamily",signFamily);
|
|
|
object.put("doctor",doctor);
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
public JSONObject updateRecode(String messageCode,String surveyCode){
|
|
|
Message message = messageDao.findByCode(messageCode);
|
|
|
message.setOver("0");
|
|
|
messageDao.save(message);
|
|
|
SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(surveyCode);
|
|
|
surveyScreenResult.setOrder(2);
|
|
|
surveyScreenResultDao.save(surveyScreenResult);
|
|
|
JSONObject object = new JSONObject();
|
|
|
object.put("message",message);
|
|
|
object.put("surveyScreenResult",surveyScreenResult);
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|