Browse Source

新医保HIS接口

lighter 3 years ago
parent
commit
cb024a7e38

+ 6 - 0
src/main/java/thyyxxk/webserver/controller/nationalmatch/NationalMatchController.java

@@ -61,4 +61,10 @@ public class NationalMatchController {
     public ResultVo<String> updateNationalLib() {
         return service.updateNationalLib();
     }
+
+    @PassToken
+    @GetMapping("/dealMisMatchedItems")
+    public ResultVo<String> dealMisMatchedItems() {
+        return service.dealMisMatchedItems();
+    }
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/yibao/PatientController.java

@@ -52,6 +52,11 @@ public class PatientController {
         return service.getMedicineFees(param);
     }
 
+    @PostMapping("/getNotUploadedFees")
+    public ResultVo<Map<String, Object>> getNotUploadedFees(@RequestBody GetFeesParam param) {
+        return service.getNotUploadedFees(param);
+    }
+
     @PassToken
     @PostMapping("/queryYbRegisterInfo")
     public ResultVo<Object> queryYbRegisterInfo(@RequestBody YbRegisterInfoParam param) {

+ 2 - 2
src/main/java/thyyxxk/webserver/dao/his/makedbzfees/MakeDbzFeesDao.java

@@ -35,12 +35,12 @@ public interface MakeDbzFeesDao {
     @Insert("<script>" +
             "insert into zy_detail_charge (inpatient_no,admiss_times,ledger_sn,detail_sn,charge_date,op_id_code, " +
             "charge_code,infant_flag,charge_status,charge_amount,charge_fee,ward_code,dept_code,order_no,ope_flag, " +
-            "gen_time,charge_code_mx,serial,doctor_code,trans_flag_yb,refer_physician,consult_physician) VALUES " +
+            "gen_time,charge_code_mx,serial,doctor_code,trans_flag_yb,refer_physician,consult_physician,exec_unit) VALUES " +
             "<foreach collection='list' item='fee' separator=',' open='' close=''>" +
             "(#{info.inpatientNo}, #{info.admissTimes}, #{info.ledgerSn}, #{fee.detailSn}, getDate(), #{info.staffId}, " +
             "#{fee.chargeCode}, 0, 2, #{fee.chargeAmount}, #{fee.chargeFee}, #{info.wardCode}, #{info.deptCode}, 1, " +
             "#{info.operation},getDate(), #{fee.chargeCodeMx},#{fee.serial},#{fee.doctorCode},0,#{info.referPhysician}," +
-            "#{info.consultPhysician})" +
+            "#{info.consultPhysician},#{fee.execDept})" +
             "</foreach>" +
             "</script>")
     void insertInfoZyDetailCharge(@Param("info") InpatientInfo info, @Param("list")List<ZyDetailCharge> zyFees);

+ 49 - 0
src/main/java/thyyxxk/webserver/dao/his/nationalmatch/NationalMatchDao.java

@@ -146,4 +146,53 @@ public interface NationalMatchDao {
                       @Param("factory") String factory,
                       @Param("specification") String specification,
                       @Param("code") String code);
+
+
+
+    @Select("select a.code,a.serial,a.new_name as name," +
+            "a.national_code,a.national_name,a.uploaded_flag, " +
+            "unit=(select name from yp_zd_unit where yp_zd_unit.code=a.dosage_unit), " +
+            "dosage=(select name from yp_zd_dosage where yp_zd_dosage.code=a.dosage), " +
+            "ltrim(a.specification) as specification,rtrim(a.pzwh) as approvalNumber, " +
+            "factory=(select name from yp_zd_manufactory where yp_zd_manufactory.code=a.manu_code) " +
+            "from yp_zd_dict a, (select max(serial) as serial,code from yp_zd_dict where isnull(visible_flag,0)=0 " +
+            "and isnull(del_flag,0)=0 group by code) b,yp_base c " +
+            "where isnull(national_status,0)=1 and a.code=b.code and a.serial=b.serial " +
+            "and c.group_no=11 and a.code=c.charge_code and a.drug_kind in " +
+            "(select code from yp_zd_drug_kind where yp_type in (1,2)) ")
+    List<StandardLocalItem> selectAllLocalMedicines();
+
+    @Select("select a.code,a.serial,a.new_name as name," +
+            "a.national_code,a.national_name,a.uploaded_flag, " +
+            "unit=(select name from yp_zd_unit where yp_zd_unit.code=a.dosage_unit), " +
+            "dosage=(select name from yp_zd_dosage where yp_zd_dosage.code=a.dosage), " +
+            "ltrim(a.specification) as specification,rtrim(a.pzwh) as approvalNumber, " +
+            "factory=(select name from yp_zd_manufactory where yp_zd_manufactory.code=a.manu_code) " +
+            "from yp_zd_dict a, (select max(serial) as serial,code from yp_zd_dict where isnull(visible_flag,0)=0 " +
+            "and isnull(del_flag,0)=0 group by code) b,yp_base c " +
+            "where isnull(national_status,0)=1 and a.code=b.code and a.serial=b.serial " +
+            "and c.group_no=22 and a.code=c.charge_code and a.drug_kind in ('0007','0003') ")
+    List<StandardLocalItem> selectAllLocalHerbals();
+
+    @Select("select code,new_name as name,charge_unit as unit,discription,specification," +
+            "national_code,uploaded_flag,national_name,yb_comment as factory from zd_charge_item " +
+            "where isnull(national_status,0)=1 and isnull(del_flag,0)=0 and class_code='J' ")
+    List<StandardLocalItem> selectAllLocalSupplies();
+
+    @Select("select code,new_name as name,charge_unit as unit, discription,specification,uploaded_flag," +
+            "national_code,national_name,s_code as standardCode, charge_amount as price from zd_charge_item " +
+            "where isnull(national_status,0)=1 and isnull(del_flag,0)=0 and class_code!='J'")
+    List<StandardLocalItem> selectAllLocalServices();
+
+    @Select("select * from si_central_medicine where national_code=#{code}")
+    List<SiCentralMedicine> selectNationalMedicinesByCode(@Param("code") String code);
+
+    @Select("select * from si_central_herbal_new where national_code=#{code}")
+    List<SiCentralHerbal> selectNationalHerbalsByCode(@Param("code") String code);
+
+    @Select("select * from si_central_services where national_code=#{code}")
+    List<SiCentralServices> selectNationalServicesByCode(@Param("code") String code);
+
+    @Select("select * from si_central_supplies_mini where national_code=#{code}")
+    List<SiCentralSuppliesMini> selectNationalSuppliesByCode(@Param("code") String code);
 }

+ 22 - 0
src/main/java/thyyxxk/webserver/dao/his/yibao/Routines.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.yibao.patient.Fee;
 import thyyxxk.webserver.entity.yibao.patient.FeeCounteract;
+import thyyxxk.webserver.entity.yibao.patient.NotUploadedFee;
 import thyyxxk.webserver.entity.yibao.patient.Overview;
 
 import java.util.Date;
@@ -238,6 +239,27 @@ public interface Routines {
                                       @Param("admissTimes") Integer admissTimes,
                                       @Param("ledgerSn") Integer ledgerSn);
 
+    @Select("select detail_sn,charge_code_mx,charge_amount,charge_fee,charge_date,yb_self_flag, " +
+            "yb_code=(select max(national_code) from ${zdTable} where code=charge_code_mx), " +
+            "charge_name=(select top 1 rtrim(name) from ${zdTable} where code=charge_code_mx) " +
+            "from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} and " +
+            "ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)=0 and isnull(serial,'') in (#{serial1},#{serial2})")
+    IPage<NotUploadedFee> selectNotUploadedFees(IPage<NotUploadedFee> iPage,
+                                                @Param("zdTable") String zdTable,
+                                                @Param("patNo") String patNo,
+                                                @Param("times") int times,
+                                                @Param("ledgerSn") int ledgerSn,
+                                                @Param("serial1") String serial1,
+                                                @Param("serial2") String serial2);
+
+    @Select("select sum(charge_fee) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} and " +
+            "ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)=0 and isnull(serial,'') in (#{serial1},#{serial2})")
+    String selectSumChargeFee(@Param("patNo") String patNo,
+                              @Param("times") int times,
+                              @Param("ledgerSn") int ledgerSn,
+                              @Param("serial1") String serial1,
+                              @Param("serial2") String serial2);
+
     @Update("update zy_actpatient set yb_register_date=#{date} where inpatient_no=#{inpatientNo}")
     void updateYbRegisterDate(@Param("inpatientNo") String inpatientNo, @Param("date") Date date);
 

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/makedbzfees/ZyDetailCharge.java

@@ -18,5 +18,6 @@ public class ZyDetailCharge implements Serializable {
     private Double chargeAmount;
     private String serial;
     private String doctorCode;
+    private String execDept;
     private BigDecimal retPrice;
 }

+ 4 - 0
src/main/java/thyyxxk/webserver/entity/yibao/patient/GetFeesParam.java

@@ -14,4 +14,8 @@ public class GetFeesParam {
     private Integer ledgerSn;
     private Integer currentPage;
     private Integer pageSize;
+    // todo 启用新医保后,上面的字段酌情删除
+    private String patNo;
+    private Integer times;
+    private String zdTable;
 }

+ 25 - 0
src/main/java/thyyxxk/webserver/entity/yibao/patient/NotUploadedFee.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.entity.yibao.patient;
+
+import lombok.Data;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.util.Date;
+
+@Data
+public class NotUploadedFee {
+    private Integer detailSn;
+    private String chargeCodeMx;
+    private String chargeAmount;
+    private String chargeFee;
+    private Date chargeDate;
+    private String ybCode;
+    private String chargeName;
+    private String ybSelfFlag;
+
+    public String getYbSelfFlag() {
+        if (StringUtil.isBlank(ybSelfFlag)) {
+            return "是";
+        }
+        return "0".equals(ybSelfFlag.trim()) ? "是" : "否";
+    }
+}

+ 1 - 0
src/main/java/thyyxxk/webserver/service/makedbzfees/MakeDbzFeesService.java

@@ -141,6 +141,7 @@ public class MakeDbzFeesService {
             zyFee.setChargeAmount(mzFee.getQuantity());
             zyFee.setSerial(mzFee.getSerial());
             zyFee.setDoctorCode(mzFee.getDoctorCode());
+            zyFee.setExecDept(mzFee.getExecDept());
             zyFees.add(zyFee);
         }
         batchIntoZyDetailCharge(zyFees, inpatientInfo);

+ 48 - 0
src/main/java/thyyxxk/webserver/service/nationalmatch/NationalMatchService.java

@@ -20,6 +20,7 @@ import thyyxxk.webserver.utils.TokenUtil;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @description: 新医保国家目录匹配Service
@@ -162,4 +163,51 @@ public class NationalMatchService {
         }
         return ResultVoUtil.success();
     }
+
+    public ResultVo<String> dealMisMatchedItems() {
+        AtomicInteger count = new AtomicInteger();
+        log.info("获取HIS西药药品中...");
+        List<StandardLocalItem> localItems = dao.selectAllLocalMedicines();
+        localItems.forEach(itm -> {
+            List<SiCentralMedicine> nationItems = dao.selectNationalMedicinesByCode(itm.getNationalCode());
+            log.info("处理:【{}】【{}】【{}】 结果:{}", itm.getCode(), itm.getNationalCode(), itm.getName(), nationItems.size());
+            if (nationItems.isEmpty()) {
+                dao.cancelMatchYp(itm.getCode(), itm.getSerial(), "99999");
+                count.getAndIncrement();
+            }
+        });
+        log.info("获取HIS中药药品中...");
+        localItems = dao.selectAllLocalHerbals();
+        localItems.forEach(itm -> {
+            List<SiCentralHerbal> nationItems = dao.selectNationalHerbalsByCode(itm.getNationalCode());
+            log.info("处理:【{}】【{}】【{}】 结果:{}", itm.getCode(), itm.getNationalCode(), itm.getName(), nationItems.size());
+            if (nationItems.isEmpty()) {
+                dao.cancelMatchYp(itm.getCode(), itm.getSerial(), "99999");
+                count.getAndIncrement();
+            }
+        });
+        log.info("获取HIS医疗项目中...");
+        localItems = dao.selectAllLocalServices();
+        localItems.forEach(itm -> {
+            List<SiCentralServices> nationItems = dao.selectNationalServicesByCode(itm.getNationalCode());
+            log.info("处理:【{}】【{}】【{}】 结果:{}", itm.getCode(), itm.getNationalCode(), itm.getName(), nationItems.size());
+            if (nationItems.isEmpty()) {
+                dao.cancelMatchXm(itm.getCode(),"99999");
+                count.getAndIncrement();
+            }
+        });
+        log.info("获取HIS医用耗材中...");
+        localItems = dao.selectAllLocalSupplies();
+        localItems.forEach(itm -> {
+            List<SiCentralSuppliesMini> nationItems = dao.selectNationalSuppliesByCode(itm.getNationalCode());
+            log.info("处理:【{}】【{}】【{}】 结果:{}", itm.getCode(), itm.getNationalCode(), itm.getName(), nationItems.size());
+            if (nationItems.isEmpty()) {
+                dao.cancelMatchXm(itm.getCode(),"99999");
+                count.getAndIncrement();
+            }
+        });
+        String message = "清理完成,已清理数据条目:" + count.get();
+        log.info(message);
+        return ResultVoUtil.success(message);
+    }
 }

