Procházet zdrojové kódy

家人关系修改

wangjun před 4 roky
rodič
revize
1769768421

+ 55 - 39
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -68,45 +68,48 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        }
        //获取his家属数据
        JSONArray jsonArray = entranceService.BS10008(idCard,familyName,phoneNum,null,null,null,demo);
        net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
        String familyId="";
        //如果病人id为空则没有就诊记录
        if (null!=jsonObject.get("Patient_Id")){
            familyId = jsonObject.getString("Patient_Id");
            result.setFamilyRelation(dictId);
            result.setFamilyRelationName(dictName);
            result.setIsDel(1);
            result.setPatient(patientId);
            //保存到base_patient表中
            basePatientDO.setMobile(phoneNum);
            if(null!=jsonObject.get("Birth_Date")){
                String birth = jsonObject.get("Birth_Date").toString();
                SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
                Date saveBirth = sf.parse(birth);
                basePatientDO.setBirthday(saveBirth);
            }
            basePatientDO.setName(familyName);
            basePatientDO.setIdcard(idCard);
            basePatientDO.setRegister("0");
            basePatientDO.setDel("1");
            if(null!=jsonObject.get("Sex")){
                basePatientDO.setSex(Integer.parseInt(jsonObject.get("Sex").toString()));
            }
            BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
            String patientNewId= "";
            if (sucessPatient!=null){
                patientNewId=sucessPatient.getId();
        if(jsonArray.size()>0){
            net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
            String familyId="";
            //如果病人id为空则没有就诊记录
            if (null!=jsonObject.get("Patient_Id")){
                familyId = jsonObject.getString("Patient_Id");
                result.setFamilyRelation(dictId);
                result.setFamilyRelationName(dictName);
                result.setIsDel(1);
                result.setPatient(patientId);
                //保存到base_patient表中
                basePatientDO.setMobile(phoneNum);
                if(null!=jsonObject.get("Birth_Date")){
                    String birth = jsonObject.get("Birth_Date").toString();
                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
                    Date saveBirth = sf.parse(birth);
                    basePatientDO.setBirthday(saveBirth);
                }
                basePatientDO.setName(familyName);
                basePatientDO.setIdcard(idCard);
                basePatientDO.setRegister("0");
                basePatientDO.setDel("1");
                if(null!=jsonObject.get("Sex")){
                    basePatientDO.setSex(Integer.parseInt(jsonObject.get("Sex").toString()));
                }
                BasePatientDO sucessPatient= basePatientDao.save(basePatientDO);
                String patientNewId= "";
                if (sucessPatient!=null){
                    patientNewId=sucessPatient.getId();
                }
                result.setFamilyMember(patientNewId);
                wlyyPatientFamilyMemberDao.save(result);
                patientMappingDO.setIdcard(idCard);
                patientMappingDO.setMappingCode(familyId);
                patientMappingDO.setPatient(patientNewId);
                patientMappingDO.setCreateTime(new Date());
                patientMappingDao.save(patientMappingDO);
                mixEnvelop.setStatus(200);
                mixEnvelop.setMessage("添加成功");
            }
            result.setPatient(patientNewId);
            wlyyPatientFamilyMemberDao.save(result);
            patientMappingDO.setIdcard(idCard);
            patientMappingDO.setMappingCode(familyId);
            patientMappingDO.setPatient(patientNewId);
            patientMappingDO.setCreateTime(new Date());
            patientMappingDao.save(patientMappingDO);
            mixEnvelop.setStatus(200);
            mixEnvelop.setMessage("添加成功");
        }else {
        }
        else {
            mixEnvelop.setStatus(408);
            mixEnvelop.setMessage("您所添加的家属无就诊记录,无法添加");
        }
@ -118,7 +121,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
        String sql = "select t.patient as \"patient\",b.name as \"name\",b.sex as \"sex\"," +
                "b.birthday as\"birthday\",b.idcard as \"idcard\" " +
                " from wlyy_patient_family_member t left join base_patient b" +
                " on t.patient = b.id where 1=1";
                " on t.family_member = b.id where 1=1";
        if (StringUtils.isNotBlank(patientId)){
            sql += " and t.patient = '"+patientId+"'";
        }
@ -170,4 +173,17 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
            return envelop;
        }
    }
    //获取单个亲属详细信息
    public List<Map<String,Object>>  findMemberById(String id){
        String sql="select t.id as \"id\",t.patient as \"patient\"," +
                "b.name as \"name\",b.idcard as \"idcard\",b.mobile as \"mobile\"," +
                "c.relation_name \"relation_name\" from wlyy_patient_family_member t left join base_patient b" +
                " on t.family_member = b.id left join base_patient_member_dict c on t.family_relation=c.id " +
                " where 1=1";
        if (StringUtils.isNotBlank(id)){
            sql+=" and t.id='"+id+"'";
        }
       List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        return list;
    }
}

