浏览代码

lis 系统接口改造第一步,门诊未确认费用查询

hurugang 2 年之前
父节点
当前提交
650aa1f5ed

+ 59 - 4
src/main/java/cn/hnthyy/thmz/Utils/DateUtil.java

@@ -9,10 +9,7 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * 日期工具类
@@ -531,6 +528,64 @@ public class DateUtil {
 
 
 
+
+    /**
+     * 获取年龄与年龄单位描述
+     * @param fromDate  1988-10-24 00:00:00
+     * @return
+     */
+    public static Map<String,Object> getAgeAndUnit(Date fromDate){
+        if(fromDate==null){
+            return null;
+        }
+        Calendar  from  =  Calendar.getInstance();
+        from.setTime(fromDate);
+        Calendar  to  =  Calendar.getInstance();
+        int fromYear = from.get(Calendar.YEAR);
+        int fromMonth = from.get(Calendar.MONTH);
+        int fromDay = from.get(Calendar.DAY_OF_MONTH);
+        int toYear = to.get(Calendar.YEAR);
+        int toMonth = to.get(Calendar.MONTH);
+        int toDay = to.get(Calendar.DAY_OF_MONTH);
+        int year = toYear  -  fromYear;
+        int month = toMonth  - fromMonth;
+        int day = toDay  - fromDay;
+        //按照减法原理,先day相减,不够向month借;然后month相减,不够向year借;最后year相减。
+        Calendar now = Calendar.getInstance();
+        if (day <0) {
+            month -=1;
+            now.add(Calendar.MONTH, -1);//得到上一个月,用来得到上个月的天数。
+            day = day + now.getActualMaximum(Calendar.DAY_OF_MONTH);
+        }
+        if (month <0) {
+            month = (month +12) %12;
+            year--;
+        }
+      Map<String,Object> map = new HashMap<>();
+        if (year >0) {
+            map.put("age",year);
+            map.put("ageUnit","岁");
+            return map;
+        }
+        if (month >0) {
+            map.put("age",month);
+            map.put("ageUnit","月");
+            return map;
+        }
+        if (day >0) {
+            map.put("age",day);
+            map.put("ageUnit","天");
+            return map;
+        }
+        if (year ==0 && month ==0 && day ==0) {
+            map.put("age",1);
+            map.put("ageUnit","天");
+            return map;
+        }
+        return null;
+    }
+
+
     /**
      * 获取出生日期  yyyy年MM月dd日
      * @param IDCard

+ 78 - 0
src/main/java/cn/hnthyy/thmz/controller/api/LisApiController.java

@@ -0,0 +1,78 @@
+package cn.hnthyy.thmz.controller.api;
+
+import cn.hnthyy.thmz.entity.MzException;
+import cn.hnthyy.thmz.service.his.zd.JcJyItemChargeService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/v1")
+@Slf4j
+public class LisApiController {
+    @Autowired
+    private JcJyItemChargeService jcJyItemChargeService;
+
+
+    /**
+     * 查询门诊未确认的检验申请
+     *
+     * @param params
+     * @return
+     */
+    @RequestMapping(value = "/interfaceHisLisMz", method = {RequestMethod.POST})
+    public Map<String, Object> interfaceHisLisMz(@RequestBody Map<String, String> params) {
+        Map<String, Object> results = new HashMap<>();
+        try {
+            if (params == null) {
+                results.put("resultCode", -1);
+                results.put("resultMessage", "查询参数不能为空");
+                return results;
+            }
+            String patientId = params.get("patientId");
+            String printJy = params.get("printJy");
+            String beninTime = params.get("beninTime");
+            String endTime = params.get("endTime");
+            if (StringUtils.isBlank(patientId)) {
+                results.put("resultCode", -1);
+                results.put("resultMessage", "患者门诊ID不能为空");
+                return results;
+            }
+            if (StringUtils.isBlank(printJy)) {
+                results.put("resultCode", -1);
+                results.put("resultMessage", "接收标志不能为空");
+                return results;
+            }
+            if (StringUtils.isBlank(beninTime)) {
+                results.put("resultCode", -1);
+                results.put("resultMessage", "开始时间不能为空");
+                return results;
+            }
+            if (StringUtils.isBlank(endTime)) {
+                results.put("resultCode", -1);
+                results.put("resultMessage", "结束时间不能为空");
+                return results;
+            }
+            results.put("resultCode", 0);
+            results.put("resultMessage", "查询门诊未确认的检验申请成功");
+            results.put("data", jcJyItemChargeService.interfaceHisLisMz(patientId, printJy, beninTime, endTime));
+            return results;
+        } catch (MzException me) {
+            results.put("resultCode", -1);
+            results.put("resultMessage", me.getMessage());
+            return results;
+        } catch (Exception e) {
+            e.printStackTrace();
+            results.put("resultCode", -1);
+            results.put("resultMessage", "系统异常,请联系his工程师");
+            return results;
+        }
+    }
+}

