You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					246 lines
				
				9.9 KiB
			
		
		
			
		
	
	
					246 lines
				
				9.9 KiB
			| 
											3 years ago
										 | package com.ynxbd.common.action;
 | ||
|  | 
 | ||
|  | import com.ynxbd.common.action.base.BaseAction;
 | ||
|  | import com.ynxbd.common.bean.TreatRecord;
 | ||
|  | import com.ynxbd.common.bean.lis.XBDLisReport;
 | ||
|  | import com.ynxbd.common.bean.report.CheckReport;
 | ||
|  | import com.ynxbd.common.bean.report.InspectionReport;
 | ||
|  | import com.ynxbd.common.bean.report.PEIS;
 | ||
|  | import com.ynxbd.common.dao.his.HisReportDao;
 | ||
|  | import com.ynxbd.common.helper.common.DateHelper;
 | ||
|  | import com.ynxbd.common.result.Result;
 | ||
|  | import com.ynxbd.common.result.ResultEnum;
 | ||
|  | import com.ynxbd.wx.wxfactory.ReqParamHelper;
 | ||
|  | import lombok.extern.slf4j.Slf4j;
 | ||
|  | import org.apache.struts2.convention.annotation.Action;
 | ||
|  | import org.apache.struts2.convention.annotation.Namespace;
 | ||
|  | 
 | ||
|  | import java.util.ArrayList;
 | ||
|  | import java.util.Comparator;
 | ||
|  | import java.util.List;
 | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @Author wsq
 | ||
|  |  * @Date 2020/8/15 12:35
 | ||
|  |  * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
 | ||
|  |  */
 | ||
|  | @Slf4j
 | ||
|  | @Namespace("/report")
 | ||
