Browse Source

医生端增加不适合用药+总后台增加不适合用药统计

cgp 2 days ago
parent
commit
9fe3d5509d

+ 19 - 0
fs-admin/src/main/java/com/fs/his/controller/FsPrescribeDataScrmController.java

@@ -7,6 +7,7 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.DoctorNotPrescribeQueryDto;
+import com.fs.his.dto.NotRecommendUseQueryDto;
 import com.fs.his.service.IFsPrescribeDataScrmService;
 import com.fs.his.vo.*;
 import com.fs.hisStore.domain.FsStoreOrderScrm;
@@ -102,6 +103,11 @@ public class FsPrescribeDataScrmController extends BaseController
         vo.setFoodAndExerciseGuidance(prescribe.getFoodAndExerciseGuidance());
         vo.setHealingAreaJson(prescribe.getHealingAreaJson());
         vo.setNoteTaboos(prescribe.getNoteTaboos());
+        if (prescribe.getDoctorConfirm()==-3){
+            vo.setNotRecommendUse(Boolean.TRUE);
+        }else {
+            vo.setNotRecommendUse(Boolean.FALSE);
+        }
         return AjaxResult.success(vo);
     }
 
@@ -127,6 +133,19 @@ public class FsPrescribeDataScrmController extends BaseController
         return util.exportExcel(exportList, "开方列表统计");
     }
 
+    /**
+     * 获取医生不适合开方列表
+     * */
+    @PostMapping("/notRecommendUseList")
+    public TableDataInfo notRecommendUseList(@Valid @RequestBody NotRecommendUseQueryDto queryDto)
+    {
+        Integer pageNum = queryDto.getPageNum() == null ? 1 : queryDto.getPageNum();
+        Integer pageSize = queryDto.getPageSize() == null ? 10 : queryDto.getPageSize();
+        PageHelper.startPage(pageNum, pageSize);
+        List<DoctorScrmPrescribeVO> list = fsPrescribeScrmService.notRecommendUseList(queryDto);
+        return getDataTable(list);
+    }
+
     /**
      * 将查询结果 VO 转换为导出专用 VO
      */

+ 5 - 0
fs-company/src/main/java/com/fs/company/controller/his/FsPrescribeDataScrmController.java

@@ -94,6 +94,11 @@ public class FsPrescribeDataScrmController extends BaseController
         vo.setFoodAndExerciseGuidance(prescribe.getFoodAndExerciseGuidance());
         vo.setHealingAreaJson(prescribe.getHealingAreaJson());
         vo.setNoteTaboos(prescribe.getNoteTaboos());
+        if (prescribe.getDoctorConfirm()==-3){
+            vo.setNotRecommendUse(Boolean.TRUE);
+        }else {
+            vo.setNotRecommendUse(Boolean.FALSE);
+        }
         return AjaxResult.success(vo);
     }
 

+ 5 - 0
fs-doctor-app/src/main/java/com/fs/app/controller/FsPrescribeDataScrmController.java

@@ -155,6 +155,11 @@ public class FsPrescribeDataScrmController extends BaseController
         vo.setFoodAndExerciseGuidance(prescribe.getFoodAndExerciseGuidance());
         vo.setHealingAreaJson(prescribe.getHealingAreaJson());
         vo.setNoteTaboos(prescribe.getNoteTaboos());
+        if (prescribe.getDoctorConfirm()==-3){
+            vo.setNotRecommendUse(Boolean.TRUE);
+        }else {
+            vo.setNotRecommendUse(Boolean.FALSE);
+        }
         return AjaxResult.success(vo);
     }
 

+ 4 - 1
fs-service/src/main/java/com/fs/his/domain/FsPrescribeDataScrm.java