+ 58 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzYjReqMapper.java

@@ -422,4 +422,62 @@ public interface MzYjReqMapper {
     @Select("select top 1  page_no from  mz_yj_req order by page_no desc")
     String selectLastPageNo();
 
+
+    /**
+     * 查询门诊未确认的检验申请
+     *
+     * @param patientId
+     * @param printJy
+     * @param beninTime
+     * @param endTime
+     * @return
+     */
+    @Select("select " +
+            " req_no as aply_id, " +
+            " 0 as aply_src, " +
+            " convert(varchar(20),req_date,120) as aply_create_date, " +
+            " patient_id as ptnt_id, " +
+            " 0 as ptnt_src, " +
+            " '0_'+patient_id as ptnt_pk, " +
+            " '0' as ptnt_no_type, " +
+            " convert(varchar(10),req_date,111) as admisse_date, " +
+            " 0 as dept_id, " +
+            " 0 as doc_id, " +
+            " '' as diag_info, " +
+            " page_no as aply_flow_num, " +
+            " 0 as aply_itm_id, " +
+            " '' as aply_itm_num, " +
+            " '' as aply_itm_code, " +
+            " '' as itm_alias, " +
+            " '' as itm_abb, " +
+            " '' as grup_num, " +
+            " '' as subj_grup, " +
+            " 0 as dflt_smpl_id, " +
+            " order_name as src_itm_name, " +
+            " req_ward as src_dept_key, " +
+            " req_doctor as src_doc_key, " +
+            " 0 as chk, " +
+            " convert(varchar(20),req_date,120) as aply_date, " +
+            " patient_id as ptnt_no, " +
+            " p_name as ptnt_name, " +
+            " '' as ptnt_bed_no, " +
+            " '' as dflt_smpl_name, " +
+            " '' as aply_itm_name, " +
+            " '' as dept_name, " +
+            " '' as doc_name, " +
+            " order_code as src_itm_key, " +
+            " 0 as emcy_mrk, " +
+            " '' as remark, " +
+            " 0 as chk_init, " +
+            "    brsf=0  " +
+            "from mz_yj_req (nolock)  " +
+            " where patient_id=#{patientId}  " +
+            "  and req_type = '2' " +
+            " and pay_mark = 0 " +
+            "  and receive_flag = #{printJy}  " +
+            "     and req_date>=#{beninTime}  " +
+            "     and req_date<=#{endTime} ")
+    List<Map<String, Object>> selectInterfaceHisLisMz(@Param("patientId") String patientId, @Param("printJy") String printJy, @Param("beninTime") String beninTime, @Param("endTime") String endTime);
+
+
 }

+ 15 - 0
src/main/java/cn/hnthyy/thmz/service/his/zd/JcJyItemChargeService.java

@@ -219,4 +219,19 @@ public interface JcJyItemChargeService {
      * @return
      */
     String queryJcIdFromYjJcPatient(String patientId);
+
+
+
+
+    /**
+     * 查询门诊未确认的检验申请
+     * @param patientId
+     * @param printJy
+     * @param beninTime
+     * @param endTime
+     * @return
+     */
+    List<Map<String, Object>> interfaceHisLisMz(String patientId, String printJy, String beninTime, String endTime) throws MzException;
+
+
 }

+ 38 - 3
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/JcJyItemChargeServiceImpl.java

@@ -7,25 +7,26 @@ import cn.hnthyy.thmz.entity.MzException;
 //import cn.hnthyy.thmz.entity.his.YjJcPatient;
 import cn.hnthyy.thmz.entity.his.YjJcRecord;
 import cn.hnthyy.thmz.entity.his.YjJcRecordReport;
-import cn.hnthyy.thmz.entity.his.mz.Employee;
-import cn.hnthyy.thmz.entity.his.mz.JcJyItemCharge;
+import cn.hnthyy.thmz.entity.his.mz.*;
 import cn.hnthyy.thmz.entity.his.yz.YzOrderOccurence;
 import cn.hnthyy.thmz.entity.his.zd.JcZdItem;
 import cn.hnthyy.thmz.entity.his.zd.JyZdItem;
