浏览代码

Merge branch 'develop' into dev/mix20191225_security

gaodm 5 年之前
父节点
当前提交
a5f060a1b1
共有 33 个文件被更改,包括 722 次插入615 次删除
  1. 6 0
      aipt-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java
  2. 7 13
      aipt-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java
  3. 3 0
      docs/027.20191220预问诊内容是否显示脚本/init_tran.sql
  4. 6 0
      icss-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java
  5. 0 3
      icss-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java
  6. 6 0
      icss-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java
  7. 0 1
      icss-service/src/main/java/com/diagbot/web/PatientInfoController.java
  8. 0 11
      prec-service/src/main/java/com/diagbot/client/AiptServiceClient.java
  9. 8 0
      prec-service/src/main/java/com/diagbot/client/TranServiceClient.java
  10. 0 8
      prec-service/src/main/java/com/diagbot/client/hystrix/AiptServiceHystrix.java
  11. 14 0
      prec-service/src/main/java/com/diagbot/client/hystrix/TranServiceHystrix.java
  12. 54 0
      prec-service/src/main/java/com/diagbot/dto/GetHospitalRankInfoDTO.java
  13. 0 144
      prec-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java
  14. 7 13
      prec-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java
  15. 184 72
      prec-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java
  16. 0 2
      prec-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java
  17. 30 0
      prec-service/src/main/java/com/diagbot/facade/SysSetFacade.java
  18. 33 0
      prec-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java
  19. 12 0
      prec-service/src/main/java/com/diagbot/vo/GetInquiryDetailVO.java
  20. 0 56
      prec-service/src/main/java/com/diagbot/vo/GetTopPatientInfoVO.java
  21. 17 0
      prec-service/src/main/java/com/diagbot/vo/HisInquirysVO.java
  22. 7 0
      prec-service/src/main/java/com/diagbot/web/InquiryInfoController.java
  23. 0 2
      prec-service/src/main/java/com/diagbot/web/PatientInfoController.java
  24. 62 84
      tran-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java
  25. 6 11
      tran-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java
  26. 172 138
      tran-service/src/main/java/com/diagbot/facade/PatientInfoDjFacade.java
  27. 36 8
      tran-service/src/main/java/com/diagbot/facade/SysSetFacade.java
  28. 5 0
      tran-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java
  29. 27 45
      tran-service/src/main/java/com/diagbot/vo/GetTopPatientInfoVO.java
  30. 5 0
      tran-service/src/main/java/com/diagbot/vo/InquiryQuoteVO.java
  31. 1 1
      tran-service/src/main/java/com/diagbot/web/PatientInfoController.java
  32. 8 2
      tran-service/src/main/java/com/diagbot/web/SysSetController.java
  33. 6 1
      tran-service/src/main/resources/mapper/PatientInfoMapper.xml

+ 6 - 0
aipt-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java

