|
@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.patient.PatientReservation;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientReservationDao;
|
|
|
import com.yihu.wlyy.service.common.account.PatientService;
|
|
|
import com.yihu.wlyy.service.third.jw.JwSmjkService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.SOAPUtil;
|
|
|
import com.yihu.wlyy.util.SendP2PUtil;
|
|
@ -50,6 +51,136 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
|
|
|
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"))
|
|
|
{
|
|
|
throw new Exception(response);
|
|
|
}
|
|
|
else if (response.toLowerCase().startsWith("ok")) { //预约成功
|
|
|
// 预约成功,获取预约号
|
|
|
code = response.replace("OK:", "").replace("ok:", "");
|
|
|
}
|
|
|
else if(response.split("\\|").length==3){
|
|
|
code = response.split("\\|")[0];
|
|
|
}
|
|
|
else{
|
|
|
throw new Exception(response);
|
|
|
}
|
|
|
|
|
|
// 查询医生职称和头像
|
|
|
GuahaoDoctor doctor = GetDoctorInfo(doctorId,hospitalId,hosDeptId);
|
|
|
// 保存预约记录
|
|
|
PatientReservation reservation = new PatientReservation();
|
|
|
reservation.setCode(code);
|
|
|
reservation.setCzrq(new Date());
|
|
|
reservation.setType("1");
|
|
|
reservation.setOrgCode(hospitalId);
|
|
|
reservation.setOrgName(hospitalName);
|
|
|
reservation.setDeptCode(hosDeptId);
|
|
|
reservation.setDeptName(hosDeptName);
|
|
|
reservation.setDoctorCode(doctorId);
|
|
|
reservation.setDoctorName(doctorName);
|
|
|
reservation.setDoctorJob(doctor.getTitle());
|
|
|
reservation.setDoctorPhoto(doctor.getPhoto());
|
|
|
reservation.setIdcard(cardNo);
|
|
|
reservation.setName(patientName);
|
|
|
reservation.setPatient(patient);
|
|
|
reservation.setPhone(patientPhone);
|
|
|
reservation.setSectionType(sectionType);
|
|
|
reservation.setSsc(clinicCard);
|
|
|
reservation.setStartTime(startTime);
|
|
|
reservation.setEndTime(endTime);
|
|
|
reservation.setStatus(1);
|
|
|
if(StringUtils.isNotBlank(dname)){
|
|
|
reservation.setDname(dname);//代理签约维护待签约人名称
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(dcode)){
|
|
|
reservation.setDoctor(dcode);//代理签约维护待签约人编码
|
|
|
SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
|
|
|
}
|
|
|
// 保存预约记录
|
|
|
patientReservationDao.save(reservation);
|
|
|
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预约排班xml转列表
|
|
|
*/
|
|
|
private List<Map<String,Object>> xmlToList(String xml) throws Exception{
|
|
|
List<Map<String,Object>> re = new ArrayList<>();
|
|
|
if (StringUtils.isEmpty(xml)) {
|
|
|
// 请求失败
|
|
|
throw new Exception("获取医生排班表失败!");
|
|
|
} else if (StringUtils.startsWith(xml, "System-Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
}
|
|
|
else if (StringUtils.startsWith(xml, "Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
}
|
|
|
Document document = DocumentHelper.parseText(xml);
|
|
|
Element root = document.getRootElement();
|
|
|
if(root.element("doctor")!=null) //包含doctor节点
|
|
|
{
|
|
|
root = root.element("doctor");
|
|
|
}
|
|
|
List<?> child = root.elements();
|
|
|
|
|
|
for (Object o : child) {
|
|
|
Element e = (Element) o;
|
|
|
// 日期
|
|
|
String date = e.attributeValue("date");
|
|
|
// a或者p
|
|
|
String time = e.attributeValue("time");
|
|
|
// 限号
|
|
|
String max = e.attributeValue("max");
|
|
|
// 已使用的号
|
|
|
String used = e.attributeValue("used");
|
|
|
// 1正常、2满号、3已过期
|
|
|
String status = e.attributeValue("status");
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("date", date);
|
|
|
map.put("time", time);
|
|
|
map.put("max", max);
|
|
|
map.put("used", used);
|
|
|
map.put("status", status);
|
|
|
// 排班信息
|
|
|
List<?> sections = e.elements();
|
|
|
List<Map<String,String>> arrangeList = new ArrayList<>();
|
|
|
for (Object s : sections) {
|
|
|
Element section = (Element) s;
|
|
|
// 限号
|
|
|
String s_max = section.attributeValue("max");
|
|
|
// 已使用的号
|
|
|
String s_used = section.attributeValue("used");
|
|
|
// 一次专家坐诊时间段的开始时间
|
|
|
String start_time = section.attributeValue("start_time");
|
|
|
// 结束时间
|
|
|
String end_time = section.attributeValue("end_time");
|
|
|
|
|
|
Map<String,String> item = new HashMap<>();
|
|
|
item.put("max", s_max);
|
|
|
item.put("used", s_used);
|
|
|
item.put("startTime", start_time);
|
|
|
item.put("endTime", end_time);
|
|
|
arrangeList.add(item);
|
|
|
}
|
|
|
map.put("sections", arrangeList);
|
|
|
re.add(map);
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************************/
|
|
|
/**
|
|
|
* 获取医院列表
|
|
|
*/
|
|
@ -120,7 +251,6 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取科室接口
|
|
|
*/
|
|
@ -260,7 +390,6 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
* status 0 停诊、1正常、2满号、3已过期
|
|
|
*/
|
|
|
public List<Map<String,Object>> GetDoctorArrange(String hospitalId,String hosDeptId,String doctorId) throws Exception{
|
|
|
List<Map<String,Object>> re = new ArrayList<>();
|
|
|
|
|
|
JSONArray params = new JSONArray();
|
|
|
JSONObject param1 = new JSONObject();
|
|
@ -290,63 +419,8 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
params.put(param5);
|
|
|
|
|
|
String xml = SOAPUtil.post(DOCTOR_ARRANGE, params);
|
|
|
if (StringUtils.isEmpty(xml)) {
|
|
|
// 请求失败
|
|
|
throw new Exception("获取医生排班表失败!");
|
|
|
} else if (StringUtils.startsWith(xml, "System-Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
}
|
|
|
else if (StringUtils.startsWith(xml, "Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
}
|
|
|
Document document = DocumentHelper.parseText(xml);
|
|
|
Element root = document.getRootElement();
|
|
|
List<?> child = root.elements();
|
|
|
for (Object o : child) {
|
|
|
Element e = (Element) o;
|
|
|
// 日期
|
|
|
String date = e.attributeValue("date");
|
|
|
// a或者p
|
|
|
String time = e.attributeValue("time");
|
|
|
// 限号
|
|
|
String max = e.attributeValue("max");
|
|
|
// 已使用的号
|
|
|
String used = e.attributeValue("used");
|
|
|
// 1正常、2满号、3已过期
|
|
|
String status = e.attributeValue("status");
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("date", date);
|
|
|
map.put("time", time);
|
|
|
map.put("max", max);
|
|
|
map.put("used", used);
|
|
|
map.put("status", status);
|
|
|
// 排班信息
|
|
|
List<?> sections = e.elements();
|
|
|
List<Map<String,String>> arrangeList = new ArrayList<>();
|
|
|
for (Object s : sections) {
|
|
|
Element section = (Element) s;
|
|
|
// 限号
|
|
|
String s_max = section.attributeValue("max");
|
|
|
// 已使用的号
|
|
|
String s_used = section.attributeValue("used");
|
|
|
// 一次专家坐诊时间段的开始时间
|
|
|
String start_time = section.attributeValue("start_time");
|
|
|
// 结束时间
|
|
|
String end_time = section.attributeValue("end_time");
|
|
|
|
|
|
Map<String,String> item = new HashMap<>();
|
|
|
item.put("max", s_max);
|
|
|
item.put("used", s_used);
|
|
|
item.put("startTime", start_time);
|
|
|
item.put("endTime", end_time);
|
|
|
arrangeList.add(item);
|
|
|
}
|
|
|
map.put("sections", arrangeList);
|
|
|
re.add(map);
|
|
|
}
|
|
|
return re;
|
|
|
return xmlToList(xml);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -424,9 +498,8 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
|
|
|
/**
|
|
|
* 创建挂号单
|
|
|
* update by linz 新增代签约人的code和name用于转诊预约
|
|
|
*/
|
|
|
public String CreateOrder(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 CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
|
|
|
String re = "";
|
|
|
|
|
|
Patient p = patientService.findByCode(patient);
|
|
@ -475,62 +548,30 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
param3.put("value", values[2]);
|
|
|
params.put(param3);
|
|
|
|
|
|
String xml = SOAPUtil.post(ORDER_CREATE, params);
|
|
|
if (StringUtils.isEmpty(xml)) {
|
|
|
String response = SOAPUtil.post(ORDER_CREATE, params);
|
|
|
if (StringUtils.isEmpty(response)) {
|
|
|
// 请求失败
|
|
|
throw new Exception("请求失败!");
|
|
|
} else if (StringUtils.startsWith(xml, "System-Error")) {
|
|
|
} else if (StringUtils.startsWith(response, "System-Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
} else if (StringUtils.startsWith(xml, "Error")) {
|
|
|
throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
|
|
|
} else if (StringUtils.startsWith(response, "Error")) {
|
|
|
// 调用失败
|
|
|
throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
|
|
|
throw new Exception(response.substring(response.indexOf(":") + 1, response.length()));
|
|
|
}
|
|
|
|
|
|
//预约成功
|
|
|
if (xml.toLowerCase().startsWith("ok")) {
|
|
|
// 预约成功,获取预约号
|
|
|
String code = xml.replace("OK:", "");
|
|
|
// 查询医生职称和头像
|
|
|
GuahaoDoctor doctor = GetDoctorInfo(doctorId,hospitalId,hosDeptId);
|
|
|
// 保存预约记录
|
|
|
PatientReservation reservation = new PatientReservation();
|
|
|
reservation.setCode(code);
|
|
|
reservation.setCzrq(new Date());
|
|
|
reservation.setType("1");
|
|
|
reservation.setOrgCode(hospitalId);
|
|
|
reservation.setOrgName(hospitalName);
|
|
|
reservation.setDeptCode(hosDeptId);
|
|
|
reservation.setDeptName(hosDeptName);
|
|
|
reservation.setDoctorCode(doctorId);
|
|
|
reservation.setDoctorName(doctorName);
|
|
|
reservation.setDoctorJob(doctor.getTitle());
|
|
|
reservation.setDoctorPhoto(doctor.getPhoto());
|
|
|
reservation.setIdcard(cardNo);
|
|
|
reservation.setName(patientName);
|
|
|
reservation.setPatient(patient);
|
|
|
reservation.setPhone(patientPhone);
|
|
|
reservation.setSectionType(sectionType);
|
|
|
reservation.setSsc(clinicCard);
|
|
|
reservation.setStartTime(startTime);
|
|
|
reservation.setEndTime(endTime);
|
|
|
reservation.setStatus(1);
|
|
|
if(StringUtils.isNotBlank(dname)){
|
|
|
reservation.setDname(dname);//代理签约维护待签约人名称
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(dcode)){
|
|
|
reservation.setDoctor(dcode);//代理签约维护待签约人编码
|
|
|
SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
|
|
|
}
|
|
|
// 保存预约记录
|
|
|
patientReservationDao.save(reservation);
|
|
|
re = code;
|
|
|
}
|
|
|
re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
|
|
|
}
|
|
|
else{
|
|
|
throw new Exception("该排班信息错误或者不存在!");
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 取消挂号单
|
|
|
*/
|
|
@ -977,4 +1018,49 @@ public class GuahaoXMService implements IGuahaoService {
|
|
|
patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
|
|
|
return patientReservation;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
JwSmjkService jwSmjkService;
|
|
|
/******************************** 基卫内网服务 ************************************************/
|
|
|
public List<Map<String,Object>> GetDoctorArrangeTenDay(String hospitalId,String hosDeptId,String doctorId) throws Exception {
|
|
|
|
|
|
String strStart = DateUtil.getStringDateShort(); //当前时间;
|
|
|
String strEnd = DateUtil.getNextDay(strStart,11); //10天预约
|
|
|
|
|
|
String response = jwSmjkService.getRegDeptSpeDoctorSectionList(hospitalId,hosDeptId,strStart,strEnd,doctorId);
|
|
|
|
|
|
return xmlToList(response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转诊预约挂号
|
|
|
*/
|
|
|
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
|
|
|
{
|
|
|
String re = "";
|
|
|
|
|
|
Patient p = patientService.findByCode(patient);
|
|
|
if (p == null) {
|
|
|
throw new Exception("患者信息不存在!");
|
|
|
}
|
|
|
|
|
|
Map<String,String> map = objectMapper.readValue(arrangeDate,Map.class);
|
|
|
if(map.containsKey("sectionType") && map.containsKey("startTime")) {
|
|
|
String sectionType = map.get("sectionType");
|
|
|
String startTime = map.get("startTime");
|
|
|
String endTime = map.get("endTime");
|
|
|
|
|
|
String response = jwSmjkService.webRegisterByFamily(cardNo,patientName,clinicCard,sectionType,startTime,hospitalId,hosDeptId,hosDeptName,doctorId,doctorName);
|
|
|
|
|
|
re = CreateOrderAfter(response,hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,sectionType,startTime,endTime,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
|
|
|
}
|
|
|
else{
|
|
|
throw new Exception("该排班信息错误或者不存在!");
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
}
|