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.
281 lines
11 KiB
281 lines
11 KiB
package com.ynxbd.common.action;
|
|
|
|
import com.ynxbd.common.action.base.BaseAction;
|
|
import com.ynxbd.common.bean.in_hosp.*;
|
|
import com.ynxbd.common.config.interceptor.AesDecode;
|
|
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 com.ynxbd.wx.wxfactory.AesWxHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
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.Comparator;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* 住院接口
|
|
*
|
|
* @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, @AesDecode 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<InHosp> resultList = new ArrayList<>();
|
|
if (!resp.success()) {
|
|
log.info("[住院]交金缴费记录查询失败信息:{}", resp.getMessage());
|
|
return Result.success(resultList);
|
|
}
|
|
|
|
List<InHosp> 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, @AesDecode 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<InHospSummaryFeeItem> 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 treatNum 住院号
|
|
*/
|
|
@Action("getInHospByTreatNum")
|
|
public Result getInHospByTreatNum(@AesDecode 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("getInHospRecords")
|
|
public Result getInHospRecords(@AesDecode 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<InHosp> records = resp.getDataMapList(InHosp.class, "InPatientInfo", "Items", "Item");
|
|
|
|
List<InHosp> resultList = new ArrayList<>();
|
|
|
|
boolean hasHosp = "1".equals(inHospState);
|
|
String inDate;
|
|
for (InHosp item : records) {
|
|
if (hasHosp) { // 只查询在院记录
|
|
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());
|
|
item.setEnTreatNum(AesWxHelper.encode(item.getTreatNum()));
|
|
resultList.add(item);
|
|
}
|
|
}
|
|
}
|
|
inHosp.setRecords(resultList);
|
|
return Result.success(inHosp);
|
|
}
|
|
|
|
/**
|
|
* [住院]通过患者ID查询住院记录(出院后)
|
|
*
|
|
* @param patientId 患者Id
|
|
* @return 住院记录
|
|
*/
|
|
@Action("getOutHospRecords")
|
|
public Result getOutHospRecords(@AesDecode String patientId, String begDate, String endDate) {
|
|
log.info("[住院]通过患者ID查询住院记录(出院后) patientId={}, begDate={}, endDate={}", patientId, begDate, endDate);
|
|
if (patientId == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
JsonResult resp = new HisInHospDao().getAllHospList(patientId);
|
|
if (!resp.success()) {
|
|
return Result.error(resp.getMessage());
|
|
}
|
|
|
|
List<InHospitalList> dataList = resp.getDataMapList(InHospitalList.class, "Items", "Item");
|
|
|
|
boolean hasDateRange = (!ObjectUtils.isEmpty(begDate) && !ObjectUtils.isEmpty(endDate));
|
|
|
|
List<InHospitalList> records = new ArrayList<>();
|
|
String inHospitalDate, outHospitalDate;
|
|
for (InHospitalList item : dataList) {
|
|
if (hasDateRange) { // 有日期范围
|
|
inHospitalDate = item.getInHospitalDate();
|
|
outHospitalDate = item.getOutHospitalDate();
|
|
if ((!ObjectUtils.isEmpty(inHospitalDate) && DateHelper.inDateRange(begDate, endDate, inHospitalDate, DateHelper.DateEnum.yyyy_MM_dd)) ||
|
|
(!ObjectUtils.isEmpty(outHospitalDate) && DateHelper.inDateRange(begDate, endDate, outHospitalDate, DateHelper.DateEnum.yyyy_MM_dd))) {
|
|
item.setEnTreatNum(AesWxHelper.encode(item.getZyNum()));
|
|
records.add(item);
|
|
}
|
|
} else {
|
|
item.setEnTreatNum(AesWxHelper.encode(item.getZyNum()));
|
|
records.add(item);
|
|
}
|
|
}
|
|
|
|
records = records.stream().sorted(Comparator.comparing(InHospitalList::getInHospitalDate, Comparator.reverseOrder())).collect(Collectors.toList());
|
|
return Result.success(records);
|
|
}
|
|
|
|
/**
|
|
* [住院]查询住院费用清单(住院中)
|
|
*
|
|
* @param date 查询日期(空为查询所有)
|
|
* @param patientId 患者id
|
|
*/
|
|
@Action("getInPatientFee")
|
|
public Result getInPatientFee(@AesDecode String patientId, String date) {
|
|
log.info("[住院]查询住院费用清单 patientId={}, date={}", patientId, date);
|
|
if (patientId == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
JsonResult resp = new HisInHospDao().getInPatientFee(patientId, date);
|
|
if (!resp.success()) {
|
|
return Result.error(resp.getMessage());
|
|
}
|
|
|
|
InHospFee inHospFee = new InHospFee();
|
|
List<InHospFeeItem> items = resp.getDataMapList(InHospFeeItem.class, "Item");
|
|
items.forEach(item -> {
|
|
BigDecimal price = item.getPrice();
|
|
Integer count = item.getCount();
|
|
if (price != null && count != null) {
|
|
item.setMoney(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 住院号
|
|
* @return 费用明细
|
|
*/
|
|
@Action("getOutHospTreatFee")
|
|
public Result getOutHospTreatFee(@AesDecode String treatNum) {
|
|
log.info("[住院]通过住院号查询所有费用明细 treatNum={}", treatNum);
|
|
if (treatNum == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
JsonResult resp = new HisInHospDao().getOutHospTreatFee(treatNum);
|
|
if (!resp.success()) {
|
|
return Result.error(resp.getMessage());
|
|
}
|
|
List<InHospAllFee> dataList = resp.getDataMapList(InHospAllFee.class, "Items", "Item");
|
|
return Result.success(dataList);
|
|
}
|
|
}
|
|
|