Forráskód Böngészése

慢病登记功能

lighter 1 éve
szülő
commit
44a26971c7

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/config/exception/ExceptionEnum.java

@@ -23,7 +23,7 @@ public enum ExceptionEnum {
     /**
      * 以下是不需要提示的错误
      * */
-    SLIGHTLY_ERROR(4001, "未知错误!"),
+    SLIGHTLY_ERROR(4001, "不需要提示的错误。"),
     /**
      * 以下是内部使用的错误
      * */

+ 57 - 0
src/main/java/thyyxxk/wxservice_server/constant/AgnterRelations.java

@@ -0,0 +1,57 @@
+package thyyxxk.wxservice_server.constant;
+
+import thyyxxk.wxservice_server.utils.StringUtil;
+
+/**
+ * @description: 代办人关系
+ * @author: DingJie
+ * @create: 2021/8/314:49
+ */
+public enum AgnterRelations {
+
+    SPOUSE("1", "配偶"),
+
+    SON("2", "子"),
+
+    DAUGHTER("3", "女"),
+
+    GRAND_CHILD("4", "孙子、孙女,或外孙子、外孙女"),
+
+    PARENT("5", "父母"),
+
+    GRAND_PARENT("6", "祖父母或外祖父母"),
+
+    BROTHER_SISTER("7", "兄弟姐妹"),
+
+    OTHER_RELATIVE("8", "同事同学"),
+
+    NOT_RELATIVE("9", "其他");
+
+    private final String code;
+    private final String name;
+
+    AgnterRelations(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static AgnterRelations get(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        for (AgnterRelations agnterRlts : AgnterRelations.values()) {
+            if (code.trim().equals(agnterRlts.getCode())) {
+                return agnterRlts;
+            }
+        }
+        return null;
+    }
+}

+ 167 - 0
src/main/java/thyyxxk/wxservice_server/controller/ChronicDiseaseController.java

@@ -0,0 +1,167 @@
+package thyyxxk.wxservice_server.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
+import thyyxxk.wxservice_server.constant.AgnterRelations;
+import thyyxxk.wxservice_server.dao.ChronicDiseaseDao;
+import thyyxxk.wxservice_server.entity.PureCodeName;
+import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.chronicdisease.CrmPatientMi;
+import thyyxxk.wxservice_server.utils.*;
+
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@RestController
+@RequestMapping("/chronicDisease")
+public class ChronicDiseaseController {
+    private final ChronicDiseaseDao dao;
+    @Value("${chronicUrl}")
+    private String chronicUrl;
+
+    @Autowired
+    public ChronicDiseaseController(ChronicDiseaseDao dao) {
+        this.dao = dao;
+    }
+
+    @GetMapping("/getCrmDictionary")
+    public ResultVo<Map<String, List<PureCodeName>>> getCrmDictionary() {
+        ResultVo<Map<String, List<PureCodeName>>> response = new RestTemplate()
+                .getForObject(chronicUrl + "/getCrmDictionary", ResultVo.class);
+        if (null == response) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (response.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, response.getMessage());
+        }
+        Map<String, List<PureCodeName>> map = response.getData();
+        map.remove("getOccupation");
+        map.remove("getCountry");
+        map.remove("getNation");
+        map.remove("getProvince");
+        map.remove("getCity");
+        map.remove("getArea");
+        return ResultVoUtil.success(map);
+    }
+
+    @GetMapping("/selectCrmPatientMiByCode")
+    public ResultVo<CrmPatientMi> selectCrmPatientMiByCode(@RequestParam("keyCode") String keyCode) {
+        ResultVo<LinkedHashMap<String, Object>> response = new RestTemplate().getForObject(
+                chronicUrl + "/selectCrmPatientMiByCode?keyCode=" + keyCode, ResultVo.class);
+        log.info("【{}】获取慢病信息:{}", keyCode, JSONObject.toJSON(response));
+        if (null == response || response.getCode() != ExceptionEnum.SUCCESS.getCode()) {
+            return getBasePatientInfo(keyCode);
+        }
+        LinkedHashMap map = response.getData();
+        String json = JSON.toJSONString(map);
+        CrmPatientMi crmPatientMi = JSONObject.parseObject(json, CrmPatientMi.class);
+        crmPatientMi.setSexLabel(filterSex(crmPatientMi.getSex()));
+        crmPatientMi.setTypeLabel(filterPType(crmPatientMi.getPType()));
+        crmPatientMi.setChronicDiseaseTypeLabel(
+                filterChronicDiseaseType(crmPatientMi.getChronicDiseaseType()));
+        AgnterRelations relation = AgnterRelations.get(crmPatientMi.getRelCode());
+        if (null != relation) {
+            crmPatientMi.setRelLabel(relation.getName());
+        }
+        if (null != crmPatientMi.getLastDate()) {
+            crmPatientMi.setLastDate(crmPatientMi.getLastDate().split(" ")[0]);
+        }
+        return ResultVoUtil.success(crmPatientMi);
+    }
+
+    private ResultVo<CrmPatientMi> getBasePatientInfo(String patientId) {
+        CrmPatientMi crmPatientMi = dao.selectPatientBaseInfo(patientId);
+        if (null == crmPatientMi) {
+            return ResultVoUtil.success(new CrmPatientMi());
+        }
+        int age = IdCardUtil.getAgeByIdCard(crmPatientMi.getSocialNo());
+        crmPatientMi.setAge(age == 0 ? null : age);
+        crmPatientMi.setSexLabel(filterSex(crmPatientMi.getSex()));
+        return ResultVoUtil.success(crmPatientMi);
+    }
+
+    @PostMapping("/saveCrmPatientMi")
+    public ResultVo<String> saveCrmPatientMi(@RequestBody CrmPatientMi params) {
+        if (null == params.getVisitTimes()) {
+            params.setVisitTimes(0);
+        }
+        if (null == params.getVisitDate()) {
+            params.setVisitDate(DateUtil.formatDatetime(new Date()));
+        }
+        JSONObject response = new RestTemplate()
+                .postForObject(chronicUrl + "/saveCrmPatientMi", params, JSONObject.class);
+        log.info("提交慢病患者信息:\n参数:{}\n结果:{}", JSONObject.toJSON(params), response);
+        if (null == response) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        if (response.getInteger("code") != 200) {
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, response.getString("message"));
+        }
+        return ResultVoUtil.success(response.getString("data"));
+    }
+
+    private String filterSex(String sex) {
+        if (StringUtil.isBlank(sex)) {
+            return null;
+        }
+        switch (sex) {
+            case "1":
+                return "男";
+            case "2":
+                return "女";
+            default:
+                return "未知";
+        }
+    }
+
+    private String filterPType(String pType) {
+        if (StringUtil.isBlank(pType)) {
+            return null;
+        }
+        switch (pType) {
+            case "1":
+                return "门诊";
+            case "2":
+                return "住院";
+            case "3":
+                return "健康体检";
+            case "4":
+                return "慢病中心";
+            case "5":
+                return "医联体";
+            case "9":
+                return "其他途径";
+            default:
+                return null;
+        }
+    }
+
+    private String filterChronicDiseaseType(String type) {
+        if (StringUtil.isBlank(type)) {
+            return null;
+        }
+        switch (type) {
+            case "01":
+                return "糖尿病";
+            case "02":
+                return "高血压";
+            case "03":
+                return "慢阻肺";
+            case "04":
+                return "脑卒中";
+            case "05":
+                return "肿瘤";
+            default:
+                return null;
+        }
+    }
+}

