Browse Source

Merge branch 'dev' of wujunjie/patient-co-management into dev

huangwenjie 7 years ago
parent
commit
e95d8ec3ba

+ 11 - 5
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -1251,12 +1251,14 @@ public class PrescriptionService extends ZysoftBaseService{
            
                Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(orderNo,recipeNo);
                if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue())){
                    if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                    /*if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
                    } else{
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                    }
                
                    }*/
                    prescription.setDispensaryType(1);
                    prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
                    prescription.setJwPayStatus(1);//0为未结算,1为结算成功,默认为0
                    prescription.setDrugDeliveryTime(new Date());
                    prescriptionDao.save(prescription);
@ -1329,7 +1331,11 @@ public class PrescriptionService extends ZysoftBaseService{
                    log.setUserName(prescription.getDoctorName());
                    log.setFlag(1);
                    log.setUserCode(prescription.getDoctor());
                    if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                    log.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());
                    log.setRemark("待配药");
                    prescriptionLogDao.save(log);
     /*               if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                        log.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
                        log.setRemark("快递配送:配药成功,配送中");
                        prescriptionLogDao.save(log);
@ -1373,7 +1379,7 @@ public class PrescriptionService extends ZysoftBaseService{
                            redisTemplate.opsForList().leftPush(channelTopic,message.toString());
//                redisTemplate.unwatch();
                        }
                    }
                    }*/
                
                }else {
                    error = "code:"+prescription.getCode()+",status:"+prescription.getStatus();

+ 19 - 12
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorFeldsherTemplateJob.java

@ -52,6 +52,7 @@ public class DoctorFeldsherTemplateJob implements Job {
            c.setTime(today);
            int weekday=c.get(Calendar.DAY_OF_WEEK);
            //查询当天医生设置的监测方案
            List<DoctorSchemeBloodSugger> patientCodeList = schemeListDao.findSuggerPatient((short)weekday);
            for (DoctorSchemeBloodSugger patientCodeLis : patientCodeList) {
                String schemecode = patientCodeLis.getCode();
@ -240,21 +241,27 @@ public class DoctorFeldsherTemplateJob implements Job {
        Date today = new Date();
        if (minutes <= 30 && minutes > 0) {
            PatientSchemeList patient = schemeListDao.findPatientBySchemecode(schemecode,type);
            String patientCode = patient.getPatientcode();
            //查询使用同一套监测方案的所有居民
            List<PatientSchemeList> patientList = schemeListDao.findPatientBySchemecode(schemecode,type);
            for (PatientSchemeList patient :patientList) {
                String patientCode = patient.getPatientcode();
            String day = formatDay.format(today);
            Date begin = formatTime.parse(day + beginTime);
            Date end = formatTime.parse(day + endTime);
            List<DevicePatientHealthIndex> healthIndices = patientHealthIndexDao.findByPatient(patientCode, type, begin, end);
            if (healthIndices==null || healthIndices.size()==0) {
                try {
                    //为居民发送监测代办事项提醒消息
                    feldsherTemplateService.sendChangeTemplate(type, patientCode, comment);
                } catch (Exception e) {
                    logger.info("DoctorFeldsherTemplateJob error ..........continue this JOB,CODE:" + patientCode + ",message:" + e.getMessage());
                String day = formatDay.format(today);
                Date begin = formatTime.parse(day + beginTime);
                Date end = formatTime.parse(day + endTime);
                //查询监测提醒时间段居民是否有对应设备数据上传
                List<DevicePatientHealthIndex> healthIndices = patientHealthIndexDao.findByPatient(patientCode, type, begin, end);
                if (healthIndices==null || healthIndices.size()==0) {
                    try {
                        //为居民发送监测代办事项提醒消息
                        feldsherTemplateService.sendChangeTemplate(type, patientCode, comment);
                    } catch (Exception e) {
                        logger.info("DoctorFeldsherTemplateJob error ..........continue this JOB,CODE:" + patientCode + ",message:" + e.getMessage());
                    }
                }
            }
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientSchemeListDao.java

@ -23,5 +23,5 @@ public interface PatientSchemeListDao extends PagingAndSortingRepository<Patient
    //根据schemecode查询患者监测方案
    @Query(" select p from PatientSchemeList p where p.schemecode = ?1 and p.type = ?2 ")
    PatientSchemeList findPatientBySchemecode(String schemecode,Integer type);
    List<PatientSchemeList> findPatientBySchemecode(String schemecode,Integer type);
}

+ 7 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorGuidanceTempDao.java

@ -38,4 +38,11 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner != 'system' and t.modelName like ?1 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listByTile(String filter, Pageable pageRequest);
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName like ?2 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listOwnerByTile(String owner, String filter, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTemp t where (t.owner = 'system' or t.owner = ?1) and t.modelName like ?2 order by t.sendTimes desc ")
    Page<DoctorGuidanceTemp> listByTileAll(String owner,String filter, Pageable pageRequest);
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java

@ -23,6 +23,10 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamId(int teamId, Pageable request);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> countGuidanceByTeamId(int teamId);
    //    由模板编码获取拥有该模板的团队信息
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamTemplateCode = ?1 ")
    List<DoctorTeamGuidanceTemplate> getTeamsByGuidance(String guidanceCode);
@ -52,4 +56,19 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
            " AND b.del = 1 AND b.title LIKE ?1 order by b.useTimes desc  ")
    Page<DoctorTeamGuidanceTemplate> listByTile(String title, Pageable pageRequest);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.creater = ?1  AND b.teamId = ?2 AND b.title LIKE ?3 order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(String doctor, int teamId, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1  AND b.creater = ?1  AND b.title LIKE ?2 GROUP BY b.teamId order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(String doctor, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.creater = ?1 AND b.title LIKE ?2 order by b.useTimes desc  ")
    List<DoctorTeamGuidanceTemplate> getListByTile(String doctor, String title, Pageable pageRequest);
}

+ 27 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.repository.template.DoctorTeamGuidanceTemplateDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.CodeFomat;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -201,53 +202,40 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param type   模板类型
     * @return
     */
    public List<Map<String, Object>> list(String doctor, String type, int pageSize, int pageNo) throws Exception {
    public List<Map<String, Object>> list(String doctor,String filter, String type, int pageSize, int pageNo) throws Exception {
        Page<DoctorGuidanceTemp> temps = null;
        PageRequest pageRequest = new PageRequest(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
        if (type.equals("1")) {
            temps = guidanceTempDao.findByOwner("system", pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
            }
        } else if (type.equals("2")) {
            temps = guidanceTempDao.findByOwner(doctor, pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
        if (StringUtils.isEmpty(filter)){
            if (type.equals("1")) {
                temps = guidanceTempDao.findByOwner("system", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.findByOwner(doctor, pageRequest);
            } else {
                temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
            }
        } else {
            temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
        }else {
            if (type.equals("1")) {
                temps = guidanceTempDao.listByTileSystem("%"+filter+"%", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.listOwnerByTile(doctor,"%"+filter+"%", pageRequest);
            } else {
                temps = guidanceTempDao.listByTileAll(doctor,"%"+filter+"%", pageRequest);
            }
        }
        List<DoctorGuidanceTemp> list = temps.getContent();
        for (int i = 0; i < list.size(); i++) {
            DoctorGuidanceTemp dgt = list.get(i);
            Map<String, Object> tem = new HashMap<>();
            tem.put("code", dgt.getCode());
            tem.put("owner", dgt.getOwner());
            tem.put("sendTimes", dgt.getSendTimes());
            tem.put("lastTime", dgt.getLastTime());
            tem.put("modelName", dgt.getModelName());
            listMap.add(tem);
        }
        return listMap;
    }

+ 48 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorTeamGuidanceService.java

@ -260,18 +260,26 @@ public class DoctorTeamGuidanceService extends BaseService {
    /**
     * 根据医生所属的单个团队获取团队模板列表
     *
     * @param doctor
     * @param filter
     * @param teamId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     */
    public List getTeamGuidanceList(int teamId, int pageNo, int pageSize) throws Exception {
    public List getTeamGuidanceList(String doctor, String filter, int teamId, int pageNo, int pageSize) throws Exception {
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest request = new PageRequest(pageNo, pageSize, sort);
        List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        List list = new ArrayList();
        List<DoctorTeamGuidanceTemplate> listGuidances = null;
        if (StringUtils.isEmpty(filter)){
            listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        }else {
            listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(doctor,"%"+filter+"%", request);
        }
        for (DoctorTeamGuidanceTemplate guidance : listGuidances) {
            Map map = new HashMap();
            String title = guidance.getTitle();
@ -282,9 +290,46 @@ public class DoctorTeamGuidanceService extends BaseService {
            map.put("useTimes", useTimes);
            list.add(map);
        }
        return list;
    }
    /**
     * 获取此医生所在的团队列表。
     *
     * @param doctorCode
     * @param filter 搜索关键字
     * @return
     */
    public List getDoctorTeams(String doctorCode,String filter) throws Exception{
        List teamList = null;
        try {
            List<AdminTeam> doctorTeams = memberDao.findDoctorTeams(doctorCode);
            teamList = new ArrayList();
            for (AdminTeam AdminTeam : doctorTeams){
                Map map = new HashMap();
                String teamName = AdminTeam.getName();
                Long teamId = AdminTeam.getId();
                map.put("teamName", teamName);
                map.put("teamId", teamId);
                if (StringUtils.isNotEmpty(filter)){
                    List<DoctorTeamGuidanceTemplate> guidances = doctorTeamGuidanceTemplateDao.countTeamListByTile(doctorCode,Integer.valueOf(teamId.toString()),"%"+filter+"%");
                    map.put("amount", guidances.size());
                }else {
                    List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.countGuidanceByTeamId(Integer.valueOf(teamId.toString()));
                    map.put("amount", listGuidances.size());
                }
                teamList.add(map);
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return teamList;
    }
    /**
     * 根据团队模板编码获取单个 有效的 模板详情
     *

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -170,14 +170,17 @@ public class DoctorGuidanceTempController extends BaseController {
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询指导模板")
    public String list(@RequestParam(required = false, defaultValue = "")
    public String list(
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "搜索关键字") String filter,
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type,
                       @RequestParam(defaultValue = "10") String pageSize,
                       @RequestParam(defaultValue = "1") @ApiParam(value = "当前页码") String pageNo) {
        try {
            int pagesize = Integer.parseInt(pageSize);
            int pageno = Integer.parseInt(pageNo) - 1;
            List<Map<String, Object>> temps = guidanceTempService.list(getUID(), type, pagesize, pageno);
            List<Map<String, Object>> temps = guidanceTempService.list(getUID(),filter, type, pagesize, pageno);
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功", "data", new JSONArray());

+ 9 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorTeamGuidanceController.java

@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
@ -31,8 +31,6 @@ import java.util.*;
@Api(description = "医生端&后端团队指导模板")
public class DoctorTeamGuidanceController extends WeixinBaseController {
    @Autowired
    private AdminTeamService adminTeamService;
    @Autowired
    private DoctorTeamGuidanceService doctorTeamGuidanceService;
    @Autowired
@ -48,19 +46,10 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    @RequestMapping(value = "/getDoctorTeams", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取医生所属的所有团队")
    public String getHealthIndexHistory() {
    public String getHealthIndexHistory(@RequestParam(required = false, defaultValue = "") @ApiParam(value = "搜索关键字") String filter) {
        try {
            String doctorCode = getUID();
            List<AdminTeam> doctorTeams = adminTeamService.getDoctorTeams(doctorCode);
            List teamList = new ArrayList();
            for (AdminTeam AdminTeam : doctorTeams) {
                Map map = new HashMap();
                String teamName = AdminTeam.getName();
                Long teamId = AdminTeam.getId();
                map.put("teamName", teamName);
                map.put("teamId", teamId);
                teamList.add(map);
            }
            List teamList = doctorTeamGuidanceService.getDoctorTeams(doctorCode,filter);
            return write(200, "获取医生所属团队成功!", "teamList", teamList);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
@ -76,11 +65,15 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    @RequestMapping(value = "/getTeamGuidanceList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取单个团队模板列表")
    public String getTeamGuidanceList(@RequestParam int teamId,
    public String getTeamGuidanceList(
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "搜索关键字") String filter,
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "团队ID") Integer teamId,
                                      @RequestParam int pageNo,
                                      @RequestParam int pageSize) {
        try {
            List list = doctorTeamGuidanceService.getTeamGuidanceList(teamId, pageNo - 1, pageSize);
            List list = doctorTeamGuidanceService.getTeamGuidanceList(getUID(),filter,teamId, pageNo - 1, pageSize);
            return write(200, "获取团队模板列表成功!", "templateList", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());