|  | @ -84,6 +84,7 @@ import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxPushLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.enterprise.EnterpriseService;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.WxAccessTokenService;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
	
		
			
				|  | @ -96,7 +97,6 @@ import jxl.write.*;
 | 
	
		
			
				|  |  | import net.sf.json.JSONArray;
 | 
	
		
			
				|  |  | import net.sf.json.JSONObject;
 | 
	
		
			
				|  |  | import net.sf.json.xml.XMLSerializer;
 | 
	
		
			
				|  |  | import org.apache.commons.codec.binary.*;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
	
		
			
				|  | @ -111,18 +111,14 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.xml.rpc.ServiceException;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
		
			
				|  |  | import java.lang.Boolean;
 | 
	
		
			
				|  |  | import java.math.BigDecimal;
 | 
	
		
			
				|  |  | import java.net.MalformedURLException;
 | 
	
		
			
				|  |  | import java.net.URL;
 | 
	
		
			
				|  |  | import java.text.DecimalFormat;
 | 
	
		
			
				|  |  | import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.Base64;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Trick on 2019/5/17.
 | 
	
	
		
			
				|  | @ -260,6 +256,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private DoctorMappingDao doctorMappingDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionSignDao prescriptionSignDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private EnterpriseService enterpriseService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -281,14 +279,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |     public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag,String ksdm) throws Exception {
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patient:" + patient);
 | 
	
		
			
				|  |  |         String patNo = patientMappingService.findHisPatNoByPatient(patient);
 | 
	
		
			
				|  |  |         if (StringUtils.isBlank(patNo)) {
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patNo " + patNo);
 | 
	
		
			
				|  |  |         return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag);
 | 
	
		
			
				|  |  |         return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag,ksdm);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -305,7 +303,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patNo:" + patNo);
 | 
	
		
			
				|  |  |         List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag);
 | 
	
		
			
				|  |  |         List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag,null);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |             WlyyOutpatientVO outpatientVO = list.get(0);
 | 
	
	
		
			
				|  | @ -794,8 +792,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //1.保存就诊实体
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
	
		
			
				|  | @ -812,7 +810,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (outpatientDO.getRegisterDate() == null) {
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterDate(new Date());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         //2.物流信息
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |         if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
 | 
	
		
			
				|  |  |             wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
 | 
	
		
			
				|  |  |             return wlyyOutpatientDO;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
 | 
	
		
			
				|  |  |         Double price = 0.0;
 | 
	
	
		
			
				|  | @ -843,19 +848,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             throw new RuntimeException("号源已经被预约,请选择其他号源");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         //2.物流信息
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |       /*  if (null!=previous&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             outpatientDao.delete(outpatient.getId());
 | 
	
		
			
				|  |  |             businessOrderDao.delete(businessOrderDO.getId());
 | 
	
		
			
				|  |  |             throw new Exception("您今日发起过复诊,不允许更改取药方式");
 | 
	
		
			
				|  |  |         }*/
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (0==expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             /*if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalCode(drugCode);
 | 
	
		
			
				|  |  |             }*/
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             System.out.println("进入物流信息");
 | 
	
		
			
				|  |  |             expressageDO.setDel(1);
 | 
	
		
			
				|  |  |             expressageDO.setCreateTime(new Date());
 | 
	
	
		
			
				|  | @ -885,6 +883,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient, chargeType);
 | 
	
		
			
				|  |  |         //发送企业模板消息给医生
 | 
	
		
			
				|  |  |         String msg = "";
 | 
	
		
			
				|  |  |         String name=outpatient.getPatientName();
 | 
	
		
			
				|  |  |         String sex = "";
 | 
	
		
			
				|  |  |         String age="";
 | 
	
		
			
				|  |  |         String date = "";
 | 
	
		
			
				|  |  |         String title = "";
 | 
	
		
			
				|  |  |         String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/onlineChat/detail?_rs_title="+outpatient.getDescription()+"&type=3&id="+outpatient.getId();
 | 
	
		
			
				|  |  |         if (patientDO!=null){
 | 
	
		
			
				|  |  |             sex=IdCardUtil.getSexForIdcard(patientDO.getIdcard());
 | 
	
		
			
				|  |  |             age = IdCardUtil.getAgeForIdcard(patientDO.getIdcard())+"";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (outpatient!=null){
 | 
	
		
			
				|  |  |             if (outpatient.getType().equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                 title = "图文复诊";
 | 
	
		
			
				|  |  |                 msg = name+"("+sex+" "+age+"岁)向您发起了图文复诊,点击查看";
 | 
	
		
			
				|  |  |             }else if (outpatient.getType().equalsIgnoreCase("2")){
 | 
	
		
			
				|  |  |                 title = "视频复诊";
 | 
	
		
			
				|  |  |                 date = DateUtil.dateToStrLong(outpatient.getRegisterDate());
 | 
	
		
			
				|  |  |                 msg = name+"("+sex+" "+age+"岁)预约了"+date+"的视频复诊,点击查看";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         enterpriseService.sendTWMesByDoctor("zsyy",outpatientDO.getDoctor(),title,msg,url);
 | 
	
		
			
				|  |  |         System.out.println("发送企业模板消息成功");
 | 
	
		
			
				|  |  |         String content = "向您发起了图文复诊,点击查看";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -1492,7 +1515,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON r.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " h.org_code = '" + orgCode + "'" +
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist'";
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist' and d.del=1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equalsIgnoreCase(chargeType)) {
 | 
	
		
			
				|  |  |                 //不过滤号别
 | 
	
	
		
			
				|  | @ -1557,7 +1580,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON r.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " h.org_code = '" + orgCode + "'" +
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist'";
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist' and d.del=1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equalsIgnoreCase(chargeType)) {
 | 
	
		
			
				|  |  |                 //不过滤号别
 | 
	
	
		
			
				|  | @ -1653,12 +1676,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |                 //调用电子病历注册
 | 
	
		
			
				|  |  |                 manageType = 2;
 | 
	
		
			
				|  |  |                 registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
 | 
	
		
			
				|  |  |                 try {
 | 
	
		
			
				|  |  |                     registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
 | 
	
		
			
				|  |  |                 }catch (Exception e){
 | 
	
		
			
				|  |  |                     e.printStackTrace();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 return res;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //下载银医通
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(outpatientDO.getCardNo(), demoFlag);
 | 
	
		
			
				|  |  |         logger.info("下载银医通");
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(), doctorMappingDO.getMappingCode(), outpatientDO.getDept(), null, outpatientDO.getWinNo(), demoFlag);
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject res = rs.getJSONObject("resquest");
 | 
	
		
			
				|  |  |         logger.info("挂号结果 res: " + res.toString());
 | 
	
	
		
			
				|  | @ -1775,7 +1803,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "<CardNO>" + outpatientDO.getCardNo() + "</CardNO>\n" +
 | 
	
		
			
				|  |  |                 "<PatientName>" + basePatientDO.getName() + "</PatientName>" +
 | 
	
		
			
				|  |  |                 "<SexCode>" + basePatientDO.getSex() + "</SexCode>";
 | 
	
		
			
				|  |  |         if (1 == basePatientDO.getSex()) {
 | 
	
		
			
				|  |  |         if (basePatientDO.getSex()!=null&&1 == basePatientDO.getSex()) {
 | 
	
		
			
				|  |  |             _xmlStr = _xmlStr + "<Sex>男</Sex>";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             _xmlStr = _xmlStr + "<Sex>女</Sex>";
 | 
	
	
		
			
				|  | @ -2056,7 +2084,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param diagnosisJson
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
 | 
	
		
			
				|  |  |     public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> result = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2067,26 +2095,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作=============================================================
 | 
	
		
			
				|  |  |         //创建处方记录
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = null;
 | 
	
		
			
				|  |  |         if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
 | 
	
		
			
				|  |  |             prescriptionDO = prescriptionDOs.get(0);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             prescriptionDO = new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO  prescriptionDO= new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |         /*List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);*/
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> wlyyPrescriptionDO1 = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(prescriptionId)){
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO1 = prescriptionDao.findById(prescriptionId);
 | 
	
		
			
				|  |  |             prescriptionDO =wlyyPrescriptionDO1.get(0);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             prescriptionDO.setOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |             prescriptionDO.setType(1);
 | 
	
		
			
				|  |  |             prescriptionDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             prescriptionDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             prescriptionDO.setStatus(10);
 | 
	
		
			
				|  |  |             prescriptionDO.setPatientCode(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             prescriptionDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             prescriptionDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             prescriptionDO.setPayStatus(0);
 | 
	
		
			
				|  |  |             if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |                 prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         prescriptionDO.setType(1);
 | 
	
		
			
				|  |  |         prescriptionDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |         prescriptionDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         prescriptionDO.setStatus(10);
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientCode(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |         prescriptionDO.setPayStatus(0);
 | 
	
		
			
				|  |  |         if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |             prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作结束=============================================================
 | 
	
	
		
			
				|  | @ -2141,7 +2171,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             savePrescriptionCheck(prescription.getDoctor(), "开具处方", 5, prescription.getId());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDO1 != null && wlyyPrescriptionDO1.size() > 0) {
 | 
	
		
			
				|  |  |             savePrescriptionCheck(prescription.getDoctor(), "处方修改", 3, prescription.getId());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2238,6 +2268,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 result.put("code", 1);
 | 
	
		
			
				|  |  |                 result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |                 result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
 | 
	
		
			
				|  |  |                 Double price = prescription.getDrugFee();
 | 
	
	
		
			
				|  | @ -2248,6 +2279,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 Map<String, Object> result1 = new HashedMap();
 | 
	
		
			
				|  |  |                 result1.put("code", 1);
 | 
	
		
			
				|  |  |                 result1.put("mes", "开方提交成功");
 | 
	
		
			
				|  |  |                 result1.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result1;
 | 
	
		
			
				|  |  |             } else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
 | 
	
		
			
				|  |  |                 Double price = prescription.getDrugFee();
 | 
	
	
		
			
				|  | @ -2258,10 +2290,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 Map<String, Object> result1 = new HashedMap();
 | 
	
		
			
				|  |  |                 result1.put("code", 1);
 | 
	
		
			
				|  |  |                 result1.put("mes", "开方提交成功");
 | 
	
		
			
				|  |  |                 result1.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result1;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 result.put("code", 1);
 | 
	
		
			
				|  |  |                 result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |                 result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2271,6 +2305,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |             result.put("code", 1);
 | 
	
		
			
				|  |  |             result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |             result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -3659,17 +3694,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |             contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好!";
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId=    "+outpatientId;
 | 
	
		
			
				|  |  |             logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |         } else if ("payRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if ("9".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                 logger.info("图文复诊订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             } else if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                 logger.info("视频复诊订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -3689,7 +3725,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好! 医生已为您开具处方,请及时支付。";
 | 
	
		
			
				|  |  |             contentMsg = "医生已为您开具处方,请及时支付。";
 | 
	
		
			
				|  |  |             remark = "点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
 | 
	
		
			
				|  |  |             logger.info("处方支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |         } else if ("msgRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好!";
 | 
	
	
		
			
				|  | @ -3994,6 +4030,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String responseMsg="";
 | 
	
		
			
				|  |  |             String prefix="https://hlwyy.xmzsh.com";
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(outpatientId)){
 | 
	
	
		
			
				|  | @ -4006,6 +4043,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         contentMsg,
 | 
	
		
			
				|  |  |                         remark
 | 
	
		
			
				|  |  |                 );
 | 
	
		
			
				|  |  |                 System.out.println("结束发送模板消息");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (consultTeam!=null&&consPatientDO!=null){
 | 
	
		
			
				|  |  |                 responseMsg = entranceService.ehospitalNotice(
 | 
	
	
		
			
				|  | @ -4653,7 +4691,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 3 GROUP BY doctor ) a on a.doctor = d.id ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         Date date = new Date();
 | 
	
		
			
				|  |  |         sql+="LEFT JOIN (SELECT  COUNT(t1.doctor) as workTotal, t1.doctor FROM  wlyy_doctor_work_time t1   WHERE   " +
 | 
	
		
			
				|  |  |                 "t1.start_time <=:startTime  AND t1.end_time >=:endTime GROUP BY t1.doctor) dw ON dw.doctor=d.id ";
 | 
	
		
			
				|  |  |         params.put("startTime", date);
 | 
	
		
			
				|  |  |         params.put("endTime", date);
 | 
	
		
			
				|  |  |         if ("1".equalsIgnoreCase(isAttention)) {
 | 
	
		
			
				|  |  |             sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient ='" + patientid + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -4672,9 +4715,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             sql += " JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += " WHERE  1=1 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         sql += " WHERE  1=1 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isBlank(chargType)) {
 | 
	
		
			
				|  |  |             sql += " AND d.charge_type is not null ";
 | 
	
	
		
			
				|  | @ -4690,7 +4732,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(iswork) && "1".equals(iswork)) {
 | 
	
		
			
				|  |  |             logger.info("iswork:" + iswork);
 | 
	
		
			
				|  |  |             Date date = new Date();
 | 
	
		
			
				|  |  |             sql += " AND (" +
 | 
	
		
			
				|  |  |                     " EXISTS ( " +
 | 
	
		
			
				|  |  |                     " SELECT " +
 | 
	
	
		
			
				|  | @ -4766,9 +4807,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += " and d.del='1' order by a.total " + consutlSort;
 | 
	
		
			
				|  |  |         sql += " and d.del='1' order by dw.workTotal desc,d.consult_status DESC,a.total " + consutlSort;
 | 
	
		
			
				|  |  |         String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String doctor = map.get("id").toString();
 | 
	
		
			
				|  |  |             //查询医生各项评价平均分
 | 
	
		
			
				|  |  |             String sqlscore = "SELECT " +
 | 
	
		
			
				|  |  |                     "AVG(a.score) AS \"score\"," +
 | 
	
		
			
				|  |  |                     "a.score_type AS \"score_type\" " +
 | 
	
		
			
				|  |  |                     "FROM base_evaluate a,base_evaluate_score b " +
 | 
	
		
			
				|  |  |                     "WHERE " +
 | 
	
		
			
				|  |  |                     "a.relation_code=b.id " +
 | 
	
		
			
				|  |  |                     "AND b.doctor='" + doctor + "' " +
 | 
	
		
			
				|  |  |                     "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Double doctorScore = new Double("0");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (listscore != null && listscore.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Map<String, Object> _listscore : listscore) {
 | 
	
		
			
				|  |  |                     doctorScore += Double.parseDouble(_listscore.get("score").toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             doctorScore = doctorScore / 3;
 | 
	
		
			
				|  |  |             map.put("doctorScore", doctorScore);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount, params);
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         if(listCount!=null){
 | 
	
	
		
			
				|  | @ -6823,7 +6887,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType) {
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType,String dept) {
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " d.id AS \"id\", " +
 | 
	
		
			
				|  |  |                 " d.name AS \"name\"" +
 | 
	
	
		
			
				|  | @ -6838,6 +6902,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(hospital)) {
 | 
	
		
			
				|  |  |             sql += " AND h.org_code ='" + hospital + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(dept)){
 | 
	
		
			
				|  |  |             sql+= " AND h.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equals(chargeType)) {
 | 
	
	
		
			
				|  | @ -7112,7 +7179,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
 | 
	
		
			
				|  |  |                     List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
 | 
	
		
			
				|  |  |                     DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
 | 
	
		
			
				|  |  |                     //his处方拼接开方条件
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |                     for (WlyyPrescriptionInfoDO info : infoDOS) {
 | 
	
	
		
			
				|  | @ -7123,6 +7190,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         //设置his药品查询条件
 | 
	
		
			
				|  |  |                         setInspectionParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, ins, outpatientDO.getIcd10());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (expressageDOS!=null&&expressageDOS.size()!=0){
 | 
	
		
			
				|  |  |                         WlyyPrescriptionExpressageDO prescriptionExpressageDO = expressageDOS.get(0);
 | 
	
		
			
				|  |  |                         if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==0){
 | 
	
		
			
				|  |  |                             for (int i=0;i<jsonData.size();i++){
 | 
	
		
			
				|  |  |                                 com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
 | 
	
		
			
				|  |  |                                 object.put("selfDelivered",0);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }else if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==1){
 | 
	
		
			
				|  |  |                             for (int i=0;i<jsonData.size();i++){
 | 
	
		
			
				|  |  |                                 com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
 | 
	
		
			
				|  |  |                                 object.put("selfDelivered",1);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     Map<String, Object> map = sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |                     //处方签名
 | 
	
		
			
				|  |  |                     logger.info("处方签名");
 | 
	
	
		
			
				|  | @ -7210,7 +7291,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
 | 
	
		
			
				|  |  |                 ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", "");
 | 
	
		
			
				|  |  |             sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", wlyyPrescriptionDO.getId());
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO.setId(prescriptionId);
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO.setCheckStatus(status);
 | 
	
	
		
			
				|  | @ -8224,7 +8305,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionEmrDO prescriptionEmrDO) throws Exception {
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionEmrDO.getId());
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionEmrDO.getPrescriptionId());
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());
 |