Browse Source

代码修改

liubing 4 years ago
parent
commit
9e791a9a0c

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/apply/PatientBedApplyDo.java

@ -17,7 +17,7 @@ public class PatientBedApplyDo extends UuidIdentityEntityWithOperator {
    private String idcard;
    private String orgCode;
    private String orgName;
    private Integer status; //状态 -1取消 0已完成 1未处理 2未评估
    private Integer status; //状态 -1取消 0已完成 1未评估 2未分配服务包
    public String getPatient() {
        return patient;

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/apply/PatientBedApplyDao.java

@ -16,6 +16,8 @@ public interface PatientBedApplyDao extends PagingAndSortingRepository<PatientBe
    PatientBedApplyDo findByIdcardAndOrgCodeAndStatus(String idcard,String orgCode,Integer status);
    PatientBedApplyDo findByIdcardAndStatus(String idcard,Integer status);
    List<PatientBedApplyDo> findByOrgCodeAndStatusIn(String orgCode,Integer[] status ,Sort sort);
    List<PatientBedApplyDo> queryByIdcardAndOrgCodeAndStatusIn(String idcard, String orgCode, Integer[] status);

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -132,6 +132,9 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
            }
            return success("修改成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
                return failed("修改失败,"+e.getMessage(),-1);
            }
            e.printStackTrace();
            return failed("修改失败",-1);
        }

+ 4 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -191,8 +191,11 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            servicePackageService.setPatientServiceItems(result.getJSONObject("resultMsg").getString("patient"));
            return Envelop.getSuccess("分配成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
                return failed("分配失败,"+e.getMessage(),-1);
            }
            e.printStackTrace();
            return failed("分配失败",-1);
            return failed("分配失败 ",-1);
        }
    }

+ 34 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/apply/PatientBedApplyService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.apply;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -46,10 +47,18 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private CapacityAssessmentRecordService assessmentRecordService;
    public JSONObject apply(String idcard,String orgCode){
        JSONObject result = new JSONObject();
        BasePatientDO basePatientDo = basePatientDao.findByIdcardAndDel(idcard,"1");
        if (basePatientDo==null){
            String failMsg = "用户不存在,无法进行床位申请";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        //展示只能申请一个机构
        List<PatientBedApplyDo> applyList = patientBedApplyDao.queryByIdcardAndOrgCodeAndStatusIn(idcard,orgCode,new Integer[]{0,1,2});
        if (applyList.size()>0){
@ -59,6 +68,17 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
            return result;
        }
        else {
            //
            String sql = " select count(*) from base_patient p,base_service_package_sign_record sr, base_service_package_record pr,base_service_package pack\n" +
                    "where p.idcard = '"+idcard+"' and p.id = sr.patient and sr.id = pr.sign_id and pr.service_package_id = pack.id and sr.`status`=1 and pack.del=1 ";
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            if (count>0){
                String failMsg = "居民已签约,无法进行床位申请";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,failMsg);
                return result;
            }
            BaseOrgDO baseOrgDO = baseOrgDao.findByCode(orgCode);
            if (baseOrgDO==null){
                String failMsg = "申请机构不存在";
@ -74,11 +94,18 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
            patientBedApplyDo.setOrgCode(orgCode);
            patientBedApplyDo.setIdcard(idcard);
            patientBedApplyDo.setOrgName(baseOrgDO.getName());
            patientBedApplyDo.setStatus(1);//申请床位是未选择医生 设为未建档(医生未创建建档记录)。
            //
            count = assessmentRecordService.isCapacityAssessment(basePatientDo.getIdcard());
            if (count>0)
            {
                patientBedApplyDo.setStatus(2);
            }
            else { //医生点击评估时 需要同步该患者至未签约列表下
                patientBedApplyDo.setStatus(1);
            }
            patientBedApplyDao.save(patientBedApplyDo);
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,patientBedApplyDo);
        }
        return result;
    }