+ 20 - 0
src/main/java/thyyxxk/webserver/service/yibao/PatientService.java

@@ -33,6 +33,8 @@ import static thyyxxk.webserver.utils.FilterUtil.cast;
 public class PatientService {
     private final PatientDao dao;
     private final Routines routines;
+    private static final String ZD_PRJCT = "zd_item_charge";
+    private static final String ZD_MEDCN = "yp_zd_dict";
 
     @Autowired
     public PatientService(PatientDao dao, Routines routines) {
@@ -133,6 +135,24 @@ public class PatientService {
         return ResultVoUtil.success(map);
     }
 
+    public ResultVo<Map<String, Object>> getNotUploadedFees(GetFeesParam param) {
+        int ledgerSn = routines.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes());
+        IPage<NotUploadedFee> iPage = new Page<>(param.getCurrentPage(), param.getPageSize());
+        Map<String, Object> map = new HashMap<>(Capacity.THREE);
+        String serial1 = "00";
+        String serial2 = "";
+        if (param.getZdTable().equals(ZD_MEDCN)) {
+            serial1 = "01";
+            serial2 = "99";
+        }
+        iPage = routines.selectNotUploadedFees(iPage, param.getZdTable(), param.getPatNo(), param.getTimes(),
+                ledgerSn, serial1, serial2);
+        map.put("totalSize", iPage.getTotal());
+        map.put("list", iPage.getRecords());
+        map.put("sum", routines.selectSumChargeFee(param.getPatNo(), param.getTimes(), ledgerSn, serial1, serial2));
+        return ResultVoUtil.success(map);
+    }
+
     private String calculateSumFee(List<Fee> fees) {
         String sum = "0.00";
         for (Fee fee : fees) {

+ 0 - 1
src/main/java/thyyxxk/webserver/utils/SiUtil.java

@@ -15,7 +15,6 @@ import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 import java.io.BufferedReader;
 import java.io.FileReader;
-import java.io.UnsupportedEncodingException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 

+ 70 - 35
src/main/java/thyyxxk/webserver/utils/TestClass.java

@@ -2,56 +2,91 @@ package thyyxxk.webserver.utils;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
 
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Consumer;
 
 /**
  * 物品领用的格式化
  * */
 public class TestClass {
+    private static final Map<String, Consumer<String>> FUNC_MAP = new ConcurrentHashMap<>();
+    private static final String MAN = "man";
+    private static final String WOMAN = "woman";
+    private static final String NONE = "";
 
-    public static void main(String[] args) {
-        String ori = readFile("D:\\yyhc.txt");
-        JSONArray arr = JSONArray.parseArray(ori);
-        Map<String, JSONObject> map = new HashMap<>();
-        for (int i = 0; i < arr.size(); i++) {
-            JSONObject itm = arr.getJSONObject(i);
-            if (!map.containsKey(itm.getString("code"))) {
-                JSONArray sizes = new JSONArray();
-                JSONObject size = new JSONObject();
-                size.put("val", itm.getString("size"));
-                sizes.add(size);
-                itm.replace("size", sizes);
-                map.put(itm.getString("code"), itm);
-            } else {
-                JSONObject size = new JSONObject();
-                size.put("val", itm.getString("size"));
-                map.get(itm.getString("code")).getJSONArray("size").add(size);
-            }
-        }
+    static {
+        FUNC_MAP.put(MAN, person -> System.out.println(person + "是男人。"));
+        FUNC_MAP.put(WOMAN, person -> System.out.println(person + "是女人。"));
+        FUNC_MAP.put(NONE, person -> System.out.println(person + "没有性别。"));
+    }
 
-        JSONArray dest = new JSONArray();
-        for (Map.Entry<String, JSONObject> entry : map.entrySet()) {
-            dest.add(entry.getValue());
+    @Data
+    static class Person {
+        private String gender;
+        private String name;
+
+        public Person(String gender, String name) {
+            this.gender = null == gender ? "" : gender;
+            this.name = name;
         }
-        System.out.println(dest);
     }
 
-    public static String readFile(String path) {
-        StringBuilder result = new StringBuilder();
-        try {
-            BufferedReader br = new BufferedReader(new FileReader(new File(path)));
-            String temp;
-            while ((temp = br.readLine()) != null) {
-                result.append(temp);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return result.toString();
+    public static void main(String[] args) {
+        Person p = new Person(MAN, "张三");
+        Person p2 = new Person(WOMAN, "李四");
+        Person p3 = new Person(null, "王五");
+
+        FUNC_MAP.get(p.getGender()).accept(p.getName());
+        FUNC_MAP.get(p2.getGender()).accept(p2.getName());
+        FUNC_MAP.get(p3.getGender()).accept(p3.getName());
+
     }
+
+//    public static void main(String[] args) {
+//        String ori = readFile("D:\\yyhc.txt");
+//        JSONArray arr = JSONArray.parseArray(ori);
+//        Map<String, JSONObject> map = new HashMap<>();
+//        for (int i = 0; i < arr.size(); i++) {
+//            JSONObject itm = arr.getJSONObject(i);
+//            if (!map.containsKey(itm.getString("code"))) {
+//                JSONArray sizes = new JSONArray();
+//                JSONObject size = new JSONObject();
+//                size.put("val", itm.getString("size"));
+//                sizes.add(size);
+//                itm.replace("size", sizes);
+//                map.put(itm.getString("code"), itm);
+//            } else {
+//                JSONObject size = new JSONObject();
+//                size.put("val", itm.getString("size"));
+//                map.get(itm.getString("code")).getJSONArray("size").add(size);
+//            }
+//        }
+//
+//        JSONArray dest = new JSONArray();
+//        for (Map.Entry<String, JSONObject> entry : map.entrySet()) {
+//            dest.add(entry.getValue());
+//        }
+//        System.out.println(dest);
+//    }
+//
+//    public static String readFile(String path) {
+//        StringBuilder result = new StringBuilder();
+//        try {
+//            BufferedReader br = new BufferedReader(new FileReader(new File(path)));
+//            String temp;
+//            while ((temp = br.readLine()) != null) {
+//                result.append(temp);
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return result.toString();
+//    }
 }