Browse Source

新医保

lighter 4 years ago
parent
commit
748c55ccc8

+ 24 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiMzDao.java

@@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.medicalinsurance.MzPatientInfo;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.FeeDetail;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.PreSetlmt;
+import thyyxxk.webserver.entity.medicalinsurance.outpatient.Regstrtn;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.Setlmt;
 
 import java.util.List;
@@ -18,6 +19,29 @@ import java.util.List;
  **/
 @Mapper
 public interface SiMzDao {
+    @Select("select a.psn_no, " +
+            "b.visit_date as begntime, " +
+            "a.certno as mdtrtCertNo, " +
+            "a.psn_cert_type, " +
+            "a.certno, " +
+            "a.psn_name, " +
+            "rtrim(b.doctor_code) as atddrNo, " +
+            "drName=(select rtrim(name) from a_employee_mi where code=b.doctor_code), " +
+            "rtrim(b.visit_dept_code) as deptCode, " +
+            "deptName=(select rtrim(name) from zd_unit_code where code=b.visit_dept_code), " +
+            "caty=(select si_caty from zd_unit_code where code=b.visit_dept_code) " +
+            "from t_si_pat_info a, mz_visit_table b where a.pat_no=#{patientId} and a.times=#{times} " +
+            "and a.pat_no=b.patient_id and a.times=b.times")
+    Regstrtn selectRegstrtn(@Param("patientId") String patientId, @Param("times") int times);
+
+    @Update("update t_si_pat_info set mdtrt_id=#{mdtrtId},insutype=#{insutype},psn_type=#{psnType} " +
+            "where pat_no=#{patientId} and times=#{times}")
+    void afterRegistrtn(@Param("patientId") String patientId,
+                        @Param("times") int times,
+                        @Param("mdtrtId") String mdtrtId,
+                        @Param("insutype") String insutype,
+                        @Param("psnType") String psnType);
+
     @Select("")
     List<FeeDetail> selectOutpatientFees(@Param("patientId") String patientId, @Param("times") int times);
 

+ 97 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiQueryDao.java

@@ -0,0 +1,97 @@
+package thyyxxk.webserver.dao.his.medicalinsurance;
+
+import org.apache.ibatis.annotations.*;
+import thyyxxk.webserver.entity.medicalinsurance.SiPatInfo;
+import thyyxxk.webserver.entity.medicalinsurance.query.PsnBaseinfo;
+
+/**
+ * @description: 查询服务Mapper
+ * @author: DingJie
+ * @create: 2021/7/2111:17
+ */
+@Mapper
+public interface SiQueryDao {
+    /**
+     * 是否已保存过此患者的医保基本信息
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param ledgerSn    账页号
+     * @return 0-未保存 1-已保存
+     */
+    @Select("select count(1) from t_si_pat_info where pat_no=#{inpatientNo} " +
+            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+    int selectSiZyInfoCount(@Param("inpatientNo") String inpatientNo,
+                            @Param("admissTimes") int admissTimes,
+                            @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 新增患者的医保基本信息(个人编码)
+     *
+     * @param psnBaseinfo 个人基本信息
+     */
+    @Insert("insert into t_si_pat_info (pat_no, times, ledger_sn, psn_no, psn_cert_type, " +
+            "certno, psn_name, gend, naty, brdy, age, med_type) values " +
+            "(#{patNo},#{times},#{ledgerSn},#{psnNo},#{psnCertType},#{certno}," +
+            "#{psnName},#{gend},#{naty},#{brdy},#{age},#{medType})")
+    void insertSiZyInfoPsnNo(PsnBaseinfo psnBaseinfo);
+
+    /**
+     * 更新患者的医保基本信息(个人编码)
+     *
+     * @param psnBaseinfo 个人基本信息
+     */
+    @Update("update t_si_pat_info set age=#{age}, med_type=#{medType} where pat_no=#{patNo} " +
+            "and times=#{times} and ledger_sn=#{ledgerSn}")
+    void updateSiZyInfoPsnNo(PsnBaseinfo psnBaseinfo);
+
+    /**
+     * 获取患者的医保基本信息
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param ledgerSn    账页号
+     * @return 医保基本信息
+     */
+    @Select("select * from t_si_pat_info where pat_no=#{inpatientNo} " +
+            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+    SiPatInfo selectSiPatInfoForZy(@Param("inpatientNo") String inpatientNo,
+                                   @Param("admissTimes") int admissTimes,
+                                   @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 获取患者的医保基本信息
+     *
+     * @param patientId 门诊号
+     * @param times 门诊次数
+     * @return 医保基本信息
+     */
+    @Select("select * from t_si_pat_info where pat_no=#{inpatientNo} " +
+            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+    SiPatInfo selectSiPatInfoForMz(@Param("patientId") String patientId,
+                                   @Param("times") int times);
+
+    /**
+     * 取消入院登记后清空就诊id
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param ledgerSn    账页号
+     */
+    @Update("update t_si_pat_info set mdtrt_id='' where pat_no=#{inpatientNo} " +
+            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+    void clearMdtrtIdForZy(@Param("inpatientNo") String inpatientNo,
+                      @Param("admissTimes") int admissTimes,
+                      @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 取消入院登记后清空就诊id
+     *
+     * @param patientId 门诊号
+     * @param times 门诊次数
+     */
+    @Update("update t_si_pat_info set mdtrt_id='' where pat_no=#{inpatientNo} " +
+            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
+    void clearMdtrtIdForMz(@Param("patientId") String patientId,
+                      @Param("times") int times);
+}

+ 3 - 77
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiZyDao.java

@@ -8,6 +8,7 @@ import thyyxxk.webserver.entity.medicalinsurance.SiChargeDetail;
 import thyyxxk.webserver.entity.medicalinsurance.ZyDisDiagYb;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.AdmDiseinfo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.AdmMdtrtinfo;
+import thyyxxk.webserver.entity.medicalinsurance.query.PsnBaseinfo;
 
 import java.util.List;
 
@@ -58,9 +59,9 @@ public interface SiZyDao {
      */
     @Select("select b.psn_no,b.insutype,a.admiss_date as begntime, " +
             "mdtrtCertType='02', " +
-            "b.idcard as mdtrtCertNo, " +
+            "b.certno as mdtrtCertNo, " +
             "certType='1', " +
-            "b.idcard as certno, " +
+            "b.certno, " +
             "b.med_type, " +
             "rtrim(a.inpatient_no) as iptNo, " +
             "rtrim(isnull(a.refer_physician,a.admiss_physician)) as atddrNo, " +
@@ -196,81 +197,6 @@ public interface SiZyDao {
     List<ZyDisDiagYb> selectZyDisDiags(@Param("inpatientNo") String inpatientNo,
                                        @Param("admissTimes") int admissTimes);
 
-    /**
-     * 是否已保存过此患者的医保基本信息
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param ledgerSn    账页号
-     * @return 0-未保存 1-已保存
-     */
-    @Select("select count(1) from t_si_pat_info where pat_no=#{inpatientNo} " +
-            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
-    int selectSiZyInfoCount(@Param("inpatientNo") String inpatientNo,
-                            @Param("admissTimes") int admissTimes,
-                            @Param("ledgerSn") int ledgerSn);
-
-    /**
-     * 获取患者的医保基本信息
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param ledgerSn    账页号
-     * @return 医保基本信息
-     */
-    @Select("select * from t_si_pat_info where pat_no=#{inpatientNo} " +
-            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
-    SiPatInfo selectSiPatInfo(@Param("inpatientNo") String inpatientNo,
-                              @Param("admissTimes") int admissTimes,
-                              @Param("ledgerSn") int ledgerSn);
-
-    /**
-     * 取消入院登记后清空就诊id
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param ledgerSn    账页号
-     */
-    @Update("update t_si_pat_info set mdtrt_id='' where pat_no=#{inpatientNo} " +
-            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
-    void clearMdtrtId(@Param("inpatientNo") String inpatientNo,
-                      @Param("admissTimes") int admissTimes,
-                      @Param("ledgerSn") int ledgerSn);
-
-    /**
-     * 新增患者的医保基本信息(个人编码)
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param ledgerSn    账页号
-     * @param psnNo       人员编号
-     * @param idcard      身份证号
-     */
-    @Insert("insert into t_si_pat_info (pat_no, times, ledger_sn, psn_no, med_type, idcard) values " +
-            "(#{inpatientNo},#{admissTimes},#{ledgerSn},#{psnNo},#{medType},#{idcard})")
-    void insertSiZyInfoPsnNo(@Param("inpatientNo") String inpatientNo,
-                             @Param("admissTimes") int admissTimes,
-                             @Param("ledgerSn") int ledgerSn,
-                             @Param("psnNo") String psnNo,
-                             @Param("medType") String medType,
-                             @Param("idcard") String idcard);
-
-    /**
-     * 更新患者的医保基本信息(个人编码)
-     *
-     * @param inpatientNo 住院号
-     * @param admissTimes 住院次数
-     * @param ledgerSn    账页号
-     * @param psnNo       人员编号
-     */
-    @Update("update t_si_pat_info set psn_no=#{psnNo},med_type=#{medType} where pat_no=#{inpatientNo} " +
-            "and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
-    void updateSiZyInfoPsnNo(@Param("inpatientNo") String inpatientNo,
-                             @Param("admissTimes") int admissTimes,
-                             @Param("ledgerSn") int ledgerSn,
-                             @Param("psnNo") String psnNo,
-                             @Param("medType") String medType);
-
     /**
      * 入院登记成功后更新患者医保信息
      *

+ 47 - 9
src/main/java/thyyxxk/webserver/entity/medicalinsurance/SiPatInfo.java

@@ -4,26 +4,23 @@ import java.io.Serializable;
 import lombok.Data;
 import java.util.Date;
 
-/**
- * @author light
- */
 @Data
 public class SiPatInfo implements Serializable {
 
-	private static final long serialVersionUID =  7639813685931479890L;
+	private static final long serialVersionUID =  6489789106587927689L;
 
 	/**
-	 * 住院号
+	 * 住院号/门诊号
 	 */
 	private String patNo;
 
 	/**
-	 * 住院次数
+	 * 住院次数/门诊次数
 	 */
 	private Integer times;
 
 	/**
-	 * 账页号
+	 * 账页号(门诊为receiptNo)
 	 */
 	private Integer ledgerSn;
 
@@ -32,11 +29,51 @@ public class SiPatInfo implements Serializable {
 	 */
 	private String psnNo;
 
+	/**
+	 * 人员证件类型
+	 */
+	private String psnCertType;
+
+	/**
+	 * 证件号码
+	 */
+	private String certno;
+
+	/**
+	 * 人员姓名
+	 */
+	private String psnName;
+
+	/**
+	 * 性别
+	 */
+	private String gend;
+
+	/**
+	 * 民族
+	 */
+	private String naty;
+
+	/**
+	 * 出生日期
+	 */
+	private Date brdy;
+
+	/**
+	 * 年龄
+	 */
+	private Double age;
+
 	/**
 	 * 险种类型
 	 */
 	private String insutype;
 
+	/**
+	 * 医疗类别
+	 */
+	private String medType;
+
 	/**
 	 * 参保地医保区划,可通过【1101】人员信息获取交易取得
 	 */
@@ -93,7 +130,8 @@ public class SiPatInfo implements Serializable {
 	private String setlId;
 
 	/**
-	 * 医疗类别
+	 * 医药机构结算ID,存放发送方报文ID
 	 */
-	private String medType;
+	private String medinsSetlId;
+
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/entity/medicalinsurance/SiSetldetail.java

@@ -22,7 +22,7 @@ public class SiSetldetail implements Serializable {
 	private Integer times;
 
 	/**
-	 * 账页号(门诊固定为0
+	 * 账页号(门诊为receiptNo
 	 */
 	private Integer ledgerSn;
 

+ 1 - 1
src/main/java/thyyxxk/webserver/entity/medicalinsurance/SiSetlinfo.java

@@ -26,7 +26,7 @@ public class SiSetlinfo implements Serializable {
 	private Integer times;
 
 	/**
-	 * 账页号(门诊固定为0
+	 * 账页号(门诊为receiptNo
 	 */
 	private Integer ledgerSn;
 

+ 107 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/outpatient/Regstrtn.java

@@ -0,0 +1,107 @@
+package thyyxxk.webserver.entity.medicalinsurance.outpatient;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @description: 门诊挂号入参
+ * @author: DingJie
+ * @create: 2021/7/2110:13
+ */
+@Data
+public class Regstrtn {
+    /**
+     * 人员编号
+     * */
+    @JSONField(name = "psn_no")
+    private String psnNo;
+
+    /**
+     * 险种类型
+     * */
+    private String insutype;
+
+    /**
+     * 挂号时间 yyyy-MM-dd HH:mm:ss
+     * */
+    private Date begntime;
+
+    /**
+     * 就诊凭证类型
+     * */
+    @JSONField(name = "mdtrt_cert_type")
+    private String mdtrtCertType;
+
+    /**
+     * 就诊凭证编号(就诊凭证类型为“01”时填写电子凭证令牌,为“02”时填写身份证号,为“03”时填写社会保障卡卡号)
+     * */
+    @JSONField(name = "mdtrt_cert_no")
+    private String mdtrtCertNo;
+
+    /**
+     * 卡识别码(就诊凭证类型为“03”时必填)
+     * */
+    @JSONField(name = "card_sn")
+    private String cardSn;
+
+    /**
+     * 证件类型
+     * */
+    @JSONField(name = "psn_cert_type")
+    private String psnCertType;
+
+    /**
+     * 证件号码
+     * */
+    private String certno;
+
+    /**
+     * 人员类别
+     * */
+    @JSONField(name = "psn_type")
+    private String psnType;
+
+    /**
+     * 人员姓名
+     * */
+    @JSONField(name = "psn_name")
+    private String psnName;
+
+    /**
+     * 门诊号
+     * */
+    @JSONField(name = "ipt_otp_no")
+    private String iptOtpNo;
+
+    /**
+     * 医师编码
+     * */
+    @JSONField(name = "atddr_no")
+    private String atddrNo;
+
+    /**
+     * 医师姓名
+     * */
+    @JSONField(name = "dr_name")
+    private String drName;
+
+    /**
+     * 科室编码
+     * */
+    @JSONField(name = "dept_code")
+    private String deptCode;
+
+    /**
+     * 科室名称
+     * */
+    @JSONField(name = "dept_name")
+    private String deptName;
+
+    /**
+     * 科别
+     * */
+    private String caty;
+
+}

+ 77 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/query/PsnBaseinfo.java

@@ -0,0 +1,77 @@
+package thyyxxk.webserver.entity.medicalinsurance.query;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @description: 人员基本信息
+ * @author: DingJie
+ * @create: 2021/7/2110:21
+ */
+@Data
+public class PsnBaseinfo {
+    /**
+     * 住院号/门诊号
+     */
+    private String patNo;
+
+    /**
+     * 住院次数/门诊次数
+     */
+    private Integer times;
+
+    /**
+     * 账页号(门诊为receiptNo)
+     */
+    private Integer ledgerSn;
+
+    /**
+     * 人员编号
+     * */
+    private String psnNo;
+
+    /**
+     * 人员证件类型
+     * */
+    private String psnCertType;
+
+    /**
+     * 证件号码
+     * */
+    private String certno;
+
+    /**
+     * 人员姓名
+     * */
+    private String psnName;
+
+    /**
+     * 性别
+     * */
+    private String gend;
+
+    /**
+     * 民族
+     * */
+    private String naty;
+    
+    /**
+     * 出生日期
+     * */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date brdy;
+
+    /**
+     * 年龄 
+     * */
+    private Double age;
+
+    /**
+     * 医疗类别
+     * */
+    private String medType;
+}

+ 30 - 30
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiMzService.java

@@ -10,15 +10,14 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.SiFunction;
 import thyyxxk.webserver.constants.sidicts.MdtrtCertType;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiMzDao;
+import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetldetailDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
 import thyyxxk.webserver.entity.ResultVo;
-import thyyxxk.webserver.entity.medicalinsurance.FundDetail;
-import thyyxxk.webserver.entity.medicalinsurance.MzPatientInfo;
-import thyyxxk.webserver.entity.medicalinsurance.SiSetldetail;
-import thyyxxk.webserver.entity.medicalinsurance.SiSetlinfo;
+import thyyxxk.webserver.entity.medicalinsurance.*;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.FeeDetail;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.PreSetlmt;
+import thyyxxk.webserver.entity.medicalinsurance.outpatient.Regstrtn;
 import thyyxxk.webserver.entity.medicalinsurance.outpatient.Setlmt;
 import thyyxxk.webserver.utils.*;
 
@@ -33,6 +32,7 @@ import java.util.List;
 @Service
 public class SiMzService {
     private final SiMzDao dao;
+    private final SiQueryDao queryDao;
     private final SiSetlinfoDao setlinfoDao;
     private final SiSetldetailDao setldetailDao;
     private final ExecService exec;
@@ -41,8 +41,9 @@ public class SiMzService {
     private static final String OUTPUT = "output";
 
     @Autowired
-    public SiMzService(SiMzDao dao, SiSetlinfoDao setlinfoDao, SiSetldetailDao setldetailDao, ExecService exec) {
+    public SiMzService(SiMzDao dao, SiQueryDao queryDao, SiSetlinfoDao setlinfoDao, SiSetldetailDao setldetailDao, ExecService exec) {
         this.dao = dao;
+        this.queryDao = queryDao;
         this.setlinfoDao = setlinfoDao;
         this.setldetailDao = setldetailDao;
         this.exec = exec;
@@ -50,24 +51,13 @@ public class SiMzService {
 
     public ResultVo<String> outpatientRegistration(MzPatientInfo p) {
         JSONObject input = exec.makeTradeHeader(SiFunction.OUTPATIENT_REGISTRATION);
-        JSONObject data = new JSONObject();
-        data.put("psn_no", p.getPsnNo());
-        data.put("insutype", p.getInsutype());
-        data.put("begntime", DateUtil.formatDatetime(p.getVisitDate()));
-        data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
-        data.put("mdtrt_cert_no", p.getSocialNo());
-        data.put("card_sn", "");
-        data.put("psn_cert_type", "1");
-        data.put("certno", p.getSocialNo());
-        data.put("psn_type", p.getPsnType());
-        data.put("psn_name", p.getName());
-        data.put("ipt_otp_no", p.getPatientId());
-        data.put("atddr_no", p.getDoctorCode());
-        data.put("dr_name", p.getDoctorName());
-        data.put("dept_code", p.getDeptCode());
-        data.put("dept_name", p.getDeptName());
-        data.put("caty", p.getDeptClass());
-        input.getJSONObject("input").put("data", data);
+        Regstrtn regstrtn = dao.selectRegstrtn(p.getPatientId(), p.getTimes());
+        regstrtn.setInsutype(p.getInsutype());
+        regstrtn.setMdtrtCertType(MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
+        regstrtn.setPsnType(p.getPsnType());
+        regstrtn.setIptOtpNo(p.getPatientId());
+        String ref = JSONObject.toJSONStringWithDateFormat(regstrtn, "yyyy-MM-dd HH:mm:ss");
+        input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
         JSONObject result = exec.executeTrade(input, SiFunction.OUTPATIENT_REGISTRATION);
         log.info("【操作员:{}】,门诊挂号:参数:{},结果:{}", TokenUtil.getTokenUserId(), input, result);
         if (null == result) {
@@ -76,23 +66,33 @@ public class SiMzService {
         if (result.getIntValue(RESULT_CODE) == 0) {
             JSONObject output = result.getJSONObject(OUTPUT).getJSONObject("data");
             String mdtrtId = output.getString("mdtrt_id");
-            String psnNo = output.getString("psn_no");
-            String patientId = output.getString("ipt_otp_no");
+            dao.afterRegistrtn(p.getPatientId(), p.getTimes(), mdtrtId, p.getInsutype(), p.getPsnType());
             return ResultVoUtil.success("挂号成功。");
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
-    public ResultVo<String> revokeOutpatientRegistration(MzPatientInfo p) {
+    public ResultVo<String> revokeOutpatientRegistration(String patientId, Integer times) {
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForMz(patientId, times);
+        if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保挂号信息。");
+        }
         JSONObject input = exec.makeTradeHeader(SiFunction.REVOKE_OUTPATIENT_REGISTRATION);
         JSONObject data = new JSONObject();
-        data.put("psn_no", p.getPsnNo());
-        data.put("mdtrt_id", p.getMdtrtId());
-        data.put("ipt_otp_no", p.getPatientId());
+        data.put("psn_no", siPatInfo.getPsnNo());
+        data.put("mdtrt_id", siPatInfo.getMdtrtId());
+        data.put("ipt_otp_no", patientId);
         input.getJSONObject("input").put("data", data);
         JSONObject result = exec.executeTrade(input, SiFunction.OUTPATIENT_REGISTRATION);
         log.info("【操作员:{}】,取消门诊挂号:参数:{},结果:{}", TokenUtil.getTokenUserId(), input, result);
-        return SiUtil.makeReturnWithoutOutput(result, "取消挂号成功。");
+        if (null == result) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (result.getIntValue(RESULT_CODE) == 0) {
+            queryDao.clearMdtrtIdForMz(patientId, times);
+            return ResultVoUtil.success("取消门诊挂号成功。");
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
     public ResultVo<String> uploadOutpatientInfo(MzPatientInfo p) {

+ 14 - 10
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiQueryService.java

@@ -8,12 +8,13 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.SiFunction;
 import thyyxxk.webserver.constants.sidicts.MdtrtCertType;
-import thyyxxk.webserver.dao.his.medicalinsurance.SiZyDao;
+import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.medicalinsurance.GeneralRevoke;
 import thyyxxk.webserver.entity.medicalinsurance.QuerySiInfo;
 import thyyxxk.webserver.entity.medicalinsurance.SiPatInfo;
 import thyyxxk.webserver.entity.medicalinsurance.ZyPatientInfo;
+import thyyxxk.webserver.entity.medicalinsurance.query.PsnBaseinfo;
 import thyyxxk.webserver.entity.medicalinsurance.query.QryPsnCmlInfo;
 import thyyxxk.webserver.entity.medicalinsurance.query.QrySpecChncDiseMdcRcd;
 import thyyxxk.webserver.utils.*;
@@ -27,13 +28,13 @@ import thyyxxk.webserver.utils.*;
 @Service
 public class SiQueryService {
     private final ExecService exec;
-    private final SiZyDao dao;
+    private final SiQueryDao dao;
     private static final String RESULT_CODE = "infcode";
     private static final String ERROR_MESSAGE = "err_msg";
     private static final String OUTPUT = "output";
 
     @Autowired
-    public SiQueryService(ExecService exec, SiZyDao dao) {
+    public SiQueryService(ExecService exec, SiQueryDao dao) {
         this.exec = exec;
         this.dao = dao;
     }
@@ -46,7 +47,7 @@ public class SiQueryService {
         JSONObject data = new JSONObject();
         data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
         data.put("mdtrt_cert_no", p.getSocialNo());
-        data.put("psn_cert_type", "1");
+        data.put("psn_cert_type", "01");
         data.put("certno", p.getSocialNo());
         data.put("psn_name", p.getName());
         input.getJSONObject("input").put("data", data);
@@ -57,15 +58,18 @@ public class SiQueryService {
         if (result.getIntValue(RESULT_CODE) == 0) {
             JSONObject output = result.getJSONObject(OUTPUT);
             JSONObject baseinfo = output.getJSONObject("baseinfo");
-            String psnNo = baseinfo.getString("psn_no");
+            PsnBaseinfo psnBaseinfo = JSONObject.parseObject(baseinfo.toJSONString(), PsnBaseinfo.class);
+            psnBaseinfo.setPatNo(p.getInpatientNo());
+            psnBaseinfo.setTimes(p.getAdmissTimes());
+            psnBaseinfo.setLedgerSn(p.getLedgerSn());
+            psnBaseinfo.setMedType(p.getMedType());
             int saved = dao.selectSiZyInfoCount(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
             if (saved == 0) {
-                dao.insertSiZyInfoPsnNo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), psnNo, p.getMedType(), p.getSocialNo());
+                dao.insertSiZyInfoPsnNo(psnBaseinfo);
             } else {
-                dao.updateSiZyInfoPsnNo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), psnNo, p.getMedType());
+                dao.updateSiZyInfoPsnNo(psnBaseinfo);
             }
-            log.info("患者人员编码已更新:住院号:{},住院次数:{},账页号:{},人员编号:{}",
-                    p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), psnNo);
+            log.info("患者基本信息已更新:{}", psnBaseinfo);
             return ResultVoUtil.success(output);
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
@@ -92,7 +96,7 @@ public class SiQueryService {
     }
 
     public ResultVo<JSONObject> queryVisitInfo(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = dao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }

+ 13 - 9
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -11,6 +11,7 @@ import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.constants.SiFunction;
 import thyyxxk.webserver.constants.sidicts.MdtrtCertType;
+import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetldetailDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiZyDao;
@@ -50,6 +51,7 @@ public class SiZyService {
     private static final String ERROR_MESSAGE = "err_msg";
     private static final String OUTPUT = "output";
     private final SiZyDao dao;
+    private final SiQueryDao queryDao;
     private final SiSetlinfoDao setlinfoDao;
     private final SiSetldetailDao setldetailDao;
     private final ExecService exec;
@@ -57,9 +59,11 @@ public class SiZyService {
     private final DismissService dismissService;
 
     @Autowired
-    public SiZyService(SiZyDao dao, SiSetlinfoDao setlinfoDao, SiSetldetailDao setldetailDao, ExecService exec,
+    public SiZyService(SiZyDao dao, SiQueryDao queryDao, SiSetlinfoDao setlinfoDao,
+                       SiSetldetailDao setldetailDao, ExecService exec,
                        SettleService settleService, DismissService dismissService) {
         this.dao = dao;
+        this.queryDao = queryDao;
         this.setlinfoDao = setlinfoDao;
         this.setldetailDao = setldetailDao;
         this.exec = exec;
@@ -129,7 +133,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> revokeAdmission(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }
@@ -144,14 +148,14 @@ public class SiZyService {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
         if (result.getIntValue(RESULT_CODE) == 0) {
-            dao.clearMdtrtId(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn());
+            queryDao.clearMdtrtIdForZy(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn());
             return ResultVoUtil.success("取消入院登记成功。");
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
     public ResultVo<String> uploadFeeDetail(Overview o) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }
@@ -252,7 +256,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> hospitalizationPreSettlement(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }
@@ -281,7 +285,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> revokeUploadFees(GeneralRevoke r) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(r.getInpatientNo(), r.getAdmissTimes(), r.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(r.getInpatientNo(), r.getAdmissTimes(), r.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }
@@ -316,7 +320,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> inpatientSettlement(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
         }
@@ -376,7 +380,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> revokeSettlement(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getSetlId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保结算信息,无法撤销结算!");
         }
@@ -431,7 +435,7 @@ public class SiZyService {
     }
 
     public ResultVo<String> revokeDischarge(ZyPatientInfo p) {
-        SiPatInfo siPatInfo = dao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
         if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getSetlId())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保出院信息,无法撤销出院!");
         }