wujunjie %!s(int64=7) %!d(string=hai) anos
pai
achega
6445c72b81

+ 11 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionFollowupContent.java

@ -20,6 +20,7 @@ public class PrescriptionFollowupContent extends IdEntity {
	private String followupProject;   //随访问卷详情类型ID(目前有1-10,和随访信息详情分类一致)
	private String followupKey;       //随访问卷详情指标KEY(和随访记录一致)
	private String followupValue;     //随访问卷详情指标值(和随访记录一致)
	private String patientCode;       //患者CODE
	private Date createTime;
	
	@Basic
@ -91,4 +92,14 @@ public class PrescriptionFollowupContent extends IdEntity {
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@Basic
	@Column(name = "patient_code")
	public String getPatientCode() {
		return patientCode;
	}
	
	public void setPatientCode(String patientCode) {
		this.patientCode = patientCode;
	}
}

+ 0 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/es/ElastricSearchSave.java

@ -1,11 +1,9 @@
package com.yihu.wlyy.config.es;
import com.alibaba.fastjson.JSONObject;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import io.searchbox.core.Update;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionFollowupContentDao.java

@ -23,4 +23,7 @@ public interface PrescriptionFollowupContentDao extends
	@Modifying
	@Query("delete PrescriptionFollowupContent p where p.prescriptionCode=?1 and p.followupProject=?2")
	void deleteByPrescriptioncodeAndFollowupProject(String prescriptioncode, String followupProject);
	
	@Query("from PrescriptionFollowupContent p where p.prescriptionCode=?1")
	List<PrescriptionFollowupContent> findByPrescriptionCode(String prescriptioncode);
}