@ -86,7 +113,7 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
    public List<Map<String,Object>> getApplyList(String doctor){
        List<Map<String,Object>> result = new ArrayList<>();
        BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
        if (doctorDO.getLevel()==2){//助老员
        if (doctorDO.getLevel()!=null&&doctorDO.getLevel()==2){//助老员
            List<BaseDoctorHospitalDO> hospitalDOS = baseDoctorHospitalDao.findDistinctOrgByDoctorCode(doctor);
            for (BaseDoctorHospitalDO obj:hospitalDOS){
                String sql="select ap.id,p.id patientCode,ap.patient_name name,p.sex,ap.idcard,p.photo,ap.status,DATE_FORMAT(ap.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
@ -112,7 +139,10 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
                }
                result.addAll(tmp);
            }
            result.sort(Comparator.comparing(obj -> ((Map<String,Object>) obj).get("create_time").toString()));
            if (result.size()>0){
                result.sort(Comparator.comparing(obj -> ((Map<String,Object>) obj).get("create_time").toString()));
            }
        }
        return result;
    }

+ 0 - 18
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -154,15 +154,6 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        archiveDO.setCreateTime(new Date());
        archiveDao.save(archiveDO);
        //床位申请修改状态
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findDistinctOrgByDoctorCode(doctorId);
        if (hospitalDOs.size()>0){
            PatientBedApplyDo bedApplyDo = patientBedApplyDao.findByIdcardAndOrgCodeAndStatus(patientDO.getIdcard(),hospitalDOs.get(0).getOrgCode(),1);
            if (bedApplyDo!=null){
                bedApplyDo.setStatus(2);
                patientBedApplyDao.save(bedApplyDo);
            }
        }
        return 0;
    }
@ -181,15 +172,6 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        archiveDO.setIdcard(patientDO.getIdcard());
        archiveDO.setCreateTime(new Date());
        archiveDao.save(archiveDO);
        List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findDistinctOrgByDoctorCode(doctorId);
        if (hospitalDOs.size()>0){
            PatientBedApplyDo bedApplyDo = patientBedApplyDao.findByIdcardAndOrgCodeAndStatus(patientDO.getIdcard(),hospitalDOs.get(0).getOrgCode(),1);
            if (bedApplyDo!=null){
                bedApplyDo.setStatus(2);
                patientBedApplyDao.save(bedApplyDo);
            }
        }
    }
}

+ 17 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -256,6 +256,16 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            result.put(ResponseContant.resultMsg,recordDO);
            return result;
        }
        if(StringUtils.isNotBlank(recordDO.getPatient())){
            BasePatientDO patientDO= patientDao.findById(recordDO.getPatient());
            if (patientDO!=null){
                PatientBedApplyDo bedApplyDo = patientBedApplyDao.findByIdcardAndStatus(patientDO.getIdcard(),1);
                if (bedApplyDo!=null){
                    bedApplyDo.setStatus(2);
                    patientBedApplyDao.save(bedApplyDo);
                }
            }
        }
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg,"患者今年已做过能力评估报告,不可重复操作");
        return result;
@ -350,6 +360,13 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
                    patientLabelDO.setLabelCode(String.valueOf(recordDO.getLevelConclusion()));
                    patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,patientLabelDO.getLabelCode()));
                    patientLabelDao.save(patientLabelDO);
                    if (patientDO!=null){
                        PatientBedApplyDo bedApplyDo = patientBedApplyDao.findByIdcardAndStatus(patientDO.getIdcard(),1);
                        if (bedApplyDo!=null){
                            bedApplyDo.setStatus(2);
                            patientBedApplyDao.save(bedApplyDo);
                        }
                    }
                    result.put("status",1);
                    result.put("message","保存成功");
                    result.put("data",recordDO);