@@ -150,7 +150,7 @@ public class FsPrescribeDataScrm extends BaseEntity {
     /** 订单来源 */
     private Integer source;
 
-    /** 医生是否确认 0待医生开方 1已开方待药师审核 -1医生拒方 -2暂不开方 */
+    /** 医生是否确认 0待医生开方 1已开方待药师审核 -1医生拒方 -2暂不开方 -3不适合用药 */
     private Integer doctorConfirm;
 
     /** 医生开始操作时间(益寿缘从医生建议开始算) */
@@ -202,4 +202,7 @@ public class FsPrescribeDataScrm extends BaseEntity {
 
     /** 医生名称*/
     private String doctorName;
+
+    /** 销售id */
+    private Long companyUserId;
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/dto/BeforePrescribeAddDoctorAdviceDTO.java

@@ -34,4 +34,9 @@ public class BeforePrescribeAddDoctorAdviceDTO {
      * 注意禁忌
      * */
     private String noteTaboos;
+
+    /**
+     * 不建议使用 选中为true否则为false
+     * */
+    private Boolean notRecommendUse;
 }

+ 36 - 0
fs-service/src/main/java/com/fs/his/dto/NotRecommendUseQueryDto.java

@@ -0,0 +1,36 @@
+package com.fs.his.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 不适合用药查询Dto
+ */
+@Data
+public class NotRecommendUseQueryDto {
+
+    /** 销售名称 */
+    private String companyUserName;
+
+    /** 医生id */
+    private Long doctorId;
+
+    /** 归属组 */
+    private Long deptId;
+
+    /** 开始时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private String beginTime;
+
+    /** 结束时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private String endTime;
+
+    // 分页相关
+    private Integer pageNum;
+
+    private Integer pageSize;
+}

+ 9 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeDataScrmMapper.java

@@ -4,6 +4,7 @@ import com.fs.his.domain.FsPrescribeDataScrm;
 import com.fs.his.dto.DoctorNotPrescribeQueryDto;
 import com.fs.his.dto.FsPrescribeDataDoctorQueryDto;
 import com.fs.his.dto.FsPrescribeDataDrugDoctorQueryDto;
+import com.fs.his.dto.NotRecommendUseQueryDto;
 import com.fs.his.vo.DoctorScrmPrescribeVO;
 import com.fs.his.vo.FsPrescribeDataScrmImgVO;
 import com.fs.qw.vo.FsPrescribeDataScrmVO;
@@ -44,6 +45,14 @@ public interface FsPrescribeDataScrmMapper
     public List<DoctorScrmPrescribeVO> selectFsPrescribeDataScrmAndOrderList(DoctorNotPrescribeQueryDto queryDto);
 
 
+    /**
+     * 查询不适合用药数据
+     *
+     * @param queryDto 处方表(SCRM)
+     * @return 处方表(SCRM)集合
+     */
+    public List<DoctorScrmPrescribeVO> notRecommendUseList(NotRecommendUseQueryDto queryDto);
+
     /**
      * 新增处方表(SCRM)
      *

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeDataScrmService.java

@@ -130,4 +130,9 @@ public interface IFsPrescribeDataScrmService
      * 医生不开方列表
      * */
     List<DoctorScrmPrescribeVO> doctorNotPrescribeList(DoctorNotPrescribeQueryDto queryDto);
+
+    /**
+     * 医生不适合用药处方列表
+     * */
+    List<DoctorScrmPrescribeVO> notRecommendUseList(NotRecommendUseQueryDto queryDto);
 }

+ 23 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeDataScrmServiceImpl.java

@@ -101,6 +101,11 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
      * */
     private static final Integer NOT_PRESCRIBE = 7;
 
+    /**
+     * 不适合用药
+     * */
+    private static final Integer NOT_RECOMMEND_USE = 8;
+
     // ==================== 基础 CRUD ====================
     @Override
     public FsPrescribeDataScrm selectFsPrescribeDataScrmByPrescribeId(Long prescribeId) {
@@ -279,6 +284,13 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         fsPrescribeDataScrm.setNoteTaboos(addDoctorAdviceDTO.getNoteTaboos());
         fsPrescribeDataScrm.setHealingAreaJson(addDoctorAdviceDTO.getHealingAreaJson());
         fsPrescribeDataScrm.setRecipeType(1);//医生已填写建议信息
+        if (addDoctorAdviceDTO.getNotRecommendUse() != null && addDoctorAdviceDTO.getNotRecommendUse()){
+            // 不适合用药
+            fsPrescribeDataScrm.setDoctorConfirm(-3);//不建议使用
+            fsPrescribeDataScrm.setNotPrescribeReason("不适合用药");
+            // 更新客户信息表状态为不适合用药
+            updateCustomerStatus(fsPrescribeDataScrm.getPrescribeId(), NOT_RECOMMEND_USE);
+        }
         return fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(fsPrescribeDataScrm);
     }
 
@@ -369,7 +381,17 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
         }
         populateDoctorNames(prescribeList);
         maskPatientPhone(prescribeList);
+        return prescribeList;
+    }
 