+ 245 - 67
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -2,6 +2,9 @@ package com.yihu.wlyy.service.app.followup;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.es.entity.FollowupContentESDO;
import com.yihu.wlyy.config.es.ElasticFactory;
import com.yihu.wlyy.config.es.ElastricSearchSave;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
@ -133,22 +136,22 @@ public class FollowUpService extends BaseService {
        re.put("followupTypeName", followupTypeName);
        //随访类别转译
        
        String followupClass = followup.getFollowupClass();
        re.put("followupClass", followupClass);
    
        String followupClassName = systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followup.getFollowupClass());
        if (StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")) {
        if(StringUtils.isNoneBlank(followupClass) && followupClass.contains(",")){
            String[] followupClassArray = followupClass.split(",");
            followupClassName = "";
            for (int i = 0; i < followupClassArray.length; i++) {
                followupClassName += systemDictService.getDictValue("FOLLOWUP_CLASS_DICT", followupClassArray[i]);
                if (i != followupClassArray.length - 1) {
                    followupClassName += ",";
                if(i != followupClassArray.length -1){
                    followupClassName +=",";
                }
            }
        }
        
        re.put("followupClassName", followupClassName);
        //随访管理状态转译
@ -181,23 +184,23 @@ public class FollowUpService extends BaseService {
            for (Followup followup : list) {
                String date = DateUtil.dateToStrShort(followup.getFollowupDate());
                Map<String, String> map = getFollowupDetail(followup);
                if (temp.containsKey(date)) {
                if(temp.containsKey(date)){
                    Map<String, Object> vo = temp.get(date);
                    vo.put("num", Integer.parseInt(vo.get("num").toString()) + 1);
                    ((List<Map<String, String>>) vo.get("list")).add(map);
                    temp.put(date, vo);
                } else {
                    vo.put("num",Integer.parseInt(vo.get("num").toString())+1);
                    ((List<Map<String, String>>)vo.get("list")).add(map);
                    temp.put(date,vo);
                }else{
                    Map<String, Object> vo = new HashMap<>();
                    List<Map<String, String>> list1 = new ArrayList<>();
                    vo.put("date", date);
                    vo.put("num", 1);
                    vo.put("date",date);
                    vo.put("num",1);
                    list1.add(map);
                    vo.put("list", list1);
                    temp.put(date, vo);
                    vo.put("list",list1);
                    temp.put(date,vo);
                }
            }
            for (Map<String, Object> map : temp.values()) {
            for (Map<String, Object> map:temp.values()){
                re.add(map);
            }
        }
@ -212,26 +215,25 @@ public class FollowUpService extends BaseService {
     * @param teamCode
     * @param page
     * @param pageSize
     * @param type     类型:0全部,1计划,2记录
     * @param type 类型:0全部,1计划,2记录
     * @return
     */
    public JSONArray getListByPatientAndTeam(String patient, Long teamCode, int page, int pageSize, String type) {
        Sort sort = new Sort(Sort.Direction.DESC, "createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize, sort);
        Sort sort = new Sort(Sort.Direction.DESC,"createTime");
        PageRequest pageRequest = new PageRequest(page, pageSize,sort);
        Page<Object> result = null;
        if (StringUtils.isBlank(type)) {
        
        if(StringUtils.isBlank(type)){
            result = followupDao.findByPatientAndTeam(patient, teamCode, pageRequest);
        } else if ("1".equals(type)) {
        }else if("1".equals(type)){
            //已经开始的就是记录
            result = followupDao.findPlanByPatientAndTeam(patient, teamCode, pageRequest);
        } else if ("2".equals(type)) {
        }else if("2".equals(type)){
            //未开始的就是计划
            result = followupDao.findRecordByPatientAndTeam(patient, teamCode, pageRequest);
        } else {
        }
        }else{}
                
        
        JSONArray array = new JSONArray();
        if (result != null && result.getContent().size() > 0) {
@ -261,10 +263,10 @@ public class FollowUpService extends BaseService {
                Object[] objArr = (Object[]) obj;
//              返回值增加居民信息
                Patient patientDetail = patientDao.findByCode(patient);
                followup.put("patientName", patientDetail.getName() != null ? patientDetail.getName() : "");
                followup.put("photo", patientDetail.getPhoto() != null ? patientDetail.getPhoto() : "");
                followup.put("sex", patientDetail.getSex() != null ? patientDetail.getSex() : "");
                followup.put("birthday", patientDetail.getBirthday() != null ? patientDetail.getBirthday() : "");
                followup.put("patientName", patientDetail.getName()!=null?patientDetail.getName():"");
                followup.put("photo", patientDetail.getPhoto()!=null?patientDetail.getPhoto():"");
                followup.put("sex", patientDetail.getSex()!=null?patientDetail.getSex():"");
                followup.put("birthday", patientDetail.getBirthday()!=null?patientDetail.getBirthday():"");
                followup.put("id", objArr[15]);
                followup.put("followupNo", objArr[16]);
@ -274,35 +276,34 @@ public class FollowUpService extends BaseService {
                followup.put("followupType", objArr[3] == null ? "" : objArr[3]);
                followup.put("followupTypeName", objArr[3] == null ? "" : (dictMap.get(objArr[3].toString()) != null ? dictMap.get(objArr[3].toString()) : ""));
                followup.put("followupClass", objArr[4] == null ? "" : objArr[4]);
    
//                followup.put("followupClassName", objArr[4] == null ? "" : (objArr[4].toString().equals("1") ? "高血压" : "糖尿病"));
                if (objArr[4] == null) {
               
                if( objArr[4] == null){
                    followup.put("followupClassName", "");
                } else {
                    if (objArr[4].toString().equals("1")) {
                }else{
                    if(objArr[4].toString().equals("1")){
                        followup.put("followupClassName", "高血压");
                    } else if (objArr[4].toString().equals("2")) {
                    }else if(objArr[4].toString().equals("2")){
                        followup.put("followupClassName", "糖尿病");
                    } else if (objArr[4].toString().equals("1,2")) {
                    }else if(objArr[4].toString().equals("3")){
                        followup.put("followupClassName", "高血压,糖尿病");
                    } else {
                    }
                    }else{}
                }
                
                
                followup.put("status", objArr[5] == null ? "" : objArr[5]);
                followup.put("statusName", objArr[5] == null ? "" : (statusMap.get(objArr[5].toString()) != null ? statusMap.get(objArr[5].toString()) : ""));
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date) objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date) objArr[7]) : "");
                followup.put("createTime", objArr[6] != null ? DateUtil.dateToStrLong((Date)objArr[6]) : "");
                followup.put("updateTime", objArr[7] != null ? DateUtil.dateToStrLong((Date)objArr[7]) : "");
                followup.put("followupManagerStatus", objArr[8] == null ? "" : objArr[8]);
                followup.put("followupManagerStatusName", objArr[8] == null ? "" : (mngStatusMap.get(objArr[8].toString()) != null ? mngStatusMap.get(objArr[8].toString()) : ""));
                followup.put("creatorCode", objArr[9]);
                followup.put("creatorName", objArr[10]);
                followup.put("creatorPhoto", objArr[11]);
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date) objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date) objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date) objArr[14]) : "");
                followup.put("followupDate", objArr[12] != null ? DateUtil.dateToStrLong((Date)objArr[12]) : "");
                followup.put("followupPlanDate", objArr[13] != null ? DateUtil.dateToStrLong((Date)objArr[13]) : "");
                followup.put("followupNextDate", objArr[14] != null ? DateUtil.dateToStrLong((Date)objArr[14]) : "");
                array.put(followup);
            }
        }
