Kaynağa Gözat

费用录入查询

lighter 2 yıl önce
ebeveyn
işleme
60c886ce3c

+ 33 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyiji/ChargeInputInquiryController.java

@@ -0,0 +1,33 @@
+package thyyxxk.webserver.controller.zhuyuanyiji;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.inpatient.FeeSelect;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.AnalyzedInputItems;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.InquiryParams;
+import thyyxxk.webserver.service.zhuyuanyiji.ChargeInputInquiryService;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/chargeInputInquiry")
+public class ChargeInputInquiryController {
+    private final ChargeInputInquiryService service;
+
+    @Autowired
+    public ChargeInputInquiryController(ChargeInputInquiryService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/selectCharges")
+    public ResultVo<List<FeeSelect>> selectCharges(@RequestParam("type") Integer type,
+                                                   @RequestParam("content") String content) {
+        return service.selectCharges(type, content);
+    }
+
+    @PostMapping("/selectInputItems")
+    public ResultVo<AnalyzedInputItems> selectInputItems(@RequestBody InquiryParams params) {
+        return service.selectInputItems(params);
+    }
+}

+ 81 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyiji/ChargeInputInquiryDao.java

@@ -0,0 +1,81 @@
+package thyyxxk.webserver.dao.his.zhuyuanyiji;
+
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.inpatient.FeeSelect;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.ChargeInputItem;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.InquiryParams;
+
+import java.util.List;
+
+public interface ChargeInputInquiryDao {
+
+    @Select("select distinct code,name,specification=N'诊疗项目', " +
+            "manufactor=(select d.name from yp_zd_manufactory d where manu_code=d.code) from zd_charge_item  " +
+            "where (py_code like #{content} or code like #{content} or name like #{content})")
+    List<FeeSelect> selectProjectCharges(String content);
+
+    @Select("select distinct code,name,specification, " +
+            "manufactor=(select d.name from yp_zd_manufactory d where manu_code=d.code) from yp_zd_dict " +
+            "where (py_code like #{content} or code like #{content} or name like #{content})")
+    List<FeeSelect> selectMedicineCharges(String content);
+
+    @Select("select rtrim(dept_code) from a_employee_mi where code=#{code}")
+    String selectUserDept(String code);
+
+    @Select("select rtrim(a.inpatient_no) as patNo,a.admiss_times as times,a.ledger_sn,a.detail_sn, " +
+            "staffName=(select rtrim(e.name) from a_employee_mi e where e.code=a.op_id_code), " +
+            "a.charge_fee,a.charge_date,inOutFlag=1,orderNo=cast(cast(a.order_no as decimal) as varchar),a.charge_amount,a.gen_time, " +
+            "chargeStatus=case when a.charge_status='2' then N'上账' when a.charge_status='3' then N'结算' else N'录入' end, " +
+            "deptName=(select e.name from zd_unit_code e where e.code=a.ward_code), " +
+            "opeFlag=case when a.ope_flag='1' then N'是' else N'否' end, " +
+            "a.charge_code_mx,a.serial,patName=b.name,spec=c.specification,drugName=c.name,orderName=c.name " +
+            "FROM zy_detail_charge a with (nolock),a_patient_mi b with (nolock),yp_zd_dict c with (nolock),zy_actpatient d with (nolock) " +
+            "where a.charge_code in ('BILL01','BILL02','BILL28') and a.inpatient_no=b.inpatient_no  " +
+            "and a.charge_code_mx=c.code and a.serial=c.serial and a.inpatient_no=d.inpatient_no  " +
+            "and a.admiss_times=d.admiss_times and a.gen_time>=#{start} and a.gen_time<=#{end} " +
+            "and a.inpatient_no like '${patNo}' and a.charge_code_mx like '${chargeCode}' " +
+            "and a.op_id_code in (select code from a_employee_mi where dept_code=#{dept}) " +
+            "union all " +
+            "select rtrim(a.inpatient_no) as patNo,a.admiss_times as times,a.ledger_sn,a.detail_sn, " +
+            "staffName=(select rtrim(e.name) from a_employee_mi e where e.code=a.op_id_code), " +
+            "a.charge_fee,a.charge_date,inOutFlag=2,orderNo=cast(cast(a.order_no as decimal) as varchar),a.charge_amount,a.gen_time, " +
+            "chargeStatus=case when a.charge_status='2' then N'上账' when a.charge_status='3' then N'结算' else N'录入' end, " +
+            "deptName=(select e.name from zd_unit_code e where e.code=a.ward_code), " +
+            "opeFlag=case when a.ope_flag='1' then N'是' else N'否' end, " +
+            "a.charge_code_mx,a.serial,patName=b.name,spec=c.specification,drugName=c.name,orderName=c.name " +
+            "FROM zy_detail_charge a with (nolock),a_patient_mi b with (nolock), " +
+            "yp_zd_dict c with (nolock),zy_inactpatient d with (nolock) " +
+            "where a.charge_code in ('BILL01','BILL02','BILL28') and a.inpatient_no=b.inpatient_no  " +
+            "and a.charge_code_mx=c.code and a.serial=c.serial and a.inpatient_no=d.inpatient_no  " +
+            "and a.admiss_times=d.admiss_times and a.gen_time>=#{start} and a.gen_time<=#{end} " +
+            "and a.inpatient_no like '${patNo}' and a.charge_code_mx like '${chargeCode}' " +
+            "and a.op_id_code in (select code from a_employee_mi where dept_code=#{dept}) ")
+    List<ChargeInputItem> selectMedicineInputItems(InquiryParams params);
+
+    @Select("SELECT rtrim(a.inpatient_no) as patNo,a.admiss_times as times,a.ledger_sn,a.detail_sn, " +
+            "staffName=(select rtrim(e.name) from a_employee_mi e where e.code=a.op_id_code), " +
+            "chargeStatus=case when a.charge_status='2' then N'上账' when a.charge_status='3' then N'结算' else N'录入' end, " +
+            "deptName=(select e.name from zd_unit_code e where e.code=a.ward_code), " +
+            "orderNo=cast(cast(a.order_no as decimal) as varchar),a.charge_amount,a.gen_time,a.charge_code_mx,a.charge_fee,a.charge_date, " +
+            "opeFlag=case when a.ope_flag='1' then N'是' else N'否' end, " +
+            "a.serial,patName=b.name,spec=c.charge_unit,drugName=c.name,orderName=c.name,c.class_code,inOutFlag=1 " +
+            "FROM zy_detail_charge a with (nolock),a_patient_mi b with (nolock),zd_charge_item c with (nolock),zy_actpatient d with (nolock) " +
+            "where a.charge_code not in ('BILL01','BILL02','BILL03','BILL28')  and a.inpatient_no=b.inpatient_no " +
+            "and a.charge_code=c.code and a.inpatient_no=d.inpatient_no and a.admiss_times=d.admiss_times " +
+            "and a.gen_time>=#{start} and a.gen_time<=#{end} and a.charge_code_mx like '${chargeCode}' " +
+            "and a.inpatient_no like '${patNo}' and a.op_id_code in (select code from a_employee_mi where dept_code=#{dept}) " +
+            "union all " +
+            "SELECT rtrim(a.inpatient_no) as patNo,a.admiss_times as times,a.ledger_sn,a.detail_sn, " +
+            "staffName=(select rtrim(e.name) from a_employee_mi e where e.code=a.op_id_code), " +
+            "chargeStatus=case when a.charge_status='2' then N'上账' when a.charge_status='3' then N'结算' else N'录入' end, " +
+            "deptName=(select e.name from zd_unit_code e where e.code=a.ward_code), " +
+            "orderNo=cast(cast(a.order_no as decimal) as varchar),a.charge_amount,a.gen_time,a.charge_code_mx,a.charge_fee,a.charge_date, " +
+            "opeFlag=case when a.ope_flag='1' then N'是' else N'否' end, " +
+            "a.serial,patName=b.name,spec=c.charge_unit,drugName=c.name,orderName=c.name,c.class_code,inOutFlag=2 " +
+            "FROM zy_detail_charge a with (nolock),a_patient_mi b with (nolock),zd_charge_item c with (nolock),zy_inactpatient d with (nolock) " +
+            "where a.charge_code not in ('BILL01','BILL02','BILL03','BILL28')  and a.inpatient_no=b.inpatient_no " +
+            "and a.charge_code=c.code and a.inpatient_no=d.inpatient_no and a.admiss_times=d.admiss_times " +
+            "and a.gen_time>=#{start} and a.gen_time<=#{end} and a.charge_code_mx like '${chargeCode}' " +
+            "and a.inpatient_no like '${patNo}' and a.op_id_code in (select code from a_employee_mi where dept_code=#{dept}) ")
+    List<ChargeInputItem> selectProjectInputItems(InquiryParams params);
+}

+ 14 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargeinputinquiry/AnalyzedInputItems.java

@@ -0,0 +1,14 @@
+package thyyxxk.webserver.entity.inpatient.chargeinputinquiry;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+@Data
+public class AnalyzedInputItems {
+    private BigDecimal sumChargeAmount;
+    private BigDecimal sumChargeFee;
+    private Map<String, List<ChargeInputItem>> chargeItems;
+}

+ 31 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargeinputinquiry/ChargeInputItem.java

@@ -0,0 +1,31 @@
+package thyyxxk.webserver.entity.inpatient.chargeinputinquiry;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class ChargeInputItem {
+    private String patNo;
+    private Integer times;
+    private Integer ledgerSn;
+    private Integer detailSn;
+    private Integer inOutFlag;
+    private String staffName;
+    private BigDecimal chargeAmount;
+    private BigDecimal chargeFee;
+    private Date chargeDate;
+    private Date genTime;
+    private String chargeStatus;
+    private String deptName;
+    private String orderNo;
+    private String opeFlag;
+    private String chargeCodeMx;
+    private String serial;
+    private String patName;
+    private String spec;
+    private String drugName;
+    private String orderName;
+    private String classCode;
+}

+ 30 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargeinputinquiry/InquiryParams.java

@@ -0,0 +1,30 @@
+package thyyxxk.webserver.entity.inpatient.chargeinputinquiry;
+
+import lombok.Data;
+import thyyxxk.webserver.utils.StringUtil;
+
+@Data
+public class InquiryParams {
+    private Integer type;
+    private String patNo;
+    private String chargeCode;
+    private String start;
+    private String end;
+    private String dept;
+
+    public String getPatNo() {
+        return StringUtil.isBlank(patNo) ? "%%" : patNo;
+    }
+
+    public String getChargeCode() {
+        return StringUtil.isBlank(chargeCode) ? "%%" : chargeCode;
+    }
+
+    public String getStart() {
+        return start + " 00:00:00.000";
+    }
+
+    public String getEnd() {
+        return end + " 23:59:59.999";
+    }
+}

+ 71 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/ChargeInputInquiryService.java

@@ -0,0 +1,71 @@
+package thyyxxk.webserver.service.zhuyuanyiji;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.zhuyuanyiji.ChargeInputInquiryDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.inpatient.FeeSelect;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.AnalyzedInputItems;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.ChargeInputItem;
+import thyyxxk.webserver.entity.inpatient.chargeinputinquiry.InquiryParams;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class ChargeInputInquiryService {
+    private final ChargeInputInquiryDao dao;
+
+    @Autowired
+    public ChargeInputInquiryService(ChargeInputInquiryDao dao) {
+        this.dao = dao;
+    }
+
+    public ResultVo<List<FeeSelect>> selectCharges(Integer type, String content) {
+        content = "%" + content.toUpperCase() + "%";
+        List<FeeSelect> list = type == 1 ? dao.selectMedicineCharges(content) : dao.selectProjectCharges(content);
+        return ResultVoUtil.success(list);
+    }
+
+    public ResultVo<AnalyzedInputItems> selectInputItems(InquiryParams params) {
+        if (StringUtil.isBlank(params.getDept())) {
+            String dept = dao.selectUserDept(TokenUtil.getTokenUserId());
+            if (StringUtil.isBlank(dept)) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                        "没有找到您的科室编码,请联系人力资源部确认您的科室信息是否有效。");
+            }
+        }
+        List<ChargeInputItem> raws = params.getType() == 1 ?
+                dao.selectMedicineInputItems(params) : dao.selectProjectInputItems(params);
+        if (raws.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        AnalyzedInputItems result = new AnalyzedInputItems();
+        BigDecimal sumChargeAmount = BigDecimal.ZERO;
+        BigDecimal sumChargeFee = BigDecimal.ZERO;
+        Map<String, List<ChargeInputItem>> chargeItems = new HashMap<>();
+        for (ChargeInputItem raw : raws) {
+            sumChargeAmount = sumChargeAmount.add(raw.getChargeAmount());
+            sumChargeFee = sumChargeFee.add(raw.getChargeFee());
+            String mapKey = raw.getPatNo() + "^" + raw.getTimes() + "^" + raw.getPatName();
+            if (chargeItems.containsKey(mapKey)) {
+                chargeItems.get(mapKey).add(raw);
+                continue;
+            }
+            List<ChargeInputItem> tempList = new ArrayList<>();
+            tempList.add(raw);
+            chargeItems.put(mapKey, tempList);
+        }
+        result.setSumChargeAmount(sumChargeAmount);
+        result.setSumChargeFee(sumChargeFee);
+        result.setChargeItems(chargeItems);
+        return ResultVoUtil.success(result);
+    }
+}