+    @Override
+    public List<DoctorScrmPrescribeVO> notRecommendUseList(NotRecommendUseQueryDto queryDto) {
+        List<DoctorScrmPrescribeVO> prescribeList = fsPrescribeDataScrmMapper.notRecommendUseList(queryDto);
+        if (CollectionUtils.isEmpty(prescribeList)) {
+            return Collections.emptyList();
+        }
+        populateDoctorNames(prescribeList);
+        maskPatientPhone(prescribeList);
         return prescribeList;
     }
 
@@ -443,6 +465,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
             throw new CustomException("状态错误");
         }
         FsPrescribeDataScrm data = new FsPrescribeDataScrm();
+        data.setCompanyUserId(customer.getCompanyUserId());
         data.setCompanyCustomerId(companyCustomerId);
         // 设置患者信息
         // 患者名称

+ 2 - 2
fs-service/src/main/java/com/fs/his/vo/DoctorScrmPrescribeVO.java

@@ -37,8 +37,8 @@ public class DoctorScrmPrescribeVO extends FsPrescribeDataScrm {
     @ExcelProperty(value = "患者电话", index = 5)
     private String patientTel;
 
-    @ExcelProperty(value = "订单编号", index = 6)
-    private String orderCode;
+    @ExcelProperty(value = "归属组别", index = 6)
+    private String deptName;
 
     @ExcelProperty(value = "创建时间", index = 9)
     @DateTimeFormat("yyyy-MM-dd HH:mm:ss")

+ 5 - 0
fs-service/src/main/java/com/fs/his/vo/PrescribeScrmDoctorAdviceVO.java

@@ -8,4 +8,9 @@ public class PrescribeScrmDoctorAdviceVO {
     private String foodAndExerciseGuidance;
     private String healingAreaJson;  // 前端存储的 JSON 字符串
     private String noteTaboos;
+
+    /**
+     * 不建议使用 选中为true否则为false
+     * */
+    private Boolean notRecommendUse;
 }

+ 2 - 8
fs-service/src/main/java/com/fs/qw/service/impl/FsCompanyCustomerServiceImpl.java

@@ -214,12 +214,10 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
     private void setCompleteStatus(FsCompanyCustomer customer) {
         // 获取用户填写内容
         String allergyHistory = customer.getAllergyHistory();
-        String presentIllness = customer.getPresentIllness();
         String currentMedication = customer.getCurrentMedication();
         Date appointmentTime = customer.getAppointmentTime();
         //只要有一个为空或空字符串,就设置completeStatus为0
         if (allergyHistory == null || allergyHistory.isEmpty()
-                || presentIllness == null || presentIllness.isEmpty()
                 || currentMedication == null || currentMedication.isEmpty()
                 || appointmentTime == null
         ) {
@@ -553,14 +551,13 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
         checkClaimStatus(oldCustomer);
         // 2. 校验四个字段至少有一个非空
         String symptom = customer.getPatientMainComplaint();
-        String presentIllness = customer.getPresentIllness();
         String currentMedication = customer.getCurrentMedication();
         String allergyHistory = customer.getAllergyHistory();
 
-        boolean anyNotEmpty = Stream.of(symptom, presentIllness, currentMedication, allergyHistory)
+        boolean anyNotEmpty = Stream.of(symptom, currentMedication, allergyHistory)
                 .anyMatch(s -> s != null && !s.trim().isEmpty());
         if (!anyNotEmpty) {
-            throw new CustomException("病情主诉、现病史、现用药情况、过敏史至少填写一项");
+            throw new CustomException("病情主诉、现用药情况、过敏史至少填写一项");
         }
 
         // 3. 将前端传入的所有字段复制到 oldCustomer(除了 id)
@@ -648,9 +645,6 @@ public class FsCompanyCustomerServiceImpl implements IFsCompanyCustomerService {
             if (StringUtils.isNotBlank(newCustomer.getPatientMainComplaint())){
                 customer.setPatientMainComplaint(newCustomer.getPatientMainComplaint());
             }
-            if (StringUtils.isNotBlank(newCustomer.getPresentIllness())){
-                customer.setPresentIllness(newCustomer.getPresentIllness());
-            }
             if (StringUtils.isNotBlank(newCustomer.getCurrentMedication())){
                 customer.setCurrentMedication(newCustomer.getCurrentMedication());
             }

+ 39 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwGroupMsgServiceImpl.java

@@ -42,6 +42,7 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
@@ -725,6 +726,9 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
 
     @Override
     public R sendSidebarOfficial(QwGroupMsgParam qwGroupMsgParam)  {
+        //处理一下title长度问题
+        String text = safeTruncateByBytes(qwGroupMsgParam.getMiniprogramTitle(), 60);
+        qwGroupMsgParam.setMiniprogramTitle(text);
         QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwGroupMsgParam.getCorpId());
 
         if (StringUtil.strIsNullOrEmpty(qwGroupMsgParam.getSender())){
@@ -892,6 +896,41 @@ public class QwGroupMsgServiceImpl implements IQwGroupMsgService
         return R.ok();
     }
 
+    /**
+     * 安全截断字符串,确保 UTF-8 字节长度不超过指定最大值,并追加省略号
+     * @param str 原始字符串
+     * @param maxBytes 最大字节长度(如企业微信限制为 64)
+     * @return 处理后的字符串
+     */
+    public static String safeTruncateByBytes(String str, int maxBytes) {
+        if (str == null || str.isEmpty()) {
+            return str;
+        }
+        // 如果原始长度未超标,直接返回
+        if (str.getBytes(StandardCharsets.UTF_8).length <= maxBytes) {
+            return str;
+        }
+
+        // 预留 3 个字节给 "..." 省略号
+        final String ellipsis = "...";
+        final int ellipsisBytes = ellipsis.getBytes(StandardCharsets.UTF_8).length;
+        int targetBytes = maxBytes - ellipsisBytes;
+
+        if (targetBytes <= 0) {
+            return ellipsis;
+        }
+
+        // 1. 先按最大字节数截取字符
+        String truncated = str.substring(0, Math.min(str.length(), targetBytes));
+
+        // 2. 循环检查字节长度,防止在汉字中间截断导致乱码
+        while (truncated.getBytes(StandardCharsets.UTF_8).length > targetBytes) {
+            truncated = truncated.substring(0, truncated.length() - 1);
+        }
+
+        return truncated + ellipsis;
+    }
+
     private String createLinkByMiniAppGeneral(Date sendTime, Long courseId, Long videoId,
                                        QwUser qwUser, Long externalId,int type,String domainName,Integer isRoom) {
 

+ 36 - 3
fs-service/src/main/resources/mapper/his/FsPrescribeDataScrmMapper.xml

@@ -67,7 +67,8 @@
         <result property="updateTime"                 column="update_time"                 />
         <result property="diagnoseChinese"            column="diagnose_chinese"            />
         <result property="remarkChinese"              column="remark_chinese"              />
-        <result property="notPrescribeReason"         column="not_prescribe_reason"              />
+        <result property="notPrescribeReason"         column="not_prescribe_reason"        />
+        <result property="companyUserId"              column="company_user_id"        />
     </resultMap>
 
     <sql id="selectFsPrescribeDataScrmVo">
@@ -82,7 +83,7 @@
                end_operate_time, operate_second, third_party_user_id, is_send_to_third_party,
                handwrite_collection_id, company_customer_id,
                food_and_exercise_guidance, healing_area_json, note_taboos, facial_diagnosis,is_document,
-               diagnose_chinese,remark_chinese,not_prescribe_reason
+               diagnose_chinese,remark_chinese,not_prescribe_reason,company_user_id
         from fs_prescribe_data_scrm
     </sql>
 
@@ -99,6 +100,7 @@
             <if test="orderCode != null"> and order_code = #{orderCode}</if>
             <if test="storeOrderId != null"> and store_order_id = #{storeOrderId}</if>
             <if test="userId != null"> and user_id = #{userId}</if>
+            <if test="companyUserId != null"> and company_user_id = #{companyUserId}</if>
             <if test="patientId != null"> and patient_id = #{patientId}</if>
             <if test="prescribeCode != null and prescribeCode != ''"> and prescribe_code = #{prescribeCode}</if>
             <if test="patientName != null and patientName != ''"> and patient_name like concat('%', #{patientName}, '%')</if>
@@ -146,7 +148,7 @@
         fpds.remark, fpds.prescribe_doctor_id, fpds.doctor_sign_url,fpds.recipe_type, fpds.source,
         fpds.doctor_confirm, fpds.company_customer_id,fpds.food_and_exercise_guidance, fpds.healing_area_json,
         fpds.note_taboos,fpds.facial_diagnosis,fpds.is_document,fpds.diagnose_chinese,fpds.remark_chinese,
-        fpds.not_prescribe_reason,cu.nick_name as companyUserName
+        fpds.not_prescribe_reason,fpds.company_user_id,cu.nick_name as companyUserName
         from fs_prescribe_data_scrm fpds left join fs_store_order_scrm orderScrm on fpds.prescribe_id = orderScrm.prescribe_id
         left join  company_user cu on orderScrm.company_user_id = cu.user_id
         <where>
@@ -179,6 +181,34 @@
         order by fpds.create_time desc
     </select>
 
+    <select id="notRecommendUseList" parameterType="com.fs.his.dto.NotRecommendUseQueryDto" resultType="com.fs.his.vo.DoctorScrmPrescribeVO">
+        select fpds.prescribe_id, fpds.prescribe_type,cd.dept_name as deptName, fpds.prescribe_code,
+        fpds.patient_age, fpds.patient_name, fpds.is_history_allergic, fpds.patient_tel,
+        fpds.patient_gender, fpds.prescribe_img_url,fpds.prescribe_img_store_url,fpds.audit_reason,
+        fpds.diagnose, fpds.doctor_id, fpds.drug_doctor_id, fpds.create_time, fpds.status,fpds.audit_time,
+        fpds.remark, fpds.prescribe_doctor_id, fpds.doctor_sign_url,fpds.recipe_type, fpds.source,
+        fpds.doctor_confirm, fpds.company_customer_id,fpds.food_and_exercise_guidance, fpds.healing_area_json,
+        fpds.note_taboos,fpds.facial_diagnosis,fpds.is_document,fpds.diagnose_chinese,fpds.remark_chinese,
+        fpds.not_prescribe_reason,cu.nick_name as companyUserName
+        from fs_prescribe_data_scrm fpds
+        left join  company_user cu on fpds.company_user_id = cu.user_id
+        left join  company_dept cd on cd.dept_id = cu.dept_id
+        <where>
+            fpds.doctor_confirm = -3
+            <if test="doctorId != null"> and fpds.doctor_id = #{doctorId}</if>
+            <if test="companyUserName != null"> and cu.nick_name like concat('%', #{companyUserName}, '%')</if>
+            <if test="deptId != null"> and cu.dept_id = #{deptId}</if>
+            <!-- 按时间范围查询 -->
+            <if test="beginTime != null and beginTime != ''">
+                and fpds.create_time >= #{beginTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and fpds.create_time &lt;= #{endTime}
+            </if>
+        </where>
+        order by fpds.create_time desc
+    </select>
+
     <select id="waitOpenPrescribeList" resultType="com.fs.qw.vo.FsPrescribeDataScrmVO">
         select pds.* from fs_prescribe_data_scrm pds
         left join fs_company_customer fcc on pds.prescribe_id = fcc.prescribe_id
@@ -297,6 +327,7 @@
             <if test="diagnoseChinese != null">diagnose_chinese,</if>
             <if test="remarkChinese != null">remark_chinese,</if>
             <if test="notPrescribeReason != null">not_prescribe_reason,</if>
+            <if test="companyUserId != null">company_user_id,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="prescribeType != null">#{prescribeType},</if>
@@ -358,6 +389,7 @@
             <if test="diagnoseChinese != null">#{diagnoseChinese},</if>
             <if test="remarkChinese != null">#{remarkChinese},</if>
             <if test="notPrescribeReason != null">#{notPrescribeReason},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
         </trim>
     </insert>
 
@@ -423,6 +455,7 @@
             <if test="diagnoseChinese != null">diagnose_chinese = #{diagnoseChinese},</if>
             <if test="remarkChinese != null">remark_chinese = #{remarkChinese},</if>
             <if test="notPrescribeReason != null">not_prescribe_reason = #{notPrescribeReason},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
         </trim>
         where prescribe_id = #{prescribeId}
     </update>