Browse Source

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

wangzhinan 1 year ago
parent
commit
1abecefd69
20 changed files with 2186 additions and 1 deletions
  1. 20 0
      business/base-service/src/main/java/com/yihu/jw/health/FoodCompDao.java
  2. 22 0
      business/base-service/src/main/java/com/yihu/jw/health/MedicinesDao.java
  3. 35 0
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordDietDao.java
  4. 35 0
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordMedicationDao.java
  5. 36 0
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordSportsDao.java
  6. 22 0
      business/base-service/src/main/java/com/yihu/jw/health/SportsDao.java
  7. 22 0
      business/base-service/src/main/java/com/yihu/jw/health/SportsTypeDao.java
  8. 91 1
      common/common-entity/src/db/2023.sql
  9. 83 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/FoodComp.java
  10. 56 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/Medicines.java
  11. 120 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordDiet.java
  12. 121 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordMedication.java
  13. 154 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordSports.java
  14. 55 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/Sports.java
  15. 54 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/health/SportsType.java
  16. 367 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthRecordController.java
  17. 441 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthRecordController.java
  18. 28 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/MedicinesService.java
  19. 383 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthRecordService.java
  20. 41 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/SportsService.java

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/health/FoodCompDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.health;
import com.yihu.jw.entity.base.health.FoodComp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FoodCompDao extends PagingAndSortingRepository<FoodComp, Long>, JpaSpecificationExecutor<FoodComp> {
	List<FoodComp> findByPid(Long pid);
	@Query("select a from FoodComp a where a.name like ?1")
	List<FoodComp> findByName(String name);
	@Query("select a from FoodComp a where a.pid <> ?1")
	List<FoodComp> findAllFoodByPidNot(Long pid);
}

+ 22 - 0
business/base-service/src/main/java/com/yihu/jw/health/MedicinesDao.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.health;
import com.yihu.jw.entity.base.health.Medicines;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface MedicinesDao extends PagingAndSortingRepository<Medicines, Long>, JpaSpecificationExecutor<Medicines> {
	@Query("select a from Medicines a where a.type = ?1 and a.del = '1'")
	List<Medicines> findAll(int type);
	Medicines findByCode(String code);
}

+ 35 - 0
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordDietDao.java