+ 15 - 0
src/main/java/thyyxxk/wxservice_server/dao/ChronicDiseaseDao.java

@@ -0,0 +1,15 @@
+package thyyxxk.wxservice_server.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.wxservice_server.entity.chronicdisease.CrmPatientMi;
+
+@Mapper
+public interface ChronicDiseaseDao {
+    @Select("select rtrim(name) as pName,rtrim(sex) as sex,rtrim(social_no) as socialNo, " +
+            "sexLabel=case when sex='1' then '男' when sex='2' then '女' else '未知' end, " +
+            "birthDate=convert(varchar(10), birth_day, 21),rtrim(patient_id) as hisMzNo, " +
+            "tj_no as hisTjNo,district_code,rtrim(phone_no) as relTel " +
+            "from mz_patient_mi where patient_id=#{patNo} ")
+    CrmPatientMi selectPatientBaseInfo(String patNo);
+}

+ 296 - 0
src/main/java/thyyxxk/wxservice_server/entity/chronicdisease/CrmPatientMi.java

@@ -0,0 +1,296 @@
+package thyyxxk.wxservice_server.entity.chronicdisease;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @ClassName CrmPatientMi
+ * @Author Administrator
+ * @Date 2023/11/23 15:15
+ * @Version 1.0
+ * @Description 慢特病基本信息
+ **/
+@Data
+public class CrmPatientMi implements Serializable {
+
+    private static final long serialVersionUID = -1L;
+
+    /**
+     * 用户ID
+     */
+    @JsonProperty("pId")
+    private String pId;
+    /**
+     * 姓名
+     */
+    @JsonProperty("pName")
+    private String pName;
+    /**
+     * 性别
+     */
+    private String sex;
+    private String sexLabel;
+    /**
+     * 出生日期
+     */
+    private String birthDate;
+    /**
+     * 病人来源
+     */
+    @JsonProperty("pType")
+    private String pType;
+    private String typeLabel;
+    /**
+     * 所属企业
+     */
+    private String entId;
+    /**
+     * 门诊号
+     */
+    private String hisMzNo;
+    /**
+     * 住院号
+     */
+    private String hisZyNo;
+    /**
+     * 病案号
+     */
+    private String hisBaNo;
+    /**
+     * 体检号
+     */
+    private String hisTjNo;
+    /**
+     * 证件号
+     */
+    private String socialNo;
+    /**
+     * 卡号
+     */
+    private String cardNo;
+    /**
+     * 婚姻状况
+     */
+    private String marryCode;
+    /**
+     * 国籍
+     */
+    private String countryCode;
+    /**
+     * 民族
+     */
+    private String nationCode;
+    /**
+     * 职业
+     */
+    private String occupationCode;
+    /**
+     * 行业
+     */
+    private String vocationCode;
+    /**
+     * 区县编码
+     */
+    private String districtCode;
+    /**
+     * 区县e-mail
+     */
+    @JsonProperty("eMail")
+    private String eMail;
+    /**
+     * 家庭电话
+     */
+    private String homeTel;
+    /**
+     * 家庭住址
+     */
+    private String homeStreet;
+    /**
+     * 家庭邮编
+     */
+    private String homeZip;
+    /**
+     * 单位电话
+     */
+    private String empTel;
+    /**
+     * 单位名称
+     */
+    private String empName;
+    /**
+     * 单位地址
+     */
+    private String empStreet;
+    /**
+     * 单位邮编
+     */
+    private String empZip;
+    /**
+     * 联系电话
+     */
+    private String relTel;
+    /**
+     * 联系电话2
+     */
+    private String relTel2;
+    /**
+     * 联系人电话
+     */
+    private String relNameTel;
+    /**
+     * 联系人姓名
+     */
+    private String relName;
+    /**
+     * 联系人关系
+     */
+    private String relCode;
+    private String relLabel;
+    /**
+     * 联系人地址
+     */
+    private String relStreet;
+    /**
+     * 联系人邮编
+     */
+    private String relZip;
+    /**
+     * 最近一次医疗方式
+     */
+    private String lastType;
+    /**
+     * 最近一次医疗时间
+     */
+    private String lastDate;
+    /**
+     * 特殊备注
+     */
+    @JsonProperty("pComment")
+    private String pComment;
+    /**
+     * 病人等级
+     */
+    private String importLevel;
+    /**
+     * 等级描述
+     */
+    private String importComment;
+    /**
+     * 潜在问题(等级)
+     */
+    private String quLevel;
+    /**
+     * 潜在问题说明
+     */
+    private String quComment;
+    /**
+     * 证件类型
+     */
+    private String certificateType = "1";
+    /**
+     * 慢特病类型
+     */
+    private String chronicDiseaseType;
+    private String chronicDiseaseTypeLabel;
+    /**
+     * 省
+     */
+    private String provinceCode;
+    /**
+     * 市
+     */
+    private String cityCode;
+    /**
+     * 详细地址
+     */
+    private String detailAdress;
+    /**
+     * 创建时间
+     */
+    private String createDate;
+    /**
+     * 创建人
+     */
+    private String creatId;
+    /**
+     * 主管医生(id)
+     */
+    private String referPhysician;
+    /**
+     * 最近一次随访次数
+     */
+    private Integer visitTimes;
+    /**
+     * 下次随访时间
+     */
+    private String visitDate;
+    /**
+     * 年龄
+     */
+    private Integer age;
+    /**
+     * 区(地区)
+     */
+    private String areaCode;
+    /**
+     * 身高
+     */
+    @TableField(exist = false)
+    private BigDecimal height;
+    /**
+     * 体重
+     */
+    @TableField(exist = false)
+    private BigDecimal weight;
+    /**
+     * 体温
+     */
+    @TableField(exist = false)
+    private BigDecimal temperature;
+    /**
+     * 收缩血压
+     */
+    @TableField(exist = false)
+    private Integer bloodPressureHigh;
+    /**
+     * 舒张血压
+     */
+    @TableField(exist = false)
+    private Integer bloodPressureLow;
+    /**
+     * 心率
+     */
+    @TableField(exist = false)
+    private Integer heartRate;
+    /**
+     * 血糖
+     */
+    @TableField(exist = false)
+    private BigDecimal bloodSugar;
+    /**
+     * 血氧
+     */
+    @TableField(exist = false)
+    private String bloodOxygen;
+    /**
+     * 呼吸频率
+     */
+    @TableField(exist = false)
+    private Integer respiratoryRate;
+    /**
+     * 慢特病类型组
+     */
+    @TableField(exist = false)
+    private List<String> chronicDiseaseTypeArr;
+    /**
+     * 主管医生名字(前端回显)
+     */
+    @TableField(exist = false)
+    private String referPhysicianName;
+
+}

