Browse Source

医院端今日新增

huangzhiyong 6 năm trước cách đây
mục cha
commit
a5b825a244

+ 51 - 12
src/main/java/com/yihu/ehr/svrinspection/controller/AssistanceApplyController.java

@ -56,7 +56,7 @@ public class AssistanceApplyController extends EnvelopRestEndPoint {
    @GetMapping(value = "/hospital")
    @ApiOperation(value = "区域检验-【医院排行】")
    public Envelop examHospitalRanking(
            @ApiParam(name = "areaCode", value = "区域编码", defaultValue = "")
            @ApiParam(name = "areaCode", value = "区域编码(为空显示全市数据)", defaultValue = "")
            @RequestParam(value = "areaCode", required = false) String areaCode,
            @ApiParam(name = "eventDate", value = "就诊时间(年月)", defaultValue = "")
            @RequestParam(value = "eventDate", required = false) String eventDate)  {
@ -83,30 +83,56 @@ public class AssistanceApplyController extends EnvelopRestEndPoint {
            map = examStatisticsService.areaExamStatistics(areaCode,date);
        } catch (ManageException e) {
            return failed(e.getMessage());
        } catch (Exception e) {
            return failed(e.getMessage());
        }
        return success(map);
    }
    @GetMapping(value = "/organizations/statistics")
    @ApiOperation(value = "机构今日检验统计查询")
    @ApiOperation(value = "机构今日检验统计查询-【医生端-头部统计信息】",notes = "医生端的头部统计信息,数据为当日的数据统计")
    public Envelop orgStatistics(
            @ApiParam(name = "orgCode", value = "机构编码(不传默认全市)", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode) throws IOException {
        String demoData = "{\"increase\":200,\"waitSolution \":100,\"solution\":100}";
        Map<String,Object> map = objectMapper.readValue(demoData,Map.class);
        Map<String,Object> map = null;
        try {
            map = examStatisticsService.organizationExamStatistics(orgCode);
        } catch (ManageException e) {
            return failed(e.getMessage());
        } catch (Exception e) {
            return failed(e.getMessage());
        }
        return success(map);
    }
    @GetMapping(value = "/organizations/basic/statistics")
    @ApiOperation(value = "机构今日检验统计查询-【基层机构端-头部统计信息】",notes = "基层机构端的头部统计信息,主要包含总检验数,及今日已处理数,今日未处理数")
    public Envelop basicOrgStatistics(
            @ApiParam(name = "orgCode", value = "机构编码(不传默认全市)", defaultValue = "")
            @RequestParam(value = "orgCode", required = false) String orgCode) throws IOException {
        Map<String,Object> map = null;
        try {
            map = examStatisticsService.basicOrgExamStatistics(orgCode);
        } catch (ManageException e) {
            return failed(e.getMessage());
        } catch (Exception e) {
            return failed(e.getMessage());
        }
        return success(map);
    }
    @GetMapping(value = "/apply/list")
    @ApiOperation(value = "机构申请/处理列表查询")
    public Collection<AssistanceApplyModel> applyList(
    @ApiOperation(value = "机构申请/处理列表查询",notes = "filters 的like查询用“?”,")
    public Envelop applyList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有信息eg:applyOrg=jkzl;createTime>=2018-11-14T18:43:57Z;createTime<2018-11-14T22:59:59Z;", defaultValue = "")
            @ApiParam(name = "filters", value = "过滤器,like用?,为空检索所有信息eg:applyOrg=jkzl;createTime>=2018-11-14T18:43:57Z;createTime<2018-11-14T22:59:59Z;", defaultValue = "")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "")
            @ApiParam(name = "sorts", value = "排序,升序+,降序-(eg:+id)", defaultValue = "+id")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
@ -116,8 +142,16 @@ public class AssistanceApplyController extends EnvelopRestEndPoint {
            HttpServletResponse response) throws IOException, ParseException {
        List<AssistanceApplyModel> assistanceApplyModelList = (List<AssistanceApplyModel>)assistanceApplyService.search(fields, filters, sorts, page, size);
        pagedResponse(request, response, assistanceApplyService.getCount(filters), page, size);
        return convertToModels(assistanceApplyModelList, new ArrayList<AssistanceApplyModel>(assistanceApplyModelList.size()), AssistanceApplyModel.class, fields);
        Envelop envelop = new Envelop();
        envelop.setTotalCount((int)assistanceApplyService.getCount(filters));
        envelop.setCurrPage(page);
        envelop.setPageSize(size);
        envelop.setDetailModelList(assistanceApplyModelList);
        envelop.setSuccessFlg(true);
        envelop.setTotalPage(envelop.getTotalPage());
        return envelop;
//        pagedResponse(request, response, assistanceApplyService.getCount(filters), page, size);
//        return convertToModels(assistanceApplyModelList, new ArrayList<AssistanceApplyModel>(assistanceApplyModelList.size()), AssistanceApplyModel.class, fields);
    }
    @GetMapping(value = "/apply/detail")
@ -134,10 +168,15 @@ public class AssistanceApplyController extends EnvelopRestEndPoint {
    @ApiOperation(value = "检验协助申请", response = AssistanceApplyModel.class)
    @PostMapping(value = "apply",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Envelop createAssistanceApply(
            @ApiParam(name = "dictionary", value = "档案申请JSON结构")
            @ApiParam(name = "apply", value = "档案申请JSON结构")
            @RequestBody AssistanceApplyModel apply)  {
        AssistanceApplyModel save = assistanceApplyService.save(apply);
        AssistanceApplyModel save = null;
        try {
            save = assistanceApplyService.saveApply(apply);
        } catch (ManageException e) {
            return failed(e.getMessage());
        }
        return success(save);
    }

+ 15 - 3
src/main/java/com/yihu/ehr/svrinspection/dao/AssistanceApplyDao.java

@ -6,14 +6,26 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
/**
 * @author HZY
 * @created 2018/11/14 15:34
 */
public interface AssistanceApplyDao extends PagingAndSortingRepository<AssistanceApplyModel,Integer> {
public interface AssistanceApplyDao extends PagingAndSortingRepository<AssistanceApplyModel, Integer> {
    Page<AssistanceApplyModel> queryAllByApplyOrgAndExamTypeAndExamDeptAndPatientNameLike(String appOrg, String type, String dept, String patientName, Pageable pageable);
    long countAllBySolutionStatusAndCreateTimeBetween(int solutionStatus, Date startDate, Date endDate);
    long countAllBySolutionOrgAndCreateTimeBetween(String orgCode, Date start, Date end);
    long countAllBySolutionOrgAndSolutionStatusAndCreateTimeBetween(String orgCode,int solutionStatus ,Date start, Date end);
    long countAllByApplyOrgAndSolutionStatus(String orgCode, int solutionStatus);
    Page<AssistanceApplyModel> queryAllByApplyOrgAndExamTypeAndExamDeptAndPatientNameLike(String appOrg, String type,String dept,String patientName, Pageable pageable);
    long countAllByApplyOrgAndCreateTimeBetween(String orgCode, Date start, Date end);
    long countAllBySolutionStatusAndCreateTimeBetween(int solutionStatus,String startDate,String endDate );
    long countAllByApplyOrgAndSolutionStatusAndCreateTimeBetween(String orgCode,int solutionStatus ,Date start, Date end);
}

+ 66 - 2
src/main/java/com/yihu/ehr/svrinspection/service/AssistanceApplyService.java

@ -28,7 +28,13 @@ public class AssistanceApplyService  extends BaseJpaService<AssistanceApplyModel
        return assistanceApplyDao.findOne(id);
    }
    public AssistanceApplyModel solutionApply(int id,String replyUserId,String replyContent) throws ManageException {
    public AssistanceApplyModel saveApply(AssistanceApplyModel assistanceApplyModel) throws ManageException {
        AssistanceApplyModel save = assistanceApplyDao.save(assistanceApplyModel);
        return save;
    }
        public AssistanceApplyModel solutionApply(int id,String replyUserId,String replyContent) throws ManageException {
        AssistanceApplyModel applyModel = findById(id);
        if (applyModel == null) {
            throw new ManageException("申请记录不存在!");
@ -48,7 +54,65 @@ public class AssistanceApplyService  extends BaseJpaService<AssistanceApplyModel
     */
    public long toDayCount(int status) {
        String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        long todayCount = assistanceApplyDao.countAllBySolutionStatusAndCreateTimeBetween(status, toDay + " 00:00:00", toDay + " 23:59:59");
        Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        long todayCount = assistanceApplyDao.countAllBySolutionStatusAndCreateTimeBetween(status, start, end);
        return todayCount;
    }
    /* ****************  基层医疗机构 ********** */
    /**
     * 通过申请机构 获取检验处理总数
     * @param applyOrg  申请机构编码
     * @param status    处理状态
     * @return
     */
    public long toDayIncreaseByApplyOrg(String applyOrg,int status){
        long count = assistanceApplyDao.countAllByApplyOrgAndSolutionStatus(applyOrg, status);
        return count;
    }
    /**
     * 通过申请机构获取 今日已处理/未处理量
     * @param solutionOrg   申请处理机构
     * @return
     */
    public long toDayCountByApplyOrg(String solutionOrg,int status) {
        String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        long todayCount = assistanceApplyDao.countAllByApplyOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg,status, start, end);
        return todayCount;
    }
    /***************************  医生端 ************************************/
    /**
     * 通过处理机构获取 今日新增申请量
     * @param solutionOrg   申请处理机构
     * @return
     */
    public long toDayIncreaseBySolutionOrg(String solutionOrg){
        String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        long count = assistanceApplyDao.countAllBySolutionOrgAndCreateTimeBetween(solutionOrg, start, end);
        return count;
    }
    /**
     * 通过处理机构获取 今日已处理/未处理量
     * @param solutionOrg   申请处理机构
     * @return
     */
    public long toDayCountBySolutionOrg(String solutionOrg,int status) {
        String toDay = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        Date start = DateUtil.parseDate(toDay + " 00:00:00",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        Date end = DateUtil.parseDate(toDay + " 23:59:59",DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
        long todayCount = assistanceApplyDao.countAllBySolutionOrgAndSolutionStatusAndCreateTimeBetween(solutionOrg,status, start, end);
        return todayCount;
    }

+ 63 - 18
src/main/java/com/yihu/ehr/svrinspection/service/ExamStatisticsService.java

@ -89,18 +89,19 @@ public class ExamStatisticsService extends BaseService {
        StringBuilder fq = new StringBuilder();
        String q = "(rowkey:*HDSD00_79* OR rowkey:*HDSD00_77*)";//solr细表中的检查检验
        if (StringUtils.isBlank(areaCode)) {
            throw new ManageException("areaCode is null,check your params");
        if (!StringUtils.isBlank(areaCode)) {
            //区域编码
            fq.append("org_area:").append(areaCode).append(" && ");
//            throw new ManageException("医院检验统计分布:areaCode is null,check your params");
        }
        if (StringUtils.isBlank(eventDate)) {
            throw new ManageException("eventDate is null,check your params");
        }
        //区域编码
        fq.append("org_area:"+areaCode);
        //事件日期
        fq.append(" && event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        fq.append("event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        //统计查询
        Map<String, Long> facetField = solrUtil.groupCount(core,q, fq.toString(),field, 0, -1);
        //获取区县列表
@ -133,7 +134,7 @@ public class ExamStatisticsService extends BaseService {
        //累计检验数
        long total = totalCount(areaCode, eventDate);
        //今日新增数
        long today = todayIncreaseCount(areaCode);
        long today = areaTodayIncreaseCount(areaCode);
        //已申请数
        long apply = assistanceApplyService.toDayCount(0);
        //已处理数
@ -144,10 +145,53 @@ public class ExamStatisticsService extends BaseService {
        result.put("increase",today);
        result.put("applied",apply);
        result.put("solution",solution);
        result.put("eventPercentage",solution);
        result.put("eventPercentage",list);
        return result;
    }
    /**
     *  【医院端】-医院今日检验数统计
     * @param orgCode
     * @return
     * @throws Exception
     */
    public Map<String,Object> organizationExamStatistics(String orgCode) throws Exception {
        Map<String,Object> result = new HashMap<>();
        //今日新增量
        long today = assistanceApplyService.toDayIncreaseBySolutionOrg(orgCode);
        //已申请,未处理数
        long apply = assistanceApplyService.toDayCountBySolutionOrg(orgCode,0);
        //已处理数
        long solution = assistanceApplyService.toDayCountBySolutionOrg(orgCode,1);
        result.put("waitSolution",apply);
        result.put("solution",solution);
        result.put("increase",today);
        return result;
    }
    /**
     *  【基层医疗结构端】-医院今日检验数统计
     * @param orgCode
     * @return
     * @throws Exception
     */
    public Map<String,Object> basicOrgExamStatistics(String orgCode) throws Exception {
        Map<String,Object> result = new HashMap<>();
        //处理总量
        long total = assistanceApplyService.toDayIncreaseByApplyOrg(orgCode,1);
        //已申请,未处理数
        long apply = assistanceApplyService.toDayCountByApplyOrg(orgCode,0);
        //已处理数
        long solution = assistanceApplyService.toDayCountByApplyOrg(orgCode,1);
        result.put("waitSolution",apply);
        result.put("solution",solution);
        result.put("total",total);
        return result;
    }
    /**
     *  solr 获取检验累计总数
     *
@ -163,7 +207,7 @@ public class ExamStatisticsService extends BaseService {
        if (!StringUtils.isBlank(areaCode)) {
            //区域编码
            fq.append("org_area:"+areaCode);
            fq.append("org_area:").append(areaCode).append(" AND ");
        }
        if (StringUtils.isBlank(eventDate)) {
@ -171,7 +215,7 @@ public class ExamStatisticsService extends BaseService {
        }
        //事件日期
        fq.append(" && event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        fq.append("event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        //统计查询
        try {
             total = solrUtil.count(core,q, fq.toString());
@ -189,20 +233,20 @@ public class ExamStatisticsService extends BaseService {
     * @return
     * @throws ManageException
     */
    public long todayIncreaseCount(String areaCode) throws ManageException {
    public long areaTodayIncreaseCount(String areaCode) throws ManageException {
        long total = 0;
        StringBuilder fq = new StringBuilder();
        String q = "(rowkey:*HDSD00_79* OR rowkey:*HDSD00_77*)";//solr细表中的检查检验
        if (!StringUtils.isBlank(areaCode)) {
            //区域编码
            fq.append("org_area:"+areaCode);
            fq.append("org_area:").append(areaCode).append(" AND ");
        }
        String createDate = DateUtil.getNowDate(DateUtil.DEFAULT_DATE_YMD_FORMAT);
        //创建日期
        fq.append(" && create_date:[" + createDate + "T00:00:00Z TO " + createDate + "T23:59:59Z]");
        //创建日期 TODO 就诊时间或者是入库的时间
        fq.append("event_date:[" + createDate + "T00:00:00Z TO " + createDate + "T23:59:59Z]");
        //统计查询
        try {
            total = solrUtil.count(core,q, fq.toString());
@ -227,18 +271,19 @@ public class ExamStatisticsService extends BaseService {
        StringBuilder fq = new StringBuilder();
        String q = "(rowkey:*HDSD00_79* OR rowkey:*HDSD00_77*)";//solr细表中的检查检验
        if (StringUtils.isBlank(areaCode)) {
            throw new ManageException("areaCode is null,check your params");
        if (!StringUtils.isBlank(areaCode)) {
            //区域编码
            fq.append("org_area:").append(areaCode).append(" && ");
//            throw new ManageException("检验次数业务分布:areaCode is null,check your params");
        }
        if (StringUtils.isBlank(eventDate)) {
            throw new ManageException("eventDate is null,check your params");
        }
        //区域编码
        fq.append("org_area:"+areaCode);
        //事件日期
        fq.append(" && event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        fq.append("event_date:[" + eventDate + "T00:00:00Z TO " + eventDate + "T23:59:59Z]");
        //统计查询
        Map<String, Long> facetField = solrUtil.groupCount(core,q, fq.toString(),"event_type", 0, -1);