Browse Source

康复计划

suqinyi 1 year ago
parent
commit
818599ac12

+ 4 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java

@ -309,7 +309,7 @@ public class ConsultTeamService extends ConsultService {
//            filter = " from wlyy_admin_team a,wlyy_admin_team_member m,wlyy_doctor d " +
//                    " LEFT JOIN wlyy_doctor_help h on d.code = h.doctor " +
//                    " LEFT JOIN wlyy_sign_family sf on sf.patient='" + patient + "' and sf.`status`>=0 and sf.specialist=d.code " +
//                    " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on p.patient = '" + patient + "' and p.create_user=d.code " +
//                    " LEFT JOIN wlyy_patient_rehabilitation_plan p on p.patient = '" + patient + "' and p.create_user=d.code " +
//                    " WHERE a.accept_type = 0 and a.available =1 and a.special_code is not null " +
//                    " and a.id = m.team_id and m.available=1 and m.doctor_code=d.code and d.`status`=1 ";
//            if (StringUtils.isNotBlank(disease)) {
@ -319,7 +319,7 @@ public class ConsultTeamService extends ConsultService {
//            filter = "from wlyy_hospital_invite_specialist s,wlyy_doctor d " +
//                    "LEFT JOIN wlyy_doctor_help h on d.code = h.doctor " +
//                    " LEFT JOIN wlyy_sign_family sf on sf.patient='" + patient + "' and sf.`status`>=0 and sf.specialist=d.code " +
//                    " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on p.patient = '" + patient + "' and p.create_user=d.code " +
//                    " LEFT JOIN wlyy_patient_rehabilitation_plan p on p.patient = '" + patient + "' and p.create_user=d.code " +
//                    " WHERE s.specialist=d.code and d.`status`=1 and s.type = '" + type + "' ";
//            if ("2".equals(type) && d != null) {
//                filter += " and s.hospital='" + d.getHospital() + "' ";
@ -3154,7 +3154,7 @@ public class ConsultTeamService extends ConsultService {
    //判断居民家庭医生专科是否有共管关系
    public int getSpecialDoctorFamilyDoctorPatientCount(String patient, String special_doctor, String family_doctor) {
        String sql = "SELECT " +
                "count(a.id) FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                "count(a.id) FROM wlyy_specialist_patient_relation a " +
                "JOIN wlyy.wlyy_sign_family b " +
                "ON a.patient=b.patient " +
                "AND b.`status`=1 " +
@ -3474,7 +3474,7 @@ public class ConsultTeamService extends ConsultService {
//    public JSONObject getConsultDoctorForConsulting(String patientCode) {
//        JSONObject result = new JSONObject();
//        String sql = "SELECT DISTINCT p.patient, p.name AS patient_name, p.`team_code`,te.`name` AS team_name, d.`code` as special_code, d.`name` as special_name, d.dept_name,d.hospital_name \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan p, wlyy_doctor d ,wlyy_admin_team te\n" +
//                "FROM wlyy_patient_rehabilitation_plan p, wlyy_doctor d ,wlyy_admin_team te\n" +
//                "WHERE p.patient = '" + patientCode + "' AND d.`code`= p.create_user and te.id = p.team_code AND te.available=1 GROUP BY p.patient, p.create_user,p.team_code";
//        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName2(sql);
//        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);

+ 4 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/controller/DoctorRehabilitaionInfoController.java

@ -251,13 +251,13 @@ public class DoctorRehabilitaionInfoController extends EnvelopRestEndpoint {
    /**
     * 查询病例信息
     */
    @RequestMapping(value = "getPatientMedicalRecordsByPatientId", method = RequestMethod.GET)
    @RequestMapping(value = "getPatientMedicalRecordsByPlanId", method = RequestMethod.GET)
    @ApiOperation("查询居民的康复计划")
    public String getPatientMedicalRecordsByPatientId(
            @ApiParam(name = "patientId", value = "居民", required = false) @RequestParam(value = "patientId", required = false) String patientId
    public String getPatientMedicalRecordsByPlanId(
            @ApiParam(name = "planId", value = "计划id", required = false) @RequestParam(value = "planId", required = false) String planId
    ) {
        try {
            List<PatientMedicalRecordsDO> result = rehabilitationInfoService.getPatientMedicalRecordsByPatientId(patientId);
            List<PatientMedicalRecordsDO> result = rehabilitationInfoService.getPatientMedicalRecordsByPlanId(planId);
            return write(200, "请求成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();

+ 7 - 7
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationGuidanceService.java

@ -68,7 +68,7 @@ public class RehabilitationGuidanceService {
    public List<Map<String, Object>> selectType(String planId) {
        String disease = "";
        if (StringUtils.isNoneBlank(planId)) {
            String sql = "select * from wlyy_specialist.wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
            String sql = "select * from wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
            sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll(sql);
            Map<String, Object> map = jdbcTemplate.queryForMap(sql);
            if (map.get("disease") != null && StringUtils.isNoneBlank(map.get("disease").toString())) {
@ -97,7 +97,7 @@ public class RehabilitationGuidanceService {
    public Page<RehabilitationguidanceDO> select(String title, Integer type, String code, String planId, Integer page, Integer pagesize) {
        String disease = "";
        if (StringUtils.isNoneBlank(planId)) {
            String sql = "select * from wlyy_specialist.wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
            String sql = "select * from wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
            sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll(sql);
            Map<String, Object> map = jdbcTemplate.queryForMap(sql);
            if (map.get("disease") != null && StringUtils.isNoneBlank(map.get("disease").toString())) {
@ -278,7 +278,7 @@ public class RehabilitationGuidanceService {
            //反馈处理30
            sendType = 30;
            String sql = "SELECT pr.manage_time as manageTime,pr.is_manage as isManage " +
                    "FROM wlyy_specialist.`wlyy_specialist_patient_relation` pr " +
                    "FROM `wlyy_specialist_patient_relation` pr " +
                    "where pr.doctor = '" + doctorCode + "' and pr.patient = '" + patientCode + "' and pr.sign_status=1 and pr.`status`=1";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            String manageTime = "";
@ -297,11 +297,11 @@ public class RehabilitationGuidanceService {
            //复诊提醒3
            //更新复诊类型
            if (StringUtils.isNoneBlank(reservationType)) {
                String updSql = "update wlyy_specialist.wlyy_rehabilitation_plan_detail set reservation_type = " + reservationType + " where id = '" + relationCode + "'";
                String updSql = "update wlyy_rehabilitation_plan_detail set reservation_type = " + reservationType + " where id = '" + relationCode + "'";
                jdbcTemplate.execute(updSql);
            }
            sendType = 11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.id ='" + relationCode + "' and pd.hospital_service_item_id='7' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime = "";
@ -322,7 +322,7 @@ public class RehabilitationGuidanceService {
        } else if (type == 4) {
            //上门服务提醒 4
            sendType = 11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.id ='" + relationCode + "' and pd.hospital_service_item_id='4' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime = "";
@ -346,7 +346,7 @@ public class RehabilitationGuidanceService {
        } else if (type == 5) {
            //家签提醒 5
            sendType = 11;//待办事项
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
            String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
                    "where pd.plan_id ='" + planId + "' and pd.hospital_service_item_id='4' and pd.status <>1 order by pd.execute_time desc ";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            String excuteTime = "";

+ 28 - 20
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java

@ -410,7 +410,7 @@ public class RehabilitationInfoService {
//                "f.czrq,f.doctor_name doctorName,f.doctor_health_name doctorHealthName,f.hospital_name hospitalName,f.admin_team_code teamCode " +
//                " from wlyy_patient_discharge d,wlyy_patient p,wlyy_sign_family f\n" +
//                "where 1=1 " + filterSql + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient AND d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "' AND d.patient NOT IN \n" +
//                "(   SELECT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" +
//                "(   SELECT i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" +
//                "AND i. STATUS != 0 AND p. CODE = i.patient GROUP BY i.patient ORDER BY i.create_time desc)GROUP BY d.patient ORDER BY d.create_time DESC ";
        String sql = "SELECT  \n" +
@ -455,7 +455,7 @@ public class RehabilitationInfoService {
//                " from wlyy_patient p,wlyy_patient_discharge d " +
//                " left JOIN wlyy_sign_family f on d.patient=f.patient AND f.`status`=1 AND f.sign_year='" + DateUtil.getSignYear() + "'" +
//                "where 1=1 " + filterSql + " and ( ISNULL(d.type) or d.type=2) AND p. CODE = d.patient  AND d.patient NOT IN \n" +
//                "(   SELECT DISTINCT i.patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" +
//                "(   SELECT DISTINCT i.patient FROM wlyy_patient_rehabilitation_plan i,wlyy_patient p   WHERE i.create_user = '" + doctorCode + "' \n" +
//                "AND i. STATUS != 0 AND p. CODE = i.patient )GROUP BY d.patient ORDER BY d.create_time DESC ";
        String sql = "SELECT '' id, p.idcard,p.id 'patient',p.`name` patientName,p.sex,d.age,p.address,\n" +
@ -485,8 +485,8 @@ public class RehabilitationInfoService {
//                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
//                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
//                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
//                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist_patient_relation pr \n" +
//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 " +
//                " and  (pr.is_manage != 1 OR isnull(pr.is_manage)) ";
@ -538,8 +538,8 @@ public class RehabilitationInfoService {
     */
    public JSONObject downCount(String doctorCode, JSONObject object) {
//        String sql1 = "SELECT COUNT(distinct i.patient) \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
//                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist_patient_relation pr \n" +
//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 ";
        String sql1 = "SELECT \n" +
@ -553,7 +553,7 @@ public class RehabilitationInfoService {
        //康复计划数量
//        String sql2 = "SELECT COUNT(distinct i.id) \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
//                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" +
//                "AND s.status = 1 AND s.expenses_status = 1 ";
        String sql2 = "SELECT COUNT(distinct i.id) \n" +
@ -566,8 +566,8 @@ public class RehabilitationInfoService {
        //家医接收
//        String sql3 = "SELECT COUNT(distinct i.patient) " +
//                " FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                " wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
//                " FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                " wlyy_specialist_patient_relation pr \n" +
//                " WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
//                " AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1";
//        Integer list3 = jdbcTemplate.queryForObject(sql3, Integer.class);
@ -587,8 +587,8 @@ public class RehabilitationInfoService {
//                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
//                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
//                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
//                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist_patient_relation pr \n" +
//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 and pr.is_manage=1";
@ -635,8 +635,8 @@ public class RehabilitationInfoService {
//                " i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
//                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
//                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
//                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
//                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
//                "wlyy_specialist_patient_relation pr \n" +
//                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
//                "AND s.expenses_status = 1 AND pr.patient=p.code and pr.team_code = i.team_code and pr.`status`>=0 and pr.sign_status=1 ";
@ -771,15 +771,15 @@ public class RehabilitationInfoService {
        String sql1 = "SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code  GROUP BY i.patient ORDER BY i.create_time DESC ";
        List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
        //康复计划数量
        String sql2 = "SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, s.admin_team_code teamCode \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p\n" +
                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient \n" +
                "AND s.status = 1 AND s.expenses_status = 1 GROUP BY i.id";
        List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
@ -789,8 +789,8 @@ public class RehabilitationInfoService {
                "SELECT s.idcard, s.patient, i. STATUS, p. NAME patientName, p.address, CONCAT(s.doctor_name,'(全科医生)' ) AS doctorName, \n" +
                "IFNULL(CONCAT(s.doctor_health_name,'(健管师)'), s.doctor_health_name ) doctorHealthName, s.hospital_name hospitalName, \n" +
                "s.admin_team_code teamCode ,pr.is_manage isManage \n" +
                "FROM wlyy_specialist.wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist.wlyy_specialist_patient_relation pr \n" +
                "FROM wlyy_patient_rehabilitation_plan i, wlyy_sign_family s, wlyy_patient p ,\n" +
                "wlyy_specialist_patient_relation pr \n" +
                "WHERE i.create_user = '" + doctorCode + "' AND i.status != 0 AND i.patient = s.patient AND p.code = i.patient AND s.status = 1 \n" +
                "AND s.expenses_status = 1 AND pr.patient=p.code  GROUP BY i.patient ORDER BY i.create_time DESC\n" +
                ") aa\n" +
@ -1288,8 +1288,16 @@ public class RehabilitationInfoService {
    /**
     * 查询病例信息
     */
    public List<PatientMedicalRecordsDO> getPatientMedicalRecordsByPatientId(String patientId) {
        String sql = "select  * from wlyy_patient_medical_records_rehabilitation where patient='" + patientId + "' order by create_time desc ";
    public List<PatientMedicalRecordsDO> getPatientMedicalRecordsByPlanId(String planId) {
        String sql = "SELECT\n" +
                " a.* \n" +
                "FROM\n" +
                "	wlyy_patient_medical_records_rehabilitation a\n" +
                "	INNER JOIN wlyy_patient_rehabilitation_plan b ON a.`CODE` = b.medical_records_code \n" +
                "WHERE\n" +
                "	b.id = '" + planId + "' \n" +
                "ORDER BY\n" +
                "	create_time DESC ";
        List<PatientMedicalRecordsDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(PatientMedicalRecordsDO.class));
        return list;
    }

+ 19 - 19
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -1752,7 +1752,7 @@ public class RehabilitationManageService {
            String healthyCondition = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label_name") + "" : "";
            String healthyConditionType = healthyConditionList.size() > 0 ? healthyConditionList.get(0).get("label") + "" : "";
            //专科医生、科室、专科医院
            String sql = "select create_user from wlyy_specialist.wlyy_patient_rehabilitation_plan where id='" + planId + "'";
            String sql = "select create_user from wlyy_patient_rehabilitation_plan where id='" + planId + "'";
            String specialDoctorCode = jdbcTemplate.queryForObject(sql, String.class);//专科code
            BaseDoctorDO specialDoctor = doctorDao.findById(specialDoctorCode).orElse(null);
            json.put("specialDoctorName", specialDoctor.getName());
@ -2419,7 +2419,7 @@ public class RehabilitationManageService {
                "YEAR (now()) - YEAR (substring(d.idcard, 7, 8)) AS age, d.sex,p.name,p.patient,p.disease,p.disease_name,d.name as doctorName," +
                "d.dept_name as deptName,d.hospital_name as hospitalName,d.hospital,p.advice_content as adviceContent,p.medical_records_code as medicalRecordsCode," +
                "p.create_time as create_time,p.status " +
                " FROM wlyy_specialist.wlyy_patient_rehabilitation_plan p " +
                " FROM wlyy_patient_rehabilitation_plan p " +
                " LEFT JOIN wlyy.wlyy_doctor d ON d.code = p.create_user " +
                "WHERE p.patient='" + patient + "'";
        sql = sql + " union " +
@ -2440,11 +2440,11 @@ public class RehabilitationManageService {
                "p.medical_records_code AS medicalRecordsCode," +
                "p.create_time AS create_time,p.status " +
                "FROM " +
                "wlyy_specialist.wlyy_patient_rehabilitation_plan p " +
                "wlyy_patient_rehabilitation_plan p " +
                "LEFT JOIN wlyy.wlyy_doctor d ON d.CODE=p.create_user" +
                " LEFT JOIN (" +
                "SELECT sr.patient AS patient,sr.team_code AS team_code " +
                "FROM wlyy_specialist.wlyy_specialist_patient_relation sr " +
                "FROM wlyy_specialist_patient_relation sr " +
                "JOIN wlyy.wlyy_doctor_special_share se ON se.special_code=sr.id " +
                "WHERE sr.patient='" + patient + "') d " +
                "ON d.patient=p.patient WHERE " +
@ -2464,9 +2464,9 @@ public class RehabilitationManageService {
            String manageStatus;
            //获取最近完成服务
            sql = "select si.`code`,si.name,opr.complete_time update_time " +
                    "from wlyy_specialist.wlyy_rehabilitation_plan_detail pd \n" +
                    "INNER  JOIN wlyy_specialist.wlyy_rehabilitation_service_item si on si.`code` = pd.hospital_service_item_id \n" +
                    "INNER JOIN wlyy_specialist.wlyy_rehabilitation_operate_records opr on opr.rehabilitation_detail_id = pd.id\n" +
                    "from wlyy_rehabilitation_plan_detail pd \n" +
                    "INNER  JOIN wlyy_rehabilitation_service_item si on si.`code` = pd.hospital_service_item_id \n" +
                    "INNER JOIN wlyy_rehabilitation_operate_records opr on opr.rehabilitation_detail_id = pd.id\n" +
                    "where plan_id='" + mp.get("id").toString() + "' and opr.`status` =1 ORDER BY opr.complete_time DESC ";
            List<Map<String, Object>> serverItems = jdbcTemplate.queryForList(sql);
            if (serverItems != null && serverItems.size() != 0) {
@ -2475,9 +2475,9 @@ public class RehabilitationManageService {
                mp.put("completeServer", "");
            }
            if (mp.get("teamCode") != null) {
                sql = "select is_manage from wlyy_specialist.wlyy_specialist_patient_relation where  patient ='" + patient + "' and team_code='" + mp.get("teamCode").toString() + "' and sign_status>0 and status=1 ORDER BY sign_date desc limit 1";
                sql = "select is_manage from wlyy_specialist_patient_relation where  patient ='" + patient + "' and team_code='" + mp.get("teamCode").toString() + "' and sign_status>0 and status=1 ORDER BY sign_date desc limit 1";
            } else {
                sql = "select is_manage from wlyy_specialist.wlyy_specialist_patient_relation where doctor = '" + mpDoctor + "' and patient ='" + patient + "' and sign_status>0 and status=1 ORDER BY sign_date desc limit 1";
                sql = "select is_manage from wlyy_specialist_patient_relation where doctor = '" + mpDoctor + "' and patient ='" + patient + "' and sign_status>0 and status=1 ORDER BY sign_date desc limit 1";
            }
            try {
                manageStatus = jdbcTemplate.queryForObject(sql, String.class);
@ -2496,7 +2496,7 @@ public class RehabilitationManageService {
            Integer unCompleteCount = 0;
            if ("1".equals(status)) {
                String unCompleteCountSql = "SELECT COUNT(*) from ( SELECT COUNT(pd.id) AS total,pd.hospital_service_item_id , COUNT( IF(pd.`status` = 1,1,null)) AS compeletTotal" +
                        " FROM wlyy_specialist.wlyy_rehabilitation_plan_detail pd WHERE " +
                        " FROM wlyy_rehabilitation_plan_detail pd WHERE " +
                        " pd.plan_id = '" + mp.get("id") + "' AND  pd.doctor='" + doctor + "' and pd.execute_time<'" + DateUtil.getStringDateShort() + " 23:59:59' " +
                        "GROUP BY pd.hospital_service_item_id HAVING total>compeletTotal) a";
                unCompleteCount = jdbcTemplate.queryForObject(unCompleteCountSql, Integer.class);
@ -2581,16 +2581,16 @@ public class RehabilitationManageService {
        if (status != null) {
            sqlCondition += "and d.status=" + status;
        }//服务项目
        String sql = " select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code,DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s') as createTime from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id " +
                " LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
        String sql = " select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code,DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s') as createTime from wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id " +
                " LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id  " +
                " where   d.plan_id='" + planId + "' " + sqlCondition + "  group by i.code";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : mapList) {
            String sql1 = "SELECT d.frequency_code,d.plan_id as planId ,d.id,DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s') AS createTime " +
                    "FROM wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                    "FROM wlyy_rehabilitation_plan_detail d " +
                    "WHERE d.plan_id = '" + planId + "' and d.hospital_service_item_id='" + map.get("code") + "'ORDER BY d.create_time DESC";
            List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(sql1);
            if (mapList1 != null && mapList1.size() != 0) {
@ -2604,8 +2604,8 @@ public class RehabilitationManageService {
        for (Map<String, Object> map : mapList) {
            if (!StringUtils.isNoneBlank(map.get("frequency_code").toString())) {
                String sqlCount = "SELECT ror.id,MAX(ror.complete_time) as date,count(*) as total FROM wlyy_specialist.`wlyy_rehabilitation_operate_records` ror, " +
                        "wlyy_specialist.wlyy_rehabilitation_plan_detail pd WHERE pd.id = ror.rehabilitation_detail_id " +
                String sqlCount = "SELECT ror.id,MAX(ror.complete_time) as date,count(*) as total FROM `wlyy_rehabilitation_operate_records` ror, " +
                        "wlyy_rehabilitation_plan_detail pd WHERE pd.id = ror.rehabilitation_detail_id " +
                        "AND pd.plan_id = '" + planId + "' AND pd.hospital_service_item_id='" + map.get("code") + "' AND ror.`status`=1 ";
                List<Map<String, Object>> mapList1 = jdbcTemplate.queryForList(sqlCount);
                int count = 0;
@ -2669,7 +2669,7 @@ public class RehabilitationManageService {
                        "\tCOUNT(pd.id) AS total ,\n" +
                        "\tCOUNT(CASE WHEN pd.`status`=1 THEN 1 ELSE NULL END) AS compeletTotal\n" +
                        "FROM\n" +
                        "\twlyy_specialist.wlyy_rehabilitation_plan_detail pd\n" +
                        "\twlyy_rehabilitation_plan_detail pd\n" +
                        "WHERE\n" +
                        "\t pd.plan_id = '" + planId + "' " +
                        "AND pd.hospital_service_item_id='" + map.get("code") + "' and (pd.frequency_code IS NOT NULL AND pd.frequency_code<>'')\n";
@ -2683,7 +2683,7 @@ public class RehabilitationManageService {
                    map.put("total", new Integer(map1.get("total").toString()));
                    map.put("compeletTotal", new Integer(map1.get("compeletTotal").toString()));
                }
                String dateSql = "SELECT  MAX(CASE WHEN pd.`status`=1 THEN pd.execute_time ELSE NULL END) AS firstDate FROM wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
                String dateSql = "SELECT  MAX(CASE WHEN pd.`status`=1 THEN pd.execute_time ELSE NULL END) AS firstDate FROM wlyy_rehabilitation_plan_detail pd " +
                        "WHERE  pd.plan_id = '" + planId + "' AND pd.hospital_service_item_id='" + map.get("code") + "'";
                List<Map<String, Object>> mapList2 = jdbcTemplate.queryForList(dateSql);
                if (mapList2 != null && mapList2.size() != 0) {
@ -2693,7 +2693,7 @@ public class RehabilitationManageService {
                    if (map1.get("firstDate") != null && StringUtils.isNoneBlank(map1.get("firstDate").toString())) {
                        condition = "and pd.execute_time >='" + map1.get("firstDate").toString() + "'";
                    }
                    String dateSql1 = "SELECT pd.execute_time as lastDate  FROM wlyy_specialist.wlyy_rehabilitation_plan_detail pd " +
                    String dateSql1 = "SELECT pd.execute_time as lastDate  FROM wlyy_rehabilitation_plan_detail pd " +
                            "WHERE  pd.plan_id = '" + planId + "' AND pd.hospital_service_item_id='" + map.get("code") + "' and pd.status=0  " + condition + " order by pd.execute_time ASC ";
                    List<Map<String, Object>> mapList3 = jdbcTemplate.queryForList(dateSql1);
                    if (mapList3 != null && mapList3.size() != 0) {

+ 3 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationPlanService.java

@ -938,8 +938,9 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
     * @return
     */
    public List<Map<String,Object>> getRehabilitationPlanLog(String planId){
        String sql ="select * from wlyy_specialist.wlyy_patient_rehabilitation_plan_log where plan_id = '"+planId+"' ORDER BY create_time DESC";
        sql = TransforSqlUtl.wlyy_patient_rehabilitation_planLogAll(sql);
        String sql ="select date_format(a.create_time, '%Y-%m-%d %H:%i:%s') 'createTime', a.*  " +
                "from wlyy_patient_rehabilitation_plan_log a " +
                "where a.plan_id = '"+planId+"' ORDER BY a.create_time DESC";
        List<Map<String,Object>> planLogList = jdbcTemplate.queryForList(sql);
        return planLogList;
    }

+ 9 - 9
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/specialist/service/SpecialistService.java

@ -256,7 +256,7 @@ public class SpecialistService{
//                    "a.health_assistant_name AS healthAssistantName, " +
                    " a.is_manage AS isManage, " +
                    "a.id AS specialCode " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "FROM wlyy_specialist_patient_relation a " +
                    "JOIN "+basedb+".wlyy_patient_disease_server b ON a.id=b.specialist_relation_code AND b.disease=" +labelCode+" and b.del=1 "+
                    "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE ";
            if(StringUtils.isNotBlank(shareDoctor)){
@ -280,7 +280,7 @@ public class SpecialistService{
                    "a.health_assistant AS healthAssistant,a.health_assistant_name as healthAssistantName" +
//                    "a.health_assistant_name AS healthAssistantName, " +
                    ",a.is_manage AS isManage " +
                    "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                    "FROM wlyy_specialist_patient_relation a " +
                    "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE " +
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND (a.is_manage = 0 or a.is_manage is null)" +
                    " AND a.team_code ='" +teamCode+"' "+
@ -706,7 +706,7 @@ public class SpecialistService{
                " r.id AS specialCode, " +
                " d.`level` " +
                " FROM " +
                " wlyy_specialist.wlyy_specialist_patient_relation r " +
                " wlyy_specialist_patient_relation r " +
                " JOIN "+basedb+".wlyy_doctor d ON r.doctor = d.`code` " +
                " WHERE  " +
                " r.patient ='"+patient+"' " +
@ -794,7 +794,7 @@ public class SpecialistService{
        String sql = "SELECT count(1) AS total " +
                "FROM wlyy.wlyy_sign_family a WHERE a.`status`=1 AND a.expenses_status=1 " +
                "AND patient IN (" +
                "SELECT patient FROM wlyy_specialist.wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "SELECT patient FROM wlyy_specialist_patient_relation WHERE sign_status> 0 AND `status`>=0 " +
                "AND doctor='"+specialdoctor+"') " +
                "AND (a.doctor='"+familydoctor+"' OR a.doctor_health='"+familydoctor+"') ";
    
@ -870,7 +870,7 @@ public class SpecialistService{
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        String centerSql =" from "+basedb+".wlyy_patient p  " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist_patient_relation r WHERE r.sign_status = '1' " +
                " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
@ -878,7 +878,7 @@ public class SpecialistService{
               whereSql;
        String countCenterSql =" from "+basedb+".wlyy_patient p " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1'" +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist_patient_relation r WHERE r.sign_status = '1'" +
                " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
@ -1185,9 +1185,9 @@ public class SpecialistService{
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        //根据手机号码精确查找居民
        String centerSql =" from "+basedb+".wlyy_patient p /*LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient */where  p.openid IS NOT NULL "+whereSql;
        String centerSql =" from "+basedb+".wlyy_patient p /*LEFT JOIN wlyy_specialist_patient_relation r ON p.code=r.patient */where  p.openid IS NOT NULL "+whereSql;
        String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
        String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
                " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1')";
@ -1249,7 +1249,7 @@ public class SpecialistService{
     * @return
     */
    public SpecialistPatientRelationDO selectByDoctorAndPatient(String doctor, String patient){
        String sql = "select * from wlyy_specialist.wlyy_specialist_patient_relation r where r.doctor in ( " +
        String sql = "select * from wlyy_specialist_patient_relation r where r.doctor in ( " +
                " SELECT m.doctor_code  FROM wlyy.wlyy_admin_team_member m " +
                " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy.wlyy_admin_team dt LEFT JOIN wlyy.wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
                " dt.available = '1' AND watm.available = '1'  AND watm.doctor_code = '"+doctor+"') AND m.available = '1'  ) and r.patient = '"+patient+"' and r.sign_status=0";