@@ -127,6 +127,12 @@ public class GetTopPatientInfoDTO {
 	@ApiModelProperty(value = "患者身份证号")
 	private String patientIdentityNum;
 
+	/**
+	 * 患者联系电话
+	 */
+	@ApiModelProperty(value = "患者联系电话")
+	private String patientPhone;
+
 	/**
 	 * 系统时间
 	 */

+ 7 - 13
aipt-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java

@@ -138,6 +138,12 @@ public class GetTopPatientInfoDjDTO {
     @ApiModelProperty(value = "病人证件号码")
     private String patientIdNo;
 
+    /**
+     * 患者联系电话
+     */
+    @ApiModelProperty(value = "患者联系电话")
+    private String patientPhone;
+
     /**
      * 系统时间
      */
@@ -158,16 +164,4 @@ public class GetTopPatientInfoDjDTO {
     @ApiModelProperty(value = "门诊号")
     private String recordId;
 
-    /**
-     * 模式分类
-     */
-    @ApiModelProperty(value = "模式分类")
-    private Integer modeClassify;
-
-    /**
-     * 模式值
-     */
-    @ApiModelProperty(value = "模式值")
-    private Integer modeValue;
-
-}
+}

+ 3 - 0
docs/027.20191220预问诊内容是否显示脚本/init_tran.sql

@@ -0,0 +1,3 @@
+use `sys-tran`;
+
+INSERT INTO `sys-tran`.`tran_sys_set` (`is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `hospital_code`, `plan`, `sys_type`, `name`, `code`, `value`, `remark`) VALUES ('N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', NULL, NULL, 'A010', '0', '17', '预问诊内容引用显示', 'quote_show', '1', '是否显示(1是,0否)');

+ 6 - 0
icss-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java

@@ -127,6 +127,12 @@ public class GetTopPatientInfoDTO {
 	@ApiModelProperty(value = "患者身份证号")
 	private String patientIdentityNum;
 
+	/**
+	 * 患者联系电话
+	 */
+	@ApiModelProperty(value = "患者联系电话")
+	private String patientPhone;
+
 	/**
 	 * 系统时间
 	 */

+ 0 - 3
icss-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java

@@ -1,13 +1,10 @@
 package com.diagbot.facade;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.TranServiceClient;
 import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.PatientInfoDTO;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.DoctorPageMode;
-import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.PatientInfoVO;

+ 6 - 0
icss-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java

@@ -24,4 +24,10 @@ public class GetHospitalRankInfoVO {
     @NotBlank(message = "医院编码必传")
     private String hospitalCode;
 
+    /**
+     * 校验是否对接预问诊 0-不校验 1-校验
+     */
+    @ApiModelProperty(value = "医院编码")
+    private Integer isCkConnectPrec = 1;
+
 }

+ 0 - 1
icss-service/src/main/java/com/diagbot/web/PatientInfoController.java

@@ -46,7 +46,6 @@ public class PatientInfoController {
         return RespDTO.onSuc(data);
     }
 
-
     @ApiOperation(value = "知识库标准化-页面顶部病人医生科室信息——查询[by:rengb]",
             notes = "hospitalCode:医院编号,必填<br>" +
                     "hospitalDeptCode:医院科室编号,必填<br>" +

+ 0 - 11
prec-service/src/main/java/com/diagbot/client/AiptServiceClient.java

@@ -4,7 +4,6 @@ import com.diagbot.biz.push.vo.SearchVO;
 import com.diagbot.client.hystrix.AiptServiceHystrix;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptRetrievalDTO;
-import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.GetTopPatientInfoDjDTO;
 import com.diagbot.dto.PushDTO;
 import com.diagbot.dto.RespDTO;
@@ -12,7 +11,6 @@ import com.diagbot.dto.VersionWrapperDTO;
 import com.diagbot.vo.ConceptSearchVO;
 import com.diagbot.vo.ConceptUsualVO;
 import com.diagbot.vo.GetTopPatientInfoDjVO;
-import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.RetrievalVO;
 import com.diagbot.vo.VersionVO;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -38,15 +36,6 @@ public interface AiptServiceClient {
      */
     @PostMapping("/push/pushInner")
     RespDTO<PushDTO> pushInner(@RequestBody SearchVO searchVO);
-    
-    /**
-     * 获取页面顶部病人医生科室信息
-     *
-     * @param getTopPatientInfoVO
-     * @return
-     */
-    @PostMapping("/patientInfo/getTopPatientInfo")
-    RespDTO<GetTopPatientInfoDTO> getTopPatientInfo(@RequestBody GetTopPatientInfoVO getTopPatientInfoVO);
 
     /**
      * 对接-获取页面顶部病人医生科室信息

+ 8 - 0
prec-service/src/main/java/com/diagbot/client/TranServiceClient.java

@@ -1,10 +1,12 @@
 package com.diagbot.client;
 
 import com.diagbot.client.hystrix.TranServiceHystrix;
+import com.diagbot.dto.GetHospitalRankInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SignInDTO;
 import com.diagbot.dto.SysHospitalDTO;
 import com.diagbot.dto.SysSetInfoDTO;
+import com.diagbot.vo.GetHospitalRankInfoVO;
 import com.diagbot.vo.HospitalSetVO;
 import com.diagbot.vo.InquiryQuoteVO;
 import com.diagbot.vo.SignInVO;
@@ -50,4 +52,10 @@ public interface TranServiceClient {
      */
     @PostMapping("/sysSet/getHospitalDatas")
     RespDTO<SysHospitalDTO> getHospitalDeptInfoData(SysHospitalCodeVO sysHospitalCodeVO);
+
+    @PostMapping("/sysSet/getHospitalRankInfo")
+    RespDTO<GetHospitalRankInfoDTO> getHospitalRankInfo(@RequestBody GetHospitalRankInfoVO getHospitalRankInfoVO);
+
+    @PostMapping("/sysSet/getParentHospitalCode")
+    RespDTO<String> getParentHospitalCode(@RequestBody String hospitalCode);
 }

+ 0 - 8
prec-service/src/main/java/com/diagbot/client/hystrix/AiptServiceHystrix.java

@@ -4,7 +4,6 @@ import com.diagbot.biz.push.vo.SearchVO;
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.ConceptRetrievalDTO;
-import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.GetTopPatientInfoDjDTO;
 import com.diagbot.dto.PushDTO;
 import com.diagbot.dto.RespDTO;
@@ -12,7 +11,6 @@ import com.diagbot.dto.VersionWrapperDTO;
 import com.diagbot.vo.ConceptSearchVO;
 import com.diagbot.vo.ConceptUsualVO;
 import com.diagbot.vo.GetTopPatientInfoDjVO;
-import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.RetrievalVO;
 import com.diagbot.vo.VersionVO;
 import lombok.extern.slf4j.Slf4j;
@@ -43,12 +41,6 @@ public class AiptServiceHystrix implements AiptServiceClient {
         return null;
     }
     
-    @Override
-    public RespDTO<GetTopPatientInfoDTO> getTopPatientInfo(GetTopPatientInfoVO getTopPatientInfoVO) {
-        log.error("【hystrix】调用{}异常", "getTopPatientInfo");
-        return null;
-    }
-
     @Override
     public RespDTO<GetTopPatientInfoDjDTO> getTopPatientInfoDj(GetTopPatientInfoDjVO getTopPatientInfoDjVO) {
         log.error("【hystrix】调用{}异常", "getTopPatientInfoDj");

+ 14 - 0
prec-service/src/main/java/com/diagbot/client/hystrix/TranServiceHystrix.java

@@ -4,7 +4,9 @@ import java.util.List;
 
 import javax.validation.Valid;
 
+import com.diagbot.dto.GetHospitalRankInfoDTO;
 import com.diagbot.dto.SysHospitalDTO;
+import com.diagbot.vo.GetHospitalRankInfoVO;
 import com.diagbot.vo.InquiryQuoteVO;
 import com.diagbot.vo.SysHospitalCodeVO;
 import org.springframework.stereotype.Component;
@@ -49,4 +51,16 @@ public class TranServiceHystrix implements TranServiceClient {
         log.error("【hystrix】调用{}异常", "getHospitalDeptInfoData");
         return null;
     }
+
+    @Override
+    public RespDTO<GetHospitalRankInfoDTO> getHospitalRankInfo(GetHospitalRankInfoVO getHospitalRankInfoVO) {
+        log.error("【hystrix】调用{}异常", "getHospitalRankInfo");
+        return null;
+    }
+
+    @Override
+    public RespDTO<String> getParentHospitalCode(String hospitalCode) {
+        log.error("【hystrix】调用{}异常", "getParentHospitalCode");
+        return null;
+    }
 }

+ 54 - 0
prec-service/src/main/java/com/diagbot/dto/GetHospitalRankInfoDTO.java

@@ -0,0 +1,54 @@
+package com.diagbot.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2019/3/19 13:56
+ */
+@ApiModel(value = "获取大小医院信息接口出参")
+@Getter
+@Setter
+public class GetHospitalRankInfoDTO {
+
+    /**
+     * 医院id
+     */
+    @ApiModelProperty(value = "医院id")
+    private Long hospitalId;
+
+    /**
+     * 医院编码
+     */
+    @ApiModelProperty(value = "医院编码")
+    private String hospitalCode;
+
+    /**
+     * 医院名称
+     */
+    @ApiModelProperty(value = "医院名称")
+    private String hospitalName;
+
+    /**
+     * 子医院id
+     */
+    @ApiModelProperty(value = "子医院id")
+    private Long sonHospitalId;
+
+    /**
+     * 子医院编码
+     */
+    @ApiModelProperty(value = "子医院编码")
+    private String sonHospitalCode;
+
+    /**
+     * 子医院名称
+     */
+    @ApiModelProperty(value = "子医院名称")
+    private String sonHospitalName;
+
+}

+ 0 - 144
prec-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java

@@ -1,144 +0,0 @@
-package com.diagbot.dto;
-
-import java.util.Date;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @Description
- * @author rgb
- * @time 2018年11月19日下午4:57:43
- */
-@ApiModel(value="页面顶部病人医生科室信息查询接口出参")
-@Getter
-@Setter
-public class GetTopPatientInfoDTO {
-	
-	/**
-	 * 医院id
-	 */
-	@ApiModelProperty(value="医院id")
-	private Long hospitalId;
-	
-	/**
-     * 医院编码
-     */
-	@ApiModelProperty(value="医院编码")
-    private String hospitalCode;
-
-    /**
-     * 医院名称
-     */
-	@ApiModelProperty(value="医院名称")
-    private String hospitalName;
-    
-    /**
-	 * 医院科室id
-	 */
-	@ApiModelProperty(value="医院科室id")
-	private Long hospitalDeptId;
-	
-    /**
-	 * 自己科室id
-	 */
-	@ApiModelProperty(value="自己科室id")
-	private Long selfDeptId;
-	
-	/**
-	 * 自己科室名称
-	 */
-	@ApiModelProperty(value="自己科室名称")
-	private String selfDeptName;
-    
-    /**
-     * 医院科室编码
-     */
-	@ApiModelProperty(value="医院科室编码")
-    private String hospitalDeptCode;
-
-    /**
-     * 医院科室名称
-     */
-	@ApiModelProperty(value="医院科室名称")
-    private String hospitalDeptName;
-    
-    /**
-	 * 医生id
-	 */
-	@ApiModelProperty(value="医生id")
-	private Long doctorId;
-	
-	/**
-     * 医生编码
-     */
-	@ApiModelProperty(value="医生编码")
-    private String doctorCode;
-
-    /**
-     * 医生姓名
-     */
-	@ApiModelProperty(value="医生姓名")
-    private String doctorName;
-    
-    /**
-   	 * 病人id
-   	 */
-	@ApiModelProperty(value="病人id")
-   	private Long patientId;
-   	
-   	/**
-     * 病人编号
-     */
-	@ApiModelProperty(value="病人编号")
-    private String patientCode;
-
-    /**
-     * 病人姓名
-     */
-	@ApiModelProperty(value="病人姓名")
-    private String patientName;
-
-    /**
-     * 病人性别
-     */
-	@ApiModelProperty(value="病人性别")
-    private String patientSex;
-    
-    /**
-     * 病人年龄
-     */
-	@ApiModelProperty(value="病人年龄")
-    private Integer patientAge;
-    
-    /**
-     * 病人证件号码
-     */
-	@ApiModelProperty(value="病人证件号码")
-    private String patientIdNo;
-
-	/**
-	 * 系统时间
-	 */
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
-	@ApiModelProperty(value="系统时间")
-	private Date systemTime;
-	
-	/**
-     * 出生日期
-     */
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
-	@ApiModelProperty(value="出生日期")
-    private Date birthday;
-	
-	/**
-     * 门诊号
-     */
-	@ApiModelProperty(value="门诊号")
-	private String recordId;
-
-}

+ 7 - 13
prec-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java

@@ -138,6 +138,12 @@ public class GetTopPatientInfoDjDTO {
     @ApiModelProperty(value = "病人证件号码")
     private String patientIdNo;
 
+    /**
+     * 患者联系电话
+     */
+    @ApiModelProperty(value = "患者联系电话")
+    private String patientPhone;
+
     /**
      * 系统时间
      */
@@ -158,16 +164,4 @@ public class GetTopPatientInfoDjDTO {
     @ApiModelProperty(value = "门诊号")
     private String recordId;
 
-    //    /**
-    //     * 模式分类
-    //     */
-    //	@ApiModelProperty(value="模式分类")
-    //    private Integer modeClassify;
-    //
-    //    /**
-    //     * 模式值
-    //     */
-    //	@ApiModelProperty(value="模式值")
-    //    private Integer modeValue;
-
-}
+}

+ 184 - 72
prec-service/src/main/java/com/diagbot/facade/InquiryInfoFacade.java

@@ -2,6 +2,7 @@ package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.diagbot.client.TranServiceClient;
+import com.diagbot.dto.GetHospitalRankInfoDTO;
 import com.diagbot.dto.GetInquiryDetailDTO;
 import com.diagbot.dto.GetInquiryDetailImgDTO;
 import com.diagbot.dto.HisInquiryDTO;
@@ -28,6 +29,7 @@ import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.GetHospitalRankInfoVO;
 import com.diagbot.vo.GetInquiryDetailVO;
 import com.diagbot.vo.HisInquirysVO;
 import com.diagbot.vo.InquiryQuoteForIcssVO;
@@ -71,6 +73,8 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
     private TranServiceClient tranServiceClient;
     @Autowired
     private InquiryQuoteFacade inquiryQuoteFacade;
+    @Autowired
+    private SysSetFacade sysSetFacade;
 
     /**
      * 问诊记录保存
@@ -182,17 +186,28 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
      * @return
      */
     public List<HisInquiryDTO> hisInquirys(HisInquirysVO hisInquirysVO) {
-        if (hisInquirysVO.getHospitalId() == null && StringUtil.isBlank(hisInquirysVO.getHospitalCode())) {
+        if (StringUtil.isBlank(hisInquirysVO.getHospitalCode())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "医院信息(医院id或者医院编码)必传!");
         }
 
         QueryWrapper<InquiryInfo> inquiryInfoQe = new QueryWrapper<InquiryInfo>();
         inquiryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
-        inquiryInfoQe.eq("is_quoted", InquiryQuotedTypeEnum.Disable.getKey());
+        inquiryInfoQe.eq(!sysSetFacade.isQuoteShow(hisInquirysVO.getHospitalCode()),
+                "is_quoted", InquiryQuotedTypeEnum.Disable.getKey());
         inquiryInfoQe.eq(hisInquirysVO.getHospitalId() != null,
                 "hospital_id", hisInquirysVO.getHospitalId());
         inquiryInfoQe.eq(StringUtil.isNotBlank(hisInquirysVO.getHospitalCode()),
                 "hospital_code", hisInquirysVO.getHospitalCode());
+
+        if (StringUtil.isNotBlank(hisInquirysVO.getSonHospitalCode())) {
+            inquiryInfoQe.and(qe ->
+                    qe.eq("son_hospital_code", hisInquirysVO.getSonHospitalCode())
+                            .or()
+                            .eq("son_hospital_code", "")
+                            .or()
+                            .isNull("son_hospital_code"));
+        }
+
         inquiryInfoQe.eq(hisInquirysVO.getHospitalDeptId() != null,
                 "hospital_dept_id", hisInquirysVO.getHospitalDeptId());
         inquiryInfoQe.eq(StringUtil.isNotBlank(hisInquirysVO.getHospitalDeptCode()),
@@ -268,6 +283,30 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         return hisInquiryDTOList;
     }
 
+    /**
+     * 历史病历列表(ICSS调用)
+     *
+     * @param hisInquirysVO
+     * @return
+     */
+    public List<HisInquiryDTO> hisInquirysForIcss(HisInquirysVO hisInquirysVO) {
+        String hospitalCode = hisInquirysVO.getHospitalCode();
+        if (StringUtil.isBlank(hospitalCode)) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "医院信息(医院id或者医院编码)必传!");
+        }
+
+        RespDTO<String> respDTO = tranServiceClient.getParentHospitalCode(hospitalCode);
+        String parentHospitalCode = respDTO.data;
+        if (StringUtil.isNotBlank(parentHospitalCode)) {
+            hisInquirysVO.setHospitalCode(parentHospitalCode);
+            if (hisInquirysVO.getIsConsonHospitalCode() == 1) {
+                hisInquirysVO.setSonHospitalCode(hospitalCode);
+            }
+        }
+
+        return hisInquirys(hisInquirysVO);
+    }
+
     /**
      * 病历详情
      *
@@ -275,8 +314,7 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
      * @return
      */
     public GetInquiryDetailDTO getInquiryDetail(GetInquiryDetailVO getInquiryDetailVO) {
-        if (getInquiryDetailVO.getHospitalId() == null
-                && StringUtil.isBlank(getInquiryDetailVO.getHospitalCode())) {
+        if (StringUtil.isBlank(getInquiryDetailVO.getHospitalCode())) {
             throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "医院信息(医院id或者医院编码)必传!");
         }
         /*if (getInquiryDetailVO.getHospitalDeptId() == null && StringUtil.isBlank(getInquiryDetailVO.getHospitalDeptCode())) {
@@ -296,11 +334,22 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         inquiryInfoQe.eq(getInquiryDetailVO.getInquiryId() != null,
                 "id", getInquiryDetailVO.getInquiryId());
         inquiryInfoQe.eq("is_deleted", IsDeleteEnum.N.getKey());
-        inquiryInfoQe.eq("is_quoted", InquiryQuotedTypeEnum.Disable.getKey());
+        inquiryInfoQe.eq(!sysSetFacade.isQuoteShow(getInquiryDetailVO.getHospitalCode()),
+                "is_quoted", InquiryQuotedTypeEnum.Disable.getKey());
         inquiryInfoQe.eq(getInquiryDetailVO.getHospitalId() != null,
                 "hospital_id", getInquiryDetailVO.getHospitalId());
         inquiryInfoQe.eq(StringUtil.isNotBlank(getInquiryDetailVO.getHospitalCode()),
                 "hospital_code", getInquiryDetailVO.getHospitalCode());
+
+        if (StringUtil.isNotBlank(getInquiryDetailVO.getSonHospitalCode())) {
+            inquiryInfoQe.and(qe ->
+                    qe.eq("son_hospital_code", getInquiryDetailVO.getSonHospitalCode())
+                            .or()
+                            .eq("son_hospital_code", "")
+                            .or()
+                            .isNull("son_hospital_code"));
+        }
+
         inquiryInfoQe.eq(getInquiryDetailVO.getHospitalDeptId() != null,
                 "hospital_dept_id", getInquiryDetailVO.getHospitalDeptId());
         inquiryInfoQe.eq(StringUtil.isNotBlank(getInquiryDetailVO.getHospitalDeptCode()),
@@ -423,50 +472,78 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         if (!inquiryInfo.getHospitalCode().equals(inquiryQuoteVO.getHospitalCode())) {
             throw new CommonException(CommonErrorCode.RPC_ERROR, "医院不一致");
         }
-        if (inquiryInfo.getIsQuoted() == 1) {
+
+        boolean isQuoteShow = sysSetFacade.isQuoteShow(inquiryQuoteVO.getHospitalCode());
+        if (!isQuoteShow && inquiryInfo.getIsQuoted() == 1) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "病历已引用过");
+        }
+
+        Date now = DateUtil.now();
+        InquiryQuote inquiryQuote = null;
+        if (inquiryInfo.getIsQuoted() == 0) {
+            inquiryInfo.setGmtModified(now);
+            //            inquiryInfo.setIsQuoted(1);
+            //            if (StringUtil.isBlank(inquiryInfo.getInquiryCode())) {
+            //                inquiryInfo.setInquiryCode(inquiryQuoteVO.getInquiryCode());
+            //            }
+            //            inquiryInfo.setPatientCode(inquiryQuoteVO.getPatientInfo().getCode());
+            //            inquiryInfo.setPatientName(inquiryQuoteVO.getPatientInfo().getName());
+            //            inquiryInfo.setPatientIdNo(inquiryQuoteVO.getPatientInfo().getIdentityNum());
+            //            inquiryInfo.setPatientBirthday(inquiryQuoteVO.getPatientInfo().getBirthday());
+            //            inquiryInfo.setPatientPhone(inquiryQuoteVO.getPatientInfo().getPhone());
+            //            inquiryInfo.setPatientSex(inquiryQuoteVO.getPatientInfo().getSex());
+        } else if (isQuoteShow) {
+            QueryWrapper<InquiryQuote> inquiryQuoteQe = new QueryWrapper<>();
+            inquiryQuoteQe.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("inquiry_id", inquiryQuoteVO.getInquiryId())
+                    .eq("hospital_code", inquiryQuoteVO.getHospitalCode())
+                    .eq("hospital_dept_code", inquiryQuoteVO.getDeptInfo().getCode())
+                    .eq("doctor_code", inquiryQuoteVO.getDoctorInfo().getCode())
+                    .eq("patient_code", inquiryQuoteVO.getPatientInfo().getCode())
+                    .eq("inquiry_code", inquiryQuoteVO.getInquiryCode())
+                    .eq(StringUtil.isNotBlank(inquiryQuoteVO.getSonHospitalCode()),
+                            "son_hospital_code", inquiryQuoteVO.getSonHospitalCode());
+            inquiryQuote = inquiryQuoteFacade.getOne(inquiryQuoteQe, false);
+        } else {
             return true;
         }
 
-        RespDTO<InquiryQuoteVO> respDTO = tranServiceClient.inquiryQuote(inquiryQuoteVO);
-        RespDTOUtil.respNGDealCover(respDTO, "病历引用失败");
-        inquiryQuoteVO = respDTO.data;
+        if (inquiryInfo.getIsQuoted() == 0 || inquiryQuote == null) {
+            RespDTO<InquiryQuoteVO> respDTO = tranServiceClient.inquiryQuote(inquiryQuoteVO);
+            RespDTOUtil.respNGDealCover(respDTO, "病历引用失败");
+            inquiryQuoteVO = respDTO.data;
+        }
 
-        Date now = DateUtil.now();
-        inquiryInfo.setGmtModified(now);
-        inquiryInfo.setIsQuoted(1);
-        inquiryInfo.setInquiryCode(inquiryQuoteVO.getInquiryCode());
-        inquiryInfo.setPatientId(inquiryQuoteVO.getPatientInfo().getId());
-        inquiryInfo.setPatientCode(inquiryQuoteVO.getPatientInfo().getCode());
-        inquiryInfo.setPatientName(inquiryQuoteVO.getPatientInfo().getName());
-        inquiryInfo.setPatientIdNo(inquiryQuoteVO.getPatientInfo().getIdentityNum());
-        inquiryInfo.setPatientBirthday(inquiryQuoteVO.getPatientInfo().getBirthday());
-        inquiryInfo.setPatientPhone(inquiryQuoteVO.getPatientInfo().getPhone());
-        inquiryInfo.setPatientSex(inquiryQuoteVO.getPatientInfo().getSex());
-        updateById(inquiryInfo);
+        if (inquiryInfo.getIsQuoted() == 0) {
+            //            inquiryInfo.setPatientId(inquiryQuoteVO.getPatientInfo().getId());
+            inquiryInfo.setIsQuoted(1);
+            updateById(inquiryInfo);
+        }
 
         //插入引用表信息
-        InquiryQuote inquiryQuote = new InquiryQuote();
-        BeanUtil.copyProperties(inquiryQuoteVO, inquiryQuote);
-        inquiryQuote.setGmtCreate(now);
+        if (inquiryQuote == null) {
+            inquiryQuote = new InquiryQuote();
+            BeanUtil.copyProperties(inquiryQuoteVO, inquiryQuote);
+            inquiryQuote.setGmtCreate(now);
+            inquiryQuote.setHospitalDeptId(inquiryQuoteVO.getDeptInfo().getId());
+            inquiryQuote.setHospitalDeptCode(inquiryQuoteVO.getDeptInfo().getCode());
+            inquiryQuote.setHospitalDeptName(inquiryQuoteVO.getDeptInfo().getName());
+            inquiryQuote.setDoctorId(inquiryQuoteVO.getDoctorInfo().getId());
+            inquiryQuote.setDoctorCode(inquiryQuoteVO.getDoctorInfo().getCode());
+            inquiryQuote.setDoctorName(inquiryQuoteVO.getDoctorInfo().getName());
+            inquiryQuote.setPatientId(inquiryQuoteVO.getPatientInfo().getId());
+            inquiryQuote.setPatientCode(inquiryQuoteVO.getPatientInfo().getCode());
+            inquiryQuote.setPatientName(inquiryQuoteVO.getPatientInfo().getName());
+            inquiryQuote.setPatientIdNo(inquiryQuoteVO.getPatientInfo().getIdentityNum());
+            inquiryQuote.setPatientBirthday(inquiryQuoteVO.getPatientInfo().getBirthday());
+            inquiryQuote.setPatientPhone(inquiryQuoteVO.getPatientInfo().getPhone());
+            inquiryQuote.setPatientSex(inquiryQuoteVO.getPatientInfo().getSex());
+            inquiryQuote.setRegVisitedState(inquiryInfo.getRegVisitedState());
+            inquiryQuote.setType(inquiryInfo.getType());
+            inquiryQuote.setDataJson(inquiryInfo.getDataJson());
+        }
         inquiryQuote.setGmtModified(now);
-        inquiryQuote.setHospitalDeptId(inquiryQuoteVO.getDeptInfo().getId());
-        inquiryQuote.setHospitalDeptCode(inquiryQuoteVO.getDeptInfo().getCode());
-        inquiryQuote.setHospitalDeptName(inquiryQuoteVO.getDeptInfo().getName());
-        inquiryQuote.setDoctorId(inquiryQuoteVO.getDoctorInfo().getId());
-        inquiryQuote.setDoctorCode(inquiryQuoteVO.getDoctorInfo().getCode());
-        inquiryQuote.setDoctorName(inquiryQuoteVO.getDoctorInfo().getName());
-        inquiryQuote.setPatientId(inquiryQuoteVO.getPatientInfo().getId());
-        inquiryQuote.setPatientCode(inquiryQuoteVO.getPatientInfo().getCode());
-        inquiryQuote.setPatientName(inquiryQuoteVO.getPatientInfo().getName());
-        inquiryQuote.setPatientIdNo(inquiryQuoteVO.getPatientInfo().getIdentityNum());
-        inquiryQuote.setPatientBirthday(inquiryQuoteVO.getPatientInfo().getBirthday());
-        inquiryQuote.setPatientPhone(inquiryQuoteVO.getPatientInfo().getPhone());
-        inquiryQuote.setPatientSex(inquiryQuoteVO.getPatientInfo().getSex());
-        inquiryQuote.setRegVisitedState(inquiryInfo.getRegVisitedState());
-        inquiryQuote.setType(inquiryInfo.getType());
-        inquiryQuote.setDataJson(inquiryInfo.getDataJson());
-
-        inquiryQuoteFacade.save(inquiryQuote);
+        inquiryQuoteFacade.saveOrUpdate(inquiryQuote);
 
         return true;
     }
@@ -482,43 +559,78 @@ public class InquiryInfoFacade extends InquiryInfoServiceImpl {
         if (inquiryInfo == null) {
             throw new CommonException(CommonErrorCode.RPC_ERROR, "病历不存在");
         }
+
+        GetHospitalRankInfoVO getHospitalRankInfoVO = new GetHospitalRankInfoVO();
+        getHospitalRankInfoVO.setHospitalCode(inquiryQuoteForIcssVO.getHospitalCode());
+        getHospitalRankInfoVO.setIsCkConnectPrec(0);
+        RespDTO<GetHospitalRankInfoDTO> respDTO = tranServiceClient.getHospitalRankInfo(getHospitalRankInfoVO);
+        RespDTOUtil.respNGDealCover(respDTO, "引用预问诊失败");
+        GetHospitalRankInfoDTO getHospitalRankInfoDTO = respDTO.data;
+        BeanUtil.copyProperties(getHospitalRankInfoDTO, inquiryQuoteForIcssVO);
+
         if (!inquiryInfo.getHospitalCode().equals(inquiryQuoteForIcssVO.getHospitalCode())) {
             throw new CommonException(CommonErrorCode.RPC_ERROR, "医院不一致");
         }
-        if (inquiryInfo.getIsQuoted() == 1) {
-            return true;
+
+        boolean isQuoteShow = sysSetFacade.isQuoteShow(inquiryQuoteForIcssVO.getHospitalCode());
+        if (!isQuoteShow && inquiryInfo.getIsQuoted() == 1) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "病历已引用过");
         }
 
         Date now = DateUtil.now();
-        inquiryInfo.setGmtModified(now);
-        inquiryInfo.setIsQuoted(1);
-        inquiryInfo.setInquiryCode(inquiryQuoteForIcssVO.getInquiryCode());
-        inquiryInfo.setPatientId(inquiryQuoteForIcssVO.getPatientId());
-        inquiryInfo.setPatientCode(inquiryQuoteForIcssVO.getPatientCode());
-        inquiryInfo.setPatientName(inquiryQuoteForIcssVO.getPatientName());
-        inquiryInfo.setPatientIdNo(
-                StringUtil.isBlank(inquiryQuoteForIcssVO.getPatientIdentityNum())
-                        ? inquiryQuoteForIcssVO.getPatientIdNo()
-                        : inquiryQuoteForIcssVO.getPatientIdentityNum()
-        );
-        inquiryInfo.setPatientBirthday(inquiryQuoteForIcssVO.getPatientBirthday());
-        inquiryInfo.setPatientPhone(inquiryQuoteForIcssVO.getPatientPhone());
-        inquiryInfo.setPatientSex(inquiryQuoteForIcssVO.getPatientSex());
-        updateById(inquiryInfo);
-
-        InquiryQuote inquiryQuote = new InquiryQuote();
-        BeanUtil.copyProperties(inquiryQuoteForIcssVO, inquiryQuote);
-        inquiryQuote.setRegVisitedState(inquiryInfo.getRegVisitedState());
-        inquiryQuote.setType(inquiryInfo.getType());
-        inquiryQuote.setDataJson(inquiryInfo.getDataJson());
-        inquiryQuote.setPatientIdNo(
-                StringUtil.isBlank(inquiryQuoteForIcssVO.getPatientIdentityNum())
-                        ? inquiryQuoteForIcssVO.getPatientIdNo()
-                        : inquiryQuoteForIcssVO.getPatientIdentityNum()
-        );
-        inquiryQuoteFacade.save(inquiryQuote);
+        InquiryQuote inquiryQuote = null;
+        if (inquiryInfo.getIsQuoted() == 0) {
+            inquiryInfo.setGmtModified(now);
+            inquiryInfo.setIsQuoted(1);
+            //            if (StringUtil.isBlank(inquiryInfo.getInquiryCode())) {
+            //                inquiryInfo.setInquiryCode(inquiryQuoteForIcssVO.getInquiryCode());
+            //            }
+            //            inquiryInfo.setPatientId(inquiryQuoteForIcssVO.getPatientId());
+            //            inquiryInfo.setPatientCode(inquiryQuoteForIcssVO.getPatientCode());
+            //            inquiryInfo.setPatientName(inquiryQuoteForIcssVO.getPatientName());
+            //            inquiryInfo.setPatientIdNo(
+            //                    StringUtil.isBlank(inquiryQuoteForIcssVO.getPatientIdentityNum())
+            //                            ? inquiryQuoteForIcssVO.getPatientIdNo()
+            //                            : inquiryQuoteForIcssVO.getPatientIdentityNum()
+            //            );
+            //            inquiryInfo.setPatientBirthday(inquiryQuoteForIcssVO.getPatientBirthday());
+            //            inquiryInfo.setPatientPhone(inquiryQuoteForIcssVO.getPatientPhone());
+            //            inquiryInfo.setPatientSex(inquiryQuoteForIcssVO.getPatientSex());
+            updateById(inquiryInfo);
+        } else if (isQuoteShow) {
+            QueryWrapper<InquiryQuote> inquiryQuoteQe = new QueryWrapper<>();
+            inquiryQuoteQe.eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("inquiry_id", inquiryQuoteForIcssVO.getInquiryId())
+                    .eq("hospital_code", inquiryQuoteForIcssVO.getHospitalCode())
+                    .eq("hospital_dept_code", inquiryQuoteForIcssVO.getHospitalDeptCode())
+                    .eq("doctor_code", inquiryQuoteForIcssVO.getDoctorCode())
+                    .eq("patient_code", inquiryQuoteForIcssVO.getPatientCode())
+                    .eq("inquiry_code", inquiryQuoteForIcssVO.getInquiryCode())
+                    .eq(StringUtil.isNotBlank(inquiryQuoteForIcssVO.getSonHospitalCode()),
+                            "son_hospital_code", inquiryQuoteForIcssVO.getSonHospitalCode());
+            inquiryQuote = inquiryQuoteFacade.getOne(inquiryQuoteQe, false);
+        } else {
+            return true;
+        }
+
+        if (inquiryQuote == null) {
+            inquiryQuote = new InquiryQuote();
+            inquiryQuote.setGmtCreate(now);
+            BeanUtil.copyProperties(inquiryQuoteForIcssVO, inquiryQuote);
+            inquiryQuote.setRegVisitedState(inquiryInfo.getRegVisitedState());
+            inquiryQuote.setType(inquiryInfo.getType());
+            inquiryQuote.setDataJson(inquiryInfo.getDataJson());
+            inquiryQuote.setPatientIdNo(
+                    StringUtil.isBlank(inquiryQuoteForIcssVO.getPatientIdentityNum())
+                            ? inquiryQuoteForIcssVO.getPatientIdNo()
+                            : inquiryQuoteForIcssVO.getPatientIdentityNum()
+            );
+        }
+        inquiryQuote.setGmtModified(now);
+        inquiryQuoteFacade.saveOrUpdate(inquiryQuote);
 
         return true;
     }
-}
 
+
+}

+ 0 - 2
prec-service/src/main/java/com/diagbot/facade/PatientInfoFacade.java

@@ -9,11 +9,9 @@ import org.springframework.stereotype.Component;
 
 import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.TranServiceClient;
-import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SignInDTO;
 import com.diagbot.util.RespDTOUtil;
-import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.SignInVO;
 
 /**

+ 30 - 0
prec-service/src/main/java/com/diagbot/facade/SysSetFacade.java

@@ -4,7 +4,11 @@ import com.diagbot.client.TranServiceClient;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SysHospitalDTO;
 import com.diagbot.dto.SysSetInfoDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.StringUtil;
 import com.diagbot.vo.HospitalSetVO;
 import com.diagbot.vo.SysHospitalCodeVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,4 +47,30 @@ public class SysSetFacade {
         RespDTOUtil.respNGDeal(sysHospitalDTO, "医院编码获取医院信息及科室信息失败!");
         return sysHospitalDTO.data;
     }
+
+    /**
+     * 是否显示引用过的预问诊
+     *
+     * @param hospitalCode
+     * @return
+     */
+    public Boolean isQuoteShow(String hospitalCode) {
+        HospitalSetVO hospitalSetVO = new HospitalSetVO();
+        hospitalSetVO.setHospitalCode(hospitalCode);
+        hospitalSetVO.setCode("quote_show");
+
+        RespDTO<List<SysSetInfoDTO>> retData = tranServiceClient.getSysSetInfoDatas(hospitalSetVO);
+        RespDTOUtil.respNGDeal(retData, "获取配置数据失败!");
+
+        if (ListUtil.isEmpty(retData.data)) {
+            return false;
+        }
+
+        if (retData.data.size() > 1) {
+            throw new CommonException(CommonErrorCode.RPC_ERROR, "获取配置数据失败!");
+        }
+
+        return StringUtil.isNotBlank(retData.data.get(0).getValue()) && retData.data.get(0).getValue().equals("1");
+    }
+
 }

+ 33 - 0
prec-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java

@@ -0,0 +1,33 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description:
+ * @author: rengb
+ * @time: 2018/11/19 18:58
+ */
+@ApiModel(value = "获取大小医院信息接口传参")
+@Getter
+@Setter
+public class GetHospitalRankInfoVO {
+
+    /**
+     * 医院编码
+     */
+    @ApiModelProperty(value = "医院编码", required = true)
+    @NotBlank(message = "医院编码必传")
+    private String hospitalCode;
+
+    /**
+     * 校验是否对接预问诊 0-不校验 1-校验
+     */
+    @ApiModelProperty(value = "医院编码")
+    private Integer isCkConnectPrec = 1;
+
+}

+ 12 - 0
prec-service/src/main/java/com/diagbot/vo/GetInquiryDetailVO.java

@@ -33,6 +33,18 @@ public class GetInquiryDetailVO {
     @ApiModelProperty(value = "医院编码")
     private String hospitalCode;
 
+    /**
+     * 子医院id
+     */
+    @ApiModelProperty(value = "子医院id")
+    private Long sonHospitalId;
+
+    /**
+     * 子医院编码
+     */
+    @ApiModelProperty(value = "子医院编码")
+    private String sonHospitalCode;
+
     /**
      * 医院科室id
      */

+ 0 - 56
prec-service/src/main/java/com/diagbot/vo/GetTopPatientInfoVO.java

@@ -1,56 +0,0 @@
-package com.diagbot.vo;
-
-import javax.validation.constraints.NotBlank;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * @Description
- * @author rgb
- * @time 2018年11月19日下午4:58:37
- */
-@ApiModel(value="页面顶部病人医生科室信息查询接口传参")
-@Getter
-@Setter
-public class GetTopPatientInfoVO {
-	
-	/**
-	 * 医院编号
-	 */
-	@ApiModelProperty(value="医院编号",required=true)
-	@NotBlank(message="医院编号必填")
-	private String hospitalCode;
-	
-	/**
-	 * 医院科室编号
-	 */
-	@ApiModelProperty(value="医院科室编号",required=true)
-	@NotBlank(message="医院科室编号必填")
-	private String hospitalDeptCode;
-	
-	/**
-	 * 医院医生编号
-	 */
-	@ApiModelProperty(value="医院医生编号",required=true)
-	@NotBlank(message="医院医生编号必填")
-	private String doctorCode;
-	
-	/**
-	 * 医院患者编号
-	 */
-	@ApiModelProperty(value="医院患者编号",required=true)
-	@NotBlank(message="医院患者编号必填")
-	private String patientCode;
-	
-	/**
-	 * 门诊号
-	 */
-	@ApiModelProperty(value="门诊号",required=true)
-	@NotBlank(message="门诊号必填")
-	private String recordId;
-	
-
-}

+ 17 - 0
prec-service/src/main/java/com/diagbot/vo/HisInquirysVO.java

@@ -30,6 +30,18 @@ public class HisInquirysVO {
     @ApiModelProperty(value = "医院编码")
     private String hospitalCode;
 
+    /**
+     * 子医院id
+     */
+    @ApiModelProperty(value = "子医院id")
+    private Long sonHospitalId;
+
+    /**
+     * 子医院编码
+     */
+    @ApiModelProperty(value = "子医院编码")
+    private String sonHospitalCode;
+
     /**
      * 医院科室id
      */
@@ -116,4 +128,9 @@ public class HisInquirysVO {
     @ApiModelProperty(value = "是否查询详情,0-不查(默认) 1-查询")
     private Integer isHaveDetail = 0;
 
+    /**
+     * 是否考虑子医院 0-不考虑  1-考虑
+     */
+    private Integer isConsonHospitalCode = 0;
+
 }

+ 7 - 0
prec-service/src/main/java/com/diagbot/web/InquiryInfoController.java

@@ -60,6 +60,13 @@ public class InquiryInfoController {
         return RespDTO.onSuc(inquiryInfoFacade.hisInquirys(hisInquirysVO));
     }
 
+    @ApiOperation(value = "历史病历列表(ICSS调用)[by:rengb]")
+    @PostMapping("/hisInquirysForIcss")
+    @SysLogger("hisInquirysForIcss")
+    public RespDTO<List<HisInquiryDTO>> hisInquirysForIcss(@Valid @RequestBody HisInquirysVO hisInquirysVO) {
+        return RespDTO.onSuc(inquiryInfoFacade.hisInquirysForIcss(hisInquirysVO));
+    }
+
     @ApiOperation(value = "病历详情[by:rengb]")
     @PostMapping("/getInquiryDetail")
     @SysLogger("getInquiryDetail")

+ 0 - 2
prec-service/src/main/java/com/diagbot/web/PatientInfoController.java

@@ -14,11 +14,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.GetTopPatientInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SignInDTO;
 import com.diagbot.facade.PatientInfoFacade;
-import com.diagbot.vo.GetTopPatientInfoVO;
 import com.diagbot.vo.SignInVO;
 
 import io.swagger.annotations.Api;

+ 62 - 84
tran-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDTO.java

@@ -1,152 +1,130 @@
-/**
- * 
- */
 package com.diagbot.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
 import java.util.Date;
 
 /**
- * @Description
  * @author rgb
+ * @Description
  * @time 2018年11月19日下午4:57:43
  */
-@ApiModel(value="页面顶部病人医生科室信息查询接口出参")
 @Getter
 @Setter
 public class GetTopPatientInfoDTO {
-	
-	/**
-	 * 医院id
-	 */
-	@ApiModelProperty(value="医院id")
-	private Long hospitalId;
-	
-	/**
+
+    /**
+     * 医院id
+     */
+    private Long hospitalId;
+
+    /**
      * 医院编码
      */
-	@ApiModelProperty(value="医院编码")
     private String hospitalCode;
 
     /**
      * 医院名称
      */
-	@ApiModelProperty(value="医院名称")
     private String hospitalName;
-    
-    /**
-	 * 医院科室id
-	 */
-	@ApiModelProperty(value="医院科室id")
-	private Long hospitalDeptId;
-	
-    /**
-	 * 自己科室id
-	 */
-	@ApiModelProperty(value="自己科室id")
-	private Long selfDeptId;
-	
-	/**
-	 * 自己科室名称
-	 */
-	@ApiModelProperty(value="自己科室名称")
-	private String selfDeptName;
-    
+
+    /**
+     * 医院科室id
+     */
+    private Long hospitalDeptId;
+
+    /**
+     * 自己科室id
+     */
+    private Long selfDeptId;
+
+    /**
+     * 自己科室名称
+     */
+    private String selfDeptName;
+
     /**
      * 医院科室编码
      */
-	@ApiModelProperty(value="医院科室编码")
     private String hospitalDeptCode;
 
     /**
      * 医院科室名称
      */
-	@ApiModelProperty(value="医院科室名称")
     private String hospitalDeptName;
-    
-    /**
-	 * 医生id
-	 */
-	@ApiModelProperty(value="医生id")
-	private Long doctorId;
-	
-	/**
+
+    /**
+     * 医生id
+     */
+    private Long doctorId;
+
+    /**
      * 医生编码
      */
-	@ApiModelProperty(value="医生编码")
     private String doctorCode;
 
     /**
      * 医生姓名
      */
-	@ApiModelProperty(value="医生姓名")
     private String doctorName;
-    
-    /**
-   	 * 病人id
-   	 */
-	@ApiModelProperty(value="病人id")
-   	private Long patientId;
-   	
-   	/**
+
+    /**
+     * 病人id
+     */
+    private Long patientId;
+
+    /**
      * 病人编号
      */
-	@ApiModelProperty(value="病人编号")
     private String patientCode;
 
     /**
      * 病人姓名
      */
-	@ApiModelProperty(value="病人姓名")
     private String patientName;
 
     /**
      * 病人性别
      */
-	@ApiModelProperty(value="病人性别")
     private String patientSex;
-    
+
     /**
      * 病人年龄
      */
-	@ApiModelProperty(value="病人年龄")
     private Integer patientAge;
-    
+
     /**
      * 病人证件号码
      */
-	@ApiModelProperty(value="病人证件号码")
     private String patientIdNo;
 
-	/**
-	 * 患者身份证号
-	 */
-	@ApiModelProperty(value = "患者身份证号")
-	private String patientIdentityNum;
-
-	/**
-	 * 系统时间
-	 */
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
-	@ApiModelProperty(value="系统时间")
-	private Date systemTime;
-	
-	/**
+    /**
+     * 患者身份证号
+     */
+    private String patientIdentityNum;
+
+    /**
+     * 患者联系电话
+     */
+    private String patientPhone;
+
+    /**
+     * 系统时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    private Date systemTime;
+
+    /**
      * 出生日期
      */
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
-	@ApiModelProperty(value="出生日期")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
     private Date birthday;
-	
-	/**
+
+    /**
      * 门诊号
      */
-	@ApiModelProperty(value="门诊号")
-	private String recordId;
-	
+    private String recordId;
+
 }

+ 6 - 11
tran-service/src/main/java/com/diagbot/dto/GetTopPatientInfoDjDTO.java

@@ -115,6 +115,11 @@ public class GetTopPatientInfoDjDTO {
      */
     private String patientIdNo;
 
+    /**
+     * 患者联系电话
+     */
+    private String patientPhone;
+
     /**
      * 系统时间
      */
@@ -132,14 +137,4 @@ public class GetTopPatientInfoDjDTO {
      */
     private String recordId;
 
-    /**
-     * 模式分类
-     */
-    private Integer modeClassify;
-
-    /**
-     * 模式值
-     */
-    private Integer modeValue;
-
-}
+}

+ 172 - 138
tran-service/src/main/java/com/diagbot/facade/PatientInfoDjFacade.java

@@ -17,6 +17,7 @@ import com.diagbot.exception.ServiceErrorCode;
 import com.diagbot.idc.VisibleIdCreater;
 import com.diagbot.service.DoctorInfoService;
 import com.diagbot.service.HospitalDeptService;
+import com.diagbot.service.PatientInfoService;
 import com.diagbot.service.impl.PatientInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
@@ -59,6 +60,9 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
     private SysSetFacade sysSetFacade;
     @Autowired
     private VisibleIdCreater visibleIdCreater;
+    @Autowired
+    @Qualifier("patientInfoServiceImpl")
+    private PatientInfoService patientInfoService;
 
     /**
      * 对接-页面顶部病人医生科室信息——查询
@@ -67,37 +71,33 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
      * @return
      */
     public GetTopPatientInfoDjDTO getTopPatientInfoDj(GetTopPatientInfoDjVO getTopPatientInfoDjVO) {
+        String hospitalCode = getTopPatientInfoDjVO.getHospitalCode();
+        String sonHospitalCode =
+                StringUtil.isNotBlank(getTopPatientInfoDjVO.getSonHospitalCode())
+                        ? getTopPatientInfoDjVO.getSonHospitalCode()
+                        : hospitalCode;
+        getTopPatientInfoDjVO.setSonHospitalCode(sonHospitalCode);
+
         GetTopPatientInfoDjDTO getTopPatientInfoDjDTO = this.baseMapper.getTopPatientInfoDj(getTopPatientInfoDjVO);
         getTopPatientInfoDjDTO.setSystemTime(DateUtil.now());
         getTopPatientInfoDjDTO.setRecordId(getTopPatientInfoDjVO.getRecordId());
         getTopPatientInfoDjDTO.setPatientAge(DateUtil.yearCompare(getTopPatientInfoDjDTO.getBirthday(), DateUtil.now()));
 
-        List<String> hospitalCodeList = Lists.newArrayList();
-        hospitalCodeList.add(getTopPatientInfoDjVO.getHospitalCode());
-        if (StringUtil.isNotBlank(getTopPatientInfoDjVO.getSonHospitalCode())) {
-            hospitalCodeList.add(getTopPatientInfoDjVO.getSonHospitalCode());
-        }
-        QueryWrapper<HospitalInfo> hospitalInfoQe = new QueryWrapper<>();
-        hospitalInfoQe.in("code", hospitalCodeList);
-        Map<String, HospitalInfo> hospitalInfoMap = hospitalInfoFacade.list(hospitalInfoQe)
-                .stream().collect(Collectors.toMap(HospitalInfo::getCode, i -> i));
-
-        HospitalInfo hospitalInfo = hospitalInfoMap.get(getTopPatientInfoDjVO.getHospitalCode());
-        HospitalInfo sonHospitalInfo = hospitalInfoMap.get(getTopPatientInfoDjVO.getSonHospitalCode());
-        getTopPatientInfoDjDTO.setHospitalId(hospitalInfo.getId());
-        getTopPatientInfoDjDTO.setHospitalCode(hospitalInfo.getCode());
-        getTopPatientInfoDjDTO.setHospitalName(hospitalInfo.getName());
-        if (sonHospitalInfo != null) {
-            getTopPatientInfoDjDTO.setSonHospitalId(sonHospitalInfo.getId());
-            getTopPatientInfoDjDTO.setSonHospitalCode(sonHospitalInfo.getCode());
-            getTopPatientInfoDjDTO.setSonHospitalName(sonHospitalInfo.getName());
+        if (!hospitalCode.equals(sonHospitalCode)) {
+            QueryWrapper<HospitalInfo> hospitalInfoQe = new QueryWrapper<>();
+            hospitalInfoQe.eq("code", hospitalCode);
+            HospitalInfo hospitalInfo = hospitalInfoFacade.getOne(hospitalInfoQe, false);
+            getTopPatientInfoDjDTO.setHospitalId(hospitalInfo.getId());
+            getTopPatientInfoDjDTO.setHospitalCode(hospitalInfo.getCode());
+            getTopPatientInfoDjDTO.setHospitalName(hospitalInfo.getName());
+        } else {
+            getTopPatientInfoDjDTO.setSonHospitalId(null);
+            getTopPatientInfoDjDTO.setSonHospitalCode(null);
+            getTopPatientInfoDjDTO.setSonHospitalName(null);
         }
 
         QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
-        hospitalDeptQe.eq("hospital_code",
-                StringUtil.isBlank(getTopPatientInfoDjVO.getSonHospitalCode())
-                        ? getTopPatientInfoDjVO.getHospitalCode()
-                        : getTopPatientInfoDjVO.getSonHospitalCode());
+        hospitalDeptQe.eq("hospital_code", sonHospitalCode);
         hospitalDeptQe.eq("code", getTopPatientInfoDjVO.getHospitalDeptCode());
         HospitalDept hospitalDept = hospitalDeptFacade.getOne(hospitalDeptQe, false);
         if (hospitalDept != null) {
@@ -141,16 +141,17 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
      * @return
      */
     private List<SignInDTO> autoGenePatinfo(SignInVO signInVO) {
+        String hospitalCode = signInVO.getHospitalCode();
+        String sonHospitalCode =
+                StringUtil.isNotBlank(signInVO.getSonHospitalCode()) ? signInVO.getSonHospitalCode() : hospitalCode;
         QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
         sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey());
         sysSetQe.and(qe1 -> qe1
                 .and(qe2 -> qe2
-                        .eq("hospital_code", signInVO.getHospitalCode())
+                        .eq("hospital_code", hospitalCode)
                         .eq("code", "patientinfo"))
                 .or(qe3 -> qe3
-                        .eq("hospital_code",
-                                StringUtil.isBlank(signInVO.getSonHospitalCode()) ? signInVO.getHospitalCode()
-                                        : signInVO.getSonHospitalCode())
+                        .eq("hospital_code", sonHospitalCode)
                         .eq("code", "default_dept")));
         Map<String, String> sysSetCodeValue = sysSetFacade.list(sysSetQe).stream()
                 .collect(Collectors.toMap(SysSet::getCode, i -> i.getValue()));
@@ -174,21 +175,22 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
         signInDTO.setHospitalDeptCode(hospitalDeptCode);
 
         QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
-        hospitalDeptQe.eq("hospital_code",
-                StringUtil.isBlank(signInVO.getSonHospitalCode()) ? signInVO.getHospitalCode() : signInVO.getSonHospitalCode());
+        hospitalDeptQe.eq("hospital_code", sonHospitalCode);
         hospitalDeptQe.eq("code", hospitalDeptCode);
         signInDTO.setHospitalDeptName(hospitalDeptFacade.getOne(hospitalDeptQe, false).getName());
 
         QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
-        patientInfoQe.eq("hospital_code", signInVO.getHospitalCode());
+        patientInfoQe.eq("hospital_code", sonHospitalCode);
         patientInfoQe.eq("name", signInVO.getPatientName());
         patientInfoQe.and(a ->
                 a.eq("id_no", signInVO.getPatientInfo()).or().eq("identity_num", signInVO.getPatientInfo()));
-        PatientInfo patientInfo = getOne(patientInfoQe, false);
-        if (patientInfo == null) {
+        patientInfoQe.orderByAsc("remark");
+        List<PatientInfo> patientInfoList = list(patientInfoQe);
+        PatientInfo patientInfo = null;
+        if (ListUtil.isEmpty(patientInfoList)) {
             patientInfo = new PatientInfo();
             patientInfo.setGmtCreate(DateUtil.now());
-            patientInfo.setHospitalCode(signInVO.getHospitalCode());
+            patientInfo.setHospitalCode(sonHospitalCode);
             patientInfo.setIdNo(signInVO.getPatientInfo());
             patientInfo.setIdentityNum(signInVO.getPatientInfo());
             patientInfo.setName(signInVO.getPatientName());
@@ -199,7 +201,10 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
             patientInfo.setRemark("1");//自动生成标志
 
             save(patientInfo);
+        } else {
+            patientInfo = patientInfoList.get(0);
         }
+
         signInDTO.setPatientCode(patientInfo.getCode());
         signInDTO.setPatientName(patientInfo.getName());
 
@@ -246,96 +251,124 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
     private void generateByRif(List<RegisterInfoDTO> rifList) {
         String hospitalCode = rifList.get(0).getHospitalCode();
         String hospitalName = rifList.get(0).getHospitalName();
-        PatientInfo patientInfo = rifList.get(0).getPatientInfo();
-        QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
-        patientInfoQe.eq("hospital_code", hospitalCode);
-        patientInfoQe.eq("code", patientInfo.getCode());
-        PatientInfo patientInfoQuery = getOne(patientInfoQe, false);
-        PatientInfo saveOrUpat = new PatientInfo();
-        Long patId = null;
-        if (patientInfoQuery != null) {
-            patId = patientInfoQuery.getId();
-            BeanUtil.copyProperties(patientInfoQuery, saveOrUpat);
-        }
-        BeanUtil.copyProperties(patientInfo, saveOrUpat);
-        saveOrUpat.setId(patId);
-        saveOrUpat.setHospitalCode(hospitalCode);
-        saveOrUpdate(saveOrUpat);
 
-        List<String> doctorCodeList = Lists.newArrayList();
-        List<DoctorInfo> doctorInfoList = Lists.newArrayList();
+        List<PatientInfo> patientSaveOrUpdateList = Lists.newArrayList();
+        List<HospitalDept> deptSaveOrUpdateList = Lists.newArrayList();
+        List<DoctorInfo> doctorSaveOrUpdateList = Lists.newArrayList();
         rifList.forEach(rif -> {
-            String sonHospitalCode = rif.getSonHospitalCode();
-            String sonHospitalName = rif.getSonHospitalName();
+            String sonHospitalCode = StringUtil.isNotBlank(rif.getSonHospitalCode()) ? rif.getSonHospitalCode() : hospitalCode;
+            String sonHospitalName = StringUtil.isNotBlank(rif.getSonHospitalCode()) ? rif.getSonHospitalName() : hospitalName;
+
+            /********** 患者部分 **********/
+            PatientInfo patientInfo = rif.getPatientInfo();
+            if (!patientSaveOrUpdateList.stream()
+                    .filter(patientSaveOrUpdate -> patientSaveOrUpdate.getHospitalCode().equals(sonHospitalCode))
+                    .map(patientSaveOrUpdate -> patientSaveOrUpdate.getCode())
+                    .collect(Collectors.toList())
+                    .contains(patientInfo.getCode())) {
+                QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
+                patientInfoQe.eq("hospital_code", sonHospitalCode);
+                patientInfoQe.eq("name", patientInfo.getName());
+                patientInfoQe.eq(StringUtil.isBlank(patientInfo.getIdentityNum())
+                                && StringUtil.isNotBlank(patientInfo.getIdNo()),
+                        "id_no", patientInfo.getIdNo());
+                patientInfoQe.eq(StringUtil.isNotBlank(patientInfo.getIdentityNum()),
+                        "identity_num", patientInfo.getIdentityNum());
+                PatientInfo patientInfoQuery = getOne(patientInfoQe, false);
+                PatientInfo saveOrUpat = new PatientInfo();
+                Long patId = null;
+                if (patientInfoQuery != null) {
+                    patId = patientInfoQuery.getId();
+                    BeanUtil.copyProperties(patientInfoQuery, saveOrUpat);
+                }
+                BeanUtil.copyProperties(patientInfo, saveOrUpat);
+                saveOrUpat.setId(patId);
+                saveOrUpat.setHospitalCode(sonHospitalCode);
+                patientSaveOrUpdateList.add(saveOrUpat);
+            }
 
+            /********** 科室部分 **********/
             List<String> deptCodeList = rif.getDetail().stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
+                    .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode())
+                            && StringUtil.isNotBlank(i.getHospitalDeptName()))
                     .map(i -> i.getHospitalDeptCode())
                     .collect(Collectors.toList());
-            QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
-            hospitalDeptQe.eq("hospital_code", StringUtil.isBlank(sonHospitalCode) ? hospitalCode : sonHospitalCode);
-            hospitalDeptQe.in("code", deptCodeList);
-            Map<String, HospitalDept> deptMap = hospitalDeptFacade.list(hospitalDeptQe)
-                    .stream()
-                    .collect(Collectors.toMap(HospitalDept::getCode, i -> i));
-            List<HospitalDept> deptSaveOrUpdateList = Lists.newArrayList();
-            rif.getDetail().stream()
-                    .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode()) && StringUtil.isNotBlank(i.getHospitalDeptName()))
-                    .forEach(i -> {
-                        HospitalDept hospitalDeptQuery = deptMap.get(i.getHospitalDeptCode());
-                        if (hospitalDeptQuery == null) {
-                            HospitalDept hospitalDept = new HospitalDept();
-                            hospitalDept.setHospitalCode(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalCode : hospitalCode);
-                            hospitalDept.setHospitalName(StringUtil.isNotBlank(sonHospitalCode) ? sonHospitalName : hospitalName);
-                            hospitalDept.setCode(i.getHospitalDeptCode());
-                            hospitalDept.setName(i.getHospitalDeptName());
-                            hospitalDept.setConceptDeptName("全科");
-                            deptSaveOrUpdateList.add(hospitalDept);
-                        } else {
-                            hospitalDeptQuery.setName(i.getHospitalDeptName());
-                            deptSaveOrUpdateList.add(hospitalDeptQuery);
-                        }
-                    });
-            if (ListUtil.isNotEmpty(deptSaveOrUpdateList)) {
-                hospitalDeptService.saveOrUpdateBatch(deptSaveOrUpdateList);
+            if (ListUtil.isNotEmpty(deptCodeList)) {
+                QueryWrapper<HospitalDept> hospitalDeptQe = new QueryWrapper<>();
+                hospitalDeptQe.eq("hospital_code", sonHospitalCode);
+                hospitalDeptQe.in("code", deptCodeList);
+                Map<String, HospitalDept> deptMap = hospitalDeptFacade.list(hospitalDeptQe)
+                        .stream()
+                        .collect(Collectors.toMap(HospitalDept::getCode, i -> i));
+                rif.getDetail().stream()
+                        .filter(i -> StringUtil.isNotBlank(i.getHospitalDeptCode())
+                                && StringUtil.isNotBlank(i.getHospitalDeptName()))
+                        .forEach(i -> {
+                            if (!deptSaveOrUpdateList.stream()
+                                    .filter(deptSaveOrUpdate -> deptSaveOrUpdate.getHospitalCode().equals(sonHospitalCode))
+                                    .map(deptSaveOrUpdate -> deptSaveOrUpdate.getCode())
+                                    .collect(Collectors.toList())
+                                    .contains(i.getHospitalDeptCode())) {
+                                HospitalDept hospitalDeptQuery = deptMap.get(i.getHospitalDeptCode());
+                                if (hospitalDeptQuery == null) {
+                                    hospitalDeptQuery = new HospitalDept();
+                                    hospitalDeptQuery.setHospitalCode(sonHospitalCode);
+                                    hospitalDeptQuery.setHospitalName(sonHospitalName);
+                                    hospitalDeptQuery.setCode(i.getHospitalDeptCode());
+                                    hospitalDeptQuery.setName(i.getHospitalDeptName());
+                                    hospitalDeptQuery.setConceptDeptName("全科");
+                                } else {
+                                    hospitalDeptQuery.setName(i.getHospitalDeptName());
+                                }
+                                deptSaveOrUpdateList.add(hospitalDeptQuery);
+                            }
+                        });
             }
 
-            rif.getDetail().stream()
+            /********** 医生部分 **********/
+            List<String> doctorCodeList = rif.getDetail().stream()
                     .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
                     .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
-                    .forEach(i -> {
-                        doctorCodeList.add(i.getCode());
-                        doctorInfoList.add(i);
-                    });
+                    .map(i -> i.getCode())
+                    .collect(Collectors.toList());
+            if (ListUtil.isNotEmpty(doctorCodeList)) {
+                QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
+                doctorInfoQe.eq("hospital_code", sonHospitalCode);
+                doctorInfoQe.in("code", doctorCodeList);
+                Map<String, DoctorInfo> doctorMap = doctorInfoFacade.list(doctorInfoQe)
+                        .stream()
+                        .collect(Collectors.toMap(DoctorInfo::getCode, i -> i));
+                rif.getDetail().stream()
+                        .filter(i -> i.getDoctorInfo() != null).map(i -> i.getDoctorInfo())
+                        .filter(i -> StringUtil.isNotBlank(i.getCode()) && StringUtil.isNotBlank(i.getName()))
+                        .forEach(i -> {
+                            if (!doctorSaveOrUpdateList.stream()
+                                    .filter(doctorSaveOrUpdate -> doctorSaveOrUpdate.getHospitalCode().equals(sonHospitalCode))
+                                    .map(doctorSaveOrUpdate -> doctorSaveOrUpdate.getCode())
+                                    .collect(Collectors.toList())
+                                    .contains(i.getCode())) {
+                                DoctorInfo doctorInfoQuery = doctorMap.get(i.getCode());
+                                DoctorInfo doctorInfo = new DoctorInfo();
+                                Long docId = null;
+                                if (doctorInfoQuery != null) {
+                                    docId = doctorInfoQuery.getId();
+                                    BeanUtil.copyProperties(doctorInfoQuery, doctorInfo);
+                                }
+                                BeanUtil.copyProperties(i, doctorInfo);
+                                doctorInfo.setHospitalCode(sonHospitalCode);
+                                doctorInfo.setId(docId);
+                                doctorSaveOrUpdateList.add(doctorInfo);
+                            }
+                        });
+            }
         });
 
-        if (ListUtil.isEmpty(doctorCodeList)) {
-            return;
+        if (ListUtil.isNotEmpty(patientSaveOrUpdateList)) {
+            patientInfoService.saveOrUpdateBatch(patientSaveOrUpdateList);
+        }
+        if (ListUtil.isNotEmpty(deptSaveOrUpdateList)) {
+            hospitalDeptService.saveOrUpdateBatch(deptSaveOrUpdateList);
         }
-
-        QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
-        doctorInfoQe.eq("hospital_code", hospitalCode);
-        doctorInfoQe.in("code", doctorCodeList);
-        Map<String, DoctorInfo> doctorMap = doctorInfoFacade.list(doctorInfoQe)
-                .stream().collect(Collectors.toMap(DoctorInfo::getCode, i -> i));
-        List<DoctorInfo> doctorSaveOrUpdateList = Lists.newArrayList();
-        doctorInfoList.forEach(i -> {
-            DoctorInfo doctorInfoQuery = doctorMap.get(i.getCode());
-            DoctorInfo doctorInfo = new DoctorInfo();
-            Long docId = null;
-            if (doctorInfoQuery != null) {
-                docId = doctorInfoQuery.getId();
-                BeanUtil.copyProperties(doctorInfoQuery, doctorInfo);
-            }
-            BeanUtil.copyProperties(i, doctorInfo);
-            doctorInfo.setHospitalCode(hospitalCode);
-            doctorInfo.setId(docId);
-            if (!doctorSaveOrUpdateList.stream()
-                    .map(doc -> doc.getCode()).distinct()
-                    .collect(Collectors.toList()).contains(doctorInfo.getCode())) {
-                doctorSaveOrUpdateList.add(doctorInfo);
-            }
-        });
         if (ListUtil.isNotEmpty(doctorSaveOrUpdateList)) {
             doctorInfoService.saveOrUpdateBatch(doctorSaveOrUpdateList);
         }
@@ -361,12 +394,12 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
                 + "\"sonHospitalName\": \"四季青街道社区卫生服务中心\","
                 + "\"patientInfo\": {"
                 + "	\"birthday\": \"1984-10-08 10:20:23\","
-                + "\"code\": \"1747\","
-                + "\"idNo\": \"330104198410083034\","
-                + "	\"hospitalCode\": \"33010400\","
+                + "\"code\": \"1759\","
+                + "\"idNo\": \"binglihao001\","
+                + "	\"hospitalCode\": \"33010480\","
                 + "	\"sex\": 1,"
-                + "	\"identityNum\": \"330104198410083034\","
-                + "	\"name\": \"沈利峰\""
+                + "	\"identityNum\": \"360827199603149901\","
+                + "	\"name\": \"刘亦菲\""
                 + "},"
                 + "\"detail\": [{"
                 + " \"hospitalDeptCode\": \"2127\","
@@ -377,11 +410,11 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
                 //                + "    \"name\": \"普通\""
                 //                + "},"
                 //                + "     \"recordId\": \"9043516\","
-                + "  \"recordTime\": \"2019-12-05 12:29:55\","
-                + " \"registerNum\": \"1\""
+                + "  \"recordTime\": \"2019-12-26 11:31:05\","
+                + " \"registerNum\": \"15\""
                 + "},{"
-                + "\"hospitalDeptCode\": \"2533\","
-                + " \"hospitalDeptName\": \"机神全科\","
+                + "\"hospitalDeptCode\": \"3005\","
+                + " \"hospitalDeptName\": \"穴位埋线注射\","
                 //                + " \"doctorInfo\": {"
                 //                + "\"code\": \"000\","
                 //                + " \"hospitalCode\": \"33010400\","
@@ -395,20 +428,20 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
                 + "{"
                 + "  \"hospitalCode\": \"33010400\","
                 + "\"hospitalName\": \"江干区卫计局\","
-                + " \"sonHospitalCode\": \"33010490\","
-                + " \"sonHospitalName\": \"闸弄口街道社区卫生服务中心\","
+                + " \"sonHospitalCode\": \"33010450\","
+                + " \"sonHospitalName\": \"九堡街道社区卫生服务中心\","
                 + "\"patientInfo\": {"
                 + " \"birthday\": \"1984-10-08 10:20:23\","
-                + "\"code\": \"1747\","
-                + " \"idNo\": \"330104198410083034\","
-                + " \"hospitalCode\": \"33010400\","
+                + "\"code\": \"1759\","
+                + " \"idNo\": \"binglihao001\","
+                + " \"hospitalCode\": \"33010450\","
                 + " \"sex\": 1,"
-                + "  \"identityNum\": \"330104198410083034\","
-                + "  \"name\": \"沈利峰\""
+                + "  \"identityNum\": \"360827199603149901\","
+                + "  \"name\": \"刘亦菲\""
                 + "},"
                 + " \"detail\": [{"
-                + "  \"hospitalDeptCode\": \"2127\","
-                + "\"hospitalDeptName\": \"中医科\","
+                + "  \"hospitalDeptCode\": \"3005\","
+                + "\"hospitalDeptName\": \"穴位埋线注射\","
                 //                + " \"doctorInfo\": {"
                 //                + "  \"code\": \"000\","
                 //                + " \"hospitalCode\": \"33010400\","
@@ -418,8 +451,8 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
                 + " \"recordTime\": \"2019-12-05 12:29:55\","
                 + "  \"registerNum\": \"1\""
                 + "},{"
-                + " \"hospitalDeptCode\": \"2533\","
-                + "    \"hospitalDeptName\": \"机神全科\","
+                + " \"hospitalDeptCode\": \"2284\","
+                + "    \"hospitalDeptName\": \"中心全科\","
                 //                + "   \"doctorInfo\": {"
                 //                + "   \"code\": \"000\","
                 //                + "  \"hospitalCode\": \"33010400\","
@@ -498,14 +531,14 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
 
         if (inquiryQuoteVO.getDoctorInfo() != null) {
             QueryWrapper<DoctorInfo> doctorInfoQe = new QueryWrapper<>();
-            doctorInfoQe.eq("hospital_code", inquiryQuoteVO.getHospitalCode());
+            doctorInfoQe.eq("hospital_code", hospitalCode);
             doctorInfoQe.eq("code", inquiryQuoteVO.getDoctorInfo().getCode());
             DoctorInfo doctorInfo = doctorInfoFacade.getOne(doctorInfoQe, false);
             Long doctorId = null;
             if (doctorInfo == null) {
                 doctorInfo = new DoctorInfo();
                 doctorInfo.setGmtCreate(now);
-                doctorInfo.setHospitalCode(inquiryQuoteVO.getHospitalCode());
+                doctorInfo.setHospitalCode(hospitalCode);
             } else {
                 doctorId = doctorInfo.getId().longValue();
             }
@@ -517,18 +550,19 @@ public class PatientInfoDjFacade extends PatientInfoServiceImpl {
         }
 
         QueryWrapper<PatientInfo> patientInfoQe = new QueryWrapper<>();
-        patientInfoQe.eq("hospital_code", inquiryQuoteVO.getHospitalCode());
+        patientInfoQe.eq("hospital_code", hospitalCode);
         patientInfoQe.eq("name", inquiryQuoteVO.getPatientInfo().getName());
-        patientInfoQe.and(a ->
-                a.eq("id_no", inquiryQuoteVO.getPatientInfo().getIdentityNum())
-                        .or()
-                        .eq("identity_num", inquiryQuoteVO.getPatientInfo().getIdentityNum()));
+        patientInfoQe.eq(StringUtil.isBlank(inquiryQuoteVO.getPatientInfo().getIdentityNum())
+                        && StringUtil.isNotBlank(inquiryQuoteVO.getPatientInfo().getIdNo()),
+                "id_no", inquiryQuoteVO.getPatientInfo().getIdNo());
+        patientInfoQe.eq(StringUtil.isNotBlank(inquiryQuoteVO.getPatientInfo().getIdentityNum()),
+                "identity_num", inquiryQuoteVO.getPatientInfo().getIdentityNum());
         PatientInfo patientInfo = getOne(patientInfoQe, false);
         Long patientId = null;
         if (patientInfo == null) {
             patientInfo = new PatientInfo();
             patientInfo.setGmtCreate(now);
-            patientInfo.setHospitalCode(inquiryQuoteVO.getHospitalCode());
+            patientInfo.setHospitalCode(hospitalCode);
         } else {
             patientId = patientInfo.getId().longValue();
         }

+ 36 - 8
tran-service/src/main/java/com/diagbot/facade/SysSetFacade.java

@@ -114,25 +114,27 @@ public class SysSetFacade extends SysSetServiceImpl {
                 .collect(Collectors.toMap(SysSet::getCode, i -> i));
 
         SysSet connectPrecSysSet = sysSetMap.get("connect_prec");
-        if (connectPrecSysSet == null
+        if (getHospitalRankInfoVO.getIsCkConnectPrec()==1
+                &&(connectPrecSysSet == null
                 || StringUtil.isBlank(connectPrecSysSet.getValue())
-                || connectPrecSysSet.getValue().equals("0")) {
+                || connectPrecSysSet.getValue().equals("0"))) {
             throw new CommonException(CommonErrorCode.RPC_ERROR, "不支持同时对接预问诊");
         }
 
-        String hospitalCode = null, sonHospitalCode = null;
+        String hospitalCode = getHospitalRankInfoVO.getHospitalCode(), sonHospitalCode = null;
         SysSet juniorHospitalSysSet = sysSetMap.get("junior_hospital");
         if (juniorHospitalSysSet != null) {
+            if (!Lists.newArrayList(juniorHospitalSysSet.getValue().split(",")).contains(hospitalCode)) {
+                throw new CommonException(CommonErrorCode.RPC_ERROR);
+            }
             hospitalCode = juniorHospitalSysSet.getHospitalCode();
             sonHospitalCode = getHospitalRankInfoVO.getHospitalCode();
-        } else {
-            hospitalCode = getHospitalRankInfoVO.getHospitalCode();
         }
 
         QueryWrapper<HospitalInfo> hospitalInfoQe = new QueryWrapper<>();
         hospitalInfoQe.eq("code", hospitalCode)
-                .or(StringUtil.isNotBlank(sonHospitalCode))
-                .eq("code", sonHospitalCode);
+                .or(StringUtil.isNotBlank(sonHospitalCode),
+                        i -> i.eq("code", getHospitalRankInfoVO.getHospitalCode()));
         Map<String, HospitalInfo> hospitalInfoMap = hospitalInfoFacade.list(hospitalInfoQe)
                 .stream().collect(Collectors.toMap(HospitalInfo::getCode, i -> i));
 
@@ -151,6 +153,32 @@ public class SysSetFacade extends SysSetServiceImpl {
         return getHospitalRankInfoDTO;
     }
 
+    /**
+     * 获取父级医院编码
+     *
+     * @param hospitalCode
+     * @return
+     */
+    public String getParentHospitalCode(String hospitalCode) {
+        if (StringUtil.isBlank(hospitalCode)) {
+            return null;
+        }
+
+        QueryWrapper<SysSet> sysSetQe = new QueryWrapper<>();
+        sysSetQe.eq("sys_type", SysTypeEnum.PREC_SERVICE.getKey())
+                .eq("code", "junior_hospital")
+                .like("value", hospitalCode);
+        SysSet juniorHospitalSysSet = getOne(sysSetQe);
+
+        if (juniorHospitalSysSet != null) {
+            if (Lists.newArrayList(juniorHospitalSysSet.getValue().split(",")).contains(hospitalCode)) {
+                return juniorHospitalSysSet.getHospitalCode();
+            }
+        }
+
+        return null;
+    }
+
     /**
      * @param hospitalCodeSetVO
      * @return
@@ -169,7 +197,7 @@ public class SysSetFacade extends SysSetServiceImpl {
         sysSetInfo.apply("find_in_set({0}, value)", data.getDoctorCode());
         if (this.count(sysSetInfo) < 1) {
             res = false;
-            if (hospitalCodeSetVO.getShowError()){
+            if (hospitalCodeSetVO.getShowError()) {
                 throw new CommonException(CommonErrorCode.RPC_ERROR, "该医院暂无模板管理者配置信息");
             }
         } else {

+ 5 - 0
tran-service/src/main/java/com/diagbot/vo/GetHospitalRankInfoVO.java

@@ -17,4 +17,9 @@ public class GetHospitalRankInfoVO {
      */
     private String hospitalCode;
 
+    /**
+     * 校验是否对接预问诊 0-不校验 1-校验
+     */
+    private Integer isCkConnectPrec = 1;
+
 }

+ 27 - 45
tran-service/src/main/java/com/diagbot/vo/GetTopPatientInfoVO.java

@@ -1,59 +1,41 @@
-/**
- * 
- */
 package com.diagbot.vo;
 
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
-import javax.validation.constraints.NotBlank;
-
 /**
- * @Description
  * @author rgb
+ * @Description
  * @time 2018年11月19日下午4:58:37
  */
-@ApiModel(value="页面顶部病人医生科室信息查询接口传参")
 @Getter
 @Setter
 public class GetTopPatientInfoVO {
-	
-	/**
-	 * 医院编号
-	 */
-	@ApiModelProperty(value="医院编号",required=true)
-	@NotBlank(message="医院编号必填")
-	private String hospitalCode;
-	
-	/**
-	 * 医院科室编号
-	 */
-	@ApiModelProperty(value="医院科室编号",required=true)
-	@NotBlank(message="医院科室编号必填")
-	private String hospitalDeptCode;
-	
-	/**
-	 * 医院医生编号
-	 */
-	@ApiModelProperty(value="医院医生编号",required=true)
-	@NotBlank(message="医院医生编号必填")
-	private String doctorCode;
-	
-	/**
-	 * 医院患者编号
-	 */
-	@ApiModelProperty(value="医院患者编号",required=true)
-	@NotBlank(message="医院患者编号必填")
-	private String patientCode;
-	
-	/**
-	 * 门诊号
-	 */
-	@ApiModelProperty(value="门诊号",required=true)
-	@NotBlank(message="门诊号必填")
-	private String recordId;
-	
+
+    /**
+     * 医院编号
+     */
+    private String hospitalCode;
+
+    /**
+     * 医院科室编号
+     */
+    private String hospitalDeptCode;
+
+    /**
+     * 医院医生编号
+     */
+    private String doctorCode;
+
+    /**
+     * 医院患者编号
+     */
+    private String patientCode;
+
+    /**
+     * 门诊号
+     */
+    private String recordId;
+
 
 }

+ 5 - 0
tran-service/src/main/java/com/diagbot/vo/InquiryQuoteVO.java

@@ -47,6 +47,11 @@ public class InquiryQuoteVO {
      */
     private String sonHospitalName;
 
+    /**
+     * 就诊序列号
+     */
+    private String inquiryCode;
+
     /**
      * 科室信息
      */

+ 1 - 1
tran-service/src/main/java/com/diagbot/web/PatientInfoController.java

@@ -65,7 +65,7 @@ public class PatientInfoController {
     @PostMapping("/getTopPatientInfo")
     @SysLogger("getTopPatientInfo")
     @ApiIgnore
-    public RespDTO<GetTopPatientInfoDTO> getTopPatientInfo(@Valid @RequestBody GetTopPatientInfoVO getTopPatientInfoVO) {
+    public RespDTO<GetTopPatientInfoDTO> getTopPatientInfo(@RequestBody GetTopPatientInfoVO getTopPatientInfoVO) {
         return RespDTO.onSuc(patientInfoFacade.getTopPatientInfo(getTopPatientInfoVO));
     }
 

+ 8 - 2
tran-service/src/main/java/com/diagbot/web/SysSetController.java

@@ -39,7 +39,6 @@ public class SysSetController {
     SysSetFacade sysSetFacade;
 
 
-
     @ApiOperation(value = "根据医院编码获取配置信息[by:wangfeng]", notes = "hospitalCode :医院code  必填<br> ")
     @PostMapping("/getSysSetInfoDatas")
     @SysLogger("getSysSetInfoDatas")
@@ -64,10 +63,17 @@ public class SysSetController {
         return RespDTO.onSuc(sysSetFacade.getHospitalRankInfo(getHospitalRankInfoVO));
     }
 
+    @ApiOperation(value = "获取父级医院编码[by:rengb]")
+    @PostMapping("/getParentHospitalCode")
+    @SysLogger("getParentHospitalCode")
+    public RespDTO<String> getParentHospitalCode(@RequestBody String hospitalCode) {
+        return RespDTO.onSuc(sysSetFacade.getParentHospitalCode(hospitalCode));
+    }
+
     @ApiOperation(value = "获取校验管理员身份[by:wangfeng]")
     @PostMapping("/getAdminCheckout")
     @SysLogger("getAdminCheckout")
-    public RespDTO<Boolean> getAdminCheckout(@Valid @RequestBody HospitalCodeSetVO hospitalCodeSetVO){
+    public RespDTO<Boolean> getAdminCheckout(@Valid @RequestBody HospitalCodeSetVO hospitalCodeSetVO) {
         return RespDTO.onSuc(sysSetFacade.getAdminCheckout(hospitalCodeSetVO));
     }
 }

+ 6 - 1
tran-service/src/main/resources/mapper/PatientInfoMapper.xml

@@ -56,6 +56,7 @@
 		case when d.sex=1 then '男' when d.sex=2 then '女' else '未知' end as patientSex,
 		d.id_no as patientIdNo,
         d.identity_num as patientIdentityNum,
+        d.phone as patientPhone,
 		d.birthday as birthday
 		FROM tran_hospital_info a LEFT JOIN tran_hospital_dept b 
 		ON a.`code`=b.hospital_code and b.`status`=1 and b.is_deleted='N' and b.`code`=#{hospitalDeptCode} 	
@@ -75,6 +76,9 @@
         a.id as hospitalId,
         a.`code` as hospitalCode,
         a.`name` as hospitalName,
+        a.id as sonHospitalId,
+        a.`code` as sonHospitalCode,
+        a.`name` as sonHospitalName,
         c.id as doctorId,
         c.`code` as doctorCode,
         c.`name` as doctorName,
@@ -83,6 +87,7 @@
         d.`name` as patientName,
         case when d.sex=1 then '男' when d.sex=2 then '女' else '未知' end as patientSex,
         case when d.identity_num is null or d.identity_num='' then d.id_no else d.identity_num end as patientIdNo,
+        d.phone as patientPhone,
         d.birthday as birthday
         FROM tran_hospital_info a
         LEFT JOIN tran_doctor_info c
@@ -92,7 +97,7 @@
         ON a.code=d.hospital_code and d.is_deleted='N' and d.`code`=#{patientCode}
         WHERE a.is_deleted='N'
         AND a.`status`=1
-        AND a.`code`=#{hospitalCode}
+        AND a.`code`=#{sonHospitalCode}
     </select>
 
 </mapper>