-import cn.hnthyy.thmz.entity.his.mz.MzYjReq;
 import cn.hnthyy.thmz.entity.his.zd.ZdChargeItem;
 import cn.hnthyy.thmz.entity.jy.InspectionsIndex;
+import cn.hnthyy.thmz.enums.GenderEnum;
 import cn.hnthyy.thmz.enums.ReqTypeEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
 import cn.hnthyy.thmz.mapper.his.YjJcPatientMapper;
 import cn.hnthyy.thmz.mapper.his.YjJcRecordMapper;
 import cn.hnthyy.thmz.mapper.his.YjJcRecordReportMapper;
+import cn.hnthyy.thmz.mapper.his.mz.MzPatientMiMapper;
 import cn.hnthyy.thmz.mapper.his.yz.YzOrderOccurenceMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JcJyItemChargeMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzYjReqMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JcZdItemMapper;
 import cn.hnthyy.thmz.mapper.his.zd.JyZdItemMapper;
 import cn.hnthyy.thmz.mapper.his.zd.ZdChargeItemMapper;
+import cn.hnthyy.thmz.service.his.RegionService;
 import cn.hnthyy.thmz.service.his.jy.InspectionsService;
 import cn.hnthyy.thmz.service.his.mz.EmployeeService;
 import cn.hnthyy.thmz.service.his.zd.JcJyItemChargeService;
@@ -75,6 +76,9 @@ public class JcJyItemChargeServiceImpl implements JcJyItemChargeService {
     @SuppressWarnings("all")
     @Autowired
     private JyZdItemMapper jyZdItemMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private MzPatientMiMapper mzPatientMiMapper;
     @Autowired
     private ZdUnitCodeService zdUnitCodeService;
     //    @Autowired
@@ -85,6 +89,8 @@ public class JcJyItemChargeServiceImpl implements JcJyItemChargeService {
     private InspectionsService inspectionsService;
     @Autowired
     private JyReportService jyReportService;
+    @Autowired
+    private RegionService regionService;
 //    @Override
 //    public List<JcJyItemCharge> queryJcItemChargeByCode(String code, String reqType) {
 //        return jcJyItemChargeMapper.selectJcItemChargeByCode(code, reqType, ReqTypeEnum.JIAN_CHA.code.equals(reqType) ? "jc_item_charge" : "jy_item_charge");
@@ -438,4 +444,33 @@ public class JcJyItemChargeServiceImpl implements JcJyItemChargeService {
     public String queryJcIdFromYjJcPatient(String patientId) {
         return mzYjReqMapper.selectJcIdFromYjJcPatient(patientId);
     }
+
+    @Override
+    public List<Map<String, Object>> interfaceHisLisMz(String patientId, String printJy, String beninTime, String endTime) throws MzException {
+        List<Map<String, Object>> data=mzYjReqMapper.selectInterfaceHisLisMz(patientId,printJy,beninTime,endTime);
+        if(data==null || data.size()==0){
+            return data;
+        }
+        MzPatientMi mzPatientMi=mzPatientMiMapper.selectByPatientId(patientId);
+        if(mzPatientMi==null){
+            throw new   MzException("患者Id没有查询到对应的患者信息!");
+        }
+        Map<String, String> regionMap=regionService.queryAll().stream().collect(Collectors.toMap(CodeNameEntity::getCode, CodeNameEntity::getName));
+        mzPatientMi.setFullAddress(regionMap,new StringBuffer());
+        Map<String,Object> ageAndUnit=DateUtil.getAgeAndUnit(mzPatientMi.getBirthDay());
+        for(Map<String, Object> map:data){
+            map.put("id_card",mzPatientMi.getSocialNo());
+            map.put("ic_card",mzPatientMi.getIcCardNo());
+            if(ageAndUnit!=null && ageAndUnit.size()>0){
+                map.put("ptnt_age",ageAndUnit.get("age"));
+                map.put("ptnt_age_unit",ageAndUnit.get("ageUnit"));
+            }
+            map.put("ptnt_sex",mzPatientMi.getSex()==null? GenderEnum.UNKNOWN:mzPatientMi.getSex());
+            map.put("src_ptnt_sex",mzPatientMi.getSex()==null? GenderEnum.UNKNOWN:mzPatientMi.getSex());
+            map.put("ctat_addr",mzPatientMi.getAddress());
+            map.put("phone_num",mzPatientMi.getPhoneNo());
+            map.put("ptnt_birth",mzPatientMi.getBirthDay());
+        }
+        return data;
+    }
 }