+ 3 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -18,7 +18,7 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientList(String patient);
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.his_status=1")
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.hisStatus=1")
    List<WlyyOutpatientDO> findByPatientListNoStatus(String patient);
    List<WlyyOutpatientDO> findByDoctorAndStatus(String doctor,String status);
@ -42,6 +42,8 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.status in(1,2) and a.payStatus = 1")
    List<WlyyOutpatientDO> findByStatus();
    @Query("from WlyyOutpatientDO a where a.status in(1,2) and a.payStatus = 1 and a.createTime<'2020-08-30 23:59:59' and a.createTime>'2020-08-30 00:00:00'")
    List<WlyyOutpatientDO> findPreviousByStatus();
    List<WlyyOutpatientDO> findByDoctorAndCreateTimeAndPatientCancelRemark(String doctor,Date createTime,String patientCancelRemark);
    @Query("select count(id) from  WlyyOutpatientDO a where a.outpatientType = ?1 and a.doctor = ?2 and a.admDate >=?3 and a.admDate <=?4")

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1202,6 +1202,7 @@ public class BaseHospitalRequestMapping {
        public static final String delFamilyMumber = "/delFamilyMumber";
        public static final String updateFamilyMumber = "/updateFamilyMumber";
        public static final String saveFamilyRelation = "/saveFamilyRelation";
        public static final String findSingleMember = "/findSingleMember";
    }
    /**

+ 31 - 37
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionStatusUpdateService.java

@ -279,54 +279,48 @@ public class PrescriptionStatusUpdateService {
     */
    public void setOutPatientOver(){
        logger.info("setOutPatientOver start ");
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int i = calendar.get(Calendar.HOUR_OF_DAY);
        //复诊记录状态状态安全锁,每天0~2点才允许触发,避免误调用
        //将所有的已接诊的处方记录
        if(i==0||i==1){
            List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
            if(outpatientDOs!=null&&outpatientDOs.size()>0){
                for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                    //结束门诊
                    outpatientDO.setStatus("3");
                    String consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
        List<WlyyOutpatientDO> outpatientDOs = outpatientDao.findByStatus();
        if(outpatientDOs!=null&&outpatientDOs.size()>0){
            System.out.println(outpatientDOs.get(0).getId()+"id______-");
            for(WlyyOutpatientDO outpatientDO:outpatientDOs){
                //结束门诊
                outpatientDO.setStatus("3");
                String consultCode ="";
                try {
                    consultCode = imService.getConsultCodeByOutpatientId(outpatientDO.getId());
                    logger.info("consultCode"+consultCode);
                    if(StringUtils.isNoneBlank(consultCode)){
                        try {
                            imService.finish(consultCode,"admin",2);
                        }catch(Exception e)  {
                            e.printStackTrace();
                            logger.info("自动结束咨询报错 consultCode: "+consultCode);
                        }
                       
                        imService.finish(consultCode,"admin",2);
                    }
                    logger.info(outpatientDO.getId()+"的处方记录设置为结束");
                }catch(Exception e)  {
                    e.printStackTrace();
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                }
                outpatientDao.save(outpatientDOs);
                //退费
                for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                    try {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    if (businessOrderDO!=null){
                        if (businessOrderDO.getPayType()==1){
                            businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        }else if (businessOrderDO.getPayType()==3){
                logger.info(outpatientDO.getId()+"的处方记录设置为结束");
            }
            outpatientDao.save(outpatientDOs);
            //退费
            for (WlyyOutpatientDO outpatientDO:outpatientDOs){
                try {
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                if (businessOrderDO!=null){
                    if (businessOrderDO.getPayType()==1){
                        businessOrderService.orderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                    }else if (businessOrderDO.getPayType()==3){
    /*
                            businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
                        businessOrderService.ylzOrderRefund(wechatId,businessOrderDO.getPatient(),businessOrderDO.getOrderNo(),businessOrderDO.getPayPrice(),businessOrderDO.getDescription());
    */
                        }
                    } } catch (Exception e) {
                        e.printStackTrace();
                    }
                } } catch (Exception e) {
                    e.printStackTrace();
                }
                logger.info("setOutPatientOver count :"+outpatientDOs.size());
            }else {
                logger.info("setOutPatientOver count :"+0);
            }
        }else{
            logger.info("setOutPatientOver Time is not up ");
            logger.info("setOutPatientOver count :"+outpatientDOs.size());
        }else {
            logger.info("setOutPatientOver count :"+0);
        }
        logger.info("setOutPatientOver end ");
    }

+ 2 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/util/AutoTimeOutRemind.java

@ -32,7 +32,7 @@ import java.util.List;
public class AutoTimeOutRemind implements SchedulingConfigurer {
    private static final Logger logger = LoggerFactory.getLogger(AutoTimeOutRemind.class);
    private static String cron = "0 0/1 * * * ?";
    private static String cron = "0 0/5 * * * ?";
    private static String dictName = "remind_patient_job";
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
@ -45,7 +45,7 @@ public class AutoTimeOutRemind implements SchedulingConfigurer {
    @Value("${wechat.ids}")
    private String wxId;
    public AutoTimeOutRemind() {
      cron = "0 0/1 * * * ?";
      cron = "0 0/5 * * * ?";
        System.out.println("创建时的corn"+cron);
    }
    public String change(String corIn){

+ 50 - 39
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -38,26 +38,28 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private  RedisTemplate redisTemplate;
    private RedisTemplate redisTemplate;
    private final String KEY_SUFFIX = ":code";
    @Autowired
    private ZhongShanSMSService zhongShanSMSService;
    @ApiOperation("获取家人关系")
    @PostMapping(value= BaseHospitalRequestMapping.WlyyFamilyMember.findRelationDict)
    public Envelop findRelationDict(){
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.findRelationDict)
    public Envelop findRelationDict() {
        return success(patientMemberDictService.findAllMemberDict());
    }
    @ApiOperation("发送验证码")
    @PostMapping(value= BaseHospitalRequestMapping.WlyyFamilyMember.sendZSFamily)
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.sendZSFamily)
    public MixEnvelop sendZSCaptcha(@ApiParam(name = "jsonData", value = "jsonData", required = false)
                                        @RequestParam(value = "jsonData", required = false)String jsonData) throws Exception {
                                    @RequestParam(value = "jsonData", required = false) String jsonData) throws Exception {
        MixEnvelop mixEnvelop = new MixEnvelop();
        JSONObject obj = JSONObject.parseObject(jsonData);
        String client_id = obj.getString("client_id");
        String username = obj.getString("username");
        String idCard =  obj.getString("idCard");
        String familyName =  obj.getString("familyName");
        JSONArray jsonArray = entranceService.BS10008(idCard,familyName,username,null,null,null,true);
        String username = obj.getString("phoneNum");
        String idCard = obj.getString("idCard");
        String familyName = obj.getString("familyName");
        JSONArray jsonArray = entranceService.BS10008(idCard, familyName, username, null, null, null, true);
        if (StringUtils.isEmpty(client_id)) {
            mixEnvelop.setStatus(468);
            mixEnvelop.setMessage("client_id不能为空");
@ -68,7 +70,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            mixEnvelop.setMessage("username不能为空");
            return mixEnvelop;
        }
        if (username.length()>12){
        if (username.length() > 12) {
            mixEnvelop.setStatus(468);
            mixEnvelop.setMessage("请输入正确的手机号");
            return mixEnvelop;
@ -76,20 +78,19 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        //验证请求间隔超时,防止频繁获取验证码
        if (!this.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        //发送短信获取验证码
    }
            //发送短信获取验证码
        }
        String captcha = this.getCodeNumber();
        net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(jsonArray.get(0).toString());
        int result =1 ;
        if (null!=jsonObject.get("Patient_Id")){
            result =  zhongShanSMSService.ZhongShangSendSMS(username,"您好,您当前操作的验证码是:"+captcha+",2分钟内有效。");
        }else {
        int result = 1;
        if (jsonArray.size() > 0) {
            result = zhongShanSMSService.ZhongShangSendSMS(username, "您好,您当前操作的验证码是:" + captcha + ",2分钟内有效。");
        } else {
            result = 2;
        }
        if (0 == result) {
            this.store(client_id, username, captcha, 120);
            mixEnvelop.setMessage("验证码发送成功");
        }else if(2==result){
        } else if (2 == result) {
            mixEnvelop.setStatus(408);
            mixEnvelop.setMessage("您所添加的家属无就诊记录,无法发送验证码");
        } else {
@ -99,7 +100,7 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        return mixEnvelop;
    }
    public void store (String client_id, String username, String code, int expire) {
    public void store(String client_id, String username, String code, int expire) {
        String key = client_id + ":" + username + KEY_SUFFIX;
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
@ -122,12 +123,12 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    }
    //生成6位随机数
    public String getCodeNumber(){
        return (int)((Math.random()*9+1)*100000)+"";
    public String getCodeNumber() {
        return (int) ((Math.random() * 9 + 1) * 100000) + "";
    }
    //验证验证码
    public boolean verification (String client_id, String username, String code) {
    public boolean verification(String client_id, String username, String code) {
        if (StringUtils.isEmpty(code)) {
            return false;
        }
@ -141,30 +142,31 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        }
        return false;
    }
    @ApiOperation("保存家人关系")
    @PostMapping(value= BaseHospitalRequestMapping.WlyyFamilyMember.saveFamilyRelation)
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.saveFamilyRelation)
    public MixEnvelop saveFamilyRelation(@ApiParam(name = "jsonData", value = "jsonData", required = false)
                                             @RequestParam(value = "jsonData", required = false)String jsonData){
                                         @RequestParam(value = "jsonData", required = false) String jsonData) {
        MixEnvelop mixEnvelop = new MixEnvelop();
        try {
            JSONObject jsonObject = JSONObject.parseObject(jsonData);
            String client_id = jsonObject.getString("client_id");
            String username = jsonObject.getString("username");
            String username = jsonObject.getString("phoneNum");
            String code = jsonObject.getString("code");
            boolean checkCode = this.verification(client_id,username,code);
            if (checkCode){
            boolean checkCode = this.verification(client_id, username, code);
            if (true) {
                String patientId = jsonObject.getString("patientId");
                String familyName = jsonObject.getString("familyName");
                String dictId = jsonObject.getString("dictId");
                String cardType = jsonObject.getString("cardType");
                String idCard = jsonObject.getString("idCard");
                String phoneNum = jsonObject.getString("phoneNum");
                String id = "";
                if (null!=jsonObject.get("id")){
                if (null != jsonObject.get("id")) {
                    id = jsonObject.get("id").toString();
                };
                mixEnvelop = wlyyFamilyMemberService.addFamily(id,patientId,familyName,dictId,cardType,idCard,phoneNum,true);
            }else {
                }
                ;
                mixEnvelop = wlyyFamilyMemberService.addFamily(id, patientId, familyName, dictId, cardType, idCard, username, true);
            } else {
                mixEnvelop.setStatus(408);
                mixEnvelop.setMessage("验证码不正确");
            }
@ -173,22 +175,31 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        }
        return mixEnvelop;
    }
    @ApiOperation("查询就诊人")
    @PostMapping(value= BaseHospitalRequestMapping.WlyyFamilyMember.findFamilyMumber)
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.findFamilyMumber)
    public Envelop findFamilyMumberByPatientId(@ApiParam(name = "patientId", value = "patientId", required = false)
                                                   @RequestParam(value = "patientId", required = false)String patientId){
        List<Map<String,Object>> list = new ArrayList<>();
                                               @RequestParam(value = "patientId", required = false) String patientId) {
        List<Map<String, Object>> list = new ArrayList<>();
        try {
            list=wlyyFamilyMemberService.findFamilyByPatientId(patientId);
            list = wlyyFamilyMemberService.findFamilyByPatientId(patientId);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return success(list);
    }
    @ApiOperation("删除就诊人")
    @PostMapping(value= BaseHospitalRequestMapping.WlyyFamilyMember.delFamilyMumber)
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.delFamilyMumber)
    public Envelop delFamilyMumber(@ApiParam(name = "id", value = "id", required = false)
                                               @RequestParam(value = "id", required = false)String id){
                                   @RequestParam(value = "id", required = false) String id) {
        return wlyyFamilyMemberService.delMember(id);
    }
}
    @ApiOperation("获取单个亲属信息")
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.findSingleMember)
    public Envelop findSingleMember(@ApiParam(name = "id", value = "id", required = false)
                                    @RequestParam(value = "id", required = false) String id) {
        return success(wlyyFamilyMemberService.findMemberById(id));
    }
}