@ -0,0 +1,35 @@
package com.yihu.jw.health;
import com.yihu.jw.entity.base.health.PatientHealthRecordDiet;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Date;
public interface PatientHealthRecordDietDao extends PagingAndSortingRepository<PatientHealthRecordDiet, Long>, JpaSpecificationExecutor<PatientHealthRecordDiet> {
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordDiet a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordDiet> findByPatient(String patient);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
    Page<PatientHealthRecordDiet> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("SELECT a FROM PatientHealthRecordDiet a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
    Page<PatientHealthRecordDiet> findDietByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改饮食记录
    @Modifying
    @Query("update PatientHealthRecordDiet a set a.recordDate = ?2,a.content = ?3,a.images= ?4 where a.id= ?1 ")
    void modifyDiet(long id,Date value1, String value2, String value3);
    //	删除饮食记录
    @Modifying
    @Query("update PatientHealthRecordDiet a set a.del = 0 where a.id= ?1 ")
    void deleteDiet(long id);
}

+ 35 - 0
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordMedicationDao.java

@ -0,0 +1,35 @@
package com.yihu.jw.health;
import com.yihu.jw.entity.base.health.PatientHealthRecordMedication;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Date;
public interface PatientHealthRecordMedicationDao extends PagingAndSortingRepository<PatientHealthRecordMedication, Long>, JpaSpecificationExecutor<PatientHealthRecordMedication> {
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordMedication a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordMedication> findByPatient(String patient);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.czrq DESC")
    Page<PatientHealthRecordMedication> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("SELECT a FROM PatientHealthRecordMedication a WHERE a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' ORDER BY a.recordDate DESC")
    Page<PatientHealthRecordMedication> findMedicalByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改用药记录
    @Modifying
    @Query("update PatientHealthRecordMedication a set a.recordDate = ?2,a.medicines = ?3,a.medicinesName= ?4 where a.id= ?1 ")
    void modifyMedication(long id, Date value1, String value2,String medicationName);
    //	删除用药记录
    @Modifying
    @Query("update PatientHealthRecordMedication a set a.del = 0 where a.id= ?1 ")
    void deleteMedication(long id);
}

+ 36 - 0
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordSportsDao.java

@ -0,0 +1,36 @@
package com.yihu.jw.health;
import com.yihu.jw.entity.base.health.PatientHealthRecordSports;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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.Date;
public interface PatientHealthRecordSportsDao extends PagingAndSortingRepository<PatientHealthRecordSports, Long>, JpaSpecificationExecutor<PatientHealthRecordSports> {
    // 查询患者标识健康记录
    @Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.del = '1'")
    Iterable<PatientHealthRecordSports> findByPatient(String patient);
    // 查询最近的健康记录
    @Query("SELECT a FROM PatientHealthRecordSports a WHERE a.patient = ?1 and a.del = '1' ORDER BY a.recordDate DESC")
    Page<PatientHealthRecordSports> findRecentByPatient(String patient, Pageable pageRequest);
    @Query("select a from PatientHealthRecordSports a where a.patient = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' order by a.recordDate desc")
    Page<PatientHealthRecordSports> findSportsByPatient(String patient, Date start, Date end, Pageable pageRequest);
    //	修改运动记录
    @Modifying
    @Query("update PatientHealthRecordSports a set a.recordDate = ?2,a.sportsTime= ?3 ,a.sportsType = ?4,a.sportsTypeName= ?5,a.sports = ?6 ,a.sportsName= ?7 where a.id= ?1 ")
    void modifySports(long id, Date value1, Double value2, String value3, String typeName, String value4, String sportName);
    //	删除运动记录
    @Modifying
    @Query("update PatientHealthRecordSports a set a.del = 0 where a.id= ?1 ")
    void deleteSports(long id);
}

+ 22 - 0
business/base-service/src/main/java/com/yihu/jw/health/SportsDao.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.health;
import com.yihu.jw.entity.base.health.Sports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface SportsDao extends PagingAndSortingRepository<Sports, Long>, JpaSpecificationExecutor<Sports> {
	
	@Query("select a from Sports a where a.del = '1'")
	List<Sports> findAll();
	
	Sports findByCode(String code);
	
}

+ 22 - 0
business/base-service/src/main/java/com/yihu/jw/health/SportsTypeDao.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.health;
import com.yihu.jw.entity.base.health.SportsType;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface SportsTypeDao extends PagingAndSortingRepository<SportsType, Long>, JpaSpecificationExecutor<SportsType> {
	
	@Query("select a from SportsType a where a.del = '1'")
	List<SportsType> findAll();
	
	SportsType findByCode(String code);
	
}

+ 91 - 1
common/common-entity/src/db/2023.sql

@ -362,4 +362,94 @@ CREATE TABLE `dm_device_category` (
  `czrq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '添加时间',
  `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='设备分类表';
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='设备分类表';
-- ysj 2023-12-14
CREATE TABLE `dm_sports` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
    `code` varchar(50) DEFAULT NULL COMMENT '运动编码',
    `name` varchar(100) DEFAULT NULL COMMENT '运动名称',
    `type` varchar(20) DEFAULT NULL COMMENT '运动强度类型标识',
    `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_dm_sports_1` (`code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COMMENT='运动类型字典表';
CREATE TABLE `dm_sports_type` (
     `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
     `code` varchar(50) DEFAULT NULL COMMENT '强度编码',
     `name` varchar(100) DEFAULT NULL COMMENT '强度名称',
     `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
     PRIMARY KEY (`id`) USING BTREE,
     KEY `idx_dm_sports_type_1` (`code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COMMENT='运动强度字典表';
CREATE TABLE `wlyy_food_comp` (
   `id` int(10) NOT NULL AUTO_INCREMENT,
   `pid` int(10) DEFAULT NULL,
   `name` varchar(50) DEFAULT NULL,
   `hot` int(10) DEFAULT '0' COMMENT '食物能量',
   `component` varchar(2000) DEFAULT NULL COMMENT '食物营养成分',
   `weight` varchar(50) DEFAULT '0' COMMENT '重量',
   `photo` varchar(50) DEFAULT NULL,
   PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4;
CREATE TABLE `dm_medicines` (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
   `code` varchar(50) NOT NULL COMMENT '药品编码',
   `name` varchar(50) NOT NULL COMMENT '药品名称',
   `type` int(11) DEFAULT NULL COMMENT '药品类型:1健康记录',
   `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
   PRIMARY KEY (`id`) USING BTREE,
   KEY `idx_dm_medicines_1` (`code`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COMMENT='药品字典';
CREATE TABLE `wlyy_patient_health_record_diet` (
    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
    `code` varchar(50) NOT NULL COMMENT '记录标识',
    `patient` varchar(50) NOT NULL COMMENT '患者标识',
    `record_date` date DEFAULT NULL COMMENT '记录时间',
    `content` varchar(500) DEFAULT NULL COMMENT '饮食内容',
    `images` varchar(3000) DEFAULT NULL COMMENT '图片HTTP地址,多图以逗号分隔',
    `sort_date` datetime DEFAULT NULL COMMENT '用于查询排序的时间',
    `czrq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '添加时间',
    `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
    `source` varchar(50) DEFAULT NULL COMMENT '记录来源(0 手动 )',
    PRIMARY KEY (`id`),
    KEY `idx_wlyy_patient_health_record_diet_1` (`patient`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COMMENT='患者健康记录(饮食)表';
CREATE TABLE `wlyy_patient_health_record_medication` (
     `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
     `code` varchar(50) NOT NULL COMMENT '记录标识',
     `patient` varchar(50) NOT NULL COMMENT '患者标识',
     `record_date` date DEFAULT NULL COMMENT '记录时间',
     `medicines` varchar(50) DEFAULT NULL COMMENT '药品标识',
     `medicines_name` varchar(100) DEFAULT NULL COMMENT '药品名称',
     `sort_date` datetime DEFAULT NULL COMMENT '用于查询排序的时间',
     `czrq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '添加时间',
     `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
     `source` varchar(50) DEFAULT NULL COMMENT '记录来源(0 手动 )',
     PRIMARY KEY (`id`),
     KEY `idx_wlyy_patient_health_record_medication_1` (`patient`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='患者健康记录(用药)表';
CREATE TABLE `wlyy_patient_health_record_sports` (
     `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
     `code` varchar(50) NOT NULL COMMENT '记录标识',
     `patient` varchar(50) NOT NULL COMMENT '患者标识',
     `record_date` date DEFAULT NULL COMMENT '记录时间',
     `sports_time` decimal(11,2) DEFAULT NULL,
     `sports_type` varchar(50) DEFAULT NULL COMMENT '运动强度',
     `sports_type_name` varchar(100) DEFAULT NULL COMMENT '运动强度名称',
     `sports` varchar(50) DEFAULT NULL COMMENT '运动类型',
     `sports_name` varchar(100) DEFAULT NULL COMMENT '运动类型名称',
     `sort_date` datetime DEFAULT NULL COMMENT '用于查询排序的时间',
     `czrq` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '添加时间',
     `del` varchar(1) DEFAULT '1' COMMENT '作废标识,1正常,0作废',
     `source` varchar(50) DEFAULT NULL COMMENT '记录来源(0 手动 )',
     PRIMARY KEY (`id`),
     KEY `idx_wlyy_patient_health_record_sports_1` (`patient`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='患者健康(运动)记录表';

+ 83 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/FoodComp.java

@ -0,0 +1,83 @@
package com.yihu.jw.entity.base.health;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 健康教育
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_food_comp")
public class FoodComp extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 412341231112321L ;
	// 父id
	private Long pid;
	// 名称
	private String name;
	// 热量
	private Long hot;
	// 成分
	private String component;
	//重量
	private String weight;
	private String photo;
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	public Long getPid() {
		return pid;
	}
	public void setPid(Long pid) {
		this.pid = pid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getHot() {
		return hot;
	}
	public void setHot(Long hot) {
		this.hot = hot;
	}
	public String getComponent() {
		return component;
	}
	public void setComponent(String component) {
		this.component = component;
	}
	public String getWeight() {
		return weight;
	}
	public void setWeight(String weight) {
		this.weight = weight;
	}
}

+ 56 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/Medicines.java

@ -0,0 +1,56 @@
package com.yihu.jw.entity.base.health;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 药品字典项目
 * @author George
 */
@Entity
@Table(name = "dm_medicines")
public class Medicines extends IdEntity {
	private static final long serialVersionUID = -6408087441099619157L;
	private String code;// 药品标识
	private String name;// 药品名称
	private Integer type;// 药品类型:1健康记录
	private String del;// 作废标识,1正常,0作废
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 120 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordDiet.java

@ -0,0 +1,120 @@
package com.yihu.jw.entity.base.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康记录(饮食)
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient_health_record_diet")
public class PatientHealthRecordDiet extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3346068714600220602L;
	// 记录标识
	private String code;
	// 患者标志
	private String patient;
	// 记录时间
	private Date recordDate;
	// 饮食内容
	private String content;
	// 图片
	private String images;
	// 排序日期
	private Date sortDate;
	// 添加时间
	private Date czrq;
	// 是否作废,1正常,0作废
	private String del;
	//记录来源 0手动 1设备同步
	private String source;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	@Column(name = "record_date")
	public Date getRecordDate() {
		return recordDate;
	}
	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getImages() {
		return images;
	}
	public void setImages(String images) {
		this.images = images;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "sort_date")
	public Date getSortDate() {
		return sortDate;
	}
	public void setSortDate(Date sortDate) {
		this.sortDate = sortDate;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
}

+ 121 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordMedication.java

@ -0,0 +1,121 @@
package com.yihu.jw.entity.base.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康记录(用药)
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient_health_record_medication")
public class PatientHealthRecordMedication extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7560620704878032077L;
	// 记录标识
	private String code;
	// 患者标志
	private String patient;
	// 记录时间
	private Date recordDate;
	// 药品标识
	private String medicines;
	// 药品名称
	private String medicinesName;
	// 排序日期
	private Date sortDate;
	// 添加时间
	private Date czrq;
	// 是否作废,1正常,0作废
	private String del;
	//记录来源 0 手动 1记录同步
	private String source;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	@Column(name = "record_date")
	public Date getRecordDate() {
		return recordDate;
	}
	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}
	public String getMedicines() {
		return medicines;
	}
	public void setMedicines(String medicines) {
		this.medicines = medicines;
	}
	@Column(name = "medicines_name")
	public String getMedicinesName() {
		return medicinesName;
	}
	public void setMedicinesName(String medicinesName) {
		this.medicinesName = medicinesName;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "sort_date")
	public Date getSortDate() {
		return sortDate;
	}
	public void setSortDate(Date sortDate) {
		this.sortDate = sortDate;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
}

+ 154 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/PatientHealthRecordSports.java

@ -0,0 +1,154 @@
package com.yihu.jw.entity.base.health;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康记录(运动)
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient_health_record_sports")
public class PatientHealthRecordSports extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5446594341010696654L;
	// 记录标识
	private String code;
	// 患者标志
	private String patient;
	// 记录时间
	private Date recordDate;
	// 运动时长(分)
	private double sportsTime;
	// 运动强度
	private String sportsType;
	// 运动强度名称
	private String sportsTypeName;
	// 运动类型
	private String sports;
	// 运动类型名称
	private String sportsName;
	// 排序日期
	private Date sortDate;
	// 添加时间
	private Date czrq;
	// 是否作废,1正常,0作废
	private String del;
	//记录来源 0 手动  1 设备同步
	private String source;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	@Column(name = "record_date")
	public Date getRecordDate() {
		return recordDate;
	}
	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}
	@Column(name = "sports_time")
	public double getSportsTime() {
		return sportsTime;
	}
	public void setSportsTime(double sportsTime) {
		this.sportsTime = sportsTime;
	}
	@Column(name = "sports_type")
	public String getSportsType() {
		return sportsType;
	}
	public void setSportsType(String sportsType) {
		this.sportsType = sportsType;
	}
	@Column(name = "sports_type_name")
	public String getSportsTypeName() {
		return sportsTypeName;
	}
	public void setSportsTypeName(String sportsTypeName) {
		this.sportsTypeName = sportsTypeName;
	}
	public String getSports() {
		return sports;
	}
	public void setSports(String sports) {
		this.sports = sports;
	}
	@Column(name = "sports_name")
	public String getSportsName() {
		return sportsName;
	}
	public void setSportsName(String sportsName) {
		this.sportsName = sportsName;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "sort_date")
	public Date getSortDate() {
		return sortDate;
	}
	public void setSortDate(Date sortDate) {
		this.sortDate = sortDate;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
}

+ 55 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/Sports.java

@ -0,0 +1,55 @@
package com.yihu.jw.entity.base.health;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 运动类型
 * @author George
 *
 */
@Entity
@Table(name = "dm_sports")
public class Sports extends IdEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8431939466804151130L;
	
	// 运动标识
	private String code;
	// 运动名称
	private String name;
	// 作废标识,1正常,0作废
	private String del;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 54 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/health/SportsType.java

@ -0,0 +1,54 @@
package com.yihu.jw.entity.base.health;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 运动强度
 * @author George
 *
 */
@Entity
@Table(name = "dm_sports_type")
public class SportsType extends IdEntity {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5957179454535924290L;
	
	// 强度标识
	private String code;
	// 强度名称
	private String name;
	// 作废标识,1正常,0作废
	private String del;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
}

+ 367 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthRecordController.java

@ -0,0 +1,367 @@
package com.yihu.jw.hospital.module.health.controller;
import com.yihu.jw.entity.base.health.PatientHealthRecordDiet;
import com.yihu.jw.entity.base.health.PatientHealthRecordMedication;
import com.yihu.jw.entity.base.health.PatientHealthRecordSports;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.health.service.PatientHealthRecordService;
import com.yihu.jw.hospital.module.jw.service.JwArchivesService;
import com.yihu.jw.hospital.module.rehabilitation.service.PatientRecordService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
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;
/**
 * 医生端:健康记录控制类
 *
 * @author George
 */
@RestController
@RequestMapping(value = "/doctor/health_record")
@Api(description = "健康记录")
public class DoctorHealthRecordController extends BaseController {
    @Autowired
    private PatientHealthRecordService patientHealthRecordService;
    @Autowired
    private JwArchivesService jwArchivesService;
    @Value("${demo.flag}")
    private Boolean demoFlag;
    @Autowired
    private PatientRecordService patientRecordService;
    /**
     * 患者最近填写的运动、用药、饮食内容
     *
     * @param patient 患者标识
     * @return
     */
    @RequestMapping(value = "recent", method = RequestMethod.GET)
    @ApiOperation("根据患者标志获取最近的保健记录")
    public String recent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
                         @RequestParam(value = "patient", required = true) String patient) {
        try {
            JSONObject json = patientHealthRecordService.findRecentByPatient(patient);
            if (json != null) {
                return write(200, "查询成功", "data", json);
            } else {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 运动记录查询接口
     *
     * @param patient  患者标识
     * @param pagesize 分页大小
     * @return
     */
    @RequestMapping(value = "list_sports", method = RequestMethod.POST)
    @ApiOperation("获取患者运动记录")
    public String sports(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
                         @RequestParam(value = "patient", required = true) String patient,
                         @ApiParam(name = "start", value = "开始时间", defaultValue = "2017-05-15 00:00:00")
                         @RequestParam(value = "start", required = true) String start,
                         @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-05-15 12:00:00")
                         @RequestParam(value = "end", required = true) String end,
                         @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                         @RequestParam(value = "page", required = true) int page,
                         @ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "10")
                         @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(patient, start, end, page, pagesize);
            if (data != null) {
                JSONArray array = new JSONArray();
                for (PatientHealthRecordSports record : data) {
                    if (record == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", record.getId());
                    // 设置记录标识
                    json.put("code", record.getCode());
                    // 设置记录日期
                    json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
                    json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
                    // 设置运动时长(分钟)
                    json.put("sports_time", record.getSportsTime());
                    // 设置运动强度
                    json.put("sports_type", record.getSportsTypeName());
                    // 设置运动类型
                    json.put("sports", record.getSportsName());
                    array.put(json);
                }
                return write(200, "查询成功", "list", array);
            } else {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 用药记录查询接口
     *
     * @param patient  患者标识
     * @param pagesize 分页大小
     * @return
     */
    @RequestMapping(value = "list_medication", method = {RequestMethod.GET})
    @ApiOperation("获取患者用药记录")
    public String medication(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
                             @RequestParam(value = "patient", required = true) String patient,
                             @ApiParam(name = "start", value = "开始")
                             @RequestParam(required = false) String start,
                             @ApiParam(name = "end", value = "结束")
                             @RequestParam(required = false) String end,
                             @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                             @RequestParam(required = false) Integer page,
                             @ApiParam(name = "sortDate", value = "日期")
                             @RequestParam(required = false) String sortDate,
                             @ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "10")
                             @RequestParam(required = true) int pagesize) {
        try {
            Page<PatientHealthRecordMedication> data = null;
            if (!StringUtils.isEmpty(sortDate)) {
                data = patientHealthRecordService.findMedicationByPatient(patient, DateUtil.strToDateLong(sortDate), page, pagesize);
            } else {
                data = patientHealthRecordService.findMedicalByPatientPage(patient, start, end, page, pagesize);
            }
            if (data != null) {
                JSONArray array = new JSONArray();
                for (PatientHealthRecordMedication record : data) {
                    if (record == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", record.getId());
                    // 设置记录标识
                    json.put("code", record.getCode());
                    // 设置记录日期
                    json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
                    json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
                    // 药品名称
                    json.put("medicines", record.getMedicinesName());
                    array.put(json);
                }
                return write(200, "查询成功", "list", array);
            } else {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 饮食记录查询接口
     *
     * @param patient  患者标识
     * @param page     页码
     * @param pagesize 分页大小
     * @return
     */
    @RequestMapping(value = "list_diet", method = RequestMethod.POST)
    @ApiOperation("饮食记录查询接口")
    public String diet(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
                       @RequestParam(value = "patient", required = true) String patient,
                       @ApiParam(name = "start", value = "开始")
                       @RequestParam(required = true) String start,
                       @ApiParam(name = "end", value = "结束")
                       @RequestParam(required = false) String end,
                       @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                       @RequestParam(required = true) int page,
                       @ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "10")
                       @RequestParam(required = true) int pagesize) {
        try {
            Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(patient, start, end, page, pagesize);
            if (data != null) {
                JSONArray array = new JSONArray();
                for (PatientHealthRecordDiet record : data) {
                    if (record == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", record.getId());
                    // 设置记录标识
                    json.put("code", record.getCode());
                    // 设置记录日期
                    json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
                    json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
                    // 设置饮食内容
                    json.put("content", record.getContent());
                    // 设置图片URL,多图以逗号分隔
                    json.put("images", record.getImages());
                    array.put(json);
                }
                return write(200, "查询成功", "list", array);
            } else {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            return errorResult(e);
        }
    }
//    @RequestMapping(value = "list_medical", method = RequestMethod.POST)
//    @ApiOperation("查询居民健康体检列表")
//    public String medical(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
//                          @RequestParam(value = "patient", required = true) String patient,
//                          @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
//                          @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
//                          @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
//                          @RequestParam(value = "pageSize", required = false) Integer pageSize) {
//        try {
//
//            if (demoFlag) {
//                String res = patientRecordService.getJosnFileResullt("list_medical");
//                return res;
//            } else {
//                Patient p = patientService.findByCode(patient);
//                if (p != null) {
//                    JSONArray re = jwArchivesService.getEhrSickMedicalList(p.getIdcard(), pageIndex, pageSize);
//                    return write(200, "查询成功", "list", re);
//                } else {
//                    return error(-1, "患者不存在");
//                }
//            }
//        } catch (ServiceException se) {
//            return write(-1, se.getMessage());
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
    @RequestMapping(value = "medical_detail", method = RequestMethod.POST)
    @ApiOperation("查询居民健康体检详情信息")
    public String medical_detail(@ApiParam(name = "medicalNo", value = "体检ID", defaultValue = "1249652")
                                 @RequestParam(value = "medicalNo", required = true) String medicalNo) {
        try {
            if (demoFlag) {
                String res = patientRecordService.getJosnFileResullt("medical_detail");
                return res;
            } else {
                JSONObject json = jwArchivesService.getEhrSickMedicalRecord(medicalNo);
                return write(200, "查询成功", "medical_detail", json);
            }
        } catch (ServiceException se) {
            return write(-1, se.getMessage());
        } catch (Exception e) {
            return errorResult(e);
        }
    }
    /**
     * 根据区域查询体检详情信息
     */
//    @ApiOperation("根据区域查询体检详情信息")
//    @PostMapping(value = "areaMedicalDetail")
//    public String areaMedicalDetail(@ApiParam(name = "areaCode", value = "区域code", defaultValue = "350205")
//                                    @RequestParam(value = "areaCode", required = false) String areaCode,
//                                    @ApiParam(name = "patientId", value = "用户id", defaultValue = "")
//                                    @RequestParam(value = "patientId", required = false) String patientId) {
//        try {
//            //查询出区域的签约人
//            if (StringUtils.isBlank(areaCode) && StringUtils.isBlank(patientId)) {
//                return write(-1, "参数为空");
//            }
//            String result = patientRecordService.areaMedicalDetail(areaCode, patientId, demoFlag);
//            return result;
//        } catch (ServiceException se) {
//            System.out.println(se);
//            return write(-1, se.getMessage());
//        } catch (Exception e) {
//            System.out.println(e);
//            return errorResult(e);
//        }
//    }
    /**
     * 保存体检详情信息
     */
//    @ApiOperation("保存体检详情信息")
//    @PostMapping(value = "saveMedicalDetail")
//    public String saveMedicalDetail(@ApiParam(name = "medicalNo", value = "体检号", defaultValue = "10891028")
//                                    @RequestParam(value = "medicalNo", required = false) String medicalNo,
//                                    @ApiParam(name = "findType", value = "查询类型 1查本地2查远程", defaultValue = "1")
//                                    @RequestParam(value = "findType", required = false) String findType,
//                                    @ApiParam(name = "findAll", value = "是否查全部,yes是 temp走补录", defaultValue = "yes")
//                                    @RequestParam(value = "findAll", required = false) String findAll) {
//        try {
//            //查询出区域的签约人
//            if (StringUtils.isBlank(medicalNo) && StringUtils.isBlank(findAll)) {
//                return write(-1, "参数为空");
//            }
//            String result = patientRecordService.saveMedicalDetailMethod(findType, findAll);
//            return result;
//
//        } catch (ServiceException se) {
//            System.out.println(se);
//            return write(-1, se.getMessage());
//        } catch (Exception e) {
//            System.out.println(e);
//            return errorResult(e);
//        }
//    }
    /**
     * patient/archives/event
     * /smjk/GetResidentEventListJson
     * 接口地址 /base/CallEhrInterface
     */
//    @ApiOperation("保存健康档案信息")
//    @PostMapping(value = "saveHealthRecord")
//    public String saveHealthRecord(
//            @ApiParam(name = "idcard", value = "身份证号", defaultValue = "") @RequestParam(value = "idcard", required = false) String idcard) {
//        try {
//            String result = patientRecordService.saveHealthRecord(idcard);
//            return result;
//        } catch (ServiceException se) {
//            System.out.println(se);
//            return write(-1, se.getMessage());
//        } catch (Exception e) {
//            System.out.println(e);
//            return errorResult(e);
//        }
//    }
    @RequestMapping(value = "dietDetail", method = RequestMethod.GET)
    @ApiOperation("饮食记录详情接口")
    public String dietDetail(@ApiParam(name = "id", value = "饮食记录ID")
                             @RequestParam(value = "id") Long dietId) {
        try {
            JSONObject json = patientHealthRecordService.findById(dietId);
            if (json.getInt("status") == 200) {
                return write(200, "查询成功!", "data", json.getJSONObject("data"));
            } else {
                return error(-1, json.getString("msg"));
            }
        } catch (Exception e) {
            return errorResult(e);
        }
    }
}

+ 441 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthRecordController.java

@ -0,0 +1,441 @@
package com.yihu.jw.hospital.module.health.controller;
import com.yihu.jw.entity.base.health.*;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.health.service.MedicinesService;
import com.yihu.jw.hospital.module.health.service.PatientHealthRecordService;
import com.yihu.jw.hospital.module.health.service.SportsService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
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.Date;
import java.util.List;
/**
 * 健康记录控制类
 * @author George
 *
 */
@RestController
@RequestMapping(value = "/patient/health_record")
@Api(description = "患者端-健康记录")
public class PatientHealthRecordController extends BaseController {
	@Autowired
	private SportsService sportsService;
	@Autowired
	private MedicinesService medicinesService;
	@Autowired
	private PatientHealthRecordService patientHealthRecordService;
	@Autowired
	private com.yihu.jw.util.common.CommonUtil CommonUtil;
	@Autowired
	private ImService imService;
	@Value("$wechat.id")
	private String wechatId;
	/**
	 * 保健记录更改接口(包括手动记录的修改和所有的删除)
	 *
	 * @param id
	 * @param type   饮食1,运动2,用药3
	 * @param value1 记录时间
	 * @param value2 饮食内容CONTETN  时长 用药
	 * @param value3 上传图片 强度
	 * @param value4 运动项目
	 * @return
	 */
	@ApiOperation("保健记录更改接口(包括手动记录的修改和所有的删除)")
	@RequestMapping(value = "/modifyHealthCare", method = RequestMethod.POST)
	public String modifyHealthCare(@RequestParam long id,
								   @RequestParam int type,
								   @RequestParam(required = false) String value1,
								   @RequestParam(required = false) String value2,
								   @RequestParam(required = false) String value3,
								   @RequestParam(required = false) String value4) {
		try {
			if(type==1&&StringUtils.isNotBlank(value3)){
			    String images = "";
                String[] imgs = value3.split(",");
                for (String img:imgs){
                    if(img.contains("group1/")){
                        images+=img+",";
                    }
                }
                if(StringUtils.isNotEmpty(images)&&images.lastIndexOf(",")==images.length()-1){
                    images = images.substring(0,images.length()-1);
                }
				// 从微信服务器获取图片
                value3 = imService.fetchWxImages(wechatId);
				if(StringUtils.isNotEmpty(value3)){
					value3 = CommonUtil.copyTempImage(value3);
				}
				if(StringUtils.isNotEmpty(value3)){
                    value3=value3+","+images.trim();
                }else {
                    value3=images;
                }
			}
			patientHealthRecordService.modifyHealthCare(id, type, value1, value2, value3, value4);
			return write(200, "更改成功!");
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "更改失败!");
		}
	}
	/**
	 * 运动强度查询接口
	 * @return
	 */
	@ApiOperation("运动强度查询接口")
	@RequestMapping(value = "sports_type", method ={RequestMethod.GET})
	public String sportsType() {
		try {
			JSONArray array = new JSONArray();
			List<SportsType> list = sportsService.finsAllSportsType();
			if (list != null) {
				for (SportsType temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 运动类型查询接口
	 * @return
	 */
	@ApiOperation("运动类型查询接口")
	@RequestMapping(value = "sports", method ={ RequestMethod.GET})
	public String sports() {
		try {
			JSONArray array = new JSONArray();
			List<Sports> list = sportsService.finsAllSports();
			if (list != null) {
				for (Sports temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 查询药品列表
	 * @return
	 */
	@RequestMapping(value = "medicines", method ={RequestMethod.GET})
	@ApiOperation("查询药品列表")
	public String medicines() {
		try {
			JSONArray array = new JSONArray();
			List<Medicines> list = medicinesService.findAllMedicines(1);
			if (list != null) {
				for (Medicines temp : list) {
					if (temp == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("code", temp.getCode());
					json.put("name", temp.getName());
					array.put(json);
				}
			}
			return write(200, "查询成功", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 添加运动记录
	 * @param record_date 记录时间
	 * @param sportsTime 运动时长(分)
	 * @param sportsType 运动强度标识
	 * @param sports 运动类型标识
	 * @return
	 */
	@RequestMapping(value = "add_sports", method ={ RequestMethod.POST})
	@ApiOperation("添加运动记录")
	public String addSports(String record_date, double sportsTime, String sportsType, String sports) {
		try {
			PatientHealthRecordSports record = new PatientHealthRecordSports();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setSportsTime(sportsTime);
			if (patientHealthRecordService.addSports(record, sportsType, sports) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 添加用药记录
	 * @param record_date 记录时间
	 * @param medicines 药品标识
	 * @param medicines_name 药品名称
	 * @return
	 */
	@RequestMapping(value = "add_medication", method ={ RequestMethod.POST})
	@ApiOperation("添加用药记录")
	public String addMedication(String record_date, String medicines, String medicines_name) {
		try {
			PatientHealthRecordMedication record = new PatientHealthRecordMedication();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setMedicines(medicines);
			record.setMedicinesName(medicines_name);
			if (patientHealthRecordService.addMedication(record) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 添加饮食记录接口
	 * @param record_date 记录时间
	 * @param content 饮食内容
	 * @param images 图片HTTP地址,多图以逗号分隔
	 * @return
	 */
	@RequestMapping(value = "add_diet", method ={ RequestMethod.POST})
	@ApiOperation("添加饮食记录接口")
	public String add(String record_date, String content, @RequestParam(required = false) String images) {
		try {
			PatientHealthRecordDiet record = new PatientHealthRecordDiet();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setContent(content);
			// 从微信服务器获取图片
			if (StringUtils.isEmpty(images)) {
				images = imService.fetchWxImages(wechatId);
			}
			if (StringUtils.isNotEmpty(images)) {
				images = CommonUtil.copyTempImage(images);
			}
			record.setImages(images);
			if (patientHealthRecordService.addDiet(record) != null) {
				return success("保存成功");
			} else {
				return error(-1, "保存失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "保存失败");
		}
	}
	/**
	 * 最近填写的运动、用药、饮食内容
	 * @return
	 */
	@RequestMapping(value = "recent", method ={ RequestMethod.GET})
	@ApiOperation("最近填写的运动、用药、饮食内容")
	public String recent() {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(getRepUID());
			if (json != null) {
				return write(200, "查询成功", "data", json);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 运动记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_sports", method ={RequestMethod.GET})
	@ApiOperation("运动记录查询接口")
	public String sports(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getRepUID(), start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordSports record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 设置运动时长(分钟)
					json.put("sports_time", record.getSportsTime());
					// 设置运动强度
					json.put("sports_type", record.getSportsTypeName());
					// 设置运动类型
					json.put("sports", record.getSportsName());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 用药记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_medication", method ={RequestMethod.GET})
	@ApiOperation("用药记录查询接口")
	public String medication(String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getRepUID(), start, end, page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordMedication record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 药品名称
					json.put("medicines", record.getMedicinesName());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	/**
	 * 饮食记录查询接口
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "list_diet", method ={ RequestMethod.GET})
	@ApiOperation("饮食记录查询接口")
	public String diet(String start,String end,int page,int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getRepUID(),start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordDiet record : data) {
					if (record == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", record.getId());
					// 设置记录标识
					json.put("code", record.getCode());
					// 设置记录日期
					json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
					json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
					// 设置饮食内容
					json.put("content", record.getContent());
					// 设置图片URL,多图以逗号分隔
					json.put("images", record.getImages());
					array.put(json);
				}
				return write(200, "查询成功", "list", array);
			} else {
				return error(-1, "查询失败");
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "dietDetail", method =RequestMethod.GET)
	@ApiOperation("饮食记录详情接口")
	public String dietDetail(@ApiParam(name = "id", value = "饮食记录ID")
								 @RequestParam(value = "id") Long dietId) {
		try {
			JSONObject json = patientHealthRecordService.findById(dietId);
			if(json.getInt("status") == 200) {
				return write(200, "查询成功!", "data", json.getJSONObject("data"));
			}else {
				return error(-1, json.getString("msg"));
			}
		} catch (Exception e) {
			return error(-1, "查询失败!");
		}
	}
}

+ 28 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/MedicinesService.java

@ -0,0 +1,28 @@
package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.Medicines;
import com.yihu.jw.health.MedicinesDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Component
@Transactional(rollbackFor = Exception.class)
public class MedicinesService extends BaseJpaService {
	@Autowired
	private MedicinesDao medicinesDao;
	/**
	 * 查询所有的药品信息
	 * @param type 药品类型:1健康记录
	 * @return	 */
	public List<Medicines> findAllMedicines(int type) {
		return medicinesDao.findAll(type);
	}
}

+ 383 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthRecordService.java

@ -0,0 +1,383 @@
package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.*;
import com.yihu.jw.health.*;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import java.text.SimpleDateFormat;
import java.util.*;
@Component
@Transactional(rollbackFor = Exception.class)
public class PatientHealthRecordService extends BaseJpaService {
	@Autowired
	private SportsTypeDao sportsTypeDao;
	@Autowired
	private SportsDao sportsDao;
	@Autowired
	private MedicinesDao medicinesDao;
	@Autowired
	private PatientHealthRecordMedicationDao patientHealthRecordMedicationDao;
	@Autowired
	private PatientHealthRecordDietDao patientHealthRecordDietDao;
	@Autowired
	private PatientHealthRecordSportsDao patientHealthRecordSportsDao;
	@Autowired
	private FoodCompDao foodCompDao;
	/**
	 * 更改保健记录(包括手动记录的修改和所有的删除)
	 *
	 * @param id
	 * @param type   饮食1,运动2,用药3
	 * @param value1 记录时间
	 * @param value2 饮食内容CONTETN  时长 用药
	 * @param value3 上传图片 强度
	 * @param value4 运动项目
	 */
	public void modifyHealthCare(long id, int type, String value1, String value2, String value3, String value4) throws Exception {
		//value类字段值均为空为删除
		if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) {
			switch (type) {
				case 1:
					patientHealthRecordDietDao.deleteDiet(id);
					break;
				case 2:
					patientHealthRecordSportsDao.deleteSports(id);
					break;
				case 3:
					patientHealthRecordMedicationDao.deleteMedication(id);
					break;
			}
		} else {
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Date recordDate = sdf.parse(value1);
			switch (type) {
				case 1:
					patientHealthRecordDietDao.modifyDiet(id, recordDate, value2, value3);
					break;
				case 2:
					SportsType sportsType = sportsTypeDao.findByCode(value3);
					String typeName = sportsType.getName();
					Sports sport = sportsDao.findByCode(value4);
					String sportName = sport.getName();
					Double sportsTime = Double.parseDouble(value2);
					patientHealthRecordSportsDao.modifySports(id, recordDate, sportsTime, value3, typeName, value4, sportName);
					break;
				case 3:
					Medicines medicines = medicinesDao.findByCode(value2);
					String medicinesName = medicines.getName();
					patientHealthRecordMedicationDao.modifyMedication(id, recordDate, value2, medicinesName);
					break;
			}
		}
	}
	/**
	 * 添加运动记录
	 * @param record 运动记录对象
	 * @return
	 */
	public PatientHealthRecordSports addSports(PatientHealthRecordSports record, String sportsType, String sports) {
		record.setCode(getCode());
		record.setSportsType(sportsType);
		record.setSportsTypeName(sportsTypeDao.findByCode(sportsType).getName());
		record.setSports(sports);
		record.setSportsName(sportsDao.findByCode(sports).getName());
		return patientHealthRecordSportsDao.save(record);
	}
	/**
	 * 添加用药记录
	 * @param record 用药记录对象
	 * @return
	 */
	public PatientHealthRecordMedication addMedication(PatientHealthRecordMedication record) {
		record.setCode(getCode());
		return patientHealthRecordMedicationDao.save(record);
	}
	/**
	 * 添加饮食记录
	 * @param record 饮食记录对象
	 * @return
	 */
	public PatientHealthRecordDiet addDiet(PatientHealthRecordDiet record) {
		record.setCode(getCode());
		return	 patientHealthRecordDietDao.save(record);
	}
	/**
	 * 按分类查询患者运动记录
	 * @param patient 患者标识
	 * @param
	 * @param pageSize 分页大小
	 * @return
	 */
	public Page<PatientHealthRecordSports> findSportsByPatient(String patient, Date sortDate, int pageSize) {
		if (pageSize <= 0) {
			pageSize = 10;
		}
		// 排序
		Sort sort = Sort.by(Direction.DESC, "sortDate");
		// 分页信息
		PageRequest pageRequest = PageRequest.of(0, pageSize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 患者标志
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if(sortDate != null){
			filters.put("sortDate", new SearchFilter("sortDate", Operator.LT, sortDate));
		}
		// 未作废
		filters.put("del", new SearchFilter("del", Operator.EQ, "1"));
		Specification<PatientHealthRecordSports> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientHealthRecordSports.class);
		return patientHealthRecordSportsDao.findAll(spec, pageRequest);
	}
	/**
	 * 查询运动记录
	 *
	 * @param patient
	 * @param start
	 * @param end
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public Page<PatientHealthRecordSports> findSportsByPatientPage(String patient,String start,String end,int page,int pagesize){
		if(page > 0) {
			page = page -1;
		}
		PageRequest pageRequest = PageRequest.of(page,pagesize);
		return patientHealthRecordSportsDao.findSportsByPatient(patient, DateUtil.strToDate(start, DateUtil.YYYY_MM_DD_HH_MM_SS)
				,DateUtil.strToDate(end,DateUtil.YYYY_MM_DD_HH_MM_SS),pageRequest);
	}
	/**
	 * 查询用药记录
	 *
	 * @param patient
	 * @param start
	 * @param end
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public Page<PatientHealthRecordMedication> findMedicalByPatientPage(String patient,String start,String end,int page,int pagesize){
		if(page > 0)
		{
			page = page -1;
		}
		PageRequest pageRequest = PageRequest.of(page,pagesize);
		return patientHealthRecordMedicationDao.findMedicalByPatient(patient, DateUtil.strToDate(start,DateUtil.YYYY_MM_DD_HH_MM_SS)
				,DateUtil.strToDate(end,DateUtil.YYYY_MM_DD_HH_MM_SS),pageRequest);
	}
	/**
	 * 查询饮食记录
	 *
	 * @param patient
	 * @param start
	 * @param end
	 * @param page
	 * @param pagesize
	 * @return
	 */
	public Page<PatientHealthRecordDiet> findDietByPatientPage(String patient,String start,String end,int page,int pagesize){
		if(page > 0) {
			page = page -1;
		}
		PageRequest pageRequest = PageRequest.of(page,pagesize);
		return patientHealthRecordDietDao.findDietByPatient(patient, DateUtil.strToDate(start,DateUtil.YYYY_MM_DD_HH_MM_SS)
				,DateUtil.strToDate(end,DateUtil.YYYY_MM_DD_HH_MM_SS),pageRequest);
	}
	/**
	 * 按分类查询患者用药记录
	 * @param patient 患者标识
	 * @param pageSize 分页大小
	 * @return
	 */
	public Page<PatientHealthRecordMedication> findMedicationByPatient(String patient, Date sortDate,Integer page, int pageSize) {
		if(page==null){
			page = 0;
		}else if(page > 0)
		{
			page = page -1;
		}
		if (pageSize <= 0) {
			pageSize = 10;
		}
		// 排序
		Sort sort = Sort.by(Direction.DESC, "sortDate");
		// 分页信息
		PageRequest pageRequest = PageRequest.of(page, pageSize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 患者标志
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if(sortDate != null){
			filters.put("sortDate", new SearchFilter("sortDate", Operator.LT, sortDate));
		}
		// 未作废
		filters.put("del", new SearchFilter("del", Operator.EQ, "1"));
		Specification<PatientHealthRecordMedication> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientHealthRecordMedication.class);
		return patientHealthRecordMedicationDao.findAll(spec, pageRequest);
	}
	/**
	 * 按分类查询患者饮食记录
	 * @param patient 患者标识
	 * @param
	 * @param pageSize 分页大小
	 * @return
	 */
	public Page<PatientHealthRecordDiet> findDietByPatient(String patient, Date sortDate, int pageSize) {
		if (pageSize <= 0) {
			pageSize = 10;
		}
		// 排序
		Sort sort = Sort.by(Direction.DESC, "sortDate");
		// 分页信息
		PageRequest pageRequest = PageRequest.of(0, pageSize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		// 患者标志
		filters.put("patient", new SearchFilter("patient", Operator.EQ, patient));
		if(sortDate != null){
			filters.put("sortDate", new SearchFilter("sortDate", Operator.LT, sortDate));
		}
		// 未作废
		filters.put("del", new SearchFilter("del", Operator.EQ, "1"));
		Specification<PatientHealthRecordDiet> spec = DynamicSpecifications.bySearchFilter(filters.values(), PatientHealthRecordDiet.class);
		return patientHealthRecordDietDao.findAll(spec, pageRequest);
	}
	/**
	 * 查询患者最近填写的运动、用药、饮食内容
	 * @param patient
	 * @return
	 */
	public JSONObject findRecentByPatient(String patient) {
		JSONObject jsonObject = new JSONObject();
		// 查询最近的运动
		Page<PatientHealthRecordSports> sports = patientHealthRecordSportsDao.findRecentByPatient(patient, PageRequest.of(0, 1));
		// 查询最近的用药
		Page<PatientHealthRecordMedication> medication = patientHealthRecordMedicationDao.findRecentByPatient(patient, PageRequest.of(0, 1));
		// 查询最近的饮食
		Page<PatientHealthRecordDiet> diet = patientHealthRecordDietDao.findRecentByPatient(patient, PageRequest.of(0, 1));
		// 查询最近的药盒使用记录
//		Page<KitDrugUseRecord> kitDrugUseRecords = kitDrugUseRecordDao.findRecentByPatient(patient, PageRequest.of(0, 1));
		if (sports != null && sports.getSize() > 0) {
			JSONObject sportObject = new JSONObject();
			for (PatientHealthRecordSports temp : sports) {
				sportObject.put("sports", temp.getSportsName());
				sportObject.put("sports_time", temp.getSportsTime());
				sportObject.put("sports_type", temp.getSportsType());
				sportObject.put("sports_typeName", temp.getSportsTypeName());
				sportObject.put("czrq", DateUtil.dateToStr(temp.getCzrq(), DateUtil.YYYY_MM_DD));
				sportObject.put("recordDate", DateUtil.dateToStr(temp.getRecordDate(), DateUtil.YYYY_MM_DD));
				sportObject.put("source","1".equals(temp.getSource())?1:0);
			}
			jsonObject.put("sprot",sportObject);
		}
		if (medication != null) {
			JSONObject medicationObject = new JSONObject();
			for (PatientHealthRecordMedication temp : medication) {
				medicationObject.put("medication", temp.getMedicinesName());
				medicationObject.put("recordDate",DateUtil.dateToStr(temp.getRecordDate(), DateUtil.YYYY_MM_DD));
				medicationObject.put("source","1".equals(temp.getSource())?1:0);
			}
			jsonObject.put("medication",medicationObject);
		}
		if (diet != null) {
			JSONObject dietObject = new JSONObject();
			for (PatientHealthRecordDiet temp : diet) {
				dietObject.put("diet", temp.getContent());
				dietObject.put("recordDate",DateUtil.dateToStr(temp.getRecordDate(), DateUtil.YYYY_MM_DD));
				dietObject.put("images",temp.getImages());
				dietObject.put("source","1".equals(temp.getSource())?1:0);
			}
			jsonObject.put("diet",dietObject);
		}
//		if(kitDrugUseRecords!=null){
//			JSONObject dietObject = new JSONObject();
//			for (KitDrugUseRecord temp : kitDrugUseRecords) {
//				dietObject.put("recordDate",DateUtil.dateToStr(temp.getUseTime(), DateUtil.YYYY_MM_DD));
//				dietObject.put("deviceSn",temp.getDeviceSn());
//				List<KitDrugDetail> kitDrugDetailList = kitDrugDetailDao.findByRelationCodeAndType(temp.getCode(),1);
//				if(kitDrugDetailList.size()>0){
//					dietObject.put("drugDetail",kitDrugDetailList.get(0).getDrugName());
//				}else{
//					dietObject.put("drugDetail","");
//				}
//			}
//			jsonObject.put("kitDrugUseRecords",dietObject);
//		}
		return jsonObject;
	}
	//根据居民饮食记录ID查看详情
    public JSONObject findById(Long id) {
		JSONObject res = new JSONObject();
		List<FoodComp> patientFoodCompList = new ArrayList<>();
		//居民记录详情
		PatientHealthRecordDiet patientHealthRecordDiet = patientHealthRecordDietDao.findById(id).orElse(null);
		if(patientHealthRecordDiet != null){
			com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
			json.put("dietDetail", patientHealthRecordDiet);
			//查看居民吃的相关食物热量
			List<FoodComp> foodCompList = foodCompDao.findAllFoodByPidNot(0L);
			String content = patientHealthRecordDiet.getContent();
			for(FoodComp foodComp : foodCompList){
				//判断居民所吃的食物是否在热量字典表
				if(content.contains(foodComp.getName())){
					patientFoodCompList.add(foodComp);
				}
			}
			if(patientFoodCompList.size() > 0){
				json.put("foodCompList", patientFoodCompList);
			}
			res.put("status", 200);
			res.put("data", json);
		}else {
			res.put("status", -1);
			res.put("msg", "居民饮食记录详情不存在");
		}
		return res;
    }
}

+ 41 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/SportsService.java

@ -0,0 +1,41 @@
package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.Sports;
import com.yihu.jw.entity.base.health.SportsType;
import com.yihu.jw.health.SportsDao;
import com.yihu.jw.health.SportsTypeDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Component
@Transactional(rollbackFor = Exception.class)
public class SportsService extends BaseJpaService {
	@Autowired
	private SportsTypeDao sportsTypeDao;
	@Autowired
	private SportsDao sportsDao;
	/**
	 * 查询所有的运动强度
	 * @return
	 */
	public List<SportsType> finsAllSportsType() {
		return sportsTypeDao.findAll();
	}
	
	/**
	 * 查询所有的运动类型
	 * @return
	 */
	public List<Sports> finsAllSports() {
		return sportsDao.findAll();
	}
}