@ -350,7 +351,7 @@ public class FollowUpService extends BaseService {
            SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
            if (signFamily == null) {
                signFamily = signFamilyDao.findBySanshiPatient(patientCode);
                if (signFamily == null) {
                if(signFamily==null){
                    throw new Exception("can not find patient's family sign info");
                }
            }
@ -415,12 +416,12 @@ public class FollowUpService extends BaseService {
    /**
     * 开始随访记录
     */
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus, String plandate) throws Exception {
    public void startFollowup(String id, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setFollowupDate(DateUtil.strToDate(date));
            //计划下次随访时间--huangwenjie.2017.10.19
            if (StringUtils.isNoneBlank(plandate)) {
            if(StringUtils.isNoneBlank(plandate)){
                followup.setFollowupNextDate(DateUtil.strToDate(plandate));
                Followup nextFollowup = new Followup();
                nextFollowup.setDataFrom(followup.getDataFrom());
@ -447,12 +448,13 @@ public class FollowUpService extends BaseService {
                nextFollowup.setIdcard(followup.getIdcard());
                nextFollowup.setSignType(followup.getSignType());
                followupDao.save(nextFollowup);
                
            }
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
            followup.setFollowupManagerStatus(followupManagerStatus);
            followup.setStatus("3");  //状态 0取消 1已完成 2未开始 3进行中
            followup.setPrescriptionCode(prescriptioncode);
            followupDao.save(followup);
        } else {
@ -463,7 +465,7 @@ public class FollowUpService extends BaseService {
    /**
     * 新增临时随访记录(返回ID)
     */
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus, String plandate) throws Exception {
    public String addFollowup(String doctorCode, String patientCode, String date, String followupType, String followupClass, String followupManagerStatus,String plandate,String prescriptioncode) throws Exception {
        String re = "";
        //获取医生信息
@ -480,8 +482,8 @@ public class FollowUpService extends BaseService {
        SignFamily signFamily = signFamilyDao.findByjiatingPatient(patientCode);
        if (signFamily == null) {
            signFamily = signFamilyDao.findBySanshiPatient(patientCode);
            if (signFamily == null)
                throw new Exception("can not find patient's family sign info");
            if(signFamily==null)
               throw new Exception("can not find patient's family sign info");
        }
        Followup followup = new Followup();
@ -499,16 +501,21 @@ public class FollowUpService extends BaseService {
        followup.setFollowupClass(followupClass);
        followup.setFollowupManagerStatus(followupManagerStatus);
        followup.setDataFrom("2");//数据来源 1基卫 2APP
        followup.setStatus("3");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中
        followup.setCreateTime(new Date());
        followup.setCreater(doctorCode);
        followup.setAdminTeamCode(signFamily.getAdminTeamId());
        followup.setSignType(2);
        //保存质询code
        followup.setSignCode(patientService.getSignCodeByPatient(patientCode));
        
        //如果有填入续方CODE,则添加续方关联--huangwenjie.2017.11.02
        if(StringUtils.isNotBlank(prescriptioncode)){
            followup.setPrescriptionCode(prescriptioncode);
        }
        //计划下次随访时间--ysj.2017.10.26
        if (StringUtils.isNoneBlank(plandate)) {
        if(StringUtils.isNoneBlank(plandate)){
            followup.setFollowupNextDate(DateUtil.strToDate(plandate));
            Followup nextFollowup = new Followup();
            nextFollowup.setDataFrom(followup.getDataFrom());
@ -564,22 +571,22 @@ public class FollowUpService extends BaseService {
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followup = followupDao.save(followup);
    
            //上传随访计划映射表记录
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            if (followupMapping == null) {
            
            if(followupMapping == null){
                followupMapping = new FollowupMapping();
            }
    
            followupMapping.setFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            followupMapping.setCode(UUID.randomUUID().toString());
            followupMapping.setCreateTime(DateUtil.getNowTimestamp());
            followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
            followupMapping.setNeedUpload(1);
            
            followUpMappingDao.save(followupMapping);
           
//            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
        } else {
            throw new Exception("not exit follow:" + id + ".\r\n");
@ -607,7 +614,9 @@ public class FollowUpService extends BaseService {
    public List<Map<String, String>> getFollowupProject(String id) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        //获取已填写的面访项目
        List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
//        List<String> project = followupContentDao.findProjectByFollowupId(Long.valueOf(id));
        //修改为通过ES查询---2017.11.01--huangwenjie
        List<String> project = esfindProjectByFollowupId(id);
        //获取所有面访项目
        List<SystemDict> dictList = systemDictService.getDictByDictName("FOLLOWUP_PROJECT");
        if (dictList != null && dictList.size() > 0) {
@ -666,13 +675,13 @@ public class FollowUpService extends BaseService {
            followupContentDao.save(newList);
        }
    
        Followup followup = followupDao.findOne(Long.valueOf(id));
    
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        if ("1".equals(followup.getStatus())) {
        if("1".equals(followup.getStatus())){
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if (followupMapping == null) {
            if(followupMapping == null){
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
@ -858,5 +867,174 @@ public class FollowUpService extends BaseService {
            e.printStackTrace();
        }
    }
    
    /**
     *ES 保存随访记录详情
     *@author huangwenjie
     *@date 2017/11/1 14:57
     */
    @Transactional
    public void esSaveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        List<FollowupContentESDO> dataList = result.getSourceAsObjectList(FollowupContentESDO.class);
        
        //删除原有记录
        this.esDeleteFollowUpContent(dataList);
        
        //保存新的随访详情信息
        List<FollowupContentESDO> newdatalist = new ArrayList<>();
        FollowupContentESDO followupContentESDO = new FollowupContentESDO();
    
        followupContentESDO = JSON.parseObject(followupProjectData,FollowupContentESDO.class);
    
        followupContentESDO.setFollowup_id(id);
        followupContentESDO.setFollowup_project(followupProject);
        followupContentESDO.setCreate_time(new Date());
        newdatalist.add(followupContentESDO);
        elastricSearchSave.save(newdatalist,esIndex,esType);
        
        
        //如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if("1".equals(followup.getStatus())){
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
            if(followupMapping == null){
                followupMapping = new FollowupMapping();
                followupMapping.setCode(UUID.randomUUID().toString());
                followupMapping.setFollowupId(Integer.parseInt(id));
                followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
                followupMapping.setCreateTime(DateUtil.getNowTimestamp());
            }
            followupMapping.setNeedUpload(1);
            followUpMappingDao.save(followupMapping);
        }
    }
    
    /**
     * ES获取面访项目数据
     */
    public FollowupContentESDO esGetFollowupProjectData(String id, String followupProject) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
    
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
                        .must(QueryBuilders.matchQuery("followup_project", followupProject))
        );
    
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        FollowupContentESDO followupContentESDO  = result.getSourceAsObject(FollowupContentESDO.class);
        return followupContentESDO;
    }
    
    /**
     *ES 删除随访详情信息
     *@author huangwenjie
     *@date 2017/11/1 15:17
     */
    public void esDeleteFollowUpContent(List<FollowupContentESDO> datalist) throws Exception{
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (FollowupContentESDO obj : datalist) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
    
            logger.info("delete data count:" + datalist.size());
            logger.info("delete flag:" + br.isSucceeded());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    
    /**
     * ES获取面访项目数据列表
     *@author huangwenjie
     *@date 2017/11/1 19:41
     */
    public List<String>  esfindProjectByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
    
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        followupContentESDOList  = result.getSourceAsObjectList(FollowupContentESDO.class);
        if(!followupContentESDOList.isEmpty()){
            for (FollowupContentESDO followupContentESDO: followupContentESDOList) {
                resultList.add(followupContentESDO.getFollowup_project());
            }
        }
        
        return resultList;
    }
    
    /**
     * ES获取面访项目数据详情
     *@author huangwenjie
     *@date 2017/11/1 19:41
     */
    public List<FollowupContentESDO>  esfindFollowUpContestsByFollowupId(String id) throws Exception {
        //根据随访ID、分类ID获取随访记录详情
        
        List<String> resultList = new ArrayList<>();
        
        JestClient jestClient = elasticFactory.getJestClient();
        //先根据条件查找出来
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        searchSourceBuilder.query(
                new BoolQueryBuilder()
                        .must(QueryBuilders.matchQuery("followup_id", id))
        );
        
        Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                .build();
        SearchResult result = jestClient.execute(search);
        
        List<FollowupContentESDO> followupContentESDOList = new ArrayList<>();
        
        return followupContentESDOList;
    }
    
    public String getFollowupByPrescriptionCode(String prescriptionCode) {
        Followup followup = followupDao.getFollowupByPrescriptionCode(prescriptionCode);
    
        String jsonString = JSON.toJSONString(followup);
        
        return jsonString;
    }
}

+ 63 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java

@ -57,7 +57,7 @@ public class PrescriptionFollowupContentService extends BaseService {
	 * @param followupProjectData
	 * @throws Exception
	 */
	public void saveInfo(String prescriptioncode, String followupProjectData) throws Exception{
	public void saveInfo(String prescriptioncode, String followupProjectData,String patientCode) throws Exception{
		JSONArray objects = JSON.parseArray(followupProjectData);
		
		if(objects!= null & objects.size() >0){
@ -76,6 +76,7 @@ public class PrescriptionFollowupContentService extends BaseService {
							prescriptionFollowupContent.setFollowupProject(followupProject);
							prescriptionFollowupContent.setFollowupKey(key);
							prescriptionFollowupContent.setFollowupValue(value);
							prescriptionFollowupContent.setPatientCode(patientCode);
							savedatas.add(prescriptionFollowupContent);
						});
					}
@ -90,4 +91,65 @@ public class PrescriptionFollowupContentService extends BaseService {
			throw new Exception("保存的分类数据不能为空!");
		}
	}
	
	/**
	 *根据续方CODE获取随访调查问卷列表
	 * @param prescriptioncode
	 * @return
	 */
	public JSONArray getList(String prescriptioncode) throws Exception{
		PrescriptionFollowupContent prescriptionFollowupContent1 = null;
		PrescriptionFollowupContent prescriptionFollowupContent2 = null;
		
		List<PrescriptionFollowupContent>  list = prescriptionFollowupContentDao.findByPrescriptionCode(prescriptioncode);
		
		for (PrescriptionFollowupContent prescriptionFollowupContent: list) {
			
			if("1".equals(prescriptionFollowupContent.getFollowupProject())){
				if(prescriptionFollowupContent1 != null){
					prescriptionFollowupContent1 = prescriptionFollowupContent;
				}else{
					continue;
				}
			}
			
			if("2".equals(prescriptionFollowupContent.getFollowupProject())){
				if(prescriptionFollowupContent2 != null){
					prescriptionFollowupContent2 = prescriptionFollowupContent;
				}else{
					continue;
				}
			}
			
			if("4".equals(prescriptionFollowupContent.getFollowupProject())){
				if(prescriptionFollowupContent2 != null){
					prescriptionFollowupContent2 = prescriptionFollowupContent;
				}else{
					continue;
				}
			}
		}
		
		JSONArray result = new JSONArray();
		
		if(prescriptionFollowupContent1 != null){
			JSONObject jsonObject1 = new JSONObject();
			jsonObject1.put("type","1");
			jsonObject1.put("name","身份异常症状问卷");
			jsonObject1.put("statue","已填写");
			jsonObject1.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject1);
		}
		
		if(prescriptionFollowupContent2 != null){
			JSONObject jsonObject2 = new JSONObject();
			jsonObject2.put("type","2");
			jsonObject2.put("name","体征及生活方式调查问卷");
			jsonObject2.put("statue","已填写");
			jsonObject2.put("createtime",prescriptionFollowupContent1.getCreateTime());
			result.add(jsonObject2);
		}
		
		return result;
	}
}

+ 79 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/DoctorPrescriptionFollowupContentController.java

@ -0,0 +1,79 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionFollowupContent;
import com.yihu.wlyy.service.app.prescription.PrescriptionFollowupContentService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 医生端-续方咨询问卷相关方法
 * @author huangwenjie
 * @date 2017/11/3 08:38
 */
@RestController
@RequestMapping(value = "/doctor/prescription/followupcontent/")
@Api(description = "医生-续方咨询问卷相关接口")
public class DoctorPrescriptionFollowupContentController extends BaseController {
	
	@Autowired
	private PrescriptionFollowupContentService prescriptionFollowupContentService;
	
	
	@RequestMapping(value = "/getinfo", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE、类型CODE,获取随访调查分类数据")
	public String getinfoByPrescriptionCodeAndFollowupProject(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupProject", value = "续方CODE", defaultValue = "问卷类型(症状、体征和问卷)")
			@RequestParam(value = "followupProject", required = true) String followupProject){
		try {
			
			List<PrescriptionFollowupContent> result = prescriptionFollowupContentService.getByPrescriptionCodeAndFollowupProject(prescriptioncode,followupProject);
			
			Map<String, String> datamap = new HashMap<>();
			
			if(!result.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: result) {
					datamap.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			
			return write(200, "请求成功!","data",datamap);
			
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "请求失败,地址不可派送!");
		}
	}
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE获取随访调查问卷列表")
	public String getList(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode){
		try {
			JSONArray result = prescriptionFollowupContentService.getList(prescriptioncode);
			return write(200, "请求成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
			error(e);
			//返回接口异常信息处理结果
			return error(-1, "请求失败!"+e.getMessage());
		}
	}
}

+ 17 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionFollowupContentController.java

@ -12,10 +12,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 续方咨询问卷相关方法
 * 患者端-续方咨询问卷相关方法
 * @author huangwenjie
 * @date 2017/11/1 22:50
 */
@ -29,7 +31,7 @@ public class PatientPrescriptionFollowupContentController extends BaseController
	
	@RequestMapping(value = "/getinfo", method = RequestMethod.GET)
	@ApiOperation("根据续方CODE、类型CODE,获取随访调查分类数据")
	public String getByPrescriptionCodeAndFollowupProject(
	public String getinfoByPrescriptionCodeAndFollowupProject(
			@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
			@RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
			@ApiParam(name = "followupProject", value = "续方CODE", defaultValue = "问卷类型(症状、体征和问卷)")
@ -37,7 +39,16 @@ public class PatientPrescriptionFollowupContentController extends BaseController
		try {
			
			List<PrescriptionFollowupContent> result = prescriptionFollowupContentService.getByPrescriptionCodeAndFollowupProject(prescriptioncode,followupProject);
			return write(200, "请求成功!","data",result);
			
			Map<String, String> datamap = new HashMap<>();
			
			if(!result.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: result) {
					datamap.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
				}
			}
			
			return write(200, "请求成功!","data",datamap);
			
		}catch (Exception e){
			//日志文件中记录异常信息
@ -50,11 +61,11 @@ public class PatientPrescriptionFollowupContentController extends BaseController
	@RequestMapping(value = "/saveinfo", method = RequestMethod.POST)
	@ApiOperation("保存随访调查分类数据")
	public String saveInfo(@ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "续方CODE")
	                           @RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
	                       @RequestParam(value = "prescriptioncode", required = true) String prescriptioncode,
	                       @ApiParam(name = "followupProjectData", value = "调查分类数据", defaultValue = "[{\"followupProject\":\"1\",\"projectData\":{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}}]")
	                       @RequestParam(value = "followupProjectData", required = true) String followupProjectData){
		try {
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData);
			prescriptionFollowupContentService.saveInfo(prescriptioncode,followupProjectData,getUID());
			return write(200, "请求成功!");
		}catch (Exception e){
			//日志文件中记录异常信息
@ -62,6 +73,6 @@ public class PatientPrescriptionFollowupContentController extends BaseController
			//返回接口异常信息处理结果
			return error(-1, "请求失败!"+e.getMessage());
		}
	
		
	}
}