Browse Source

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 4 years ago
parent
commit
c70ed28e9f

+ 25 - 1
common/common-entity/sql记录

@ -1,3 +1,4 @@
-- 2021-01-11 ysj 新增随访相关
DROP TABLE IF EXISTS `wlyy_followup`;
CREATE TABLE `wlyy_followup` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
@ -45,4 +46,27 @@ CREATE TABLE `wlyy_followup` (
  KEY `idx_prescription_code` (`prescription_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1889415 DEFAULT CHARSET=utf8mb4 COMMENT='随访计划表';
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
-------
-- 2021-01-12 ysj 新增随访相关
CREATE TABLE `wlyy_followup_drugs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_id` int(11) DEFAULT NULL COMMENT '随访ID',
  `drugs_code` varchar(50) DEFAULT NULL COMMENT '药品代码',
  `drugs_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
  `drugs_group` varchar(50) DEFAULT NULL COMMENT '药品分组(糖尿病--胰岛特殊处理)',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `dose` varchar(200) DEFAULT NULL COMMENT '次剂量',
  `unit` varchar(50) DEFAULT NULL COMMENT '用药单位【字典MEASURE_UNIT_DICT】',
  `frequency` varchar(50) DEFAULT NULL COMMENT '用药频率【字典RECIPE_FREQUENCY_DICT】',
  PRIMARY KEY (`id`),
  KEY `wlyy_followup_drugs_followup_id_index` (`followup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8mb4 COMMENT='随访用药记录';

+ 104 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupDrugs.java

@ -0,0 +1,104 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访用药记录
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_drugs")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_followup_drugs")
public class FollowupDrugs extends IdEntity {
	//随访ID
	private Long followupId;
	//药品代码
	private String drugsCode;
	//药品名称
	private String drugsName;
	//药品分组(糖尿病--胰岛特殊处理)胰岛素分类insulin,其他药品为normal
	private String drugsGroup;
	//次剂量
	private String dose;
	//用药单位【字典MEASURE_UNIT_DICT】
	private String unit;
	//用药频率【字典RECIPE_FREQUENCY_DICT】
	private String frequency;
	//创建时间
	private Date createTime;
	public Long getFollowupId() {
		return followupId;
	}
	public void setFollowupId(Long followupId) {
		this.followupId = followupId;
	}
	public String getDrugsCode() {
		return drugsCode;
	}
	public void setDrugsCode(String drugsCode) {
		this.drugsCode = drugsCode;
	}
	public String getDrugsName() {
		return drugsName;
	}
	public void setDrugsName(String drugsName) {
		this.drugsName = drugsName;
	}
	public String getDrugsGroup() {
		return drugsGroup;
	}
	public void setDrugsGroup(String drugsGroup) {
		this.drugsGroup = drugsGroup;
	}
	
	public String getDose() {
		return dose;
	}
	
	public void setDose(String dose) {
		this.dose = dose;
	}
	
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public String getFrequency() {
		return frequency;
	}
	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 18 - 1
svr/svr-door-serivce/sql/初始sql.sql

@ -750,7 +750,7 @@ DROP TABLE IF EXISTS `wlyy_followup`;
CREATE TABLE `wlyy_followup` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_no` varchar(50) DEFAULT NULL,
  `followup_date` datetime NOT NULL COMMENT '随访时间',
  `followup_date` datetime NULL COMMENT '随访时间',
  `followup_plan_date` datetime DEFAULT NULL COMMENT '计划随访时间',
  `followup_next_date` datetime DEFAULT NULL COMMENT '计划下次随访时间',
  `followup_type` varchar(50) DEFAULT NULL COMMENT '随访方式【字典FOLLOWUP_WAY_DICT】',
@ -793,6 +793,8 @@ CREATE TABLE `wlyy_followup` (
  KEY `idx_prescription_code` (`prescription_code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1889415 DEFAULT CHARSET=utf8mb4 COMMENT='随访计划表';
ALTER TABLE wlyy_door_service_order ADD followup_date varchar(50) COMMENT '随访时间' ;
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('29', NULL, 'FOLLOWUP_PROJECT', '1', '1', '症状', NULL, NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('30', NULL, 'FOLLOWUP_PROJECT', '2', '1', '体征', NULL, NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('31', NULL, 'FOLLOWUP_PROJECT', '3', '1', '实验室检查', NULL, NULL);
@ -811,5 +813,20 @@ INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('42', NULL, 'FOLLOWUP_MANAGER_STATUS', '2', '1', '失管', '2', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('43', NULL, 'FOLLOWUP_MANAGER_STATUS', '2', '1', '拒管', '3', NULL);
CREATE TABLE `wlyy_followup_drugs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `followup_id` int(11) DEFAULT NULL COMMENT '随访ID',
  `drugs_code` varchar(50) DEFAULT NULL COMMENT '药品代码',
  `drugs_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
  `drugs_group` varchar(50) DEFAULT NULL COMMENT '药品分组(糖尿病--胰岛特殊处理)',
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `dose` varchar(200) DEFAULT NULL COMMENT '次剂量',
  `unit` varchar(50) DEFAULT NULL COMMENT '用药单位【字典MEASURE_UNIT_DICT】',
  `frequency` varchar(50) DEFAULT NULL COMMENT '用药频率【字典RECIPE_FREQUENCY_DICT】',
  PRIMARY KEY (`id`),
  KEY `wlyy_followup_drugs_followup_id_index` (`followup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=436 DEFAULT CHARSET=utf8mb4 COMMENT='随访用药记录';
-- 统计

+ 2 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowUpController.java

@ -31,6 +31,8 @@ public class DoctorFollowUpController extends BaseController {
    @Autowired
    private DoorOrderService doorOrderService;
    @ApiOperation("暂不需要新增随访")
    @PostMapping(value = "/notAddFollowup")
    public String notAddFollowup(@ApiParam(name = "orderId", value = "订单id", defaultValue = "4")

+ 64 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/followup/DoctorFollowupDrugsController.java

@ -0,0 +1,64 @@
package com.yihu.jw.door.controller.doctor.followup;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.followup.FollowupDrugsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
 * 医生端:随访接口
 * 
 * @author hzp add 2016-12-07
 *
 */
@RestController
@RequestMapping(value = "/doctor/followup/drugs", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访用药接口")
public class DoctorFollowupDrugsController extends BaseController {
	@Autowired
	private FollowupDrugsService followupDrugsService;
	@ApiOperation("获取面访用药数据")
	@RequestMapping(value = "/getFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	public String getFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
									@RequestParam(value="id",required = true) String id)
	{
		try {
			Map<String,Object> response = followupDrugsService.getFollowupDrugs(id);
			return write(200, "获取面访用药数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取面访用药数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存面访用药数据")
	@RequestMapping(value = "/saveFollowupDrugs", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	public String saveFollowupDrugs(@ApiParam(name="id",value="随访记录ID",defaultValue = "")
										  @RequestParam(value="id",required = true) String id,
									      @ApiParam(name="drugsData",value="面访用药数据",defaultValue = "[]")
										  @RequestParam(value="drugsData",required = true) String drugsData)
	{
		try {
			followupDrugsService.saveFollowupDrugs(id,drugsData);
			return write(200, "保存面访用药数据成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "保存面访用药数据失败!"+e.getMessage());
		}
	}
}

+ 5 - 2
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowUpDao.java

@ -71,8 +71,11 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
	Followup getFollowupByPrescriptionCode(String prescriptionCode);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupType = ?2 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode,String followupType);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupClass = ?2 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode,String followupClass);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.followupClass = ?2 and a.status <> '0'")
    List<Followup> getFollowupListByPrescriptionCode(String prescriptionCode,String followupClass);
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
    List<Followup> getFollowupListByPrescriptionCode(String prescriptionCode);

+ 22 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/followup/FollowupDrugsDao.java

@ -0,0 +1,22 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.door.dao.followup;
import com.yihu.jw.entity.followup.FollowupDrugs;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FollowupDrugsDao extends PagingAndSortingRepository<FollowupDrugs, Long>, JpaSpecificationExecutor<FollowupDrugs> {
    @Modifying
    @Query("delete FollowupDrugs a where a.followupId=?1")
    int deleteByFollowupId(Long followupId) throws Exception;
    List<FollowupDrugs> findByFollowupId(Long followupId) throws Exception;
}

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java

@ -358,7 +358,7 @@ public class DoorOrderService {
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(id);
        if (null != consult) {
            doorServiceOrder.setSessionId(doorServiceOrder.getProxyPatient() + "_" + consult.getId() + "_"  + doorServiceOrder.getNumber() +  "_" +  consult.getType());
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_"  + doorServiceOrder.getNumber() +  "_" +  consult.getType());
        }
        // 设置服务小结

+ 46 - 5
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowUpService.java

@ -2,11 +2,13 @@ package com.yihu.jw.door.service.followup;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.door.dao.WlyyDoorServiceOrderDao;
import com.yihu.jw.door.dao.followup.FollowUpDao;
import com.yihu.jw.door.service.common.WlyySystemDictService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.es.es.ElasticFactory;
import com.yihu.jw.es.es.ElastricSearchSave;
@ -53,6 +55,37 @@ public class FollowUpService {
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private WlyyDoorServiceOrderDao doorServiceOrderDao;
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        JestClient jestClient = null;
        FollowupContentESDO followupContentESDO = null;
        try {
            //根据随访ID、分类ID获取随访记录详情
            jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("followup_id", id))
                            .must(QueryBuilders.matchQuery("followup_project", followupProject))
            );
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            followupContentESDO = result.getSourceAsObject(FollowupContentESDO.class);
        } finally {
            if (jestClient != null) {
                jestClient.shutdownClient();
            }
        }
        return followupContentESDO;
    }
    /**
     * 新增临时随访记录(返回ID)
@ -73,8 +106,8 @@ public class FollowUpService {
        String followupClasss[] = followupClass.split(",");
        for (String followupClassTemp:followupClasss){
            Followup followupTemp = followupDao.getFollowupByPrescriptionCode(relateCode,followupClassTemp);
            if(followupTemp != null){
            List<Followup> followupTemp = followupDao.getFollowupListByPrescriptionCode(relateCode,followupClassTemp);
            if(followupTemp.size()>0){
                continue;
            }
            Followup followup = new Followup();
@ -82,6 +115,8 @@ public class FollowUpService {
                Date followDate = DateUtil.strToDate(date);
                followup.setFollowupDate(followDate);
                followup.setFollowupPlanDate(followDate);
            }else{
                followup.setFollowupDate(new Date());
            }
            followup.setDoctorCode(doctorCode);
@ -140,6 +175,11 @@ public class FollowUpService {
            }
            followupDao.save(followup);
        }
        WlyyDoorServiceOrderDO orderDO = doorServiceOrderDao.findOne(relateCode);
        if(orderDO!=null){
            orderDO.setFollowupDate(DateUtil.getStringDate());
        }
    }
@ -344,7 +384,6 @@ public class FollowUpService {
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        String followupClass = followup.getFollowupClass();
        re.put("followupClass", followupClass);
@ -364,8 +403,10 @@ public class FollowUpService {
        //随访管理状态转译
        re.put("followupManagerStatus", followup.getFollowupManagerStatus());
        String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
        re.put("followupManagerStatusName", followupManagerStatusName);
        if(StringUtils.isNoneBlank(followup.getFollowupManagerStatus())){
            String followupManagerStatusName = systemDictService.getDictValue("FOLLOWUP_MANAGER_STATUS", followup.getFollowupManagerStatus());
            re.put("followupManagerStatusName", followupManagerStatusName);
        }
        re.put("doctorCode", followup.getDoctorCode());
        re.put("doctorName", followup.getDoctorName());

+ 80 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/followup/FollowupDrugsService.java

@ -0,0 +1,80 @@
package com.yihu.jw.door.service.followup;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.door.dao.followup.FollowupDrugsDao;
import com.yihu.jw.entity.followup.FollowupDrugs;
import com.yihu.jw.followup.FollowupContentESDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.*;
/**
 * Created by yeshijie on 2021/1/11.
 */
@Component
@Transactional(rollbackOn = Exception.class)
public class FollowupDrugsService {
    @Autowired
    private FollowupDrugsDao followupDrugsDao;
    @Autowired
    private FollowUpService followUpService;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 获取面访用药数据
     */
    public Map<String,Object> getFollowupDrugs(String id) throws Exception
    {
        Map<String,Object> re = new HashMap<>();
        FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(id, "6");
        if(followupContentESDO != null){
            re.put("DRUG_COMPLIANCE_CODE",followupContentESDO.getDRUG_COMPLIANCE_CODE());
        }
        //获取用药记录
        List<FollowupDrugs> drugsList = followupDrugsDao.findByFollowupId(Long.valueOf(id));
        re.put("DRUG_LIST",drugsList);
        return re;
    }
    /**
     *保存面访用药数据
     */
    @Transactional
    public void saveFollowupDrugs(String id,String drugsData) throws Exception {
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String,String>> list = objectMapper.readValue(drugsData,javaType);
        Long followupId = Long.valueOf(id);
        //删除原有用药记录
        followupDrugsDao.deleteByFollowupId(Long.valueOf(followupId));
        if(list!=null && list.size()>0)
        {
            List<FollowupDrugs> newList = new ArrayList<>();
            for(Map<String,String> item:list)
            {
                FollowupDrugs drug = new FollowupDrugs();
                drug.setFollowupId(followupId);
                drug.setDrugsGroup(item.get("drugsGroup"));
                drug.setDrugsCode(item.get("drugsCode"));
                drug.setDrugsName(item.get("drugsName"));
                drug.setDose(item.get("dose"));
                drug.setUnit(item.get("unit"));
                drug.setFrequency(item.get("frequency"));
                drug.setCreateTime(new Date());
                newList.add(drug);
            }
            followupDrugsDao.save(newList);
        }
    }
}

+ 2 - 2
svr/svr-door-serivce/src/main/resources/application.yml

@ -303,11 +303,11 @@ spring:
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://365q88j171.oicp.vip:44840/fastdfs/
  fastdfs_file_url: https://365q88j171.oicp.vip/fastdfs/
fast-dfs:
  tracker-server: 10.9.1.247:22122
  public-server: http://365q88j171.oicp.vip:44840/fastdfs/
  public-server: https://365q88j171.oicp.vip/fastdfs/
neiwang:
  enable: true