+ 4 - 2
src/main/java/thyyxxk/wxservice_server/service/PatientCardsService.java

@@ -7,8 +7,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.PatientCardsDao;
+import thyyxxk.wxservice_server.entity.BriefPatInfo;
 import thyyxxk.wxservice_server.entity.ResultVo;
 import thyyxxk.wxservice_server.entity.analyzeidcard.IdCardAnalyzeResult;
+import thyyxxk.wxservice_server.entity.appointment.PatientBriefInfo;
+import thyyxxk.wxservice_server.entity.chronicdisease.CrmPatientMi;
 import thyyxxk.wxservice_server.entity.patientcards.ChangeCardParam;
 import thyyxxk.wxservice_server.entity.patientcards.ModifyBindParam;
 import thyyxxk.wxservice_server.entity.wxapi.PushMessageParam;
@@ -44,9 +47,8 @@ public class PatientCardsService {
         String openid = json.getString("openid");
         if (openid != null) {
             return ResultVoUtil.success(openid);
-        } else {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, json.getString("errmsg"));
         }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, json.getString("errmsg"));
     }
 
     public ResultVo<List<IdCardAnalyzeResult>> getPatientIdByOpenId(String openId) {

+ 3 - 0
src/main/java/thyyxxk/wxservice_server/utils/IdCardUtil.java

@@ -204,6 +204,9 @@ public class IdCardUtil {
      * 根据身份证号计算年龄
      * */
     public static int getAgeByIdCard(String idCard) {
+        if (!isValidatedIdCard(idCard)) {
+            return 0;
+        }
         String birthDay = idCard.substring(6, 14);
         String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
         String yearStr = time.split("-")[0];

+ 1 - 0
src/main/resources/application-8083.yml

@@ -71,6 +71,7 @@ management:
 
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 appletThmzUrl: http://172.16.32.160:81/thmz
+chronicUrl: http://172.16.32.160:8077/chronicDisease
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
 physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/
 production: true

+ 1 - 0
src/main/resources/application-8085.yml

@@ -72,6 +72,7 @@ management:
 
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 appletThmzUrl: http://172.16.32.160:81/thmz
+chronicUrl: http://172.16.32.160:8077/chronicDisease
 inspectionUrl: http://172.16.32.178:622/pushservice.asmx?wsdl
 physicalCheck: http://172.16.32.183:8888/bdp/dataservice/api/
 production: true

+ 5 - 4
src/main/resources/application.yml

@@ -9,8 +9,8 @@ spring:
     cache: false
   datasource:
     driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-#    url: jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb
-    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
+    url: jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb
+#    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
     hikari:
       username: sa
       password:
@@ -70,8 +70,9 @@ management:
     prometheus:
       enabled: true
 
-hrgApiUrl: http://172.16.30.119:8089/thmz/api/v1
-appletThmzUrl: http://172.16.30.119:8089/thmz
+hrgApiUrl: http://172.16.30.22:8089/thmz/api/v1
+appletThmzUrl: http://172.16.30.22:8089/thmz
+chronicUrl: http://172.16.30.26:8706/chronicDisease
 #hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 #appletThmzUrl: http://172.16.32.160:81/thmz