|  | public class ReportAction extends BaseAction {
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * [体检报告]
 | ||
|  |      */
 | ||
|  |     @Action("getPEISByPatient")
 | ||
|  |     public Result getPEISByPatient(String name, String idCardNo, String patientId, String begDate, String endDate) {
 | ||
|  |         // http://localhost:8080/wx/report/getPEISByPatient.do?patientId=153671&idCardNo=533103198212184014&name=%E8%82%96%E7%81%BF&token=123
 | ||
|  |         log.info("[体检报告]查询:patientId={}, idCardNo={}, name={}, begDate={}, endDate={}", patientId, idCardNo, name, begDate, endDate);
 | ||
|  |         if (patientId == null || idCardNo == null || name == null || begDate == null || endDate == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_DEFECT);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<PEIS> reportList = new HisReportDao().getPEISReportByPatient(name, idCardNo, begDate, endDate);
 | ||
|  | 
 | ||
|  |         List<PEIS> resultList = new ArrayList<>();
 | ||
|  |         for (PEIS report : reportList) {
 | ||
|  |             if (report.getExamDate() != null && DateHelper.inDateRange(begDate, endDate, report.getExamDate(), DateHelper.DateEnum.yyyy_MM_dd)) {
 | ||
|  |                 resultList.add(report);
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * [检查报告]
 | ||
|  |      */
 | ||
|  |     @Action("getCheckByPatient")
 | ||
|  |     public Result getCheckByPatient(String begDate, String endDate, String patientId, String openid) {
 | ||
|  |         patientId = getDecodeString(patientId);
 | ||
|  |         // http://localhost:8080/wx/report/getCheckByPatient.do?patientId=153671&token=123
 | ||
|  |         log.info("[检查报告]查询 patientId={}, begDate={}, endDate={}", patientId, begDate, endDate);
 | ||
|  |         if (patientId == null || begDate == null || endDate == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_DEFECT);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<CheckReport> reportList = new HisReportDao().getCheckByPatient(patientId, begDate, endDate);
 | ||
|  | 
 | ||
|  |         List<CheckReport> resultList = new ArrayList<>();
 | ||
|  |         for (CheckReport report : reportList) {
 | ||
|  |             if (report.getApplyDate() != null && DateHelper.inDateRange(begDate, endDate, report.getApplyDate(), DateHelper.DateEnum.yyyy_MM_dd)) {
 | ||
|  |                 resultList.add(report);
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * [就诊记录]查询
 | ||
|  |      *
 | ||
|  |      * @param begDate     开始日期
 | ||
|  |      * @param endDate     结束日期
 | ||
|  |      * @param patientId   患者id
 | ||
|  |      * @param patientType 0:全部,1:门诊号,2:住院号
 | ||
|  |      * @param reportType  0:全部,1:检查,2:检验,3:检查+检验
 | ||
|  |      * @param isLately    是否只查询最近一条记录
 | ||
|  |      */
 | ||
|  |     @Action("getTreatRecordList")
 | ||
|  |     public Result getTreatRecordList(String begDate, String endDate, String patientId, String patientType, String reportType, Boolean isLately) {
 | ||
|  |         patientId = getDecodeString(patientId);
 | ||
|  |         // http://localhost:8081/wx/report/getTreatRecordList.do?patientId=406212&begDate=201801-01&endDate=2020-08-12&patientType=0&reportType=2
 | ||
|  |         if (patientId == null || begDate == null || endDate == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_DEFECT);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<TreatRecord> records = new HisReportDao().getTreatRecordList(patientId, begDate, endDate, patientType, reportType);
 | ||
|  | 
 | ||
|  | 
 | ||
|  |         if (records.size() > 0 && isLately != null && isLately) {
 | ||
|  |             List<TreatRecord> resultList = new ArrayList<>();
 | ||
|  | 
 | ||
|  |             records.stream().max(Comparator.comparing(TreatRecord::getConsultDate)).ifPresent(resultList::add);
 | ||
|  |             return Result.success(resultList);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         for (TreatRecord record : records) {
 | ||
|  |             if (record.getTreatNum() != null) {
 | ||
|  |                 record.setEnTreatNum(ReqParamHelper.encode(record.getTreatNum()));
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(records);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * [患者]查询化验(检验)结果
 | ||
|  |      */
 | ||
|  |     @Action("getInspectByPatient")
 | ||
|  |     public Result getInspectByPatient(String openid, String patientId, String begDate, String endDate) {
 | ||
|  |         patientId = getDecodeString(patientId);
 | ||
|  | 
 | ||
|  |         // http://localhost:8080/wx/report/getInspectByPatient.do?patientId=153671&token=123
 | ||
|  |         log.info("化验(检验)结果查询:patientId={}, begDate={}, endDate={}", patientId, begDate, endDate);
 | ||
|  |         if (patientId == null || begDate == null || endDate == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_DEFECT);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         List<InspectionReport> reportList = new HisReportDao().getInspectByPatient(patientId);
 | ||
|  | 
 | ||
|  |         List<InspectionReport> resultList = new ArrayList<>();
 | ||
|  |         for (InspectionReport report : reportList) {
 | ||
|  |             if (report.getApplyDate() != null && DateHelper.inDateRange(begDate, endDate, report.getApplyDate(), DateHelper.DateEnum.yyyy_MM_dd)) {
 | ||
|  |                 resultList.add(report);
 | ||
|  |             }
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     /**
 | ||
|  |      * [门诊号]根据门诊号查询化验(检验)结果
 | ||
|  |      */
 | ||
|  |     @Action("getInspectByTreatNum")
 | ||
|  |     public Result getInspectByTreatNum(String type, String treatNum, String patientId) {
 | ||
|  |         treatNum = getDecodeString(treatNum);
 | ||
|  |         patientId = getDecodeString(patientId);
 | ||
|  |         // http://localhost:8080/wx/report/getInspectByTreatNum.do?patientId=153671&token=123
 | ||
|  |         log.info("[化验(检验)]结果查询:patientId={}, type={}, treatNum={}", patientId, type, treatNum);
 | ||
|  |         if (patientId == null || type == null || treatNum == null) {
 | ||
|  |             return Result.error(ResultEnum.PARAM_IS_BLANK);
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         String mzNum = null, zyNum = null;
 | ||
|  |         if ("1".equals(type)) {
 | ||
|  |             mzNum = treatNum;
 | ||
|  |         } else {
 | ||
|  |             zyNum = treatNum;
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         ArrayList<XBDLisReport> resultList = new ArrayList<>();
 | ||
|  |         XBDLisReport xbdLisReport;
 | ||
|  |         List<InspectionReport> reports = new HisReportDao().getInspectByTreatNum(patientId, zyNum, mzNum);
 | ||
|  |         for (InspectionReport report : reports) {
 | ||
|  |             xbdLisReport = new XBDLisReport();
 | ||
|  |             xbdLisReport.setReportName(report.getName());
 | ||
|  |             xbdLisReport.setSpecimenName(report.getType());
 | ||
|  |             xbdLisReport.setReportDate(report.getReportDate());
 | ||
|  |             xbdLisReport.setReporter(report.getReportDoctName());
 | ||
|  |             xbdLisReport.setItem(report.getItem());
 | ||
|  |             xbdLisReport.setTreatId(report.getMzNum() != null ? report.getMzNum() : report.getZyNum());
 | ||
|  |             xbdLisReport.setBedNo(report.getBedNum());
 | ||
|  | 
 | ||
|  |             resultList.add(xbdLisReport);
 | ||
|  |         }
 | ||
|  |         return Result.success(resultList);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | //    /**
 | ||
|  | //     * 根据openid查询检查报告
 | ||
|  | //     */
 | ||
|  | //    @Action("getCheckAll")
 | ||
|  | //    public String getCheckAll() {
 | ||
|  | //        String openid = getString("openid");
 | ||
|  | //        log.info("根据openid查询检查报告 openid={}", openid);
 | ||
|  | //        if (openid == null) {
 | ||
|  | //            return Result.error(ResultEnum.PARAM_NOT_COMPLETE);
 | ||
|  | //        }
 | ||
|  | //
 | ||
|  | //        List<Patient> patients = new PatientDao().selectListByOpenid(openid);
 | ||
|  | //
 | ||
|  | //        List<List<CheckReport>> reports = new ArrayList<>();
 | ||
|  | //        HisReportDao hisReportDao = new HisReportDao();
 | ||
|  | //        for (Patient patient : patients) {
 | ||
|  | //            List<CheckReport> reportItem = hisReportDao.getCheckByPatient(patient);
 | ||
|  | //            reports.add(reportItem);
 | ||
|  | //        }
 | ||
|  | //        return Result.success(reports);
 | ||
|  | //    }
 | ||
|  | //
 | ||
|  | //    /**
 | ||
|  | //     * 根据openid查询体检报告
 | ||
|  | //     */
 | ||
|  | //    @Action("getPEISReportAll")
 | ||
|  | //    public String getPEISReportAll() {
 | ||
|  | //        String openid = getString("openid");
 | ||
|  | //        log.info("根据openid查询体检报告 openid={}", openid);
 | ||
|  | //        if (openid == null) {
 | ||
|  | //            return Result.error(ResultEnum.PARAM_NOT_COMPLETE);
 | ||
|  | //        }
 | ||
|  | //
 | ||
|  | //        List<Patient> patients = new PatientDao().selectListByOpenid(openid);
 | ||
|  | //
 | ||
|  | //        List<List<PEIS>> reports = new ArrayList<>();
 | ||
|  | //        HisReportDao hisReportDao = new HisReportDao();
 | ||
|  | //        for (Patient patient : patients) {
 | ||
|  | //            List<PEIS> reportItem = hisReportDao.getPEISReportByPatient(patient);
 | ||
|  | //            reports.add(reportItem);
 | ||
|  | //        }
 | ||
|  | //
 | ||
|  | //
 | ||
|  | //        return Result.success(reports);
 | ||
|  | //    }
 | ||
|  | //
 | ||
|  | //    /**
 | ||
|  | //     * 根据openid查询检验结果
 | ||
|  | //     */
 | ||
|  | //    @Action("getInspectionAll")
 | ||
|  | //    public String getInspectionAll() {
 | ||
|  | //        String openid = getString("openid");
 | ||
|  | //        log.info("根据openid查询检验结果,openid={}", openid);
 | ||
|  | //        if (openid == null) {
 | ||
|  | //            return Result.error(ResultEnum.PARAM_NOT_COMPLETE);
 | ||
|  | //        }
 | ||
|  | //
 | ||
|  | //        List<Patient> patients = new PatientDao().selectListByOpenid(openid);
 | ||
|  | //
 | ||
|  | //        List<List<InspectionReport>> reports = new ArrayList<>();
 | ||
|  | //        HisReportDao hisReportDao = new HisReportDao();
 | ||
|  | //        for (Patient patient : patients) {
 | ||
|  | //            List<InspectionReport> reportItem = hisReportDao.getInspectByPatient(patient.getPatientId());
 | ||
|  | //            reports.add(reportItem);
 | ||
|  | //        }
 | ||
|  | //        return Result.success(reports);
 | ||
|  | //    }
 | ||
|  | 
 | ||
|  | }
 |