@ -384,12 +401,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        recordDO.setSignTime(new Date());
        capacityAssessmentRecordDao.save(recordDO);
        //完成评估 修改床位生请状态为已完成
        PatientBedApplyDo bedApplyDo = patientBedApplyDao.findByIdcardAndOrgCodeAndStatus(recordDO.getIdcard(),recordDO.getOrgCode(),2);
        if (bedApplyDo!=null) {
            bedApplyDo.setStatus(0);
            patientBedApplyDao.save(bedApplyDo);
        }
    }
    /**

+ 29 - 13
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.sign;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.sign.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -11,6 +12,7 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -67,6 +69,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private BasePatientMedicardCardService basePatientMedicardCardService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientBedApplyDao bedApplyDao;
    /**
     * 查找签约机构
@ -308,6 +312,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId) throws Exception{
        BasePatientDO patientDO = patientDao.findById(patientId);
        JSONObject result = new JSONObject();
        ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
        signRecordDO.setPatient(patientId);
@ -336,6 +341,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    archiveDao.save(archiveDO);
                }
            }else{
                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
                if(archiveDO!=null){
                    archiveDO.setSignStatus(1);
                    archiveDao.save(archiveDO);
                }
                signId = signRecordDOs.get(0).getId();
                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
@ -367,17 +377,23 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
           Map<String,List<Map<String,Object>>> newItem = itemList.stream().collect(Collectors.groupingBy(e->e.get("code").toString()));
           if (newItem.containsKey("emergencyAssistance")&&signItem.containsKey("emergencyAssistance")){
               String message = "重复签约服务项目:"+newItem.get("emergencyAssistance").get(0).get("name").toString();
               result.put(ResponseContant.resultFlag, ResponseContant.fail);
               result.put(ResponseContant.resultMsg,message);
               return result;
               throw new Exception(message);
           }
            CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
            capacityAssessmentRecordDO.setServicePackageStatus(1);
            capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
            servicePackageRecordDao.save(recordDOList);
        }
        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
        capacityAssessmentRecordDO.setServicePackageStatus(1);
        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        servicePackageRecordDao.save(recordDOList);
        //修改床位生请状态为已完成
        PatientBedApplyDo bedApplyDo = bedApplyDao.findByIdcardAndStatus(patientDO.getIdcard(),2);
        if (bedApplyDo!=null) {
            bedApplyDo.setStatus(0);
            bedApplyDao.save(bedApplyDo);
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,"分配成功");
        result.put(ResponseContant.resultMsg,signRecordDO);
        return result;
    }
@ -427,7 +443,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    public List<Map<String,Object>> serviceItemByPackageId(String packageId){
        String sql ="select it.code,it.name,count(it.code)count,pack.introduce,pack.type,pack.`name` from base_service_package_item it " +
                "INNER JOIN base_service_package pack on it.service_package_id = pack.id  where it.service_package_id='"+packageId+"' group by it.code ";
                "INNER JOIN base_service_package pack on it.service_package_id = pack.id  where it.service_package_id='"+packageId+"' and pack.del=1 group by it.code ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
@ -437,14 +453,14 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String sql="select  DISTINCT pack.*,CASE WHEN pack.type=1 THEN '养老服务' WHEN pack.type=2 THEN '医疗服务'\n" +
                "WHEN pack.type=3 THEN '安防监护' WHEN pack.type=4 THEN '慢病管理' ELSE pack.type\n" +
                "END as 'typeName' from base_service_package_record re, base_service_package_item item,base_service_package pack  \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and item.code='"+serverItem+"' and re.sign_id in (\n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and pack.del=1 and  item.code='"+serverItem+"' and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) ";
        List<Map<String,Object>> resultSql = jdbcTemplate.queryForList(sql);
        //查询服务包的服务项目
        for (Map<String,Object> map:resultSql){
            String packageId = map.get("id").toString();
            sql="select DISTINCT it.code serverItem,it.name,pack.introduce,pack.type packageType,pack.`name` packageName from base_service_package_item it \n" +
                    "INNER JOIN base_service_package pack on it.service_package_id = pack.id  where it.service_package_id='"+packageId+"' group by it.code";
                    "INNER JOIN base_service_package pack on it.service_package_id = pack.id  where pack.del=1 and it.service_package_id='"+packageId+"' group by it.code";
            List<Map<String,Object>> resultTmp = jdbcTemplate.queryForList(sql);
            map.put("serverItems",resultTmp);
        }
@ -459,13 +475,13 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.`code`='"+serverItem+"' and item.service_package_id='"+packageId+"' and item.service_package_id = pack.id " +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 ";
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 ";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public Map<String,Object> getPackageDetailById(String packageId){
        String sql="select * from base_service_package where id='"+packageId+"' ";
        String sql="select * from base_service_package where id='"+packageId+"' and del=1 ";
        Map<String,Object>result = jdbcTemplate.queryForMap(sql);
        sql = "select org_code,org_name,introduce from base_service_package_item where service_package_id='"+packageId+"'\n" +
                "GROUP BY org_code ORDER BY create_time desc ";