package com.ynxbd.common.action; import com.ynxbd.common.action.base.BaseAction; import com.ynxbd.common.bean.in_hosp.*; import com.ynxbd.common.dao.his.HisInHospDao; import com.ynxbd.common.helper.common.DateHelper; import com.ynxbd.common.result.JsonResult; import com.ynxbd.common.result.Result; import com.ynxbd.common.result.ResultEnum; import lombok.extern.slf4j.Slf4j; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; /** * 住院接口 * * @Author wsq * @Date 2021/2/26 12:50 * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved. */ @Slf4j @Namespace("/inHosp") public class InHospAction extends BaseAction { /** * [住院]预交金缴费记录查询 * * @param begDate 开始日期 * @param endDate 结束日期 * @param patientId 患者id */ @Action("getPreMoneyList") public Result getPreMoneyList(String begDate, String endDate, String patientId) { log.info("[住院]预交金缴费记录查询, patientId={}", patientId); if (patientId == null || begDate == null || endDate == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } JsonResult resp = new HisInHospDao().getPreMoneyList(patientId); List resultList = new ArrayList<>(); if (!resp.success()) { log.info("[住院]交金缴费记录查询失败信息:{}", resp.getMessage()); return Result.success(resultList); } List list = resp.getDataMapList(InHosp.class, "Item"); String prepayDate; for (InHosp item : list) { prepayDate = item.getPrepayDate(); if (prepayDate != null) { prepayDate = DateHelper.dateFormatShort(prepayDate); if (prepayDate != null && DateHelper.inDateRange(begDate, endDate, prepayDate, DateHelper.DateEnum.yyyy_MM_dd)) { resultList.add(item); } } } return Result.success(resultList); } /** * [住院]查询住院日费用汇总 * * @param date 查询日期(空为查询所有) * @param patientId 患者id */ @Action("getInHospSumFee") public Result getInHospSumFee(String date, String patientId) { log.info("[住院]查询住院日费用汇总 patientId={}, date={}", patientId, date); if (patientId == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } JsonResult resp = new HisInHospDao().getInHospSumFee(patientId, date); if (!resp.success()) { return Result.error(resp.getMessage()); } InHospSummaryFee inHospSummaryFee = new InHospSummaryFee(); List items = resp.getDataMapList(InHospSummaryFeeItem.class, "Item"); inHospSummaryFee.setItems(items); inHospSummaryFee.setPatientId(resp.getDataMapString("PatientId")); inHospSummaryFee.setPatientName(resp.getDataMapString("PatientName")); inHospSummaryFee.setTreatNum(resp.getDataMapString("ZYNum")); inHospSummaryFee.setSex(resp.getDataMapString("Sex")); inHospSummaryFee.setStayDeptName(resp.getDataMapString("StayDeptName")); inHospSummaryFee.setAdmissionDate(resp.getDataMapString("AdmissionDate")); inHospSummaryFee.setDischargeDate(resp.getDataMapString("DischargeDate")); inHospSummaryFee.setLengthOfStay(resp.getDataMapString("LengthOfStay")); inHospSummaryFee.setSummaryFee(resp.getDataMapString("SummaryFee")); return Result.success(inHospSummaryFee); } /** * [住院]查询住院费用清单 * * @param date 查询日期(空为查询所有) * @param patientId 患者id */ @Action("getInHospFee") public Result getInHospFee(String date, String patientId) { log.info("[住院]查询住院费用清单 patientId={}, date={}", patientId, date); if (patientId == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } JsonResult resp = new HisInHospDao().getInHospFee(patientId, date); if (!resp.success()) { return Result.error(resp.getMessage()); } InHospFee inHospFee = new InHospFee(); List items = resp.getDataMapList(InHospFeeItem.class, "Item"); items.forEach(item -> { BigDecimal price = item.getPrice(); Integer count = item.getCount(); if (price != null && count != null) { item.setPayMoney(price.multiply(new BigDecimal(count))); } }); inHospFee.setItems(items); inHospFee.setPatientName(resp.getDataMapString("PatientName")); inHospFee.setAdmissionDate(resp.getDataMapString("AdmissionDate")); inHospFee.setAdmissionDeptName(resp.getDataMapString("AdmissionDeptName")); inHospFee.setStayDeptName(resp.getDataMapString("StayDeptName")); inHospFee.setAttendingPhysician(resp.getDataMapString("setAttendingPhysician")); inHospFee.setLengthOfStay(resp.getDataMapString("LengthOfStay")); inHospFee.setTotalHospitalization(resp.getDataMapBigDecimal("TotalHospitalization")); return Result.success(inHospFee); } /** * [住院]通过住院号查询患者信息(含预交金) * * @param treatNum 住院号 */ @Action("getInHospByTreatNum") public Result getInHospByTreatNum(String treatNum) { log.info("[住院]通过住院号查询患者信息(含预交金) treatNum={}", treatNum); if (treatNum == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } JsonResult resp = new HisInHospDao().getInHospByTreatNum(treatNum); if (!resp.success()) { return Result.error(resp.getMessage()); } InHosp inHosp = resp.dataMapToBean(InHosp.class); treatNum = resp.getDataMapString("InPatientNum"); inHosp.setTreatNum(treatNum); return Result.success(inHosp); } /** * [住院]通过患者ID查询在院患者信息 * * @param patientId 患者id * @param begDate 开始日期 * @param endDate 结束日期 * @param inHospState { 0 | null 查询所有;1:只查询在院记录; } */ @Action("getInHospByPatientId") public Result getInHospByPatientId(String patientId, String begDate, String endDate, String inHospState) { log.info("[住院]通过患者ID查询在院患者信息 patientId={}, endDate={}, endDate={}", patientId, begDate, endDate); if (patientId == null || begDate == null || endDate == null) { return Result.error(ResultEnum.PARAM_IS_DEFECT); } JsonResult resp = new HisInHospDao().getInHospByPatientId(patientId); if (!resp.success()) { return Result.error(resp.getMessage()); } InHosp inHosp = resp.dataMapToBean(InHosp.class, "InPatientInfo"); if (inHosp == null) { return Result.success(new InHosp()); } List records = resp.getDataMapList(InHosp.class, "InPatientInfo", "Items", "Item"); List resultList = new ArrayList<>(); String inDate; for (InHosp item : records) { if ("1".equals(inHospState)) { // 只查询在院记录 if (item.getOutDate() != null) { // 已出院 continue; } } inDate = item.getInDate(); if (inDate != null) { inDate = DateHelper.dateFormatShort(inDate); if (inDate != null && DateHelper.inDateRange(begDate, endDate, inDate, DateHelper.DateEnum.yyyy_MM_dd)) { item.setTreatNum(item.getInPatientNum()); resultList.add(item); } } } inHosp.setRecords(resultList); return Result.success(inHosp); } /** * [住院]通过患者ID查询患者所有住院记录 * @param patientId 患者Id * @return 住院记录 */ @Action("getHospListByPatientId") public Result getHospListByPatientId(String patientId) { log.info("[住院]通过患者ID查询患者所有住院记录, patientId-{}",patientId); if(patientId==null) return Result.error(ResultEnum.PARAM_IS_DEFECT); JsonResult resp = new HisInHospDao().getAllHospList(patientId); List inHospitalList = resp.getDataMapList(InHospitalList.class, "Items","Item"); return Result.success(inHospitalList); } /** * [住院]通过住院号查询所有费用明细 * @param treatNum 住院号 * @return 费用明细 */ @Action("getAllFeeByTreat") public Result getAllFeeByTreat(String treatNum){ log.info("[住院]通过住院号查询所有费用明细, treatNum-{}",treatNum); if(treatNum==null) return Result.error(ResultEnum.PARAM_IS_DEFECT); JsonResult resp = new HisInHospDao().getAllFee(treatNum); List inHospAllFee = resp.getDataMapList(InHospAllFee.class, "Items","Item"); return Result.success(inHospAllFee); } }