Browse Source

新增处方模板类型功能和解决门诊指引单扫码缴费失败问题

hurugang 3 years ago
parent
commit
d6af869f89

+ 34 - 7
src/main/java/cn/hnthyy/thmz/controller/CommonController.java

@@ -1,10 +1,7 @@
 package cn.hnthyy.thmz.controller;
 
 import cn.hnthyy.thmz.comment.UserLoginToken;
-import cn.hnthyy.thmz.enums.ClassCodeEnum;
-import cn.hnthyy.thmz.enums.OrderFrequencyEnum;
-import cn.hnthyy.thmz.enums.SupplyTypeEnum;
-import cn.hnthyy.thmz.enums.TemplateTypeEnum;
+import cn.hnthyy.thmz.enums.*;
 import cn.hnthyy.thmz.service.his.mz.*;
 import cn.hnthyy.thmz.service.his.zd.*;
 import lombok.extern.slf4j.Slf4j;
@@ -530,7 +527,7 @@ public class CommonController {
 
 
     /**
-     * 查询所有医疗范文类型
+     * 查询所有医疗范文范围
      *
      * @return
      */
@@ -540,7 +537,7 @@ public class CommonController {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             resultMap.put("code", 0);
-            resultMap.put("message", "查询所有医疗范文类型成功");
+            resultMap.put("message", "查询所有医疗范文范围成功");
             List<Map<String, Object>> data = new ArrayList<>();
             Arrays.stream(TemplateTypeEnum.values()).forEach(templateTypeEnum -> {
                 Map<String, Object> temp = new HashMap<>();
@@ -550,6 +547,37 @@ public class CommonController {
             });
             resultMap.put("data", data);
             return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("查询所有医疗范文范围型失败,错误信息{}", e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "查询所有医疗范文范围失败");
+            return resultMap;
+        }
+    }
+
+
+    /**
+     * 查询所有医疗范文类型
+     *
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/getTemplateKindTypes", method = {RequestMethod.GET})
+    public Map<String, Object> getTemplateKindTypes() {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            resultMap.put("code", 0);
+            resultMap.put("message", "查询所有医疗范文类型成功");
+            List<Map<String, Object>> data = new ArrayList<>();
+            Arrays.stream(TemplateKindTypeEnum.values()).forEach(templateKindTypeEnum -> {
+                Map<String, Object> temp = new HashMap<>();
+                temp.put("code", templateKindTypeEnum.code);
+                temp.put("name", templateKindTypeEnum.name);
+                data.add(temp);
+            });
+            resultMap.put("data", data);
+            return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
             log.error("查询所有医疗范文类型失败,错误信息{}", e);
@@ -559,7 +587,6 @@ public class CommonController {
         }
     }
 
-
     /**
      * 查询所有的部位列表
      *

+ 4 - 3
src/main/java/cn/hnthyy/thmz/controller/mz/MzChargeDetailController.java

@@ -1611,7 +1611,7 @@ public class MzChargeDetailController {
                 if (BigDecimal.ZERO.equals(unitPrice)) {
                     unitPrice = BigDecimal.valueOf(0.01D);
                 }
-                unitPrice = unitPrice.multiply(BigDecimal.valueOf(100));
+                //unitPrice = unitPrice.multiply(BigDecimal.valueOf(100));
                 BigDecimal quantity = mz.getQuantity() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getQuantity());
                 BigDecimal drugWin = mz.getDrugWin() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getDrugWin());
                 BigDecimal amount = (BigDecimal) map.get("itemTotalFee");
@@ -1622,10 +1622,11 @@ public class MzChargeDetailController {
                 totalAmount = totalAmount.add(tempAmount);
                 map.put("itemTotalFee", amount.add(tempAmount));
             }
-            String payQrcode = haiCiAdapterService.genMzPayQrcode(totalAmount.intValue(), patientId, patientId + "_" + times + "_1");
+            totalAmount=totalAmount.setScale(1, BigDecimal.ROUND_HALF_UP);
+            String payQrcode = haiCiAdapterService.genMzPayQrcode(totalAmount.multiply(BigDecimal.valueOf(100)).intValue(), patientId, patientId + "_" + times + "_1");
             results.put("code", 0);
             results.put("message", "门诊缴费指引单查询成功");
-            results.put("totalAmount", totalAmount.divide(BigDecimal.valueOf(100)).setScale(1, BigDecimal.ROUND_HALF_UP));
+            results.put("totalAmount", totalAmount);
             results.put("data", returnList);
             if (payQrcode != null) {
                 results.put("payQrcode", payQrcode);

+ 26 - 31
src/main/java/cn/hnthyy/thmz/controller/mz/TemplateController.java

@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
 import java.util.Map;
@@ -37,36 +38,36 @@ public class TemplateController {
     public Map<String, Object> saveTemplate(@RequestBody Template template, HttpServletRequest httpServletRequest) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
-            if(template==null){
+            if (template == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "保存医疗范文失败,参数为空");
                 return resultMap;
             }
-            if(template.getTemplateType()==null){
+            if (template.getTemplateType() == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "保存医疗范文失败,范文类型参数为空");
                 return resultMap;
             }
-            if(template.getTemplateStatus()==null){
+            if (template.getTemplateStatus() == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "保存医疗范文失败,范文状态参数为空");
                 return resultMap;
             }
-            if(StringUtils.isBlank(template.getTemplateData())){
+            if (StringUtils.isBlank(template.getTemplateData())) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "保存医疗范文失败,范文内容参数为空");
                 return resultMap;
             }
             User tokenUser = TokenUtil.getUser(httpServletRequest);
-            if(TemplateTypeEnum.SECTION_TEMPLATE.code.equals(template.getTemplateType())){
-                Employee employee= employeeService.queryByUserCode(tokenUser.getUserIdCode());
-                if(employee!=null && StringUtils.isNotBlank(employee.getDeptCode())){
+            if (TemplateTypeEnum.SECTION_TEMPLATE.code.equals(template.getTemplateType())) {
+                Employee employee = employeeService.queryByUserCode(tokenUser.getUserIdCode());
+                if (employee != null && StringUtils.isNotBlank(employee.getDeptCode())) {
                     template.setDeptNo(employee.getDeptCode());
                 }
             }
-            if(template.getId()==null){
+            if (template.getId() == null) {
                 template.setCreateId(tokenUser.getUserIdCode());
-            }else {
+            } else {
                 template.setUpdateId(tokenUser.getUserIdCode());
             }
             int num = templateService.saveTemplate(template);
@@ -93,8 +94,6 @@ public class TemplateController {
     }
 
 
-
-
     /**
      * 删除医疗范文
      *
@@ -106,12 +105,12 @@ public class TemplateController {
     public Map<String, Object> removeTemplate(@RequestBody Template template, HttpServletRequest httpServletRequest) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
-            if(template==null){
+            if (template == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "删除医疗范文失败,参数为空");
                 return resultMap;
             }
-            if(template.getId()==null){
+            if (template.getId() == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "删除医疗范文失败,范文主键参数为空");
                 return resultMap;
@@ -143,10 +142,6 @@ public class TemplateController {
     }
 
 
-
-
-
-
     /**
      * 查询医生自己的,科室和全院的医疗范文  ,不查询内容
      *
@@ -154,18 +149,18 @@ public class TemplateController {
      */
     @UserLoginToken
     @RequestMapping(value = "/getTemplate", method = {RequestMethod.GET})
-    public Map<String, Object> getTemplate(HttpServletRequest httpServletRequest) {
+    public Map<String, Object> getTemplate(@RequestParam("templateKindType") String templateKindType, HttpServletRequest httpServletRequest) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             User tokenUser = TokenUtil.getUser(httpServletRequest);
-            Employee employee= employeeService.queryByUserCode(tokenUser.getUserIdCode());
-            String deptNo=null;
-            if(employee!=null && StringUtils.isNotBlank(employee.getDeptCode())){
-                deptNo=employee.getDeptCode();
+            Employee employee = employeeService.queryByUserCode(tokenUser.getUserIdCode());
+            String deptNo = null;
+            if (employee != null && StringUtils.isNotBlank(employee.getDeptCode())) {
+                deptNo = employee.getDeptCode();
             }
             resultMap.put("code", 0);
             resultMap.put("message", "查询医疗范文成功");
-            resultMap.put("data",templateService.queryTemplate(tokenUser.getUserIdCode(), deptNo));
+            resultMap.put("data", templateService.queryTemplate(tokenUser.getUserIdCode(), deptNo, ("null".equals(templateKindType) || StringUtils.isBlank(templateKindType)) ? null : Integer.valueOf(templateKindType)));
             return resultMap;
         } catch (MzException e) {
             resultMap.put("code", -1);
@@ -191,16 +186,16 @@ public class TemplateController {
     public Map<String, Object> getTemplateById(@RequestParam("id") Long id) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
-            if(id==null){
+            if (id == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "查询医疗范文失败,主键为空");
                 return resultMap;
             }
             resultMap.put("code", 0);
             resultMap.put("message", "查询医疗范文成功");
-            resultMap.put("data",templateService.queryById(id));
+            resultMap.put("data", templateService.queryById(id));
             return resultMap;
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
             resultMap.put("message", "根据id查询医疗范文失败,请联系管理员");
@@ -220,21 +215,21 @@ public class TemplateController {
     public Map<String, Object> increaseNumber(@RequestParam("id") Long id) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
-            if(id==null){
+            if (id == null) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "更新模板调用次数失败,主键为空");
                 return resultMap;
             }
-            Template template =templateService.queryById(id);
+            Template template = templateService.queryById(id);
             Template updateTemplate = new Template();
             updateTemplate.setId(id);
-            updateTemplate.setUsedTimes(template.getUsedTimes()==null?1:template.getUsedTimes()+1);
+            updateTemplate.setUsedTimes(template.getUsedTimes() == null ? 1 : template.getUsedTimes() + 1);
             templateService.modifyTemplateByKey(updateTemplate);
             resultMap.put("code", 0);
             resultMap.put("message", "更新模板调用次数成功");
-            resultMap.put("data",template);
+            resultMap.put("data", template);
             return resultMap;
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
             resultMap.put("message", "更新模板调用次数失败,请联系管理员");

+ 5 - 1
src/main/java/cn/hnthyy/thmz/entity/thmz/Template.java

@@ -29,7 +29,11 @@ public class Template implements Serializable {
 	 */
 	private String icdText;
 	/**
-	 * 0-个人模板  1-科室模板 2-全院模板 {@link cn.hnthyy.thmz.enums.TemplateTypeEnum}
+	 * 范文类型 0-西成药  1-中草药 2-诊疗 3-检查 4-检验 5-入院 6-综合 {@link cn.hnthyy.thmz.enums.TemplateKindTypeEnum}
+	 */
+	private Integer templateKindType;
+	/**
+	 *   范文范围 0-个人模板  1-科室模板 2-全院模板 {@link cn.hnthyy.thmz.enums.TemplateTypeEnum}
 	 */
 	private Integer templateType;
 

+ 40 - 0
src/main/java/cn/hnthyy/thmz/enums/TemplateKindTypeEnum.java

@@ -0,0 +1,40 @@
+package cn.hnthyy.thmz.enums;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ *  0-西成药  1-中草药 2-诊疗 3-检查 4-检验 5-入院 6-综合
+ */
+public enum TemplateKindTypeEnum {
+    WESTERN_MEDICINE(0,"西成药"),
+    CHINESE_HERBAL_MEDICINE(1,"中草药"),
+    DIAGNOSIS(2,"诊疗"),
+    INSPECT(3,"检查"),
+    TEST(4,"检验"),
+    ADMISSION(5,"入院"),
+    FULL(6,"综合");
+
+    public Integer code;
+    public String name;
+
+    TemplateKindTypeEnum(Integer code, String name){
+        this.code=code;
+        this.name=name;
+    }
+
+    /**
+     * 根据编码查询对应的类型
+     * @param code
+     * @return
+     */
+    public static TemplateKindTypeEnum geteTemplateTypeByCode(Integer code){
+        List<TemplateKindTypeEnum> classCodeEnums= Arrays.asList(values());
+        for (TemplateKindTypeEnum classCode:classCodeEnums){
+            if(classCode.code.equals(code)){
+                return classCode;
+            }
+        }
+        return null;
+    }
+}

+ 14 - 7
src/main/java/cn/hnthyy/thmz/mapper/thmz/TemplateMapper.java

@@ -16,8 +16,8 @@ public interface TemplateMapper {
      * @param template
      * @return
      */
-    @Insert("INSERT INTO t_template(name,icd_text, template_type, template_data, create_id,dept_no,template_status,used_times,create_time,update_id,update_time) VALUES " +
-            "(#{name},#{icdText}, #{templateType}, #{templateData}, #{createId},#{deptNo},#{templateStatus},0,#{createTime},#{updateId},#{updateTime})")
+    @Insert("INSERT INTO t_template(name,icd_text, template_type,template_kind_type, template_data, create_id,dept_no,template_status,used_times,create_time,update_id,update_time) VALUES " +
+            "(#{name},#{icdText}, #{templateType}, #{templateKindType}, #{templateData}, #{createId},#{deptNo},#{templateStatus},0,#{createTime},#{updateId},#{updateTime})")
     @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
     int insertTemplate(Template template);
 
@@ -29,12 +29,16 @@ public interface TemplateMapper {
      * @return
      */
     @Select({"<script>",
-            "select id,name,icd_text, template_type, create_id,dept_no,template_status,used_times,create_time,update_id,update_time from t_template where template_status =0 and (template_type=2 or create_id=#{createId}",
+            "select id,name,icd_text, template_type,template_kind_type, create_id,dept_no,template_status,used_times,create_time,update_id,update_time from t_template where template_status =0 " ,
+            "<when test='templateKindType!=null'>",
+            " and template_kind_type =#{templateKindType}",
+            "</when>",
+             "and (template_type=2 or create_id=#{createId}",
             "<when test='deptNo!=null'>",
             "or dept_no =#{deptNo}",
-            "</when>"
-            , ") order by used_times DESC </script>"})
-    List<Template> selectTemplate(@Param("createId") String createId, @Param("deptNo") String deptNo);
+            "</when>",
+             ") order by used_times DESC </script>"})
+    List<Template> selectTemplate(@Param("createId") String createId, @Param("deptNo") String deptNo, @Param("templateKindType") Integer templateKindType);
 
     /**
      * 按照id查询
@@ -42,7 +46,7 @@ public interface TemplateMapper {
      * @param id
      * @return
      */
-    @Select("select id,name,icd_text, template_type,template_data, create_id,dept_no,template_status,used_times,create_time,update_id,update_time from t_template where id=#{id}")
+    @Select("select id,name,icd_text, template_type,template_kind_type,template_data, create_id,dept_no,template_status,used_times,create_time,update_id,update_time from t_template where id=#{id}")
     Template selectById(@Param("id") Long id);
 
     /**
@@ -60,6 +64,9 @@ public interface TemplateMapper {
             "<when test='icdText!=null'>",
             ",icd_text =#{icdText}",
             "</when>",
+            "<when test='templateKindType!=null'>",
+            ",template_kind_type =#{templateKindType}",
+            "</when>",
             "<when test='templateType!=null'>",
             ",template_type =#{templateType}",
             "</when>",

+ 11 - 10
src/main/java/cn/hnthyy/thmz/service/impl/thmz/TemplateServiceImpl.java

@@ -29,44 +29,45 @@ public class TemplateServiceImpl implements TemplateService {
     private TCommonParamsMapper tCommonParamsMapper;
     @Autowired
     MzChargeDetailService mzChargeDetailService;
+
     @Override
     public int saveTemplate(Template template) throws MzException {
-        MzPrescriptionVo mzPrescriptionVo= (MzPrescriptionVo)JsonUtil.jsontoObject(template.getTemplateData(),MzPrescriptionVo.class);
-        if(mzPrescriptionVo==null){
+        MzPrescriptionVo mzPrescriptionVo = (MzPrescriptionVo) JsonUtil.jsontoObject(template.getTemplateData(), MzPrescriptionVo.class);
+        if (mzPrescriptionVo == null) {
             throw new MzException("保存处方失败,处方参数不能为空");
         }
-        mzChargeDetailService.setFullMzPrescriptionVo(mzPrescriptionVo,false,false);
+        mzChargeDetailService.setFullMzPrescriptionVo(mzPrescriptionVo, false, false);
         template.setTemplateData(JsonUtil.object2Json(mzPrescriptionVo));
         if (template.getId() == null) {
             template.setCreateTime(new Date());
             int num = templateMapper.insertTemplate(template);
-            TCommonParams tCommonParams= new TCommonParams();
+            TCommonParams tCommonParams = new TCommonParams();
             tCommonParams.setCreateIdCode(template.getCreateId());
             tCommonParams.setCreateTime(template.getCreateTime());
             tCommonParams.setParamsStatus(YesNoEnum.NO.code);
             tCommonParams.setUsedTimes(0L);
-            if(template.getEmrChiefComplaint()!=null && StringUtils.isNotBlank(template.getEmrChiefComplaint())){
+            if (template.getEmrChiefComplaint() != null && StringUtils.isNotBlank(template.getEmrChiefComplaint())) {
                 tCommonParams.setParamsName(template.getEmrChiefComplaint());
                 tCommonParams.setPyCode(PyWbUtil.toBigFirstChar(template.getEmrChiefComplaint()));
                 tCommonParams.setWbCode(PyWbUtil.getWBCode(template.getEmrChiefComplaint()));
                 tCommonParams.setParamsType(ParamsTypeEnum.SYMPTOM.code);
                 tCommonParamsMapper.insertTCommonParams(tCommonParams);
             }
-            if(template.getEmrHpi()!=null && StringUtils.isNotBlank(template.getEmrHpi())){
+            if (template.getEmrHpi() != null && StringUtils.isNotBlank(template.getEmrHpi())) {
                 tCommonParams.setParamsName(template.getEmrHpi());
                 tCommonParams.setPyCode(PyWbUtil.toBigFirstChar(template.getEmrHpi()));
                 tCommonParams.setWbCode(PyWbUtil.getWBCode(template.getEmrHpi()));
                 tCommonParams.setParamsType(ParamsTypeEnum.HISTORY_OF_PRESENT_ILLNESS.code);
                 tCommonParamsMapper.insertTCommonParams(tCommonParams);
             }
-            if(template.getEmrPs()!=null && StringUtils.isNotBlank(template.getEmrPs())){
+            if (template.getEmrPs() != null && StringUtils.isNotBlank(template.getEmrPs())) {
                 tCommonParams.setParamsName(template.getEmrPs());
                 tCommonParams.setPyCode(PyWbUtil.toBigFirstChar(template.getEmrPs()));
                 tCommonParams.setWbCode(PyWbUtil.getWBCode(template.getEmrPs()));
                 tCommonParams.setParamsType(ParamsTypeEnum.FAMILY_HISTORY.code);
                 tCommonParamsMapper.insertTCommonParams(tCommonParams);
             }
-            if(template.getIcdCode()!=null && StringUtils.isNotBlank(template.getIcdCode())){
+            if (template.getIcdCode() != null && StringUtils.isNotBlank(template.getIcdCode())) {
                 tCommonParams.setParamsName(template.getIcdCode());
                 tCommonParams.setPyCode(PyWbUtil.toBigFirstChar(template.getIcdCode()));
                 tCommonParams.setWbCode(PyWbUtil.getWBCode(template.getIcdCode()));
@@ -80,8 +81,8 @@ public class TemplateServiceImpl implements TemplateService {
     }
 
     @Override
-    public List<Template> queryTemplate(String createId, String deptNo) {
-        return templateMapper.selectTemplate(createId, deptNo);
+    public List<Template> queryTemplate(String createId, String deptNo, Integer templateKindType) {
+        return templateMapper.selectTemplate(createId, deptNo, templateKindType);
     }
 
     @Override

+ 4 - 1
src/main/java/cn/hnthyy/thmz/service/thmz/TemplateService.java

@@ -20,14 +20,17 @@ public interface TemplateService {
 
     /**
      * 查询医生自己的,科室和全院的医疗范文  ,不查询内容
+     *
      * @param createId
      * @param deptNo
+     * @param templateKindType
      * @return
      */
-    List<Template> queryTemplate(String createId, String deptNo);
+    List<Template> queryTemplate(String createId, String deptNo, Integer templateKindType);
 
     /**
      * 按照id查询
+     *
      * @param id
      * @return
      */

+ 1 - 0
src/main/resources/otherSource/thyy_mz_system.sql

@@ -367,6 +367,7 @@ CREATE TABLE `t_template`  (
   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
   `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '医疗范文名称',
   `icd_text` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '诊断',
+  `template_kind_type` int(1) NULL DEFAULT 6 COMMENT '0-西成药  1-中草药 2-诊疗 3-检查 4-检验 5-入院 6-综合',
   `template_type` int(1) NULL DEFAULT NULL COMMENT '0-个人模板  1-科室模板 2-全院模板',
   `template_data` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模板内容',
   `create_id` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '创建人ID',

+ 57 - 5
src/main/resources/static/js/mz/clinic.js

@@ -16,6 +16,7 @@ $(function () {
     initListDeptSelect();
     initResponceTypeSelect();
     initTemplateTypeSelect();
+    initTemplateKindTypeSelect('templateKindType');
     initZyClassTypeSelect();
     initInstructionSelect();
     setSelectSize();
@@ -453,7 +454,7 @@ function contentMethod() {
             '                    </form>' +
             '                </div>' +
             '            </div>' +
-            '            <div style="height: 33%;padding-left: 15px;">' +
+            '            <div style="height: 33%;padding-left: 15px;width: 100%;">' +
             '                <button type="button" style="cursor: default;margin-bottom: 0px;margin-right: 0px;margin-top: 5px;"' +
             '                class="btn btn-primary">' +
             '                <span id="recommendType"></span>推荐' +
@@ -465,12 +466,21 @@ function contentMethod() {
             '                    </form>' +
             '                </div>' +
             '            </div>' +
-            '            <div style="height: 33%;padding-left: 15px;">' +
+            '            <div style="height: 33%;padding-left: 15px;width: 100%;">' +
             '                <button type="button"' +
             '                        style="cursor: default;margin-bottom: 0px;margin-right: 0px;margin-top: 5px;    font-size: 12px;"' +
             '                        class="btn btn-primary">' +
             '                    医疗范本' +
             '                </button>' +
+            '                <div class="item" style="width: 230px;height: 35px;float: right;line-height: 35px;margin-right: 40px;">' +
+            '                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="templateKindTypeForm">范文类型' +
+            '                            </label>' +
+            '                            <div class="col-md-8 col-sm-8 col-xs-12">' +
+            '                                <select class="form-control selectpicker show-tick" title="请选择"  onchange="fitTemplateData()"' +
+            '                                        id="templateKindTypeForm">' +
+            '                                </select>' +
+            '                            </div>' +
+            '                </div>'+
             '                <div style="height: calc(100% - 44px);border: 1px solid #DDDDDD;overflow-y: auto;margin-top: 5px;width: 100%;position: relative;">' +
             '                    <form class="form-horizontal form-label-left mz-fixed-form" novalidate autocomplete="off"' +
             '                          style="height: 100%;overflow-y: auto;width: 100%;" id="TemplateData">' +
@@ -478,6 +488,7 @@ function contentMethod() {
             '                </div>' +
             '            </div>';
         $("#smartAssistPopoverContent").html(html);
+        initTemplateKindTypeSelect('templateKindTypeForm');
         fitPatientHisData();
         fitSymptomData();
         fitEmrHpiData();
@@ -683,7 +694,7 @@ function fitTemplateData() {
     var emptyHtml = '<img src="/thmz/images/no-recommend.png" style="height: 120px;position: absolute;top: 50%;transform: translateY(-50%);margin-left: -30px;margin-left: 145px;">';
     $.ajax({
         type: "GET",
-        url: '/thmz/getTemplate',
+        url: '/thmz/getTemplate?templateKindType='+$("#templateKindTypeForm").val(),
         contentType: "application/json;charset=UTF-8",
         dataType: "json",
         async: false,
@@ -1612,6 +1623,10 @@ function callTemplate() {
                 editPrescription(jsonData, 1);
                 $("#templateId").val(res.data.id);
                 $("#templateName").val(res.data.name);
+                $("#templateKindType").selectpicker('val', res.data.templateKindType);
+                $("#templateKindType").selectpicker('refresh');
+                $("#templateType").selectpicker('val', res.data.templateType);
+                $("#templateType").selectpicker('refresh');
                 $("#medicalModelModal").modal("hide");
                 closePopover();
             } else {
@@ -1982,7 +1997,7 @@ function initSmallDeptByDept() {
 // }
 
 /**
- * 初始化医疗范文类型下拉选
+ * 初始化医疗范文范围下拉选
  */
 function initTemplateTypeSelect() {
     $.ajax({
@@ -2010,6 +2025,35 @@ function initTemplateTypeSelect() {
 }
 
 
+/**
+ * 初始化医疗范文类型下拉选
+ * @param templateKindTypeId
+ */
+function initTemplateKindTypeSelect(templateKindTypeId) {
+    $.ajax({
+        type: "GET",
+        url: '/thmz/getTemplateKindTypes',
+        contentType: "application/json;charset=UTF-8",
+        dataType: "json",
+        headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
+        success: function (res) {
+            if (res == '401' || res == 401) {
+                window.location.href = '/thmz/login/view'
+                return;
+            }
+            if (res.code == 0) {
+                res.data.forEach(function (item) {
+                    var html = '<option value="' + item.code + '">' + item.name + '</option>';
+                    $('#'+templateKindTypeId).append(html);
+                });
+                $('#'+templateKindTypeId).selectpicker('refresh');
+            } else {
+                errorMesage(res);
+            }
+        }
+    });
+}
+
 /**
  * 初始频次下拉选
  * @param id
@@ -5770,9 +5814,14 @@ function saveapidAccepts() {
         errorMesageSimaple("范文名称不能为空!");
         return;
     }
+    var templateKindType = $("#templateKindType").val();
+    if (templateKindType == null || templateKindType == "") {
+        errorMesageSimaple("范文类型不能为空!");
+        return;
+    }
     var templateType = $("#templateType").val();
     if (templateType == null || templateType == "") {
-        errorMesageSimaple("范文类型不能为空!");
+        errorMesageSimaple("范文范围不能为空!");
         return;
     }
     var templateStatus = $("#templateStatus").val();
@@ -5795,6 +5844,7 @@ function saveapidAccepts() {
                 "id": $("#templateId").val(),
                 "name": templateName,
                 "icdText": jsonData.icdText != null ? jsonData.icdText : jsonData.mzBlRecord.tentativeDiagnosis,
+                "templateKindType": templateKindType,
                 "templateType": templateType,
                 "templateStatus": templateStatus,
                 "templateData": JSON.stringify(jsonData),
@@ -5863,6 +5913,8 @@ function removeTemplate() {
 function clearApidAcceptsModal() {
     $("#templateId").val(null);
     $("#templateName").val(null);
+    $("#templateKindType").selectpicker('val', 0);
+    $("#templateKindType").selectpicker('refresh');
     $("#templateType").selectpicker('val', 0);
     $("#templateType").selectpicker('refresh');
     $("#templateStatus").selectpicker('val', 0);

+ 14 - 3
src/main/resources/templates/mz/clinic.html

@@ -1539,10 +1539,21 @@
                     </div>
                     <div class="item form-group">
                         <div class="col-md-12 col-sm-12 col-xs-12 item">
-                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="templateType">范文类型
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="templateKindType">范文类型
                             </label>
                             <div class="col-md-8 col-sm-8 col-xs-12">
-                                <select class="form-control selectpicker show-tick"
+                                <select class="form-control selectpicker show-tick" title="请选择"
+                                        id="templateKindType">
+                                </select>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="item form-group">
+                        <div class="col-md-12 col-sm-12 col-xs-12 item">
+                            <label class="control-label col-md-4 col-sm-4 col-xs-12" for="templateType">范文范围
+                            </label>
+                            <div class="col-md-8 col-sm-8 col-xs-12">
+                                <select class="form-control selectpicker show-tick" title="请选择"
                                         id="templateType">
                                 </select>
                             </div>
@@ -1553,7 +1564,7 @@
                             <label class="control-label col-md-4 col-sm-4 col-xs-12" for="templateStatus">范文状态
                             </label>
                             <div class="col-md-8 col-sm-8 col-xs-12">
-                                <select class="form-control selectpicker show-tick"
+                                <select class="form-control selectpicker show-tick" title="请选择"
                                         id="templateStatus">
                                 </select>
                             </div>