Browse Source

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

# Conflicts:
#	patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
lyr 8 years ago
parent
commit
41c1f90e7b
17 changed files with 1072 additions and 152 deletions
  1. 137 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientEvent.java
  2. 80 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientEventImg.java
  3. 13 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientEventDao.java
  4. 15 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientEventImgDao.java
  5. 87 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientEventService.java
  6. 219 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/archives/PatientRecordService.java
  7. 8 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java
  8. 4 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java
  9. 43 41
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  10. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  11. 270 106
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java
  12. 27 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendP2PUtil.java
  13. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java
  14. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java
  15. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/record/RecordController.java
  16. 3 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  17. 158 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/archives/PatientArchivesController.java

+ 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;
	}
}

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

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientEvent;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientEventDao extends PagingAndSortingRepository<PatientEvent, Long>, JpaSpecificationExecutor<PatientEvent> {
      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;
}

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

@ -0,0 +1,87 @@
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 org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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();
        //修改时先删除原有图片
        //保存就诊记录相关图片
    }
    /**
     * 删除就诊事件详情
     */
    @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);
    }
}

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

@ -0,0 +1,219 @@
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;
    /******************************************************************************************************************/
    /**
     * 获取门/急诊记录 + 住院记录
     */
    public List<Map<String,Object>> getAllEvent(String patientCode, String type, String page, String pageSize) throws Exception
    {
        List<Map<String,Object>> 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);
            for (int i=0;i<array.length();i++) {
                JSONObject item = array.getJSONObject(i);
                Map<String,Object> 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);
            }
            //*******排序、过滤
        }
        else{
        }
        for(PatientEvent item:eventList)
        {
            Map<String,Object> 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,Object>> getExamAndLabReport(String patientCode,String page,String pageSize) throws Exception
    {
        List<Map<String,Object>> 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";
        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,Object> 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);
            }
            //*******排序、过滤
        }
        else{
        }
        for(Map<String,Object> item:appList)
        {
            Map<String,Object> map = new HashMap<>();
            map.put("id",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",item.get("org_name"));
            map.put("label",item.get("label")); //检测项目
            map.put("dataFrom","1");//基卫数据
            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);
    }
}

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java

@ -18,6 +18,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
import org.json.JSONArray;
@ -328,6 +329,13 @@ public class FamilyService {
        }
        patientInviteLogDao.save(patientInvitationLog);
        String content ="";
        if(patient.getSex()==2){
            content = patient.getName()+"小姐,再次感谢您对我的信任。同时,我也衷心的希望能够拥有为您整个家庭提供问下服务的荣幸。在此诚意地邀请您为"+doctor.getName()+"进行签约。";
        }else{
            content = patient.getName()+"先生,再次感谢您对我的信任。同时,我也衷心的希望能够拥有为您整个家庭提供问下服务的荣幸。在此诚意地邀请您为"+doctor.getName()+"进行签约。";
        }
        SendP2PUtil.sendP2Pmsg(doctorCode,patientCode,"1",content);
        return "1";
    }

+ 4 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java

@ -12,6 +12,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -197,7 +198,9 @@ public class ExpensesRemindService extends BaseService {
                PushMsgTask.getInstance().putWxMsg(tokenUtils.getAccessToken(), 8, p.getOpenid(), p.getName(), json);
                wFlag = true;
            }
            //发送IM
            SendP2PUtil.sendP2Pmsg(doc.getCode(),p.getCode(),"1",doc.getName() + "医生提醒您:为完成家庭医生签约," +
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);

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

@ -1773,22 +1773,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);
@ -1796,8 +1796,7 @@ 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 " +
@ -1806,21 +1805,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);
@ -1830,11 +1829,11 @@ 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());
@ -2094,20 +2093,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 " +
@ -2121,15 +2121,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 " +
@ -2139,7 +2140,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);
@ -2155,11 +2156,12 @@ 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是否为空 为空就是未标注

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SOAPUtil;
import com.yihu.wlyy.util.SendP2PUtil;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
@ -496,6 +497,7 @@ public class GuahaoXMService implements IGuahaoService {
                }
                if(StringUtils.isNotBlank(dcode)){
                    reservation.setDoctor(dcode);//代理签约维护待签约人编码
                    SendP2PUtil.sendP2Pmsg(dcode,patient,"1","我已成功为您预约:"+startTime+","+hospitalName+hosDeptName+doctorName+"医生的号源。您可直接前往医院就诊</br><a name='guahao' href='javascript:void(0)' data-id='"+code+"'>点击查看详情</a>");
                }
                // 保存预约记录
                patientReservationDao.save(reservation);

+ 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(re);
                        } 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(re);
                        } 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");
    }
}

+ 27 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SendP2PUtil.java

@ -0,0 +1,27 @@
package com.yihu.wlyy.util;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import java.util.ArrayList;
import java.util.List;
public class SendP2PUtil {
	public static String sendP2Pmsg(String from,String to,String contentType,String content){
		String url = SystemConf.getInstance().getSystemProperties().getProperty("im_list_get")
				+ "api/v1/chats/pm";
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("from", from));
		params.add(new BasicNameValuePair("to", to));
		params.add(new BasicNameValuePair("content",  content));
		params.add(new BasicNameValuePair("contentType",contentType));
		String response = HttpClientUtil.post(url, params, "UTF-8");
		if (StringUtils.isEmpty(response)) {
			return "-1";
		}else{
			return "200";
		}
	}
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthEduArticleController.java

@ -7,7 +7,9 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.health.*;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.SendP2PUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.doctor.message.DoctorMessageController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.htmlparser.Parser;
@ -303,6 +305,7 @@ public class DoctorHealthEduArticleController extends WeixinBaseController {
					// 设置为示读
					heap.setRead(1);
					list.add(heap);
					SendP2PUtil.sendP2Pmsg(doctor.getCode(), p, "4", "{\"title\":\"" + temp.getTitle() + "\",\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}");
					if (StringUtils.isNotEmpty(patientTemp.getOpenid())) {
						// 推送消息给微信端
						JSONObject json = new JSONObject();

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.health;
import com.yihu.wlyy.util.SendP2PUtil;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -79,6 +80,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
			// 保存
			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
				SendP2PUtil.sendP2Pmsg(getUID(), patient, "1",content);
				return success("保存成功!");
			} else {
				return error(-1, "保存失败!");

+ 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

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

@ -111,13 +111,13 @@ public class DoctorFamilyContractController extends WeixinBaseController {
        }
    }
    /**
     * 根据标签查看当前医生签约的居民
     * 根据标签查看当前医生签约的居民  3 健康管理师  2是全科
     */
    @RequestMapping(value = "/getPatientByLable")
    @ResponseBody
    public String getPatientByLable(String labelType) {
    public String getPatientByLable(String labelType,String level) {
        try {
            JSONObject list = familyContractService.getPatientByLable(getUID(), labelType);
            JSONObject list = familyContractService.getPatientByLable(getUID(), labelType,level);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            return error(-1, "查询失败");

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

@ -0,0 +1,158 @@
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,Object>> 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);
            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 {
            //"443a196ef8744536a531260eb26c05d7"
            List<Map<String,Object>> 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, "保存就诊事件失败!");
        }
    }
}