Prechádzať zdrojové kódy

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing 4 rokov pred
rodič
commit
90358acdd7

+ 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);

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.aop.ServicesAuth;
@ -7,7 +8,9 @@ import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
@ -123,9 +126,15 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
                                  @ApiParam(name = "doctorId", value = "医生id")
                                  @RequestParam(value = "doctorId", required = false)String doctorId)throws Exception{
        try{
            patientService.updPatient(jsonData, doctorId);
            JSONObject result =  patientService.updPatient(jsonData, doctorId);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return success("修改成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
                return failed("修改失败,"+e.getMessage(),-1);
            }
            e.printStackTrace();
            return failed("修改失败",-1);
        }

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

@ -21,6 +21,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
@ -183,12 +184,18 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
            ServicePackageSignRecordDO signRecordDO = servicePackageService.servicePackageSign(jsonData,doctorId,patientId);
            servicePackageService.setPatientServiceItems(signRecordDO.getPatient());
            return success("分配成功");
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }
            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);
        }
    }

+ 45 - 7
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,11 +113,12 @@ 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,p.name,p.sex,p.idcard,p.photo,ap.status,DATE_FORMAT(ap.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_patient_bed_apply ap INNER JOIN base_patient p where ap.idcard = p.idcard and org_code='"+obj.getOrgCode()+"' " +
                    "and ap.status <> -1 and ap.status<>0";
                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 " +
                        "from base_patient_bed_apply ap LEFT JOIN base_patient p ON ap.idcard = p.idcard WHERE org_code='"+obj.getOrgCode()+"' " +
                        "and ap.status <> -1 and ap.status<>0";
                List<Map<String,Object>> tmp = jdbcTemplate.queryForList(sql);
                for (Map<String,Object> map:tmp){
                    if (map.get("idcard")==null){
@ -100,11 +128,21 @@ public class PatientBedApplyService extends BaseJpaService<PatientBedApplyDo, Pa
                        Integer age  = IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
                        map.put("age",age);
                    }
                    if (map.get("sex")==null){
                        try {
                            String sex = IdCardUtil.getSexForIdcard_new(map.get("idcard").toString());
                            map.put("sex",Integer.parseInt(sex));
                        }catch (Exception e){
                            e.printStackTrace();
                        }
                    }
                }
                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;
    }

+ 3 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
@ -433,7 +434,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (!assistanceDO.getPatient().equals(patient)){
        if (!(assistanceDO.getPatient().equals(patient)||assistanceDO.getProxyPatient().equals(patient))){
            String failMsg = "当前救助工单不是您的工单,无法取消";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
@ -500,6 +501,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        emergencyAssistanceDao.save(assistanceDO);
        return getOrderDetail(orderId);
    }

+ 10 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -14,6 +14,7 @@ import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
@ -141,7 +142,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param doctorId
     */
    @Transactional(rollbackFor = Exception.class)
    public void updPatient(String jsonData,String doctorId) throws Exception{
    public JSONObject updPatient(String jsonData,String doctorId) throws Exception{
        JSONObject jsonObject = JSON.parseObject(jsonData);
        BasePatientDO patientDetail = JSONObject.parseObject(jsonObject.getJSONObject("patient").toJSONString(), BasePatientDO.class);
        BasePatientDO patientBrief = patientDao.findById(patientDetail.getId());
@ -174,11 +175,16 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        patientDao.save(patientBrief);
        JSONObject jsonObject1 = jsonObject.getJSONObject("signRecordDO");
        JSONObject result  = new JSONObject();
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        if(jsonObject1!=null){
            servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
            servicePackageService.setPatientServiceItems(patientBrief.getId());
            result = servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.success) {
                servicePackageService.setPatientServiceItems(patientBrief.getId());
            }
        }
        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);
        }
    }
    /**

+ 48 - 10
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,10 +12,12 @@ 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;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
@ -66,6 +69,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private BasePatientMedicardCardService basePatientMedicardCardService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientBedApplyDao bedApplyDao;
    /**
     * 查找签约机构
@ -306,7 +311,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param doctorId
     */
    @Transactional(rollbackFor = Exception.class)
    public ServicePackageSignRecordDO servicePackageSign(String jsonData,String doctorId,String patientId) throws Exception{
    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);
        List<ServicePackageRecordDO> recordDOList = signRecordDO.getRecordDOList();
@ -334,12 +341,23 @@ 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());
            }
        }
        //服务项目 emergencyAssistance 只能签约一个
        String sqlItem = "select item.`code`,item.name from base_service_package_item item INNER JOIN base_service_package_record pr on item.service_package_id = pr.service_package_id\n" +
                "where pr.sign_id='"+signId+"' GROUP BY item.`code`";
        List<Map<String,Object>> itemList = jdbcTemplate.queryForList(sqlItem);
        Map<String,List<Map<String,Object>>> signItem = itemList.stream().collect(Collectors.groupingBy(e->e.get("code").toString()));
        Iterator<ServicePackageRecordDO> iterator = recordDOList.iterator();
        while (iterator.hasNext()) {
            ServicePackageRecordDO recordDO = iterator.next();
@ -351,12 +369,32 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        }
        if(recordDOList.size()>0){
            CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
            capacityAssessmentRecordDO.setServicePackageStatus(1);
            capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
            List<String> packages = recordDOList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
            String packagesId = packages.stream().map(String::valueOf).collect(Collectors.joining("','"));
            sqlItem = "select item.`code`,item.name from base_service_package_item item " +
                    "where item.service_package_id in ('"+packagesId+"') GROUP BY item.`code`";
            itemList = jdbcTemplate.queryForList(sqlItem);
           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();
               throw new Exception(message);
           }
        }
        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
        capacityAssessmentRecordDO.setServicePackageStatus(1);
        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        servicePackageRecordDao.save(recordDOList);
        return signRecordDO;
        //修改床位生请状态为已完成
        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,signRecordDO);
        return result;
    }
@ -405,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;
    }
@ -415,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);
        }
@ -437,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 ";