Преглед изворни кода

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

пре 8 година
родитељ
комит
5fe34c51c9

+ 137 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientEvent.java

@ -0,0 +1,137 @@
package com.yihu.wlyy.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
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;
/**
 * 患者就诊事件
 */
@Entity
@Table(name = "wlyy_patient_event")
public class PatientEvent extends IdEntity implements Serializable {
	// 患者代码
	private String patient;
	// 就诊时间
	private Date eventDate;
	// 就诊类型
	private String eventType;
	// 机构代码
	private String orgCode;
	// 机构名称
	private String orgName;
	// 科室代码
	private String deptCode;
	// 科室名称
	private String deptName;
	// 医生代码
	private String doctorCode;
	// 医生名称
	private String doctorName;
	// 诊断
	private String dianosis;
	// 创建时间
	private Date createTime;
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEventDate() {
		return eventDate;
	}
	public void setEventDate(Date eventDate) {
		this.eventDate = eventDate;
	}
	public String getEventType() {
		return eventType;
	}
	public void setEventType(String eventType) {
		this.eventType = eventType;
	}
	public String getOrgCode() {
		return orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	public String getOrgName() {
		return orgName;
	}
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	public String getDeptCode() {
		return deptCode;
	}
	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	public String getDoctorCode() {
		return doctorCode;
	}
	public void setDoctorCode(String doctorCode) {
		this.doctorCode = doctorCode;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getDianosis() {
		return dianosis;
	}
	public void setDianosis(String dianosis) {
		this.dianosis = dianosis;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 80 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientEventImg.java

@ -0,0 +1,80 @@
package com.yihu.wlyy.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 患者就诊事件
 */
@Entity
@Table(name = "wlyy_patient_event_img")
public class PatientEventImg extends IdEntity implements Serializable {
	// 事件ID
	private Long eventId;
	// 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
	private String imgType;
	// 图片标签
	private String imgLabel;
	// 图片说明
	private String imgContent;
	// 图片路径
	private String imgUrl;
	// 创建时间
	private Date createTime;
	public Long getEventId() {
		return eventId;
	}
	public void setEventId(Long eventId) {
		this.eventId = eventId;
	}
	public String getImgType() {
		return imgType;
	}
	public void setImgType(String imgType) {
		this.imgType = imgType;
	}
	public String getImgLabel() {
		return imgLabel;
	}
	public void setImgLabel(String imgLabel) {
		this.imgLabel = imgLabel;
	}
	public String getImgContent() {
		return imgContent;
	}
	public void setImgContent(String imgContent) {
		this.imgContent = imgContent;
	}
	public String getImgUrl() {
		return imgUrl;
	}
	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 15 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientEventDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientEvent;
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 PatientEventDao extends PagingAndSortingRepository<PatientEvent, Long>, JpaSpecificationExecutor<PatientEvent> {
      @Query("select a from PatientEvent a where a.patient = ?1 order by a.eventDate desc")
      List<PatientEvent> findByPatient(String patient) throws Exception;
}

+ 15 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientEventImgDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientEventImg;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientEventImgDao extends PagingAndSortingRepository<PatientEventImg, Long>, JpaSpecificationExecutor<PatientEventImg> {
     List<PatientEventImg> findByEventId(Long eventId) throws Exception;
}

+ 41 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -33,7 +33,9 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.beanutils.converters.IntegerConverter;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -101,6 +103,8 @@ public class DoctorInfoService extends BaseService {
    DoctorWorkTimeService workTimeService;
    @Autowired
    TalkGroupService talkGroupService;
    @Autowired
    WeiXinAccessTokenUtils accessTokenUtils;
    /**
     * 获取医生的签约病人
@ -832,6 +836,23 @@ public class DoctorInfoService extends BaseService {
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", ""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        Patient p = patientDao.findByCode(patient);
        JSONObject data = new JSONObject();
        if(StringUtils.isNotEmpty(oldDoctorCode)) {
            data.put("first", "因签约团队内分工调整,您的责任医生有变动," + signFamily.getDoctorHealthName() +
                    "医生无法继续为您服务,具体变动如下:");
            data.put("keyword1", "家庭签约");
            data.put("keyword2", newD.getName());
            data.put("remark",  signFamily.getDoctorName() + "医生与" + newD.getName() +
                    "医生一道,为您提供优质健康服务");
        } else {
            data.put("first", "您的签约团队新增一位责任医生,其将与" + signFamily.getDoctorName() +
                    "医生一道,为您提供优质健康管理服务,医生信息如下:");
            data.put("keyword1", "家庭签约");
            data.put("keyword2", newD.getName());
        }
        PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), data);
    }
    @Transactional
@ -885,6 +906,15 @@ public class DoctorInfoService extends BaseService {
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", ""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        Patient p = patientDao.findByCode(patient);
        JSONObject data = new JSONObject();
        data.put("first", "您的签约团队新增一位责任医生,其将与" + signFamily.getDoctorName() +
                "医生一道,为您提供优质健康管理服务,医生信息如下:");
        data.put("keyword1", "家庭签约");
        data.put("keyword2", newD.getName());
        PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), data);
        return 1;
    }
@ -1031,5 +1061,16 @@ public class DoctorInfoService extends BaseService {
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-", ""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        Patient p = patientDao.findByCode(patient);
        JSONObject data = new JSONObject();
        data.put("first", "因签约团队内分工调整,您的责任医生有变动," + signFamily.getDoctorName() +
                "医生无法继续为您服务,具体变动如下:");
        data.put("keyword1", "家庭签约");
        data.put("keyword2", newD.getName());
        data.put("remark", newD.getName() + "医生" +
                (StringUtils.isNotEmpty(signFamily.getDoctorHealthName()) ? ( "与" + signFamily.getDoctorHealthName() + "医生一道") : "") +
                ",为您提供优质健康服务");
        PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), data);
    }
}

+ 134 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientEventService.java

@ -0,0 +1,134 @@
package com.yihu.wlyy.service.app.archives;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.PatientEvent;
import com.yihu.wlyy.entity.patient.PatientEventImg;
import com.yihu.wlyy.repository.patient.PatientEventDao;
import com.yihu.wlyy.repository.patient.PatientEventImgDao;
import com.yihu.wlyy.util.DateUtil;
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 org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by hzp on 2016/11/25.
 * 患者就诊事件管理
 */
@Service
public class PatientEventService {
    @Autowired
    private PatientEventDao patientEventDao;
    @Autowired
    private PatientEventImgDao patientEventImgDao;
    @Autowired
    private ObjectMapper objectMapper;
    /**
     * 获取就诊事件详情
     */
    public JSONObject getEventDetail(String id) throws Exception
    {
        JSONObject re = new JSONObject();
        PatientEvent event = patientEventDao.findOne(Long.valueOf(id));
        if(event!=null)
        {
            re =  new JSONObject(event);
            List<PatientEventImg> list = patientEventImgDao.findByEventId(event.getId());
            re.put("eventImg",list);
        }
        else{
            throw new Exception("不存在该就诊事件!");
        }
        return re;
    }
    /**
     * 保存就诊事件详情
     */
    @Transactional
    public void saveEventDetail(String data) throws Exception
    {
        JSONObject json = new JSONObject(data);
        PatientEvent event = new PatientEvent();
        if(!StringUtils.isEmpty(json.optString("id")))
        {
            event.setId(json.getLong("id"));
        }
        else{
            event.setCreateTime(new Date());
        }
        event.setPatient(json.optString("patient"));
        event.setEventDate(DateUtil.strToDate(json.optString("eventDate")));
        event.setEventType(json.optString("eventType"));
        event.setOrgCode(json.optString("orgCode"));
        event.setOrgName(json.optString("orgName"));
        event.setDeptCode(json.optString("deptCode"));
        event.setDeptName(json.optString("deptName"));
        event.setDianosis(json.optString("dianosis"));
        //保存就诊记录
        patientEventDao.save(event);
        if(event.getId() != null) {
            //修改时先删除原有图片
            List<PatientEventImg> imgList = patientEventImgDao.findByEventId(event.getId());
            if(imgList!=null && imgList.size()>0)
            {
                patientEventImgDao.delete(imgList);
            }
        }
        //保存就诊记录相关图片
        JSONArray array = json.getJSONArray("eventImg");
        if(array!=null && array.length()>0)
        {
            List<PatientEventImg> imgList = new ArrayList<>();
            for(int i=0;i<array.length();i++)
            {
                JSONObject item = array.getJSONObject(i);
                PatientEventImg img = new PatientEventImg();
                img.setCreateTime(new Date());
                img.setEventId(event.getId());
                // 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
                img.setImgType(item.optString("imgType"));
                // 图片标签
                img.setImgLabel(item.optString("imgLabel"));
                // 图片说明
                img.setImgContent(item.optString("imgContent"));
                // 图片路径
                img.setImgUrl(item.optString("imgUrl"));
                imgList.add(img);
            }
            patientEventImgDao.save(imgList);
        }
    }
    /**
     * 删除就诊事件详情
     */
    @Transactional
    public void deleteEventDetail(String id) throws Exception
    {
        PatientEvent event = patientEventDao.findOne(Long.valueOf(id));
        patientEventDao.delete(event);
        List<PatientEventImg> list = patientEventImgDao.findByEventId(event.getId());
        patientEventImgDao.delete(list);
    }
}

+ 284 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java

@ -0,0 +1,284 @@
package com.yihu.wlyy.service.app.archives;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientEvent;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientEventDao;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
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 java.util.*;
/**
 * Created by hzp on 2016/11/24.
 * 市民健康档案服务
 */
@Service
public class PatientRecordService {
    @Autowired
    private JwSmjkService jwSmjkService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientEventDao patientEventDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper  objectMapper;
    /**
     * 字符串List排序
     */
    public List<Map<String, String>> sortMapList(List<Map<String, String>> mapList, final String sort, final String order) {
        Collections.sort(mapList, new Comparator<Map<String, String>>() {
            public int compare(Map<String, String> o1, Map<String, String> o2) {
                String map1value = o1.get(sort);
                String map2value = o2.get(sort);
                if ("DESC".equals(order.toUpperCase())) {
                    return map2value.compareTo(map1value);
                } else {
                    return map1value.compareTo(map2value);
                }
            }
        });
        return mapList;
    }
    /******************************************************************************************************************/
    /**
     * 获取门/急诊记录 + 住院记录
     */
    public List<Map<String,String>> getAllEvent(String patientCode, String type, String page, String pageSize) throws Exception
    {
        List<Map<String,String>> re = new ArrayList<>();
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        //获取基卫数据
        String response = jwSmjkService.getResidentEventListJson(patient.getSsc(),type,page,pageSize);
        //获取app数据
        List<PatientEvent> eventList = patientEventDao.findByPatient(patientCode);
        if(!StringUtils.isEmpty(response))
        {
            JSONArray array = new JSONArray(response);
            String max = "";
            String min = "";
            for (int i=0;i<array.length();i++) {
                JSONObject item = array.getJSONObject(i);
                if(i==0) //最大值
                {
                    max = item.optString("END_TIME");
                }
                else if(i==array.length()-1) //最小值
                {
                    min = item.optString("END_TIME");
                }
                Map<String,String> map = new HashMap<>();
                map.put("id",item.optString("EVENT"));
                map.put("patient",patientCode);
                map.put("eventDate",item.optString("END_TIME"));
                map.put("eventType",item.optString("TYPE"));
                map.put("orgName",item.optString("ORG_NAME"));
                map.put("dianosis",item.optString("DIAGNOSIS"));
                map.put("createTime",item.optString("END_TIME"));
                map.put("dataFrom","1");//基卫数据
                re.add(map);
            }
            //过滤***********
            for(PatientEvent item:eventList)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",item.getId().toString());
                map.put("patient",item.getPatient());
                map.put("eventDate",DateUtil.dateToStrLong(item.getEventDate()));
                map.put("eventType",item.getEventType());
                map.put("orgName",item.getOrgName());
                map.put("dianosis",item.getDianosis());
                map.put("createTime",DateUtil.dateToStrLong(item.getCreateTime()));
                map.put("dataFrom","2");   //APP数据
                re.add(map);
            }
            //排序
            re = sortMapList(re,"eventDate","DESC");
        }
        else{
            for(PatientEvent item:eventList)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",item.getId().toString());
                map.put("patient",item.getPatient());
                map.put("eventDate",DateUtil.dateToStrLong(item.getEventDate()));
                map.put("eventType",item.getEventType());
                map.put("orgName",item.getOrgName());
                map.put("dianosis",item.getDianosis());
                map.put("createTime",DateUtil.dateToStrLong(item.getCreateTime()));
                map.put("dataFrom","2");   //APP数据
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 基卫通过event获取档案类型列表
     */
    public List<Map<String,Object>> getEventCatalog(String strEvent) throws Exception
    {
        List<Map<String,Object>> re = new ArrayList<>();
        String response = jwSmjkService.getEventCatalog(strEvent);   //【基卫接口】
        return re;
    }
    /**
     * 获取健康档案信息详情
     */
    public String getHealthData(String patientCode, String strEvent, String strCatalog, String strSerial) throws Exception
    {
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        String respon = jwSmjkService.getHealthData(patient.getSsc(), strEvent, strCatalog, strSerial);  //【基卫接口】
        return respon;
    }
    /**
     * 获取检查检验列表
     */
    public List<Map<String,String>> getExamAndLabReport(String patientCode,String page,String pageSize) throws Exception
    {
        List<Map<String,String>> re = new ArrayList<>();
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        //获取基卫数据
        String response = jwSmjkService.getExamAndLabReport(patient.getSsc(),page,pageSize);     //【基卫接口】
        //获取app数据
        String sql = "select a.*,b.img_type as catalog,GROUP_CONCAT(b.img_label) as label from wlyy_patient_event a\n" +
                "left join wlyy_patient_event_img b on b.event_id=a.id and b.img_type in ('检查报告','检验报告')\n" +
                "where a.patient='"+patientCode+"'\n" +
                "group by b.img_type order by a.event_date desc";
        List<Map<String,Object>> appList = jdbcTemplate.queryForList(sql);
        if(!StringUtils.isEmpty(response))
        {
            JSONArray array = new JSONArray(response);
            for (int i=0;i<array.length();i++) {
                JSONObject item = array.getJSONObject(i);
                Map<String,String> map = new HashMap<>();
                map.put("id",item.optString("EVENT"));
                map.put("patient",patientCode);
                map.put("eventDate",item.optString("END_TIME"));
                String type = "";
                if("0221".equals(item.optString("CATALOG_CODE")))
                {
                    type = "检验";
                }
                else if("0231".equals(item.optString("CATALOG_CODE")))
                {
                    type = "检查";
                }
                map.put("type",type);
                map.put("catalogCode",item.optString("CATALOG_CODE")); //【基卫】档案类型
                map.put("serial",item.optString("SERIAL")); //【基卫】档案序号
                map.put("orgName",item.optString("ORG_NAME"));
                map.put("label",item.optString("ITEM")); //检测项目
                map.put("dataFrom","1");//基卫数据
                re.add(map);
            }
            //*******过滤
            for(Map<String,Object> item:appList)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",item.get("id").toString());
                map.put("patient",patientCode);
                map.put("eventDate",DateUtil.dateToStrLong((Date) item.get("event_date")));
                String type = "";
                if("检验报告".equals(item.get("catalog")))
                {
                    type = "检验";
                }
                else if("检查报告".equals(item.get("catalog")))
                {
                    type = "检查";
                }
                map.put("type",type);
                map.put("catalogCode","");
                map.put("serial","");
                map.put("orgName",String.valueOf(item.get("org_name")));
                map.put("label",String.valueOf(item.get("label"))); //检测项目
                map.put("dataFrom","2");//基卫数据
                re.add(map);
            }
            //排序
            re = sortMapList(re,"eventDate","DESC");
        }
        else{
            for(Map<String,Object> item:appList)
            {
                Map<String,String> map = new HashMap<>();
                map.put("id",String.valueOf(item.get("id")));
                map.put("patient",patientCode);
                map.put("eventDate",DateUtil.dateToStrLong((Date) item.get("event_date")));
                String type = "";
                if("检验报告".equals(item.get("catalog")))
                {
                    type = "检验";
                }
                else if("检查报告".equals(item.get("catalog")))
                {
                    type = "检查";
                }
                map.put("type",type);
                map.put("catalogCode","");
                map.put("serial","");
                map.put("orgName",String.valueOf(item.get("org_name")));
                map.put("label",String.valueOf(item.get("label"))); //检测项目
                map.put("dataFrom","2");//基卫数据
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 获取用药列表
     */
    public String getDrugsListPage(String patientCode,String page,String pageSize) throws Exception
    {
        //获取患者
        Patient patient = patientDao.findByCode(patientCode);
        return jwSmjkService.getDrugsListPage(patient.getSsc(),page,pageSize);
    }
}

+ 92 - 47
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -30,6 +30,7 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.beanutils.converters.IntegerConverter;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -110,6 +111,8 @@ public class FamilyContractService extends BaseService {
    SignPatientLabelInfoDao labelInfoDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    WeiXinAccessTokenUtils accessTokenUtils;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
@ -1612,6 +1615,15 @@ public class FamilyContractService extends BaseService {
     */
    public JSONObject updateSignInfo(String patient, String healthDoctor, String doctor, String expensesType) {
        JSONObject result = new JSONObject();
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            result.put("status", -1);
            result.put("msg", "居民不存在");
            return result;
        }
        List<JSONObject> wxMessages = new ArrayList<>();
        SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
@ -1644,6 +1656,22 @@ public class FamilyContractService extends BaseService {
                    teamMember.setCzrq(new Date());
                    doctorTeamDoctor.save(teamMember);
                }
                JSONObject data = new JSONObject();
                data.put("first", "因签约团队内分工调整,您的责任医生有变动," + signFamily.getDoctorHealthName() +
                        "医生无法继续为您服务,具体变动如下:");
                data.put("keyword1", "家庭签约");
                data.put("keyword2", docHealth.getName());
                data.put("remark", signFamily.getDoctorName() + "医生与" + docHealth.getName() +
                        "医生一道,为您提供优质健康服务");
                wxMessages.add(data);
            } else {
                JSONObject data = new JSONObject();
                data.put("first", "您的签约团队新增一位责任医生,其将与" + signFamily.getDoctorName() +
                        "医生一道,为您提供优质健康管理服务,医生信息如下:");
                data.put("keyword1", "家庭签约");
                data.put("keyword2", docHealth.getName());
                wxMessages.add(data);
            }
            // 新增团队信息
            if (StringUtils.isNotEmpty(signFamily.getTeamCode())) {
@ -1701,6 +1729,16 @@ public class FamilyContractService extends BaseService {
            signFamily.setDoctor(docQk.getCode());
            signFamily.setDoctorName(docQk.getName());
            signFamily.setCzrq(new Date());
            JSONObject data = new JSONObject();
            data.put("first", "因签约团队内分工调整,您的责任医生有变动," + signFamily.getDoctorName() +
                    "医生无法继续为您服务,具体变动如下:");
            data.put("keyword1", "家庭签约");
            data.put("keyword2", docQk.getName());
            data.put("remark", docQk.getName() + "医生" +
                    (StringUtils.isNotEmpty(signFamily.getDoctorHealthName()) ? ("与" + signFamily.getDoctorHealthName() + "医生一道") : "") +
                    ",为您提供优质健康服务");
            wxMessages.add(data);
        }
        if (StringUtils.isNotEmpty(expensesType)) {
@ -1716,6 +1754,10 @@ public class FamilyContractService extends BaseService {
        result.put("status", 1);
        result.put("msg", "更新成功");
        for (JSONObject msg : wxMessages) {
            PushMsgTask.getInstance().putWxMsg(accessTokenUtils.getAccessToken(), 10, p.getOpenid(), p.getName(), msg);
        }
        return result;
    }
@ -1734,22 +1776,22 @@ public class FamilyContractService extends BaseService {
                " WHERE " +
                " sf.type = 2 " +
                " AND sf. STATUS >= 0 " +
                " and sf.doctor = ? "+
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) ) a where 1=1" ;
        if(!org.springframework.util.StringUtils.isEmpty(patientAddr)){
            sql+= " AND a.address like '%"+patientAddr+"%'";
        }
        if(!org.springframework.util.StringUtils.isEmpty(patientName)){
            sql+= " AND a.name like '%"+patientName+"%'";
        }
        List<Map<String, Object>> datas =  jdbcTemplate.queryForList(sql, doctorCode );
        if(datas!=null&&datas.size()>0){
            for(Map<String, Object> map:datas){
                JSONObject jo=new JSONObject();
                jo.put("signcode",map.get("signcode"));
                jo.put("name",map.get("name"));
                jo.put("code",map.get("code"));
                jo.put("hasopenid",map.get("hasopenid"));
                " and sf.doctor = ? " +
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) ) a where 1=1";
        if (!org.springframework.util.StringUtils.isEmpty(patientAddr)) {
            sql += " AND a.address like '%" + patientAddr + "%'";
        }
        if (!org.springframework.util.StringUtils.isEmpty(patientName)) {
            sql += " AND a.name like '%" + patientName + "%'";
        }
        List<Map<String, Object>> datas = jdbcTemplate.queryForList(sql, doctorCode);
        if (datas != null && datas.size() > 0) {
            for (Map<String, Object> map : datas) {
                JSONObject jo = new JSONObject();
                jo.put("signcode", map.get("signcode"));
                jo.put("name", map.get("name"));
                jo.put("code", map.get("code"));
                jo.put("hasopenid", map.get("hasopenid"));
                jo.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard").toString()));
                jo.put("sex", IdCardUtil.getSexForIdcard_new(map.get("idcard").toString()));
                returnMap.put(jo);
@ -1757,7 +1799,8 @@ public class FamilyContractService extends BaseService {
        }
        return returnMap;
    }
    public JSONObject findNoHealthSignFamilyHealth(String doctorCode, String labelType, String patientName) throws  Exception{
    public JSONObject findNoHealthSignFamilyHealth(String doctorCode, String labelType, String patientName) throws Exception {
        JSONObject returnMap = new JSONObject();
        //健康管理师
        String sql = "SELECT " +
@ -1766,21 +1809,21 @@ public class FamilyContractService extends BaseService {
                "  p.code code, " +
                "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                "  sp.id labelid, " +
                "  CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                "  CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, " +
                "  sp.label_type labeltype, " +
                "  p.idcard idcard " +
         " FROM " +
                " FROM " +
                " wlyy_sign_family sf " +
                " JOIN wlyy_patient p ON sf.patient = p.CODE " +
                " left JOIN wlyy_sign_patient_label_info sp ON sf.patient = sp.patient AND sp.label_type = ? AND sp.`status` = 1 " +
          " WHERE " +
                " WHERE " +
                " sf.type = 2 " +
                " AND sf. STATUS >= 0 " +
                " and sf.doctor = ? "+
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) " ;
                " and sf.doctor = ? " +
                " AND ( sf.doctor_health is null or sf.doctor_health ='' ) ";
        List<Map<String, Object>> datas = null;
        //查找居民
        datas = jdbcTemplate.queryForList(sql,labelType , doctorCode );
        datas = jdbcTemplate.queryForList(sql, labelType, doctorCode);
        //根据类别查找标签
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
@ -1790,17 +1833,16 @@ public class FamilyContractService extends BaseService {
            }
            if (datas != null && datas.size() > 0) {
                for (Map<String, Object> map : datas) {
                    JSONObject jo=new JSONObject();
                    jo.put("signcode",map.get("signcode"));
                    jo.put("name",map.get("name"));
                    jo.put("code",map.get("code"));
                    jo.put("hasopenid",map.get("hasopenid"));
                    JSONObject jo = new JSONObject();
                    jo.put("signcode", map.get("signcode"));
                    jo.put("name", map.get("name"));
                    jo.put("code", map.get("code"));
                    jo.put("hasopenid", map.get("hasopenid"));
                    jo.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard").toString()));
                    jo.put("sex", IdCardUtil.getSexForIdcard_new(map.get("idcard").toString()));
                    JSONArray jr = returnMap.getJSONArray(map.get("labelname").toString());
                    //判断是否为空
                    if (jr == null) {
                        jr = new JSONArray();
                    JSONArray jr = new JSONArray();
                    if (returnMap.has(map.get("labelname").toString())) {
                        jr = returnMap.getJSONArray(map.get("labelname").toString());
                    }
                    jr.put(jo);
                    returnMap.put(map.get("labelname").toString(), jr);
@ -2054,20 +2096,21 @@ public class FamilyContractService extends BaseService {
        return returnMap;
    }
    public JSONObject getPatientByLable(String doctorCode, String labelType) throws Exception {
    public JSONObject getPatientByLable(String doctorCode, String labelType, String level) throws Exception {
        JSONObject returnMap = new JSONObject();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //判断当前用户是健康管理师还是全科
        List<Map<String, Object>> datas = null;
        if (doctor.getLevel() == 3) {
        if (level.equals("3")) {
            //健康管理师
            String sql = "SELECT " +
                    "  sf. CODE signcode, " +
                    "  p.name name, " +
                    "  p.photo photo, " +
                    "  p.code code, " +
                    "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                    "  sp.id labelid, " +
                     " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                    " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, " +
                    "  sp.label_type labeltype, " +
                    "  p.idcard idcard " +
                    " FROM " +
@ -2081,15 +2124,16 @@ public class FamilyContractService extends BaseService {
            //查找居民
            datas = jdbcTemplate.queryForList(sql, labelType, doctorCode);
        } else if (doctor.getLevel() == 2) {
            //健康管理师
        } else if (level.equals("2")) {
            //全科
            String sql = "SELECT " +
                    "  sf. CODE signcode, " +
                    "  p.name name, " +
                    "  p.photo photo, " +
                    "  p.code code, " +
                    "  CASE WHEN p.openid is null THEN '0' WHEN p.openid='' THEN '0' else 1 END hasopenid, " +
                    "  sp.id labelid, " +
                    " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, "+
                    " CASE WHEN sp.label_name is null THEN '未标注' WHEN sp.label_name='' THEN '未标注' else sp.label_name END labelname, " +
                    "  sp.label_type labeltype, " +
                    "  p.idcard idcard " +
                    " FROM " +
@ -2099,7 +2143,7 @@ public class FamilyContractService extends BaseService {
                    " WHERE " +
                    " sf.type = 2 " +
                    " AND sf. STATUS >= 0 " +
                    " and ( sf.doctor = ? or sf.doctor_health = ? ) ";
                    " and  sf.doctor = ?  ";
            //查找居民
            datas = jdbcTemplate.queryForList(sql, labelType, doctorCode, doctorCode);
@ -2115,18 +2159,19 @@ public class FamilyContractService extends BaseService {
            }
            if (datas != null && datas.size() > 0) {
                for (Map<String, Object> map : datas) {
                    JSONObject jo=new JSONObject();
                    jo.put("signcode",map.get("signcode"));
                    jo.put("name",map.get("name"));
                    jo.put("code",map.get("code"));
                    jo.put("hasopenid",map.get("hasopenid"));
                    JSONObject jo = new JSONObject();
                    jo.put("signcode", map.get("signcode"));
                    jo.put("name", map.get("name"));
                    jo.put("photo", map.get("photo"));
                    jo.put("code", map.get("code"));
                    jo.put("hasopenid", map.get("hasopenid"));
                    jo.put("age", IdCardUtil.getAgeForIdcard(map.get("idcard").toString()));
                    jo.put("sex", IdCardUtil.getSexForIdcard_new(map.get("idcard").toString()));
                    //判断name是否为空 为空就是未标注
                    //把患者添加到对应的组
                    JSONArray jr = returnMap.getJSONArray(map.get("labelname").toString());
                    if (jr == null) {
                        jr = new JSONArray();
                    JSONArray jr = new JSONArray();
                    if (returnMap.has(map.get("labelname").toString())) {
                        jr = returnMap.getJSONArray(map.get("labelname").toString());
                    }
                    jr.put(jo);
                    returnMap.put(map.get("labelname").toString(), jr);

+ 270 - 106
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -45,8 +45,272 @@ public class JwSmjkService {
    @Autowired
    SystemDictService systemDictService;
    /****************************************************************************************************************************/
    /**
     * 获取门/急诊记录 + 住院记录
     */
    public String getResidentEventListJson(String strSSID,String type,String page,String pageSize)
    {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return "";
        }
        else {
            String re = "";
            try {
                String url = jwUrl + "/third/smjk/ResidentEventList";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("strSSID", strSSID));
                if (!StringUtils.isEmpty(type)) {
                    params.add(new BasicNameValuePair("type", type));
                }
                params.add(new BasicNameValuePair("page", page));
                params.add(new BasicNameValuePair("pageSize", pageSize));
                String response = HttpClientUtil.post(url, params, "UTF-8");
                if (!StringUtils.isEmpty(response)) {
                    JSONObject responseObject = new JSONObject(response);
                    int status = responseObject.getInt("status");
                    if (status == 200) {
                        String data = responseObject.getString("data");
                        if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                            throw new Exception(data);
                        } else {
                            JSONObject jsonData = new JSONObject(data);
                            JSONArray jsonArray = jsonData.getJSONArray("EventList");
                            re = jsonArray.toString();
                        }
                    } else {
                        throw new Exception(responseObject.getString("msg"));
                    }
                } else {
                    throw new Exception("null response.");
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return re;
        }
    }
    /**
     * 通过event获取档案类型列表
     */
    public String getEventCatalog(String strEvent)
    {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return "";
        }
        else {
            try {
                String url = jwUrl + "/third/smjk/EventCatalog";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("strEvent", strEvent));
                String response = HttpClientUtil.post(url, params, "UTF-8");
                String result = "";
                if (!StringUtils.isEmpty(response)) {
                    JSONObject jsonObject = new JSONObject(response);
                    int status = jsonObject.getInt("status");
                    if (status == 200) {
                        result = jsonObject.getString("data");
                    }
                    else {
                        throw new Exception(jsonObject.getString("msg"));
                    }
                }
                else {
                    throw new Exception("null response.");
                }
                return result;
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
                return "";
            }
        }
    }
    /**
     * 获取健康档案信息详情
     */
    public String getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return ehrService.getHealthData(strSSID,strEvent,strCatalog,strSerial);
        }
        else {
            try {
                String url = jwUrl + "/third/smjk/HealthData";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("strSSID", strSSID));
                params.add(new BasicNameValuePair("strEvent", strEvent));
                params.add(new BasicNameValuePair("strCatalog", strCatalog));
                params.add(new BasicNameValuePair("strSerial", strSerial));
                String response = HttpClientUtil.post(url, params, "UTF-8");
                String result = "";
                if (!StringUtils.isEmpty(response)) {
                    JSONObject jsonObject = new JSONObject(response);
                    int status = jsonObject.getInt("status");
                    if (status == 200) {
                        result = jsonObject.getString("data");
                        result = result.replaceAll("<\\?xml version=\"1.0\" encoding=\"utf-8\"\\?>", "");
                        if (result.startsWith("error")) {
                            throw new Exception(result);
                        }
                    }
                    else {
                        throw new Exception(jsonObject.getString("msg"));
                    }
                }
                else {
                    throw new Exception("null response.");
                }
                return result;
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
                return "";
            }
        }
    }
    /**
     * 获取检查检验列表
     */
    public String getExamAndLabReport(String strSSID,String page,String pageSize)
    {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return "";
        }
        else {
            try {
                String url = jwUrl + "/third/smjk/ExamAndLabReport";
                List<NameValuePair> params = new ArrayList<>();
                params.add(new BasicNameValuePair("strSSID", strSSID));
                params.add(new BasicNameValuePair("page", page));
                params.add(new BasicNameValuePair("pageSize", pageSize));
                String response = HttpClientUtil.post(url, params, "UTF-8");
                String re = "";
                if (!StringUtils.isEmpty(response)) {
                    JSONObject jsonObject = new JSONObject(response);
                    int status = jsonObject.getInt("status");
                    if (status == 200) {
                        String data = jsonObject.getString("data");
                        if (!StringUtils.isEmpty(data) && data.startsWith("error")) {
                            throw new Exception(data);
                        } else {
                            JSONObject jsonData = new JSONObject(data);
                            JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                            re = jsonArray.toString();
                        }
                    } else {
                        throw new Exception(jsonObject.getString("msg"));
                    }
                } else {
                    throw new Exception("null response.");
                }
                return re;
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
                return "";
            }
        }
    }
    /**
     * 获取用药列表
     */
    public String getDrugsListPage(String strSSID,String page,String pageSize) throws Exception
    {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return "";
        }
        else {
            String url = jwUrl + "/third/smjk/DrugsListPage";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            params.add(new BasicNameValuePair("page", page));
            params.add(new BasicNameValuePair("pageSize", pageSize));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            String result = "";
            if (!StringUtils.isEmpty(response)) {
                JSONObject jsonObject = new JSONObject(response);
                int status = jsonObject.getInt("status");
                if (status == 200) {
                    result = jsonObject.getString("data");
                }
                else {
                    throw new Exception(jsonObject.getString("msg"));
                }
            }
            else {
                throw new Exception("null response.");
            }
            return result;
        }
    }
    /****************************************************************************************************************************/
    /**
     * 获取住院记录
     * 获取转诊预约医生号源信息
     */
    public String getRegDeptSpeDoctorSectionList(String OrgCode,String DeptCode,String strStart,String strEnd,String DocCode)  throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/smjk/RegDeptSpeDoctorSectionList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("OrgCode", OrgCode));
        params.add(new BasicNameValuePair("DeptCode", DeptCode));
        params.add(new BasicNameValuePair("strStart", strStart));
        params.add(new BasicNameValuePair("strEnd", strEnd));
        params.add(new BasicNameValuePair("DocCode", DocCode));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
    /*************************************** 旧版本函数 *************************************************************************/
    /**
     * 获取住院记录(X)
     */
    public String getHospitalizationRecord(String strSSID, String startNum, String endNum) throws Exception {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
@ -137,7 +401,7 @@ public class JwSmjkService {
    }
    /**
     * 获取门/急诊记录
     * 获取门/急诊记录(X)
     */
    public String getOutpatientRecord(String strSSID, String startNum, String endNum) throws Exception {
@ -229,87 +493,7 @@ public class JwSmjkService {
    }
    /**
     * 获取门/急诊记录 + 住院记录
     */
    public String getResidentEventListJson(String strSSID,String type,String page,String pageSize) throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/smjk/ResidentEventList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("strSSID", strSSID));
        if(!StringUtils.isEmpty(type))
        {
            params.add(new BasicNameValuePair("type", type));
        }
        params.add(new BasicNameValuePair("page", page));
        params.add(new BasicNameValuePair("pageSize", pageSize));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        if (!StringUtils.isEmpty(response)){
            JSONObject responseObject = new JSONObject(response);
            int status = responseObject.getInt("status");
            if (status == 200) {
                String data = responseObject.getString("data");
                if (!StringUtils.isEmpty(data) && re.startsWith("error")) {
                    throw new Exception(re);
                }
                else{
                    JSONObject jsonData = new JSONObject(data);
                    JSONArray jsonArray = jsonData.getJSONArray("EhrList");
                    re = jsonArray.toString();
                }
            }
            else{
                throw new Exception(responseObject.getString("msg"));
            }
        }
        else{
            throw new Exception("null response.");
        }
        return re;
    }
    /**
     * 获取健康档案信息
     */
    public String getHealthData(String strSSID, String strEvent, String strCatalog, String strSerial) throws Exception {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
        {
            return ehrService.getHealthData(strSSID,strEvent,strCatalog,strSerial);
        }
        else {
            String url = jwUrl + "/third/smjk/HealthData";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("strSSID", strSSID));
            params.add(new BasicNameValuePair("strEvent", strEvent));
            params.add(new BasicNameValuePair("strCatalog", strCatalog));
            params.add(new BasicNameValuePair("strSerial", strSerial));
            String response = HttpClientUtil.post(url, params, "UTF-8");
            String result = "";
            if (!StringUtils.isEmpty(response)) {
                JSONObject jsonObject = new JSONObject(response);
                int status = jsonObject.getInt("status");
                if (status == 200) {
                    result = jsonObject.getString("data");
                    result = result.replaceAll("<\\?xml version=\"1.0\" encoding=\"utf-8\"\\?>", "");
                    if (result.startsWith("error")) {
                        return result;
                    }
                }
            }
            return result;
        }
    }
    /***************************************************************************************************************************/
    /**
     * 获取检查报告信息
     * 获取检查报告信息 (X)
     */
    private JSONArray getChecking(String strSSID, String startNum, String endNum) throws Exception {
        String api = "/third/smjk/ExamReport";
@ -317,7 +501,7 @@ public class JwSmjkService {
    }
    /**
     * 获取检验报告信息
     * 获取检验报告信息(X)
     */
    private JSONArray getInspection(String strSSID, String startNum, String endNum) throws Exception {
        String api = "/third/smjk/LabReport";
@ -396,7 +580,7 @@ public class JwSmjkService {
    }
    /**
     * 获取检查检验 信息
     * 获取检查检验 信息(X)
     * @param strSSID
     * @param startNum
     * @param endNum
@ -446,10 +630,9 @@ public class JwSmjkService {
            return total.toString();
        }
    }
    /****************************************************************************************************************************/
    /**
     * 获取用药记录
     * 获取用药记录(X)
     */
    public String getDrugsList(String strSSID, String startNum,String endNum) throws Exception {
        if(SystemConf.getInstance().getEhrUsed())     //演示环境
@ -538,23 +721,4 @@ public class JwSmjkService {
            return resultArray.toString();
        }
    }
    /**
     * 获取转诊预约医生号源信息
     */
    public String getRegDeptSpeDoctorSectionList(String OrgCode,String DeptCode,String strStart,String strEnd,String DocCode)  throws Exception
    {
        String re = "";
        String url = jwUrl + "/third/smjk/RegDeptSpeDoctorSectionList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("OrgCode", OrgCode));
        params.add(new BasicNameValuePair("DeptCode", DeptCode));
        params.add(new BasicNameValuePair("strStart", strStart));
        params.add(new BasicNameValuePair("strEnd", strEnd));
        params.add(new BasicNameValuePair("DocCode", DocCode));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
}

+ 10 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -175,7 +175,7 @@ public class PushMsgTask {
    /**
     * 发送微信模板消息
     *
     * @param type 1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育
     * @param type 1:签约成功  2:签约失败  3:咨询回复通知  4:健康指导提醒  5:解约申请通知  6:预约挂号成功通知  7:预约取消通知 8 缴费提醒 9 健康教育  10 签约医生变更
     * @param json 当type==1||type==2时:{"first":"消息主题",”doctor":"医生code","doctorName":"医生名","date":"签约时间","content":"签约内容","remark":"消息备注"}
     *             type==3时:{"first":"消息主题","consult":"医生咨询编号","consultcontent":"咨询内容","replycontent":"回复内容","doctorName":"医生名","remark":"消息备注"}
     *             type==4时:{"first":"消息主题","date":"指导时间","orgName":"指导机构","doctorName":"指导医生名","content":"指导内容","remark":"消息备注"}
@ -183,6 +183,7 @@ public class PushMsgTask {
     *             type==6时:{"first":"消息主题","date":"预约时间",”id":"预约ID","doctorName":"医生名","orgName":"预约医院","deptName":"预约科室","remark":"消息备注"}
     *             type==7时:{"first":"消息主题","name":"就诊人名","date":"预约时间","doctorName":"医生名","orgName":"预约医院","remark":"消息备注"}
     *             type==9时:{"first":"消息主题","name":"患教标题","doctorName":"医生名","date":"发送时间","remark":"消息备注"}
     *             type==10时:{"first":"消息主题","name":"患教标题","doctorName":"医生名","date":"发送时间","remark":"消息备注"}
     * @return
     */
    private boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
@ -405,6 +406,14 @@ public class PushMsgTask {
                keyword5.setColor("#000000");
                keyword5.setValue(json.getString("remark"));
                m.put("remark", keyword5);
            } else if (type == 10){
                temp.setUrl("");
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties()
                        .getProperty("template_healthy_article"));
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
            }
            temp.setData(m);
            ObjectMapper mapper = new ObjectMapper();

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/RecordController.java

@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 */
@Controller
@RequestMapping(value = "/wlyy_service/record", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-健康档案服务")
@Api(description = "医生端-健康档案服务(旧版本接口)")
public class RecordController extends BaseController {
    @Autowired

+ 14 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -70,12 +70,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
     */
    @RequestMapping(value = "getPatientByLevel")
    @ResponseBody
    public String getPatientByLevel() {
    public String getPatientByLevel(String doctorCode) {
        try {
            JSONObject returnJO = new JSONObject();
            Map<String, List<Patient>> list = familyContractService.getPatientByLevel(getUID());
            if(list!=null&&list.size()>0){
                for(Map.Entry<String, List<Patient>> entyr:list.entrySet()) {
            Map<String, List<Patient>> list = familyContractService.getPatientByLevel(doctorCode);
            if (list != null && list.size() > 0) {
                for (Map.Entry<String, List<Patient>> entyr : list.entrySet()) {
                    JSONArray array = new JSONArray();
                    addList(returnJO, entyr.getValue(), array, entyr.getKey());
                }
@ -110,19 +110,22 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            returnJO.put(key, array);
        }
    }
    /**
     * 根据标签查看当前医生签约的居民
     * 根据标签查看当前医生签约的居民  3 健康管理师  2是全科
     */
    @RequestMapping(value = "/getPatientByLable")
    @ResponseBody
    public String getPatientByLable(String labelType) {
    public String getPatientByLable(String labelType, String level, String doctorcode) {
        try {
            JSONObject list = familyContractService.getPatientByLable(getUID(), labelType);
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 医生签约患者列表查询接口
     *
@ -836,7 +839,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            String labelType,
            @RequestParam(required = false) String patientName) {
        try {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(),labelType,patientName);
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
@ -846,6 +849,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    /**
     * 搜索患者
     *
     * @param patientAddr
     * @param patientName
     * @return
@ -856,13 +860,14 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            @RequestParam(required = false) String patientAddr,
            @RequestParam(required = false) String patientName) {
        try {
            JSONArray list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(),patientAddr,patientName);
            JSONArray list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), patientAddr, patientName);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取没有健康管理师的签约数据数目
     *

+ 157 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java

@ -0,0 +1,157 @@
package com.yihu.wlyy.web.patient.archives;
import com.yihu.wlyy.service.app.archives.PatientEventService;
import com.yihu.wlyy.service.app.archives.PatientRecordService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/11/24.
 */
@Controller
@RequestMapping(value = "/patient/archives", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-健康档案服务接口")
public class PatientArchivesController extends BaseController {
    @Autowired
    private PatientRecordService patientRecordService;
    @Autowired
    private PatientEventService patientEventService;
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getAllEvent(@ApiParam(name="type",value="类型",defaultValue = "")
                              @RequestParam(value="type",required = false) String type,
                              @ApiParam(name="page",value="第几页",defaultValue = "1")
                              @RequestParam(value="page",required = true) String page,
                              @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
                              @RequestParam(value="pageSize",required = true) String pageSize) {
        try {
            List<Map<String,String>> result = patientRecordService.getAllEvent(getUID(),type,page,pageSize);
            return write(200, "获取就诊记录成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取门/急诊数据失败!");
        }
    }
    @RequestMapping(value = "/event/healthData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取健康档案详情(基卫)")
    public String getHealthData(@ApiParam(name="event",value="事件ID",defaultValue = "")
                                @RequestParam(value="event",required = true) String event,
                                @ApiParam(name="catalog",value="档案类型",defaultValue = "")
                                @RequestParam(value="catalog",required = true) String catalog,
                                @ApiParam(name="strSerial",value="该类别顺序号,默认填1",defaultValue = "1")
                                @RequestParam(value="strSerial",required = true) String strSerial) {
        try {
            String result = patientRecordService.getHealthData(getUID(), event, catalog, strSerial);
            return write(200, "获取健康档案详情成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取健康档案详情失败!");
        }
    }
    @RequestMapping(value = "/event/catalog", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("通过事件号获取档案类型列表(基卫)")
    public String getEventCatalog(@ApiParam(name="event",value="事件ID",defaultValue = "")
                                @RequestParam(value="event",required = true) String event) {
        try {
            List<Map<String,Object>> result = patientRecordService.getEventCatalog(event);
            return write(200, "通过事件号获取档案类型列表成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    @RequestMapping(value = "/event/drug", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取用药记录(基卫)")
    public String getDrugsList(@ApiParam(name="page",value="第几页",defaultValue = "1")
                                   @RequestParam(value="page",required = true) String page,
                               @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
                                   @RequestParam(value="pageSize",required = true) String pageSize) {
        try {
            String result = patientRecordService.getDrugsListPage(getUID(), page, pageSize);     //"P20161008001"
            return write(200, "获取用药记录成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取用药记录失败!");
        }
    }
    @ApiOperation("获取检查检验报告(基卫+APP)")
    @RequestMapping(value = "/event/report", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public String getReportList(@ApiParam(name="page",value="第几页",defaultValue = "1")
                                    @RequestParam(value="page",required = true) String page,
                                @ApiParam(name="pageSize",value="每页几行",defaultValue = "10")
                                    @RequestParam(value="pageSize",required = true) String pageSize)
    {
        try {
            List<Map<String,String>> result = patientRecordService.getExamAndLabReport(getUID(), page, pageSize);
            return write(200, "获取检查检验报告成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取检查检验报告失败!");
        }
    }
    /******************************************* 就诊事件管理 **********************************************************/
    @RequestMapping(value = "/event/detail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取就诊事件详情")
    public String getEventDetail(@ApiParam(name="event",value="事件ID",defaultValue = "")
                                 @RequestParam(value="event",required = true) String event)
    {
        try {
            JSONObject result = patientEventService.getEventDetail(event);
            return write(200, "获取就诊事件详情成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取就诊事件详情失败!");
        }
    }
    @RequestMapping(value = "/event/save", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("保存就诊事件详情")
    public String saveEventDetail(@ApiParam(name="data",value="就诊事件json数据",defaultValue = "")
                                 @RequestParam(value="data",required = true) String data)
    {
        try {
            patientEventService.saveEventDetail(data);
            return write(200, "保存就诊事件成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "保存就诊事件失败!");
        }
    }
}