Browse Source

客服与中医药开发

chenyongxing 7 years ago
parent
commit
a78dc78278

+ 69 - 2
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -1,7 +1,13 @@
package com.yihu.mm.controller.medicine;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.entity.Patient;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PhysicalExaminationService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@ -11,9 +17,70 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(value = "/medicine/physicalExamination")
public class PhysicalExaminationController extends BaseController {
    @RequestMapping(value = "/findTest",produces="application/json;charset=UTF-8")
    @Value("${examCode}")
    private String examCode;
    @Autowired
    private PatientService patientService;
    @Autowired
    private PhysicalExaminationService physicalExaminationService;
    @ApiOperation(value = "获取试卷列表")
    @RequestMapping(value = "/findExames",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findExames(@ApiParam(name = "tp_type", value = "'问卷类型',(备选值:1,2,4)1:初筛问卷,2:助理问卷,4:现场问卷", required = true)@RequestParam(required = false, name = "tp_type") String tp_type) {
        physicalExaminationService.findExames(tp_type,examCode);
        return null;
    }
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
    @RequestMapping(value = "/insertslip",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode){
        Patient patient = patientService.findByCode(patientCode);
        return physicalExaminationService.insertslip(patient);
    }
    @ApiOperation(value = "获取试题")
    @RequestMapping(value = "/findExames",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = false, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = false, name = "pb_id") String pb_id,
                               @ApiParam(name = "pb_id", value = "咨询编号", required = true)@RequestParam(required = false, name = "pb_id") String ct_id){
        return null;
    }
    @ApiOperation(value = "提交试卷答案")
    @RequestMapping(value = "/handleExam",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
    }
    @ApiOperation(value = "四诊资料采集")
    @RequestMapping(value = "/dillphoneimgdata",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String login(@ApiParam(name = "type", value = "账号", required = true)@RequestParam(required = false, name = "type") String type) throws Exception {
    public String dillphoneimgdata(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                             @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                             @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
    }
    @ApiOperation(value = "查找报告单")
    @RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        return null;
    }
}

+ 88 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/dao/PatientDao.java

@ -0,0 +1,88 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.dao;
import com.yihu.mm.entity.Patient;
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 PatientDao extends PagingAndSortingRepository<Patient, Long>,JpaSpecificationExecutor<Patient> {
	// 查询患者姓名
	@Query("select p.name from Patient p where p.code=?1")
	String findNameByCode(String code);
    // 根据姓名查询
    @Query("select p.code from Patient p where p.name=?1")
    String[] findByName(String name);
	// 根據患者標識查詢患者信息
	@Query("select p from Patient p where p.code=?1")
	Patient findByCode(String code);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1 and p.idcard =?2")
    Patient findByCodeAndIdcard(String code, String idcard);
	// 根據身份證號查詢患者信息
	@Query("select p from Patient p where p.idcard=?1")
	Patient findByIdcard(String idcard);
	@Query("select p from Patient p where p.ssc=?1")
	Patient findBySsc(String ssc);
	// 根據手机号查詢患者信息
	@Query("select p from Patient p where p.mobile=?1")
	Patient findByMobile(String mobile);
	// 根據病情等级获取患者信息
	@Query("select p from Patient p where p.diseaseCondition=?1")
	Iterable<Patient> findInfoByLevel(int level);
	@Query("select p from Patient p where p.openid=?1")
	Patient findByOpenid(String openid);
	@Query("select count(1) from Patient p where p.openid=?1")
	int countByOpenid(String openid);
	//清空openid
	@Modifying
	@Query("update Patient p set p.openid = null where p.code <> ?1 and p.openid = ?2")
	int clearOpenid(String patient, String openid);
    @Modifying
    @Query(value = "update Patient p set p.status=?1 where p.id=?2 ")
    int updateStatus(Integer status, Long id);
    @Modifying
    @Query(value = "update Patient p set p.password=?1,p.salt=?2 where p.id=?3 ")
    int initPassword(String password, String salt, Long id);
    @Query(value = "select count(1) from Patient p where p.mobile = ?1")
    int isMobileExist(String mobile);
    @Query(value = "select count(1) from Patient p where p.idcard = ?1")
    int isIdCardExist(String idcard);
    @Query(value = "select count(1) from Patient p where p.ssc = ?1")
    int isSscExist(String ssc);
	@Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!='' ")
	List<Patient> findByCity(String city);
	@Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!=''  and p.town in ?2 ")
	List<Patient> findByCityAndTowns(String city, String towns[]);
	@Query(value = "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient WHERE p.city = ?1 and p.mobile is not null and p.mobile!=''  and f.hospital in ?2 ",nativeQuery = true)
	List<Patient> findByCityAndHospital(String city, String hospital[]);
	@Query("select p from Patient p where p.idcard=?1 and p.ssc=?2")
	Patient findByIdcardAndSsc(String idcard, String ssc);
}

+ 425 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/entity/Patient.java

@ -0,0 +1,425 @@
package com.yihu.mm.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * 患者信息
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient")
public class Patient extends IdEntity implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8358924836164389434L;
	// 业务主键
	private String code;
	// 身份证号
	private String idcard;
	// 登录密码
	private String password;
	private String salt;
	// 姓名
	private String name;
	// 生日
	private Date birthday;
	// 性別,1男,2女
	private Integer sex;
	// 手機號
	private String mobile;
	// (基卫)手機號
	private String mobileRemarks;
	// 聯繫電話
	private String phone;
	// 社保卡號
	private String ssc;
	// 頭像HTTP地址
	private String photo;
	// 省代碼
	private String province;
	// 城市代碼
	private String city;
	// 區縣代碼
	private String town;
	// 街道代码
	private String street;
	// 省名
	private String provinceName;
	// 市名
	private String cityName;
	// 區縣名
	private String townName;
	// 街道名称
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
	private Integer points;
	// 更新時間
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
	// 居委会字段id
	private String sickVillage;
	// 居委会字段名称
	private String sickVillageName;
//	是否绑定电子社保卡
	private Integer sicardStatus;
//	绑定电子社保卡时间
	private Date sicardTime;
	//是否分配过微信标签  1分配过 0或者空没有
	private Integer isWxtag;
	public Integer getSicardStatus() {
		return sicardStatus;
	}
	public void setSicardStatus(Integer sicardStatus) {
		this.sicardStatus = sicardStatus;
	}
	public Date getSicardTime() {
		return sicardTime;
	}
	public void setSicardTime(Date sicardTime) {
		this.sicardTime = sicardTime;
	}
	private List<SignPatientLabelInfo> labelInfos=new ArrayList<>();//患者的疾病标签list
	public Patient() {
	}
	public Patient(Long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getSalt() {
		return salt;
	}
	public void setSalt(String salt) {
		this.salt = salt;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	public Integer getSex() {
		return sex;
	}
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getSsc() {
		return ssc;
	}
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	@Column(name = "photo", insertable = false)
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	public String getProvince() {
		return province;
	}
	public void setProvince(String province) {
		this.province = province;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getTown() {
		return town;
	}
	public void setTown(String town) {
		this.town = town;
	}
	public String getStreet() {
		return street;
	}
	public void setStreet(String street) {
		this.street = street;
	}
	@Column(name = "province_name")
	public String getProvinceName() {
		return provinceName;
	}
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	@Column(name = "city_name")
	public String getCityName() {
		return cityName;
	}
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	@Column(name = "town_name")
	public String getTownName() {
		return townName;
	}
	public void setTownName(String townName) {
		this.townName = townName;
	}
	@Column(name = "street_name")
	public String getStreetName() {
		return streetName;
	}
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public Integer getDisease() {
		return disease;
	}
	public void setDisease(Integer disease) {
		this.disease = disease;
	}
	@Column(name = "disease_condition")
	public Integer getDiseaseCondition() {
		return diseaseCondition;
	}
	public void setDiseaseCondition(Integer diseaseCondition) {
		this.diseaseCondition = diseaseCondition;
	}
	@Column(name = "record_amount")
	public Integer getRecordAmount() {
		return recordAmount;
	}
	public void setRecordAmount(Integer recordAmount) {
		this.recordAmount = recordAmount;
	}
	public Integer getPoints() {
		return points;
	}
	public void setPoints(Integer points) {
		this.points = points;
	}
	@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 getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Transient
	public List<SignPatientLabelInfo> getLabelInfos() {
		return labelInfos;
	}
	public void setLabelInfos(List<SignPatientLabelInfo> labelInfos) {
		this.labelInfos = labelInfos;
	}
	public String getMobileRemarks() {
		return mobileRemarks;
	}
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	public Date getOpenidTime() {
		return openidTime;
	}
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
	public String getSickVillage() {
		return sickVillage;
	}
	public void setSickVillage(String sickVillage) {
		this.sickVillage = sickVillage;
	}
	public String getSickVillageName() {
		return sickVillageName;
	}
	public void setSickVillageName(String sickVillageName) {
		this.sickVillageName = sickVillageName;
	}
	public Integer getIsWxtag() {
		return isWxtag;
	}
	public void setIsWxtag(Integer isWxtag) {
		this.isWxtag = isWxtag;
	}
	//---------------------------常量----------------------------
	public enum isWchatTage{
		yes(1),no(0);
		isWchatTage(Integer value) {
			this.value = value;
		}
		private Integer value;
		public Integer getValue() {
			return value;
		}
		public void setValue(Integer value) {
			this.value = value;
		}
	}
}

+ 27 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java

@ -0,0 +1,27 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.service;
import com.yihu.mm.dao.PatientDao;
import com.yihu.mm.entity.Patient;
import org.springframework.stereotype.Service;
/**
 * 患者基本信息类.
 *
 * @author George
 */
@Service
public class PatientService {
    private PatientDao patientDao;
    public Patient findByCode(String code) {
        return patientDao.findByCode(code);
    }
}

+ 16 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java

@ -1,4 +1,20 @@
package com.yihu.mm.service;
import com.yihu.mm.entity.Patient;
import org.springframework.stereotype.Service;
@Service
public class PhysicalExaminationService {
    public void findExames(String type, String examCode) {
    }
    public String insertslip(Patient patient) {
        return null;
    }
}

+ 1 - 0
patient-co-customization/patient-co-modern-medicine/src/main/resources/application.yml

@ -1,6 +1,7 @@
server:
  port: 8080
examCode:         #越人试卷题目code
security:
  basic:

+ 12 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/common/account/CustomerController.java

@ -62,10 +62,22 @@ public class CustomerController extends BaseController {
            req.getSession().setAttribute("code",curUser.getCode());
            req.getSession().setAttribute("name",curUser.getName());
            req.getSession().setAttribute("isLogin", "true");
            req.getSession().setMaxInactiveInterval(-1);//设置session用不过期
            return write(1,"登入成功","user",curUser);
        }
    }
    @RequestMapping(value = "/logout",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String logout(HttpServletRequest req) throws Exception {
        req.getSession().removeAttribute("userInfo");
        req.getSession().removeAttribute("mobile");
        req.getSession().removeAttribute("code");
        req.getSession().removeAttribute("name");
        req.getSession().removeAttribute("isLogin");
        return write(1,"退出成功");
    }
    /**
     *通过社保卡号或者身份证查找服务对象
     * @return

+ 16 - 7
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Doctor.java

@ -1,17 +1,16 @@
package com.yihu.wlyy.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 医生信息
@ -363,6 +362,16 @@ public class Doctor extends IdEntity {
    @Transient
    public String getLevelName() {
		// 类型:1专科医生,2全科医生,3健康管理师
		if(1==level){
			levelName = "专科医生";
		}else if(2==level){
			levelName = "全科医生";
		}else if(level==3){
			levelName = "健康管理所";
		}else{
			levelName = "";
		}
        return levelName;
    }

+ 44 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/Patient.java

@ -1,15 +1,13 @@
package com.yihu.wlyy.entity;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
/**
 * 患者信息
@ -66,8 +64,10 @@ public class Patient extends IdEntity implements Serializable {
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
	private Integer disease;
	private String diseaseName;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	private String diseaseConditionName;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
@ -324,4 +324,42 @@ public class Patient extends IdEntity implements Serializable {
    public void setMobileRemarks(String mobileRemarks) {
        this.mobileRemarks = mobileRemarks;
    }
    @Transient
	public String getDiseaseName() {//0健康,1高血压,2糖尿病,3高血压+糖尿病
		if(0==disease) {
			this.diseaseName = "健康";
		}else if(1==disease) {
			this.diseaseName = "高血压";
		}else if(2==disease) {
			this.diseaseName = "糖尿病";
		}else if(3==disease) {
			this.diseaseName = "高血压+糖尿病";
		}else{
			this.diseaseName = "";
		}
		return diseaseName;
	}
	public void setDiseaseName(String diseaseName) {
		this.diseaseName = diseaseName;
	}
	@Transient
	public String getDiseaseConditionName() {
		if(0==diseaseCondition) {
			this.diseaseConditionName = "绿标";
		}else if(1==diseaseCondition) {
			this.diseaseConditionName = "黄标";
		}else if(2==diseaseCondition) {
			this.diseaseConditionName = "红标";
		}else{
			this.diseaseConditionName = "";
		}
		return diseaseConditionName;
	}
	public void setDiseaseConditionName(String diseaseConditionName) {
		this.diseaseConditionName = diseaseConditionName;
	}
}

+ 10 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/SignFamily.java

@ -39,6 +39,7 @@ public class SignFamily extends IdEntity {
    private Date begin;         // 签约开始日期
    private Date end;           // 签约结束日期
    private Integer status;     // 签约状态(-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约
    private String statusName;
    private String images;      // 签约图片附件URL,多图以逗号分隔
    private String reason;      // 解约原因
    private Date czrq;          // 操作时间
@ -502,4 +503,13 @@ public class SignFamily extends IdEntity {
    public void setReleaseSpeak(String releaseSpeak) {
        this.releaseSpeak = releaseSpeak;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
}

+ 5 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/filter/SessionOutTimeFilter.java

@ -32,6 +32,11 @@ public class SessionOutTimeFilter extends OncePerRequestFilter {
        Object isLogin = httpServletRequest.getSession().getAttribute("isLogin");
        if (isLogin == null || (String) isLogin != "true") {
//            request.setAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME,"请重新登入");
            if(path.indexOf("customer")>-1){
                httpServletResponse.getOutputStream().write("{\"code\":-200}".getBytes());//-200   客服未登录
                return ;
            }
            httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/login");
            return;
        }

+ 20 - 27
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -5,14 +5,15 @@ import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.service.manager.family.FamilyMemberService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.sign.SignFamilyService;
import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class CustomerService{
@ -20,45 +21,37 @@ public class CustomerService{
	@Autowired
	private FamilyMemberService familyMemberService;
	@Autowired
	private SignFamilyService signFamilyService;
	private FamilyContractService contractService;
	@Autowired
	private HosDoctorService hosDoctorService;
	public Map<String,Object> findServerInfo(Patient patient) throws Exception {
		Map<String, Object> resp = new HashMap<>();
		//查找家庭成员关系
		JSONArray familyMembers = familyMemberService.getAllFamilyMembers(patient.getCode());
		resp.put("family",familyMembers.toString());
		List<Map<String, Object>> familyMembers = familyMemberService.getAllFamilyMembers(patient.getCode());
		resp.put("family",familyMembers);
		//查询签约信息
		SignFamily signInfo = contractService.findSignByPatient(patient.getCode());
		if(signInfo!=null){
			signInfo.setStatusName("已签约");
		}
		//查询家庭成员的每个签约信息    以及签约医生
		List signFamilys = new ArrayList<SignFamily>();
		List doctors = new ArrayList<Doctor>();
		Iterator<Object> familyMember = familyMembers.iterator();
		while (familyMember.hasNext()) {
			JSONObject jsonObjectbject = (JSONObject) familyMember.next();
			String code = jsonObjectbject.getString("code");//居民code
			SignFamily signFamily = signFamilyService.findByPatientCode(code);
			if(signFamily!=null){
				signFamilys.add(signFamily);
			}
		for(Map<String, Object> familyMember:familyMembers) {
			//查找签约的医生信息
			if(jsonObjectbject.has("doctor")){
				String doctor = jsonObjectbject.getString("doctor");//医生code
				if(StringUtils.isNotBlank(doctor)){
					Doctor doctorInfo = hosDoctorService.getDoctorByCode(doctor);
					if(null!=doctorInfo){
						doctors.add(doctorInfo);
					}
			String doctor = (String) familyMember.get("doctor");//医生code
			if(StringUtils.isNotBlank(doctor)){
				Doctor doctorInfo = hosDoctorService.getDoctorByCode(doctor);
				if(null!=doctorInfo){
					doctors.add(doctorInfo);
				}
			}
		}
		resp.put("signFamilys",signFamilys);
		resp.put("signInfo",signInfo);
		resp.put("doctors",doctors);
		//查找签约医生
		return resp;
	}
}

+ 49 - 73
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java

@ -9,12 +9,12 @@ import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -54,15 +54,14 @@ public class FamilyMemberService extends BaseService {
    }
    /**
     * 获取所有家庭成员,包括自己
     * @param patient
     * @return
     */
    public JSONArray getAllFamilyMembers(String patient){
        JSONArray resultArray = new JSONArray();
        resultArray.put(getPatient(patient));
    public List<Map<String,Object>> getAllFamilyMembers(String patient){
        List<Map<String,Object>> list = new ArrayList<>();
        list.add(getPatient(patient));
        String sql = "select * " +
                " from " +
@ -78,105 +77,82 @@ public class FamilyMemberService extends BaseService {
        if (result != null && result.size() > 0) {
            JSONArray tem = new JSONArray();//存储其他
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                Map<String,Object> map1 = new HashMap();
                SignFamily sign = contractService.findSignByPatient(map.get("code").toString());
                boolean ssSign = false;
                boolean jtSign = false;
                map.put("statusName","未签约");
                if(sign!=null){
                    if (sign.getType() == 1 ) {
                        ssSign = true;
                    } else if (sign.getType() == 2 ) {
                        jtSign = true;
                    }
                    obj.put("doctor",sign.getDoctor());
                    obj.put("doctorName",sign.getDoctorName());
                    map1.put("statusName","已签约");
                    map1.put("doctor",sign.getDoctor());
                    map1.put("doctorName",sign.getDoctorName());
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                obj.put("code", map.get("code"));
                obj.put("name", map.get("name"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", family_relation);
                obj.put("familyRelationName", relations.get(map.get("family_relation")));
                if (ssSign && jtSign) {
                    obj.put("signType", 3);
                } else if (!ssSign && jtSign) {
                    obj.put("signType", 2);
                } else if (ssSign && !jtSign) {
                    obj.put("signType", 1);
                } else {
                    obj.put("signType", 0);
                }
                map1.put("code", map.get("code"));
                map1.put("name", map.get("name"));
                map1.put("sex", map.get("sex"));
                map1.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
                map1.put("birthday", map.get("birthday"));
                map1.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                map1.put("photo", map.get("photo"));
                map1.put("mobile", map.get("mobile"));
                map1.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                map1.put("familyRelation", family_relation);
                map1.put("familyRelationName", relations.get(map.get("family_relation")));
                if(family_relation==0){
                    tem.put(obj);
                    tem.put(map1);
                }else {
                    resultArray.put(obj);
                    list.add(map1);
                }
            }
            if(tem.length()>0){
                for(int i =0;i<tem.length();i++){
                    resultArray.put(tem.get(i));
                if(family_relation==0){
                    tem.put(map1);
                }else {
                    list.add(map1);
                }
            }
        }
        return resultArray;
        return list;
    }
    public JSONObject getPatient(String patient){
    public Map getPatient(String patient){
        Patient p = patientDao.findByCode(patient);
        //查询签约信息
        JSONObject obj = new JSONObject();
        Map map = new HashMap<String,Object>();
        SignFamily sign = contractService.findSignByPatient(p.getCode());
        boolean ssSign = false;
        boolean jtSign = false;
        String doctor = null;
        String doctorName = null;
        map.put("statusName","未签约");
        if (sign != null) {
            if (sign.getType() == 1 ) {
                ssSign = true;
            } else if (sign.getType() == 2 ) {
                jtSign = true;
            }
            doctor = sign.getDoctor();
            doctorName = sign.getDoctorName();
            map.put("statusName","已签约");
        }
        obj.put("doctor",doctor);
        obj.put("doctorName",doctorName);
        obj.put("code", p.getCode());
        obj.put("name", p.getName());
        obj.put("sex", p.getSex());
        obj.put("birthday", p.getBirthday());
        obj.put("isAuthorize", 1);
        map.put("doctor",doctor);
        map.put("doctorName",doctorName);
        map.put("code", p.getCode());
        map.put("name", p.getName());
        map.put("sex", p.getSex());
        map.put("birthday", p.getBirthday());
        map.put("isAuthorize", 1);
        String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
        obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
        obj.put("idcardAll", idCard);
        obj.put("ssc", p.getSsc());
        obj.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        obj.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
        obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
        obj.put("familyRelation", -1);
        obj.put("familyRelationName", "自己");
        obj.put("isAuthorize", 1);//0:未授权,1:已授权
        if (ssSign && jtSign) {
            obj.put("signType", 3);
        } else if (!ssSign && jtSign) {
            obj.put("signType", 2);
        } else if (ssSign && !jtSign) {
            obj.put("signType", 1);
        } else {
            obj.put("signType", 0);
        }
        return obj;
        map.put("idcard", CommonUtil.getIdcardEncode(idCard));
        map.put("idcardAll", idCard);
        map.put("ssc", p.getSsc());
        map.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        map.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
        map.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
        map.put("familyRelation", -1);
        map.put("familyRelationName", "自己");
        map.put("isAuthorize", 1);//0:未授权,1:已授权
        return map;
    }
}