소스 검색

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

zd_123 7 년 전
부모
커밋
0df1bd365b
27개의 변경된 파일952개의 추가작업 그리고 587개의 파일을 삭제
  1. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/Followup.java
  2. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/organization/HospitalMapping.java
  3. 3 3
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdress.java
  4. 2 5
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  5. 9 5
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/SignController.java
  6. 4 4
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/SignZYService.java
  7. 2 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java
  8. 18 9
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  9. 6 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/followup/FollowUpMappingDao.java
  10. 5 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/organization/HospitalMappingDao.java
  11. 7 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java
  12. 418 385
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  13. 42 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  14. 5 3
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  15. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java
  16. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpMappingDao.java
  17. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdressDao.java
  18. 49 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  19. 2 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  20. 99 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdressService.java
  21. 36 19
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  22. 103 135
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  23. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  24. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  25. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  26. 72 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java
  27. 2 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/followup/Followup.java

@ -41,6 +41,8 @@ public class Followup extends IdEntity {
	private String orgCode;
	//社区名称
	private String orgName;
	//基卫机构编码
	private String jworgCode;
	//患者代码
	private String patientCode;
	//患者姓名
@ -262,4 +264,12 @@ public class Followup extends IdEntity {
	public void setJwdoctorCode(String jwdoctorCode) {
		this.jwdoctorCode = jwdoctorCode;
	}
	
	public String getJworgCode() {
		return jworgCode;
	}
	
	public void setJworgCode(String jworgCode) {
		this.jworgCode = jworgCode;
	}
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/organization/HospitalMapping.java

@ -29,6 +29,8 @@ public class HospitalMapping extends IdEntity {
    private String appSecret;
    //机构编码号(来自基卫)
    private String sbCode;
    // 基卫授权码
    private String licence;
    public String getSbCode() {
        return sbCode;
@ -85,4 +87,12 @@ public class HospitalMapping extends IdEntity {
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    
    public String getLicence() {
        return licence;
    }
    
    public void setLicence(String licence) {
        this.licence = licence;
    }
}

+ 3 - 3
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionAdress.java

@ -23,7 +23,7 @@ public class PrescriptionAdress extends IdEntity {
    private String cityName;//城市
    private String townName;//区
    private String adress; //地址
    private String defaultFlag;//0.非首选,1.首选
    private Integer defaultFlag;//0.非首选,1.首选
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
@ -107,11 +107,11 @@ public class PrescriptionAdress extends IdEntity {
        this.adress = adress;
    }
    public String getDefaultFlag() {
    public Integer getDefaultFlag() {
        return defaultFlag;
    }
    public void setDefaultFlag(String defaultFlag) {
    public void setDefaultFlag(Integer defaultFlag) {
        this.defaultFlag = defaultFlag;
    }

+ 2 - 5
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -19,9 +19,6 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -675,7 +672,7 @@ public class DeviceService {
            String value1 = data.getValue1();
            // 餐后
            if (index % 2 == 0) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter ,minValueAfter )) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
                    //体征异常,更新体征数据状态
@ -683,7 +680,7 @@ public class DeviceService {
                    patientHealthIndexDao.save(data);
                }
            } else { //餐前
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) {
                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) {
                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L),请处理";
                    //体征异常,更新体征数据状态

+ 9 - 5
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/SignController.java

@ -133,11 +133,13 @@ public class SignController {
            @ApiParam(name="TIME_END",value="修改的开始时间",defaultValue = "2017-06-7 23:59:59")
            @RequestParam(value="TIME_END",required = false) String TIME_END,
            @ApiParam(name="IDENTITY_CARD_NO",value="身份证号",defaultValue = "350221197506113526")
            @RequestParam(value="IDENTITY_CARD_NO",required = false) String IDENTITY_CARD_NO){
            @RequestParam(value="IDENTITY_CARD_NO",required = false) String IDENTITY_CARD_NO,
            @ApiParam(name="ORG_CODE",value="机构代码",defaultValue = "3502030500")
            @RequestParam(value="ORG_CODE",required = false) String ORG_CODE){
        try {
            String response = "";
            if(StringUtils.isBlank(IDENTITY_CARD_NO)){
                response = signZYService.getEhrChroDaysFollowUpInfoRecord(TIME_START,TIME_END);
                response = signZYService.getEhrChroDaysFollowUpInfoRecord(TIME_START,TIME_END,ORG_CODE);
            }else{
                response = signZYService.getEhrChroDaysFollowUpInfoRecordByIdcard(IDENTITY_CARD_NO);
            }
@ -156,14 +158,16 @@ public class SignController {
    }
    
    @RequestMapping(value = "uploadEhrSickChroDaysFollowUpRecord",method = RequestMethod.POST)
    @ApiOperation("查询家庭医生服务日常随访信息接口")
    @ApiOperation("上传家庭医生服务日常随访信息")
    public Result uploadEhrSickChroDaysFollowUpRecord(
            @ApiParam(name="OPERATOR",value="操作员代码",defaultValue = "")
            @RequestParam(value="OPERATOR",required = true) String OPERATOR,
            @ApiParam(name="data",value="Json格式字符串",defaultValue = "")
            @RequestParam(value="data",required = true) String data){
            @RequestParam(value="data",required = true) String data,
            @ApiParam(name="ORG_CODE",value="机构代码",defaultValue = "3502030500")
            @RequestParam(value="ORG_CODE",required = false) String ORG_CODE){
        try {
            String response = signZYService.uploadEhrSickChroDaysFollowUpRecord(OPERATOR,data);
            String response = signZYService.uploadEhrSickChroDaysFollowUpRecord(OPERATOR,data,ORG_CODE);
            return Result.success("上传成功!",response);
        } catch (Exception ex) {
            ex.printStackTrace();

+ 4 - 4
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/SignZYService.java

@ -145,8 +145,8 @@ public class SignZYService {
     * @param time_end
     * @return
     */
	public String getEhrChroDaysFollowUpInfoRecord(String time_start, String time_end)  throws Exception{
        String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
	public String getEhrChroDaysFollowUpInfoRecord(String time_start, String time_end,String ORG_CODE)  throws Exception{
        String[] hospitalMapping = getHospitalMapping(ORG_CODE); //获取机构映射
        String response = zysoftService.getEhrChroDaysFollowUpInfoRecord(time_start,time_end,hospitalMapping[0],hospitalMapping[1]);
        return response;
	}
@ -168,8 +168,8 @@ public class SignZYService {
     * @param data
     * @return
     */
	public String uploadEhrSickChroDaysFollowUpRecord(String operator, String data) throws Exception{
        String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
	public String uploadEhrSickChroDaysFollowUpRecord(String operator, String data,String ORG_CODE) throws Exception{
        String[] hospitalMapping = getHospitalMapping(ORG_CODE); //获取机构映射
        String response = zysoftService.uploadEhrSickChroDaysFollowUpRecord(operator,data,hospitalMapping[0],hospitalMapping[1]);
        return response;
	}

+ 2 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java

@ -828,6 +828,7 @@ public class ZysoftService {
        header.put("LICENCE",licence);
        
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("TIME_START",time_start);
        params.put("TIME_END",time_end);
        
@ -868,7 +869,7 @@ public class ZysoftService {
        
        com.alibaba.fastjson.JSONObject json = JSON.parseObject(data);
        
        String response = postSecond("getEhrChroDaysFollowUpInfoRecord","查询家庭医生服务日常随访信息接口",json,header);
        String response = postSecond("uploadEhrSickChroDaysFollowUpRecord ","上传家庭医生服务日常随访信息",json,header);
        
        return response;
	}

+ 18 - 9
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -30,13 +30,13 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
        try {
            // 启动签约到期处理JOB
            if (!quartzHelper.isExistJob("sign_end_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_end_job_trigger");
                quartzHelper.addJob(SignEndJob.class, trigger, "sign_end_job", new HashMap<String, Object>());
                logger.info("sign end job start success");
            } else {
                logger.info("sign end job exist");
            }
//            if (!quartzHelper.isExistJob("sign_end_job")) {
//                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_end_job_trigger");
//                quartzHelper.addJob(SignEndJob.class, trigger, "sign_end_job", new HashMap<String, Object>());
//                logger.info("sign end job start success");
//            } else {
//                logger.info("sign end job exist");
//            }
            if (!quartzHelper.isExistJob("evaluate_score_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("evaluate_score_job");
                quartzHelper.addJob(EvaluateScoreJob.class, trigger, "evaluate_score_job", new HashMap<String, Object>());
@ -170,7 +170,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("old_people_tijian_syb_job  job exist");
            }
    
            //居民随访信息同步,每天陵城3点执行一次
            //居民随访信息同步,每天凌晨3点执行一次
            if (!quartzHelper.isExistJob("patient_followup_syb_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("patient_followup_syb_job");
                quartzHelper.addJob(FollowUpSynJob.class, trigger, "patient_followup_syb_job", new HashMap<String, Object>());
@ -178,11 +178,20 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("patient_followup_syb_job  job exist");
            }
    
            //居民随访信息上传基卫,每天凌晨4点执行一次
            if (!quartzHelper.isExistJob("patient_followup_upload_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("patient_followup_upload_job");
                quartzHelper.addJob(FollowUpUploadJob.class, trigger, "patient_followup_upload_job", new HashMap<String, Object>());
                logger.info("patient_followup_upload_job  job success");
            } else {
                logger.info("patient_followup_upload_job  job exist");
            }
            //老年人体检消息发送记录,每天凌晨1点执行一次
            if (!quartzHelper.isExistJob("patient_physical_examination_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("patient_physical_examination_job");
                quartzHelper.addJob(OldPeoplePhysicalExaminationSynJob.class, trigger, "patient_physical_examination_job", new HashMap<String, Object>());
                quartzHelper.addJob(PatientPhysicalExaminationJob.class, trigger, "patient_physical_examination_job", new HashMap<String, Object>());
                logger.info("patient_physical_examination_job  job success");
            } else {
                logger.info("patient_physical_examination_job  job exist");

+ 6 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/followup/FollowUpMappingDao.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.repository.followup;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -14,4 +16,8 @@ import java.util.List;
public interface FollowUpMappingDao extends PagingAndSortingRepository<FollowupMapping, Long>, JpaSpecificationExecutor<FollowupMapping> {
	
	List<FollowupMapping> findByNeedUpload(Integer needupload);
	
	@Modifying
	@Query("update FollowupMapping p set p.needUpload=?1 where p.followupId=?2")
	void updateNeedUploadByFollowupId(Integer needUpload,Integer followupId);
}

+ 5 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/organization/HospitalMappingDao.java

@ -10,6 +10,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 医院映射接口
 **/
@ -28,4 +30,7 @@ public interface HospitalMappingDao extends PagingAndSortingRepository<HospitalM
	HospitalMapping findByAppId(String appId);
	HospitalMapping findByCode(String code);
	
	@Query("select a from HospitalMapping a where a.licence is not null and a.licence<>'' and a.type='1'")
	List<HospitalMapping> findJwOrg();
}

+ 7 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java

@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -31,6 +32,7 @@ import java.util.List;
 * 居民近365天无体检记录时,系统自动发送一条体检提醒信息。使用“代办事项通知”模板
 * 代理机制还存在
 */
@Service
public class PatientPhysicalExaminationService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
@ -70,9 +72,11 @@ public class PatientPhysicalExaminationService extends BaseService {
            for (SignFamily signFamilie : signFamilies) {
                String patientCode = signFamilie.getPatient();
                Patient patient = patientDao.findByCode(patientCode);
                String url = "huanzhe/html/jiankangtijian.html?openid=" + patient.getOpenid() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName();
                if (patient == null) {
                    continue;
                }
                String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() + "&toUser=" + patient.getCode() + "&toName=" + patient.getName();
                json.put("url", url);
                String mobile = patient.getMobile();
                if (StringUtils.isNotBlank(patient.getOpenid())) {
                    json.put("first", first);
@ -102,7 +106,7 @@ public class PatientPhysicalExaminationService extends BaseService {
                        }
                    }
                }
                if (flag){
                if (flag) {
                    //发送成功保存发送记录
                    PhysicalExaminationRecords records = new PhysicalExaminationRecords();
                    records.setCode(getCode());

+ 418 - 385
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -34,11 +34,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.text.DecimalFormat;
@ -427,411 +430,433 @@ public class JwPrescriptionService {
    public void getFollowUpByTime(String startdate, String enddate) throws Exception {
    
        logger.info("查询居民随访记录,开始时间" + startdate + ",结束时间:" + enddate);
        List<HospitalMapping> list = hospitalMappingDao.findJwOrg();
        for (HospitalMapping hospitalMapping: list) {
    
        String url = jwUrl + "/third/sign/getEhrChroDaysFollowUpInfoRecord";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("TIME_START", startdate));//开始时间
        params.add(new BasicNameValuePair("TIME_END", enddate));//结束时间
        String response = httpClientUtil.post(url, params, "UTF-8");
    
        //居民随访记录
        List<Followup> followups = new ArrayList<>();
    
        if (StringUtils.isNotBlank(response)) {
            JSONObject reobj = JSON.parseObject(response);
            Integer status = reobj.getInteger("status");
            String errmsg = reobj.getString("msg");
            if (200 == status) {
                JSONObject jwData = reobj.getJSONObject("data");
                Integer jwCode = jwData.getInteger("CODE");
                if (1 == jwCode) {
                    JSONArray dataArray = jwData.getJSONArray("DATA");
                    for (int i = 0; i < dataArray.size(); i++) {
                        Followup followup = new Followup();
            String url = jwUrl + "/third/sign/getEhrChroDaysFollowUpInfoRecord";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("TIME_START", startdate));//开始时间
            params.add(new BasicNameValuePair("TIME_END", enddate));//结束时间
            params.add(new BasicNameValuePair("ORG_CODE", hospitalMapping.getCode()));//机构编码
//            params.add(new BasicNameValuePair("IDENTITY_CARD_NO", "350221197506113526"));//身份证
            String response = httpClientUtil.post(url, params, "UTF-8");
    
                        JSONObject json = dataArray.getJSONObject(i);
            //居民随访记录
            List<Followup> followups = new ArrayList<>();
    
                        SignFamily sign = null;
            if (StringUtils.isNotBlank(response)) {
                JSONObject reobj = JSON.parseObject(response);
                Integer status = reobj.getInteger("status");
                String errmsg = reobj.getString("msg");
                if (200 == status) {
                    JSONObject jwData = reobj.getJSONObject("data");
                    Integer jwCode = jwData.getInteger("CODE");
                    if (1 == jwCode) {
                        JSONArray dataArray = jwData.getJSONArray("DATA");
                        for (int i = 0; i < dataArray.size(); i++) {
                            Followup followup = new Followup();
                    
                            JSONObject json = dataArray.getJSONObject(i);
                    
                            SignFamily sign = null;
                    
                            //随访主表信息
                            String isNewCreate = json.getString("IS_NEW_CREATE");//是否新增
                            String followupNo = json.getString("FOLLOWUP_NO");//随访编号【基卫】:家庭医生服务随访主表ID
                            String dataFrom = json.getString("FOLLOWUP_SOURCE");//随访来源 1.平台端 2.移动端 3.第三方健康之路(移动端)"
                    
//                            if ("0".equals(isNewCreate) || "3".equals(dataFrom)) {//修改
//                                followup = followUpDao.findByFollowupNo(followupNo);
//                                if(followup == null){
//                                    followup = new Followup();
//                                }
//                            }
    
                        //随访主表信息
                        String isNewCreate = json.getString("IS_NEW_CREATE");//是否新增
                        String followupNo = json.getString("FOLLOWUP_NO");//随访编号【基卫】:家庭医生服务随访主表ID
                        String dataFrom = json.getString("FOLLOWUP_SOURCE");//随访来源 1.平台端 2.移动端 3.第三方健康之路(移动端)"
                        
                        if ("0".equals(isNewCreate) || "3".equals(dataFrom)) {//修改
                            followup = followUpDao.findByFollowupNo(followupNo);
                            if (followup == null) {
                                followup.setFollowupNo(followupNo);
                            if(followup == null){
                                followup = new Followup();
                            }
                        }
    
                            followup.setFollowupNo(followupNo);
                    
                            if ("1".equals(dataFrom) || "2".equals(dataFrom)) {
                                followup.setDataFrom("1");
                            } else if ("3".equals(dataFrom)) {
                                followup.setDataFrom("2");
                            }
                            followup.setDataFrom(dataFrom);
                    
                            String followupDate = json.getString("THIS_FOLLOWUP_VISIT_DATE");//随访时间:此次随访时间
                            followup.setFollowupDate(DateUtil.strToDate(followupDate));
                            String followupPlanDate = "";//随访计划时间
                            String followupNextDate = json.getString("NEXT_FOLLOWUP_DATE");//计划下次随访时间:下次随访时间
                            followup.setFollowupNextDate(DateUtil.strToDate(followupNextDate));
                            followup.setFollowupPlanDate(DateUtil.strToDate(followupDate));
                    
                            /******************* 医生机构映射 ****************/
                    
                            String jworgCode = json.getString("ORG_CODE");//基卫机构编码
                            followup.setJworgCode(jworgCode);//基卫机构编码
                            String jwdoctorCode = json.getString("FOLLOWUP_VISIT_DOCTOR_NAME");//基卫医生CODE:随访医生 基卫系统的随访医生ID
                            followup.setJwdoctorCode(jwdoctorCode);
                            //医院映射
                            HospitalMapping hm = hospitalMappingDao.getCodeByMapping(jworgCode, "1");
                            if (hm == null) {
                                logger.info("no mapping hospital:" + jworgCode);
                                continue;
                            }
                            //医生映射
                            Doctor doctor = doctorDao.findMappingDoctor(jwdoctorCode, jworgCode);
                            if (doctor == null) {
                                logger.info("no mapping hospital:" + jworgCode + ",familyDoctor:" + jwdoctorCode);
                                continue;
                            }
                            followup.setOrgCode(hm.getCode());//i健康机构编码
                            String doctorCode = doctor.getCode();//医生CODE
                            String doctorName = doctor.getName();//医生姓名 "FOLLOWUP_VISIT_DOCTOR_NAME_N":"随访医生 基卫系统的随访医生中文名"
                            String orgName = hm.getName();//机构名称
                            followup.setDoctorCode(doctorCode);
                            followup.setDoctorName(doctorName);
                            followup.setOrgName(orgName);
                    
                            String idcard = json.getString("IDENTITY_CARD_NO");//患者身份证
                            Patient patient = patientDao.findByIdcard(idcard);
                            String patientCode = patient.getCode();//患者CODE
                            String patientName = patient.getName();//患者姓名
                            followup.setIdcard(idcard);
                            followup.setPatientCode(patientCode);
                            followup.setPatientName(patientName);
                    
                            String followupStatus = "1";//状态 0取消 1已完成 2未开始 3进行中 *基卫没有状态字段,传递过来的默认都是已完成的*
                            String followupContentPhone = "";//电话随访内容 -------
                            String followupManagerStatus = "";//随访管理状态【字典FOLLOWUP_MANAGER_STATUS】-------
                            String followupClass = json.getString("FAMILY_FOLLOWUP_CLASS_NAMES");//随访类别【1.高血压 2.糖尿病】
                    
                            if (followupClass.contains("高血压") && followupClass.contains("糖尿病")) {
                                followupClass = "1,2";
                            }else if(followupClass.contains("高血压")){
                                followupClass= "1";
                            }else if(followupClass.contains("糖尿病")){
                                followupClass= "2";
                            }else{}
                    
                            String visitWayCode = json.getString("VISIT_WAY_CODE");//随访来源 1.门诊,2.家庭,3.电话,4.健康小屋
                            String creater = doctor.getCode();//创建者
                            followup.setStatus(followupStatus);
                            followup.setFollowupClass(followupClass);
                            followup.setFollowupType(visitWayCode);
                            followup.setCreater(creater);
                    
                            //判断是否存在
                            sign = signFamilyDao.findByIdcard(idcard);
                            //判断是否存在签约修改身份证情况
                            if (sign == null) {
                                logger.info("no sign familyy patient idcard:" + idcard);
                                continue;
                            }
                            Integer signType = Integer.parseInt(sign.getSignSource());//签约类型 1三师 2家庭
                            Long adminTeamCode = new Long(sign.getAdminTeamId());//行政团队
                            String signCode = sign.getCode();//签约表Code
                            followup.setAdminTeamCode(adminTeamCode);
                            followup.setSignCode(signCode);
                    
                            //随访记录详
                            HashMap<String, String> followupContent1 = new HashMap<>();
                            HashMap<String, String> followupContent2 = new HashMap<>();
                            HashMap<String, String> followupContent3 = new HashMap<>();
                            HashMap<String, String> followupContent4 = new HashMap<>();
                            HashMap<String, String> followupContent5 = new HashMap<>();
                            HashMap<String, String> followupContent6 = new HashMap<>();
                            HashMap<String, String> followupContent7 = new HashMap<>();
                            HashMap<String, String> followupContent8 = new HashMap<>();
                            HashMap<String, String> followupContent9 = new HashMap<>();
                            HashMap<String, String> followupContent10 = new HashMap<>();
                    
                            //症状
                            followupContent1.put("NO_SYMPTOM", json.getString("NO_SYMPTOM"));//无症状【0.无 1.有】
                            followupContent1.put("HEADACHE", json.getString("HEADACHE"));//头痛头晕【0.无 1.有】
                            followupContent1.put("NAUSEA", json.getString("NAUSEA"));//恶心呕吐【0.无 1.有】
                            followupContent1.put("VERTIGO_TINNITUS", json.getString("VERTIGO_TINNITUS"));//眼花耳鸣【0.无 1.有】
                            followupContent1.put("DIFFICULTY_BREATHING", json.getString("DIFFICULTY_BREATHING"));//呼吸困难【0.无 1.有】
                            followupContent1.put("PALPITATIONS", json.getString("PALPITATIONS"));//心悸胸闷【0.无 1.有】
                            followupContent1.put("EPISTAXIS_BLEEDING", json.getString("EPISTAXIS_BLEEDING"));//鼻衄出血不止【0.无 1.有】
                            followupContent1.put("LIMBS_NUMB", json.getString("LIMBS_NUMB"));//四肢发麻【0.无 1.有】
                            followupContent1.put("EXTREMITY_EDEMA", json.getString("EXTREMITY_EDEMA"));//下肢水肿【0.无 1.有】
                            followupContent1.put("SYMPTOM_OTHER", json.getString("SYMPTOM_OTHER"));//"其他症状"
                            followupContent1.put("POLYDIPSIA", json.getString("POLYDIPSIA"));//多饮【0.无 1.有】
                            followupContent1.put("MORE_FOOD", json.getString("MORE_FOOD"));//多食【0.无 1.有】
                            followupContent1.put("MORE_URINE", json.getString("MORE_URINE"));//多尿【0.无 1.有】
                            followupContent1.put("BLURRED_VISION", json.getString("BLURRED_VISION"));//视力模糊【0.无 1.有】
                            followupContent1.put("INFECTION", json.getString("INFECTION"));//感染【0.无 1.有】
                            followupContent1.put("NUMB_HANDS", json.getString("NUMB_HANDS"));//手脚麻木【0.无 1.有】
                            followupContent1.put("WEIGHT_LOSS", json.getString("WEIGHT_LOSS"));//体重明显下降【0.无 1.有】
                            followupContent1.put("HYPOG_REACT_CODE", json.getString("HYPOG_REACT_CODE"));//低血糖反应【0.无;1.偶尔;2.频繁;】
                    
                            //体征信息
                            followupContent2.put("HEIGHT", json.getString("HEIGHT"));//身高
                            followupContent2.put("HEIGHT_EXP", json.getString("HEIGHT_EXP"));//期望身高
                            followupContent2.put("WEIGHT", json.getString("WEIGHT"));//体重
                            followupContent2.put("WEIGHT_EXP", json.getString("WEIGHT_EXP"));//期望体重
                            followupContent2.put("BP_D", json.getString("BP_D"));//舒张压
                            followupContent2.put("BP_U", json.getString("BP_U"));//收缩压
                            followupContent2.put("BS_FPG", json.getString("BS_FPG"));//空腹血糖
                            followupContent2.put("NO_BS_FPG", json.getString("NO_BS_FPG"));//餐后血糖
                            followupContent2.put("RANDOM_BLOOD_SUGAR", json.getString("RANDOM_BLOOD_SUGAR"));//随机血糖
                            followupContent2.put("BMI", json.getString("BMI"));//体质指数
                            followupContent2.put("BMI_EXP", json.getString("BMI_EXP"));//期望体质
                            followupContent2.put("OTHER_POSITIVE_SIGNS", json.getString("OTHER_POSITIVE_SIGNS"));//体征其他
                            followupContent2.put("POFDA_MARK", json.getString("POFDA_MARK"));//足背动脉搏动【TOUCH_DICT】
                            followupContent2.put("HEART_RATE", json.getString("HEART_RATE"));//心率
                    
                            //检查室检查
                            followupContent3.put("GHB", json.getString("GHB"));//糖化血红蛋白
                            followupContent3.put("RENAL_FUNCTION_CREATININE", json.getString("RENAL_FUNCTION_CREATININE"));//血清肌酐
                            followupContent3.put("RENAL_FUNCTION_BUN", json.getString("RENAL_FUNCTION_BUN"));//血尿素氮
                            followupContent3.put("MICROALBUMINURIA", json.getString("MICROALBUMINURIA"));//尿微量白蛋白
                            followupContent3.put("EXAM_DATE", json.getString("EXAM_DATE"));//检查日期
                            followupContent3.put("BLOOD_FAT_TRIGLYCERIDE", json.getString("BLOOD_FAT_TRIGLYCERIDE"));//甘油三酯 V01
                            followupContent3.put("BLOOD_FAT_TC", json.getString("BLOOD_FAT_TC"));//总胆固醇 V02
                            followupContent3.put("BLOOD_FAT_LDLC", json.getString("BLOOD_FAT_LDLC"));//血清低密度脂蛋白胆固醇 V03
                    
                            //生活方式
                            followupContent4.put("DAILY_SMOKING", json.getString("DAILY_SMOKING"));//日吸烟量
                            followupContent4.put("SOMKING_EXP", json.getString("SOMKING_EXP"));//日吸烟期望
                            followupContent4.put("DAILY_DRINKING", json.getString("DAILY_DRINKING"));//日饮酒量
                            followupContent4.put("DRINK_EXP", json.getString("DRINK_EXP"));//日饮酒期望
                            followupContent4.put("EXERCISE_FREQ_CODE", json.getString("EXERCISE_FREQ_CODE"));//运动频率【HYGIENE_SPORT_FREQ_DICT】
                            followupContent4.put("EXERCISE_FREQ_CODE_EXP", json.getString("EXERCISE_FREQ_CODE_EXP"));//运动频率期望【HYGIENE_SPORT_FREQ_DICT】
                            followupContent4.put("EXERCISE_DURATION_MINS", json.getString("EXERCISE_DURATION_MINS"));//运动时长(min) 分钟/次
                            followupContent4.put("EXERCISE_DURATION_MINS_EXP", json.getString("EXERCISE_DURATION_MINS_EXP"));//运动时长期望(min) 分钟/次期望
                            followupContent4.put("SALT_TAKEN_LEVEL_CODE", json.getString("SALT_TAKEN_LEVEL_CODE"));//摄盐情况【LIGHT_WEIGHT_DICT】
                            followupContent4.put("SALT_TAKEN_LEVEL_EXP", json.getString("SALT_TAKEN_LEVEL_EXP"));//摄盐情况期望【LIGHT_WEIGHT_DICT】
                            followupContent4.put("PSY_ADJUST_RESULT_CODE", json.getString("PSY_ADJUST_RESULT_CODE"));//心里调整【GOOD_FAIR_POOR_DICT】
                            followupContent4.put("COMPLIANCE_RESULT_CODE", json.getString("COMPLIANCE_RESULT_CODE"));//遵医行为【GOOD_FAIR_POOR_DICT】
                            followupContent4.put("DAILY_STAPLE", json.getString("DAILY_STAPLE"));//主食(克/天)
                    
                            //随访评价
                            followupContent5.put("HYP_FOLLOWUP_TYPE_CODE", json.getString("HYP_FOLLOWUP_TYPE_CODE"));//高血压随访分类【FOLLOW_TYPE_DICT】
                            followupContent5.put("HYP_COMPLICATION_DETAIL", json.getString("HYP_COMPLICATION_DETAIL"));//高血压随访分类--详情
                            followupContent5.put("DIA_FOLLOWUP_TYPE_CODE", json.getString("DIA_FOLLOWUP_TYPE_CODE"));//糖尿病随访分类【FOLLOW_TYPE_DICT】
                            followupContent5.put("DIA_COMPLICATION_DETAIL", json.getString("DIA_COMPLICATION_DETAIL"));//糖尿病随访分类--详情
                    
                            //用药情况
                            followupContent6.put("DRUG_COMPLIANCE_CODE", json.getString("DRUG_COMPLIANCE_CODE"));//服药依从性【DRUG_STATE_DICT】
                    
                            //控制目标
                            followupContent7.put("CONTROL_DATE", json.getString("CONTROL_DATE"));//控制日期 V04
                            followupContent7.put("CONTROL_CONSTITUTOR", json.getString("CONTROL_CONSTITUTOR"));//制定者 V05
                            followupContent7.put("CONTROL_BP_U", json.getString("CONTROL_BP_U"));//血压收缩压 V06
                            followupContent7.put("CONTROL_BP_D", json.getString("CONTROL_BP_D"));//血压舒张压 V07
                            followupContent7.put("CONTROL_BS_FPG", json.getString("CONTROL_BS_FPG"));//空腹血糖 V08
                            followupContent7.put("CONTROL_NO_BS_FPG", json.getString("CONTROL_NO_BS_FPG"));//餐后血糖 V09
                            followupContent7.put("CONTROL_GHB", json.getString("CONTROL_GHB"));//糖化血红蛋白 V10
                            followupContent7.put("CONTROL_TRIGLYCERIDE", json.getString("CONTROL_TRIGLYCERIDE"));//甘油三酯 V11
                            followupContent7.put("CONTROL_TOTAL_CHOLESTEROL", json.getString("CONTROL_TOTAL_CHOLESTEROL"));//总胆固醇 V12
                            followupContent7.put("CONTROL_LDL", json.getString("CONTROL_LDL"));//低密度脂蛋白 V13
                            followupContent7.put("CONTROL_WEIGHT", json.getString("CONTROL_WEIGHT"));//体重 V14
                            followupContent7.put("CONTROL_EXERCISE_FREQ_CODE", json.getString("CONTROL_EXERCISE_FREQ_CODE"));//运动频率 V15
                            followupContent7.put("CONTROL_EXERCISE_DURATION_MINS", json.getString("CONTROL_EXERCISE_DURATION_MINS"));//运动时长 V16
                    
                            //健康教育
                            followupContent8.put("ARCHIVE_TIME", json.getString("ARCHIVE_TIME"));//健康教育日期 V17
                            followupContent8.put("ARCHIVE_OPERATOR_NAME", json.getString("ARCHIVE_OPERATOR_NAME"));//健康教育记录者 基卫系统医生【传中文名称】 V18
                            followupContent8.put("HEALTH_EDUCATE", json.getString("HEALTH_EDUCATE"));//健康教育【CHRO_HEALTH_EDUCATE_DICT】 V19
                            followupContent8.put("EDUCATE_CONTENT", json.getString("EDUCATE_CONTENT"));//健康教育内容 V20
                    
                            //转诊
                            followupContent9.put("DRUG_ADVERSE_MARK", json.getString("DRUG_ADVERSE_MARK"));//药物不良反应【0.无;1.有;】
                            followupContent9.put("ADR_REMARK", json.getString("ADR_REMARK"));//药物不良反应【内容】
                            followupContent9.put("TRANSFER_RESON", json.getString("TRANSFER_RESON"));//转诊原因
                            followupContent9.put("TRANSFER_ORG_DEPT", json.getString("TRANSFER_ORG_DEPT"));//转诊机构科室
                            followupContent9.put("REFUSE_REFERRAL", json.getString("REFUSE_REFERRAL"));//患者拒绝转诊【0 否 1 是】
                            followupContent9.put("REFUSE_REFERRAL_WHY", json.getString("REFUSE_REFERRAL_WHY"));//患者拒绝转诊内容
                    
                            //多余字段
                            followupContent10.put("ARCHIVE_ID", json.getString("ARCHIVE_ID"));//档案ID
                            followupContent10.put("CHECK_FEE_TYPE", json.getString("CHECK_FEE_TYPE"));//检测费用类型
                            followupContent10.put("FAMILY_FOLLOWUP_ID", json.getString("FAMILY_FOLLOWUP_ID"));//随访细表外键随访ID
                    
                            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
                            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
                            TransactionStatus transactionStatus = transactionManager.getTransaction(def); // 获得事务状态
                            try {
                                followup = followUpDao.save(followup);
                                Long followupId = followup.getId();
                                //删除原有记录
                                followupContentDao.deleteByFollowupId(followup.getId());
                                //组装数据
                                List<FollowupContent> newList = new ArrayList<>();
                        
                        if ("1".equals(dataFrom) || "2".equals(dataFrom)) {
                            followup.setDataFrom("1");
                        } else if ("3".equals(dataFrom)) {
                            followup.setDataFrom("2");
                        }
                        followup.setDataFrom(dataFrom);
                                followupContent1.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("1");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        String followupDate = json.getString("THIS_FOLLOWUP_VISIT_DATE");//随访时间:此次随访时间
                        followup.setFollowupDate(DateUtil.strToDate(followupDate));
                        String followupPlanDate = "";//随访计划时间
                        String followupNextDate = json.getString("NEXT_FOLLOWUP_DATE");//计划下次随访时间:下次随访时间
                        followup.setFollowupNextDate(DateUtil.strToDate(followupNextDate));
    
                        /******************* 医生机构映射 ****************/
    
                        String orgCode = json.getString("ORG_CODE");//机构编码
                        followup.setOrgCode(orgCode);
                        String jwdoctorCode = json.getString("FOLLOWUP_VISIT_DOCTOR_NAME");//基卫医生CODE:随访医生 基卫系统的随访医生ID
                        followup.setJwdoctorCode(jwdoctorCode);
                        //医院映射
                        HospitalMapping hm = hospitalMappingDao.getCodeByMapping(orgCode, "1");
                        if (hm == null) {
                            logger.info("no mapping hospital:" + orgCode);
                            continue;
                        }
                        //医生映射
                        Doctor doctor = doctorDao.findMappingDoctor(jwdoctorCode, orgCode);
                        if (doctor == null) {
                            logger.info("no mapping hospital:" + orgCode + ",familyDoctor:" + jwdoctorCode);
                            continue;
                        }
                                followupContent2.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("2");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        String doctorCode = doctor.getCode();//医生CODE
                        String doctorName = doctor.getName();//医生姓名 "FOLLOWUP_VISIT_DOCTOR_NAME_N":"随访医生 基卫系统的随访医生中文名"
                        String orgName = hm.getName();//机构名称
                        followup.setDoctorCode(doctorCode);
                        followup.setDoctorName(doctorName);
                        followup.setOrgName(orgName);
                                followupContent3.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("3");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        String idcard = json.getString("IDENTITY_CARD_NO");//患者身份证
                        Patient patient = patientDao.findByIdcard(idcard);
                        String patientCode = patient.getCode();//患者CODE
                        String patientName = patient.getName();//患者姓名
                        followup.setIdcard(idcard);
                        followup.setPatientCode(patientCode);
                        followup.setPatientName(patientName);
    
                        String followupStatus = "1";//状态 0取消 1已完成 2未开始 3进行中 *基卫没有状态字段,传递过来的默认都是已完成的*
                        String followupContentPhone = "";//电话随访内容 -------
                        String followupManagerStatus = "";//随访管理状态【字典FOLLOWUP_MANAGER_STATUS】-------
                        String followupClass = json.getString("FAMILY_FOLLOWUP_CLASS_NAMES");//随访类别【1.高血压 2.糖尿病】
    
                        if (followupClass.contains("高血压") && followupClass.contains("糖尿病")) {
                            followupClass = "1,2";
                        }else if(followupClass.contains("高血压")){
                            followupClass= "1";
                        }else if(followupClass.contains("糖尿病")){
                            followupClass= "2";
                        }else{}
                                followupContent4.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("4");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        String visitWayCode = json.getString("VISIT_WAY_CODE");//随访来源 1.门诊,2.家庭,3.电话,4.健康小屋
                        String creater = doctor.getCode();//创建者
                        followup.setStatus(followupStatus);
                        followup.setFollowupClass(followupClass);
                        followup.setFollowupType(visitWayCode);
                        followup.setCreater(creater);
    
                        //判断是否存在
                        sign = signFamilyDao.findByIdcard(idcard);
                        //判断是否存在签约修改身份证情况
                        if (sign == null) {
                            logger.info("no sign familyy patient idcard:" + idcard);
                            continue;
                        }
                        Integer signType = Integer.parseInt(sign.getSignSource());//签约类型 1三师 2家庭
                        Long adminTeamCode = new Long(sign.getAdminTeamId());//行政团队
                        String signCode = sign.getCode();//签约表Code
                        followup.setAdminTeamCode(adminTeamCode);
                        followup.setSignCode(signCode);
                                followupContent5.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("5");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //随访记录详
                        HashMap<String, String> followupContent1 = new HashMap<>();
                        HashMap<String, String> followupContent2 = new HashMap<>();
                        HashMap<String, String> followupContent3 = new HashMap<>();
                        HashMap<String, String> followupContent4 = new HashMap<>();
                        HashMap<String, String> followupContent5 = new HashMap<>();
                        HashMap<String, String> followupContent6 = new HashMap<>();
                        HashMap<String, String> followupContent7 = new HashMap<>();
                        HashMap<String, String> followupContent8 = new HashMap<>();
                        HashMap<String, String> followupContent9 = new HashMap<>();
                        HashMap<String, String> followupContent10 = new HashMap<>();
                                followupContent6.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("6");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //症状
                        followupContent1.put("NO_SYMPTOM", json.getString("NO_SYMPTOM"));//无症状【0.无 1.有】
                        followupContent1.put("HEADACHE", json.getString("HEADACHE"));//头痛头晕【0.无 1.有】
                        followupContent1.put("NAUSEA", json.getString("NAUSEA"));//恶心呕吐【0.无 1.有】
                        followupContent1.put("VERTIGO_TINNITUS", json.getString("VERTIGO_TINNITUS"));//眼花耳鸣【0.无 1.有】
                        followupContent1.put("DIFFICULTY_BREATHING", json.getString("DIFFICULTY_BREATHING"));//呼吸困难【0.无 1.有】
                        followupContent1.put("PALPITATIONS", json.getString("PALPITATIONS"));//心悸胸闷【0.无 1.有】
                        followupContent1.put("EPISTAXIS_BLEEDING", json.getString("EPISTAXIS_BLEEDING"));//鼻衄出血不止【0.无 1.有】
                        followupContent1.put("LIMBS_NUMB", json.getString("LIMBS_NUMB"));//四肢发麻【0.无 1.有】
                        followupContent1.put("EXTREMITY_EDEMA", json.getString("EXTREMITY_EDEMA"));//下肢水肿【0.无 1.有】
                        followupContent1.put("SYMPTOM_OTHER", json.getString("SYMPTOM_OTHER"));//"其他症状"
                        followupContent1.put("POLYDIPSIA", json.getString("POLYDIPSIA"));//多饮【0.无 1.有】
                        followupContent1.put("MORE_FOOD", json.getString("MORE_FOOD"));//多食【0.无 1.有】
                        followupContent1.put("MORE_URINE", json.getString("MORE_URINE"));//多尿【0.无 1.有】
                        followupContent1.put("BLURRED_VISION", json.getString("BLURRED_VISION"));//视力模糊【0.无 1.有】
                        followupContent1.put("INFECTION", json.getString("INFECTION"));//感染【0.无 1.有】
                        followupContent1.put("NUMB_HANDS", json.getString("NUMB_HANDS"));//手脚麻木【0.无 1.有】
                        followupContent1.put("WEIGHT_LOSS", json.getString("WEIGHT_LOSS"));//体重明显下降【0.无 1.有】
                        followupContent1.put("HYPOG_REACT_CODE", json.getString("HYPOG_REACT_CODE"));//低血糖反应【0.无;1.偶尔;2.频繁;】
                                followupContent7.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("7");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //体征信息
                        followupContent2.put("HEIGHT", json.getString("HEIGHT"));//身高
                        followupContent2.put("HEIGHT_EXP", json.getString("HEIGHT_EXP"));//期望身高
                        followupContent2.put("WEIGHT", json.getString("WEIGHT"));//体重
                        followupContent2.put("WEIGHT_EXP", json.getString("WEIGHT_EXP"));//期望体重
                        followupContent2.put("BP_D", json.getString("BP_D"));//舒张压
                        followupContent2.put("BP_U", json.getString("BP_U"));//收缩压
                        followupContent2.put("BS_FPG", json.getString("BS_FPG"));//空腹血糖
                        followupContent2.put("NO_BS_FPG", json.getString("NO_BS_FPG"));//餐后血糖
                        followupContent2.put("RANDOM_BLOOD_SUGAR", json.getString("RANDOM_BLOOD_SUGAR"));//随机血糖
                        followupContent2.put("BMI", json.getString("BMI"));//体质指数
                        followupContent2.put("BMI_EXP", json.getString("BMI_EXP"));//期望体质
                        followupContent2.put("OTHER_POSITIVE_SIGNS", json.getString("OTHER_POSITIVE_SIGNS"));//体征其他
                        followupContent2.put("POFDA_MARK", json.getString("POFDA_MARK"));//足背动脉搏动【TOUCH_DICT】
                        followupContent2.put("HEART_RATE", json.getString("HEART_RATE"));//心率
                                followupContent8.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("8");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //检查室检查
                        followupContent3.put("GHB", json.getString("GHB"));//糖化血红蛋白
                        followupContent3.put("RENAL_FUNCTION_CREATININE", json.getString("RENAL_FUNCTION_CREATININE"));//血清肌酐
                        followupContent3.put("RENAL_FUNCTION_BUN", json.getString("RENAL_FUNCTION_BUN"));//血尿素氮
                        followupContent3.put("MICROALBUMINURIA", json.getString("MICROALBUMINURIA"));//尿微量白蛋白
                        followupContent3.put("EXAM_DATE", json.getString("EXAM_DATE"));//检查日期
                        followupContent3.put("BLOOD_FAT_TRIGLYCERIDE", json.getString("BLOOD_FAT_TRIGLYCERIDE"));//甘油三酯 V01
                        followupContent3.put("BLOOD_FAT_TC", json.getString("BLOOD_FAT_TC"));//总胆固醇 V02
                        followupContent3.put("BLOOD_FAT_LDLC", json.getString("BLOOD_FAT_LDLC"));//血清低密度脂蛋白胆固醇 V03
    
                        //生活方式
                        followupContent4.put("DAILY_SMOKING", json.getString("DAILY_SMOKING"));//日吸烟量
                        followupContent4.put("SOMKING_EXP", json.getString("SOMKING_EXP"));//日吸烟期望
                        followupContent4.put("DAILY_DRINKING", json.getString("DAILY_DRINKING"));//日饮酒量
                        followupContent4.put("DRINK_EXP", json.getString("DRINK_EXP"));//日饮酒期望
                        followupContent4.put("EXERCISE_FREQ_CODE", json.getString("EXERCISE_FREQ_CODE"));//运动频率【HYGIENE_SPORT_FREQ_DICT】
                        followupContent4.put("EXERCISE_FREQ_CODE_EXP", json.getString("EXERCISE_FREQ_CODE_EXP"));//运动频率期望【HYGIENE_SPORT_FREQ_DICT】
                        followupContent4.put("EXERCISE_DURATION_MINS", json.getString("EXERCISE_DURATION_MINS"));//运动时长(min) 分钟/次
                        followupContent4.put("EXERCISE_DURATION_MINS_EXP", json.getString("EXERCISE_DURATION_MINS_EXP"));//运动时长期望(min) 分钟/次期望
                        followupContent4.put("SALT_TAKEN_LEVEL_CODE", json.getString("SALT_TAKEN_LEVEL_CODE"));//摄盐情况【LIGHT_WEIGHT_DICT】
                        followupContent4.put("SALT_TAKEN_LEVEL_EXP", json.getString("SALT_TAKEN_LEVEL_EXP"));//摄盐情况期望【LIGHT_WEIGHT_DICT】
                        followupContent4.put("PSY_ADJUST_RESULT_CODE", json.getString("PSY_ADJUST_RESULT_CODE"));//心里调整【GOOD_FAIR_POOR_DICT】
                        followupContent4.put("COMPLIANCE_RESULT_CODE", json.getString("COMPLIANCE_RESULT_CODE"));//遵医行为【GOOD_FAIR_POOR_DICT】
                        followupContent4.put("DAILY_STAPLE", json.getString("DAILY_STAPLE"));//主食(克/天)
                                followupContent9.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("9");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //随访评价
                        followupContent5.put("HYP_FOLLOWUP_TYPE_CODE", json.getString("HYP_FOLLOWUP_TYPE_CODE"));//高血压随访分类【FOLLOW_TYPE_DICT】
                        followupContent5.put("HYP_COMPLICATION_DETAIL", json.getString("HYP_COMPLICATION_DETAIL"));//高血压随访分类--详情
                        followupContent5.put("DIA_FOLLOWUP_TYPE_CODE", json.getString("DIA_FOLLOWUP_TYPE_CODE"));//糖尿病随访分类【FOLLOW_TYPE_DICT】
                        followupContent5.put("DIA_COMPLICATION_DETAIL", json.getString("DIA_COMPLICATION_DETAIL"));//糖尿病随访分类--详情
    
                        //用药情况
                        followupContent6.put("DRUG_COMPLIANCE_CODE", json.getString("DRUG_COMPLIANCE_CODE"));//服药依从性【DRUG_STATE_DICT】
                                followupContent10.forEach((k, v) -> {
                                    FollowupContent item = new FollowupContent();
                                    item.setFollowupId(followupId);
                                    item.setFollowupProject("10");
                                    item.setFollowupKey(k);
                                    item.setFollowupValue(v);
                                    item.setCreateTime(new Date());
                                    newList.add(item);
                                });
                        
                        //控制目标
                        followupContent7.put("CONTROL_DATE", json.getString("CONTROL_DATE"));//控制日期 V04
                        followupContent7.put("CONTROL_CONSTITUTOR", json.getString("CONTROL_CONSTITUTOR"));//制定者 V05
                        followupContent7.put("CONTROL_BP_U", json.getString("CONTROL_BP_U"));//血压收缩压 V06
                        followupContent7.put("CONTROL_BP_D", json.getString("CONTROL_BP_D"));//血压舒张压 V07
                        followupContent7.put("CONTROL_BS_FPG", json.getString("CONTROL_BS_FPG"));//空腹血糖 V08
                        followupContent7.put("CONTROL_NO_BS_FPG", json.getString("CONTROL_NO_BS_FPG"));//餐后血糖 V09
                        followupContent7.put("CONTROL_GHB", json.getString("CONTROL_GHB"));//糖化血红蛋白 V10
                        followupContent7.put("CONTROL_TRIGLYCERIDE", json.getString("CONTROL_TRIGLYCERIDE"));//甘油三酯 V11
                        followupContent7.put("CONTROL_TOTAL_CHOLESTEROL", json.getString("CONTROL_TOTAL_CHOLESTEROL"));//总胆固醇 V12
                        followupContent7.put("CONTROL_LDL", json.getString("CONTROL_LDL"));//低密度脂蛋白 V13
                        followupContent7.put("CONTROL_WEIGHT", json.getString("CONTROL_WEIGHT"));//体重 V14
                        followupContent7.put("CONTROL_EXERCISE_FREQ_CODE", json.getString("CONTROL_EXERCISE_FREQ_CODE"));//运动频率 V15
                        followupContent7.put("CONTROL_EXERCISE_DURATION_MINS", json.getString("CONTROL_EXERCISE_DURATION_MINS"));//运动时长 V16
                                followupContentDao.save(newList);
                        
                        //健康教育
                        followupContent8.put("ARCHIVE_TIME", json.getString("ARCHIVE_TIME"));//健康教育日期 V17
                        followupContent8.put("ARCHIVE_OPERATOR_NAME", json.getString("ARCHIVE_OPERATOR_NAME"));//健康教育记录者 基卫系统医生【传中文名称】 V18
                        followupContent8.put("HEALTH_EDUCATE", json.getString("HEALTH_EDUCATE"));//健康教育【CHRO_HEALTH_EDUCATE_DICT】 V19
                        followupContent8.put("EDUCATE_CONTENT", json.getString("EDUCATE_CONTENT"));//健康教育内容 V20
    
                        //转诊
                        followupContent9.put("DRUG_ADVERSE_MARK", json.getString("DRUG_ADVERSE_MARK"));//药物不良反应【0.无;1.有;】
                        followupContent9.put("ADR_REMARK", json.getString("ADR_REMARK"));//药物不良反应【内容】
                        followupContent9.put("TRANSFER_RESON", json.getString("TRANSFER_RESON"));//转诊原因
                        followupContent9.put("TRANSFER_ORG_DEPT", json.getString("TRANSFER_ORG_DEPT"));//转诊机构科室
                        followupContent9.put("REFUSE_REFERRAL", json.getString("REFUSE_REFERRAL"));//患者拒绝转诊【0 否 1 是】
                        followupContent9.put("REFUSE_REFERRAL_WHY", json.getString("REFUSE_REFERRAL_WHY"));//患者拒绝转诊内容
    
                        //多余字段
                        followupContent10.put("ARCHIVE_ID", json.getString("ARCHIVE_ID"));//档案ID
                        followupContent10.put("CHECK_FEE_TYPE", json.getString("CHECK_FEE_TYPE"));//检测费用类型
                        followupContent10.put("FAMILY_FOLLOWUP_ID", json.getString("FAMILY_FOLLOWUP_ID"));//随访细表外键随访ID
    
                        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
                        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
                        TransactionStatus transactionStatus = transactionManager.getTransaction(def); // 获得事务状态
                        try {
                            followup = followUpDao.save(followup);
                            Long followupId = followup.getId();
                            //删除原有记录
                            followupContentDao.deleteByFollowupId(followup.getId());
                            //组装数据
                            List<FollowupContent> newList = new ArrayList<>();
    
                            followupContent1.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("1");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent2.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("2");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent3.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("3");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent4.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("4");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent5.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("5");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent6.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("6");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent7.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("7");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent8.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("8");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent9.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("9");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContent10.forEach((k, v) -> {
                                FollowupContent item = new FollowupContent();
                                item.setFollowupId(followupId);
                                item.setFollowupProject("10");
                                item.setFollowupKey(k);
                                item.setFollowupValue(v);
                                item.setCreateTime(new Date());
                                newList.add(item);
                            });
    
                            followupContentDao.save(newList);
    
                            List<FollowupDrugs> DRUG_LIST = new ArrayList<>();//用药记录
    
                            for (int j = 1; j < 7; j++) {
                                if (json.containsKey("PHYSIC_NAME" + j)) {
                                    FollowupDrugs drug = new FollowupDrugs();
                                    drug.setFollowupId(followupId);
                                    drug.setDrugsGroup("normal");
                                    drug.setDrugsCode("");
                                    drug.setDrugsName(json.getString("PHYSIC_NAME" + j));//药物名称
                                    drug.setDose(Double.valueOf(json.getString("PHYSIC_DOSE" + j)));//剂量
                                    drug.setUnit(json.getString("PHYSIC_UNIT" + j));//单位【MEASURE_UNIT_DICT】
                                    drug.setFrequency(json.getString("FREQUENCY" + j));//频次【RECIPE_FREQUENCY_DICT】
                                    drug.setCreateTime(new Date());
                                    DRUG_LIST.add(drug);
                                List<FollowupDrugs> DRUG_LIST = new ArrayList<>();//用药记录
                        
                                for (int j = 1; j < 7; j++) {
                                    if (json.containsKey("PHYSIC_NAME" + j)) {
                                        FollowupDrugs drug = new FollowupDrugs();
                                        drug.setFollowupId(followupId);
                                        drug.setDrugsGroup("normal");
                                        drug.setDrugsCode("");
                                        drug.setDrugsName(json.getString("PHYSIC_NAME" + j));//药物名称
                                        if(StringUtils.isNoneBlank(json.getString("PHYSIC_DOSE" + j))){
                                            drug.setDose(Double.valueOf(json.getString("PHYSIC_DOSE" + j)));//剂量
                                        }
                                        
                                        drug.setUnit(json.getString("PHYSIC_UNIT" + j));//单位【MEASURE_UNIT_DICT】
                                        drug.setFrequency(json.getString("FREQUENCY" + j));//频次【RECIPE_FREQUENCY_DICT】
                                        drug.setCreateTime(new Date());
                                        DRUG_LIST.add(drug);
                                    }
                                }
                            }
    
                            for (int k = 1; k < 4; k++) {
                                if (json.containsKey("PHYSIC_NAME" + k)) {
                                    FollowupDrugs drug = new FollowupDrugs();
                                    drug.setFollowupId(followupId);
                                    drug.setDrugsGroup("insulin");
                                    drug.setDrugsCode("");
                                    drug.setDrugsName(json.getString("INSULIN_NAME" + k));//胰岛素药物名称
                                    drug.setDose(Double.valueOf(json.getString("INSULIN_DOSE" + k)));//胰岛素剂量
                                    drug.setUnit(json.getString("INSULIN_UNIT" + k));//v单位【MEASURE_UNIT_DICT】
                                    drug.setFrequency(json.getString("INSULIN_FREQUENCY" + k));//胰岛素频次【RECIPE_FREQUENCY_DICT】
                                    drug.setCreateTime(new Date());
                                    DRUG_LIST.add(drug);
                        
                                for (int k = 1; k < 4; k++) {
                                    if (json.containsKey("PHYSIC_NAME" + k)) {
                                        FollowupDrugs drug = new FollowupDrugs();
                                        drug.setFollowupId(followupId);
                                        drug.setDrugsGroup("insulin");
                                        drug.setDrugsCode("");
                                        drug.setDrugsName(json.getString("INSULIN_NAME" + k));//胰岛素药物名称
                                        if(StringUtils.isNoneBlank(json.getString("INSULIN_DOSE" + k))){
                                            drug.setDose(Double.valueOf(json.getString("INSULIN_DOSE" + k)));//胰岛素剂量
                                        }
                                        drug.setUnit(json.getString("INSULIN_UNIT" + k));//v单位【MEASURE_UNIT_DICT】
                                        drug.setFrequency(json.getString("INSULIN_FREQUENCY" + k));//胰岛素频次【RECIPE_FREQUENCY_DICT】
                                        drug.setCreateTime(new Date());
                                        DRUG_LIST.add(drug);
                                    }
                                }
                                //删除原有用药记录
                                followupDrugsDao.deleteByFollowupId(followupId);
                                followupDrugsDao.save(DRUG_LIST);
                        
                                transactionManager.commit(transactionStatus);
                            } catch (Exception ex) {
                                logger.info("同步随访信息报错,errmessage:" + ex.toString());
                                transactionManager.rollback(transactionStatus);
                                continue;
                            }
                            //删除原有用药记录
                            followupDrugsDao.deleteByFollowupId(followupId);
                            followupDrugsDao.save(DRUG_LIST);
                            
                            transactionManager.commit(transactionStatus);
                        } catch (Exception ex) {
                            logger.info("同步随访信息报错,errmessage:" + ex.toString());
                            transactionManager.rollback(transactionStatus);
                            continue;
                        }
                    } else {
                        String jwMessage = jwData.getString("MESSAGE");
                        logger.info("同步随访信息报错接口失败:" + jwMessage+",hosipitalcode" + hospitalMapping.getCode());
                        continue;
                    }
            
                } else {
                    String jwMessage = jwData.getString("MESSAGE");
                    throw new Exception("同步随访信息报错接口失败:" + jwMessage);
                    logger.info("同步随访信息报错接口失败:" + errmsg+",hosipitalcode" + hospitalMapping.getCode());
                    continue;
                }
    
            } else {
                throw new Exception("同步随访信息报错请求失败," + errmsg);
                logger.info("同步随访信息报错接口失败:无数据返回, hosipitalcode" + hospitalMapping.getCode());
                continue;
            }
        } else {
            throw new Exception("同步随访信息报错请求失败,无数据返回!");
        }
    }
    
    /**
     * 上传居民随访记录到基卫
     */
    @Transactional
    public void uploadFollowUpRecordToJW() throws Exception {
        //查找出需要上传的随访映射记录
        List<Followup> followupMappings = followUpDao.findByFollowMappingNeedUpload(1);
@ -854,6 +879,7 @@ public class JwPrescriptionService {
                    String OPERATOR = followup.getJwdoctorCode();//操作员&录入医生
                    if (StringUtils.isBlank(OPERATOR)) {
                        OPERATOR = doctorMappingDao.findByDocotrCodeAndJwDoctorHospital(followup.getDoctorCode(), followup.getOrgCode());
                        followup.setJwdoctorCode(OPERATOR);
                    }
                    followupResultMap.put("OPERATOR",OPERATOR);
                    
@ -864,7 +890,12 @@ public class JwPrescriptionService {
                    followupResultMap.put("FOLLOWUP_ID",FOLLOWUP_ID);
                    
                    String FAMILY_FOLLOWUP_TYPE = "3";//随访类型,必传值3 【必填】
                    String ORG_CODE = followup.getOrgCode();//机构编码
                    String ORG_CODE = followup.getOrgCode();//本地机构编码
                    String JW_ORG_CODE = followup.getJworgCode();//基卫机构编码
                    if(StringUtils.isBlank(JW_ORG_CODE)){
                        JW_ORG_CODE = hospitalMappingDao.getMappingCode(ORG_CODE,"1");
                        followup.setJworgCode(JW_ORG_CODE);
                    }
                    String FOLLOWUP_SOURCE = "3";//健康之路移动端
                    String IDENTITY_CARD_NO = followup.getIdcard();
                    String FAMILY_FOLLOWUP_CLASS_NAMES = followup.getFollowupClass();
@ -877,7 +908,7 @@ public class JwPrescriptionService {
                    } else {}
    
                    followupResultMap.put("FAMILY_FOLLOWUP_TYPE",FAMILY_FOLLOWUP_TYPE);
                    followupResultMap.put("ORG_CODE",ORG_CODE);
                    followupResultMap.put("ORG_CODE",JW_ORG_CODE);
                    followupResultMap.put("FOLLOWUP_SOURCE",FOLLOWUP_SOURCE);
                    followupResultMap.put("IDENTITY_CARD_NO",IDENTITY_CARD_NO);
                    followupResultMap.put("FAMILY_FOLLOWUP_CLASS_NAMES",FAMILY_FOLLOWUP_CLASS_NAMES);
@ -936,16 +967,16 @@ public class JwPrescriptionService {
                    if(!followupDrugsInsulin.isEmpty()){
                        for (int  j= 0; j < followupDrugsInsulin.size(); j++) {
                            int tag = j+1;
                            followupResultMap.put("PHYSIC_NAME"+tag,followupDrugsInsulin.get(j).getDrugsName());
                            followupResultMap.put("FREQUENCY"+tag,followupDrugsInsulin.get(j).getFrequency());
                            followupResultMap.put("PHYSIC_UNIT"+tag,followupDrugsInsulin.get(j).getUnit());
                            followupResultMap.put("PHYSIC_DOSE"+tag,df.format(followupDrugsInsulin.get(j).getDose()));
                            followupResultMap.put("INSULIN_NAME"+tag,followupDrugsInsulin.get(j).getDrugsName());
                            followupResultMap.put("INSULIN_FREQUENCY"+tag,followupDrugsInsulin.get(j).getFrequency());
                            followupResultMap.put("INSULIN_UNIT"+tag,followupDrugsInsulin.get(j).getUnit());
                            followupResultMap.put("INSULIN_DOSE"+tag,df.format(followupDrugsInsulin.get(j).getDose()));
                        }
                    }
    
                    jsonObject = JSONObject.parseObject(JSON.toJSONString(followupResultMap));
                    
                    String url = jwUrl + "/third/archives/uploadEhrSickChroDaysFollowUpRecord";
                    String url = jwUrl + "/third/sign/uploadEhrSickChroDaysFollowUpRecord";
    
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("OPERATOR", OPERATOR));
@ -963,8 +994,6 @@ public class JwPrescriptionService {
                                JSONArray dataArray = jwData.getJSONArray("DATA");
                                for (int i = 0; i < dataArray.size(); i++) {
                    
                                    OldPeoplePhysicalExaminationEntity oldPeoplePhysicalExaminationEntity = new OldPeoplePhysicalExaminationEntity();
                    
                                    JSONObject json = dataArray.getJSONObject(i);
                                    
                                    String jw_followup_no = json.getString("FOLLOWUP_NO");
@ -972,24 +1001,28 @@ public class JwPrescriptionService {
                                    followup.setFollowupNo(jw_followup_no);
    
                                    followUpDao.save(followup);//获取的基卫随访主表ID,更新回数据库
    
                                    String strid = String.valueOf(followup.getId());
                                    
                                    followUpMappingDao.updateNeedUploadByFollowupId(0,Integer.parseInt(strid));
                                }
                                
                            } else {
                                String jwMessage = jwData.getString("MESSAGE");
                                logger.info("随访记录上传失败,普通药品或者胰岛素类药瓶超过了上线,随访主表ID:" + followup.getId().toString()+",err:"+jwMessage);
                                logger.info("随访记录上传失败,随访主表ID:" + followup.getId().toString()+",err:"+jwMessage);
                                continue;
                            }
            
                        } else {
                            logger.info("随访记录上传失败,普通药品或者胰岛素类药瓶超过了上线,随访主表ID:" + followup.getId().toString()+",err:请求失败");
                            logger.info("随访记录上传失败,随访主表ID:" + followup.getId().toString()+",err:请求失败");
                            continue;
                        }
                    } else {
                        logger.info("随访记录上传失败,普通药品或者胰岛素类药瓶超过了上线,随访主表ID:" + followup.getId().toString()+",无返回值");
                        logger.info("随访记录上传失败:" + followup.getId().toString()+",无返回值");
                        continue;
                    }
                } catch (Exception e) {
                    logger.info("随访记录上传失败,普通药品或者胰岛素类药瓶超过了上线,随访主表ID:" + followup.getId().toString()+",err"+e.getMessage());
                    logger.info("随访记录上传失败,随访主表ID:" + followup.getId().toString()+",err"+e.getMessage());
                    continue;
                }
            }

+ 42 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.quota;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.ConsultCleanerJob;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.job.consult.FinishConsultJob;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
@ -606,7 +607,7 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    
    /**
     *根据时间范围同步居民随访记录
     *@author huangwenjie
@ -640,6 +641,29 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    
    /**
     * 居民随访记录上传(上传到基卫)
     *@author huangwenjie
     *@date 2017/10/23 08:45
     */
    @RequestMapping(value = "/executeFollowUpUploadJob", method = RequestMethod.POST)
    @ApiOperation("居民随访记录上传(上传到基卫)")
    public String executeFollowUpSynByTime() {
        try {
            try {
                //上传居民随访记录到基卫
                jwPrescriptionService.uploadFollowUpRecordToJW();
            }catch (Exception e){
                e.printStackTrace();
            }
            
            return write(200, "执行成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     *老年人体检系统发送提醒,每天早上8点执行一次
@ -659,4 +683,21 @@ public class JobController extends BaseController {
    }
    /**
     * 医生评价分数统计
     * @return
     */
    @RequestMapping(value = "startEvaluateScoreJob", method = RequestMethod.GET)
    @ApiOperation("医生评价分数统计")
    public String startEvaluateScoreJob() {
        try {
            quartzHelper.startNow(EvaluateScoreJob.class, "startEvaluateScoreJob", null);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 5 - 3
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -113,12 +113,14 @@ onepay_query_job=0 0/3 * * * ?
# 老年人体检记录同步,每天凌晨1点执行一次
old_people_tijian_syb_job=0 0 1 * * ?
# 老年人体检记录同步,每天凌晨1点执行一次
# 同步居民随访记录,每天凌晨3点执行一次
patient_followup_syb_job=0 0 3 * * ?
# 居民随访记录上传(上传到基卫),每天凌晨4点执行一次
patient_followup_upload_job=0 0 3 * * ?
# 老年人体检系统发送提醒记录,每天8点执行一次
#patient_physical_examination_job=0 0 8 * * ?
patient_physical_examination_job=0 0/10 * * * ?
patient_physical_examination_job=0 0 8 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java

@ -204,6 +204,7 @@ public class PresModeAdapter {
                            prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                            prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            prescriptionInfo.setSubjectClass(info.getString("SUBJECT_CLASS"));//科目类型
                            prescriptionInfos.add(prescriptionInfo);
                        }
                        p.put("prescriptionInfo",prescriptionInfos);

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpMappingDao.java

@ -0,0 +1,25 @@
package com.yihu.wlyy.repository.followup;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * 随访记录映射表
 * @author huangwenjie
 * @date 2017/10/23 14:05
 */
public interface FollowUpMappingDao extends PagingAndSortingRepository<FollowupMapping, Long>, JpaSpecificationExecutor<FollowupMapping> {
	
	List<FollowupMapping> findByNeedUpload(Integer needupload);
	
	FollowupMapping findByFollowupId(Integer followupid);
	
	@Modifying
	@Query("update FollowupMapping p set p.needUpload=?1 where p.followupId=?2")
	void updateNeedUploadByFollowupId(Integer needUpload, Integer followupId);
}

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionAdressDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdress;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/10/20.
 */
public interface PrescriptionAdressDao extends PagingAndSortingRepository<PrescriptionAdress, Long>, JpaSpecificationExecutor<PrescriptionAdress> {
}

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

@ -6,11 +6,13 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.followup.FollowupMapping;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.followup.FollowUpMappingDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
@ -82,6 +84,8 @@ public class FollowUpService extends BaseService {
    private PatientService patientService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private FollowUpMappingDao followUpMappingDao;
    /**
@ -267,7 +271,7 @@ public class FollowUpService extends BaseService {
                }else{
                    if(objArr[4].toString().equals("1")){
                        followup.put("followupClassName", "高血压");
                    }else if(objArr[4].toString().equals("1")){
                    }else if(objArr[4].toString().equals("2")){
                        followup.put("followupClassName", "糖尿病");
                    }else if(objArr[4].toString().equals("1,2")){
                        followup.put("followupClassName", "高血压,糖尿病");
@ -406,6 +410,32 @@ public class FollowUpService extends BaseService {
            //计划下次随访时间--huangwenjie.2017.10.19
            if(StringUtils.isNoneBlank(plandate)){
                followup.setFollowupNextDate(DateUtil.strToDate(plandate));
                Followup nextFollowup = new Followup();
                nextFollowup.setDataFrom(followup.getDataFrom());
                nextFollowup.setStatus("2");
                nextFollowup.setFollowupType(followupType);
                nextFollowup.setFollowupNo(followup.getFollowupNo());
                nextFollowup.setFollowupDate(DateUtil.strToDate(plandate));
                nextFollowup.setFollowupPlanDate(DateUtil.strToDate(plandate));
                nextFollowup.setJwdoctorCode(followup.getJwdoctorCode());
                nextFollowup.setJworgCode(followup.getJworgCode());
                nextFollowup.setOrgCode(followup.getOrgCode());
                nextFollowup.setOrgName(followup.getOrgName());
                nextFollowup.setCreater(followup.getCreater());
                nextFollowup.setSignCode(followup.getSignCode());
                nextFollowup.setAdminTeamCode(followup.getAdminTeamCode());
                nextFollowup.setFollowupClass(followupClass);
                nextFollowup.setFollowupManagerStatus(followupManagerStatus);
                nextFollowup.setPatientName(followup.getPatientName());
                nextFollowup.setPatientCode(followup.getPatientCode());
                nextFollowup.setCreateTime(new Date());
                nextFollowup.setUpdateTime(new Date());
                nextFollowup.setDoctorCode(followup.getDoctorCode());
                nextFollowup.setDoctorName(followup.getDoctorName());
                nextFollowup.setIdcard(followup.getIdcard());
                nextFollowup.setSignType(followup.getSignType());
                followupDao.save(nextFollowup);
                
            }
            followup.setFollowupType(followupType);
            followup.setFollowupClass(followupClass);
@ -490,10 +520,24 @@ public class FollowUpService extends BaseService {
        Followup followup = followupDao.findOne(Long.valueOf(id));
        if (followup != null) {
            followup.setStatus("1");  //状态 0取消 1已完成 2未开始 3进行中
            followupDao.save(followup);
            //上传随访计划
            new Thread(new FollowupUploadTask(String.valueOf(followup.getId()))).start();
            followup = followupDao.save(followup);
    
            //上传随访计划映射表记录
            FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(String.valueOf(followup.getId())));
            
            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");
        }

+ 2 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -139,8 +139,6 @@ public class PhysicalExaminationRemindService extends BaseService {
                    break;
                }
            }
        } else {
            re = 1;
        }
        return re;
    }
@ -335,7 +333,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        String mobile = patient.getMobile();
        Boolean flag = true;
        // 推送消息给微信端
        String url = "huanzhe/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
        String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
        String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~";
        JSONObject json = new org.json.JSONObject();
        json.put("first",first);
@ -409,7 +407,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        Date yesteryear = c.getTime();
        List<Patient> patients = patientDao.findExaminationRemind(teamId, yesteryear);
        for (Patient patient : patients) {
            String url = "huanzhe/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
            String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
            String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~";
            json.put("first",first);
            json.put("url",url);

+ 99 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdressService.java

@ -0,0 +1,99 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionAdress;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionAdressDao;
import com.yihu.wlyy.service.BaseService;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2017/10/20.
 */
@Service
@Transactional(rollbackOn = Exception.class)
public class PrescriptionAdressService extends BaseService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionAdressDao prescriptionAdressDao;
    //获取列表
    public List<Map<String,Object>> getAdressList(String patient){
        String sql = "SELECT ad.* FROM wlyy_prescription_adress ad WHERE ad.patient ='"+patient+"' ORDER BY ad.default_flag DESC";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    //保存
    public String saveAdress(String adressJosn){
        JSONObject jsonObject = JSONObject.fromObject(adressJosn);
        PrescriptionAdress p = (PrescriptionAdress) net.sf.json.JSONObject.toBean(jsonObject,PrescriptionAdress.class);
        p.setCreateTime(new Date());
        if(p.getDefaultFlag()==1){
            String sql ="UPDATE wlyy_prescription_adress set defaultFlag = 0 WHERE patient ='"+p.getPatient()+"' ";
            jdbcTemplate.execute(sql);
        }
        prescriptionAdressDao.save(p);
        return "1";
    }
    //更新
    public String updateAdress(String adressJson){
        JSONObject jsonObject = JSONObject.fromObject(adressJson);
        PrescriptionAdress p = (PrescriptionAdress) net.sf.json.JSONObject.toBean(jsonObject,PrescriptionAdress.class);
        p.setCreateTime(new Date());
        if(p.getDefaultFlag()==1){
            String sql ="UPDATE wlyy_prescription_adress set defaultFlag = 0 WHERE patient ='"+p.getPatient()+"' ";
            jdbcTemplate.execute(sql);
        }
        prescriptionAdressDao.save(p);
        return "1";
    }
    //删除
    public String delAdress(Long id){
        prescriptionAdressDao.delete(id);
        return "1";
    }
    public List<Map<String,Object>> getProvince(){
        String sql = "SELECT " +
                " p.`code`, " +
                " p.`name` " +
                " FROM " +
                " dm_province p";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String,Object>> getCityByProvince(String province){
        String sql = "SELECT " +
                " p.`code`, " +
                " p.`name` " +
                " FROM " +
                " dm_city p " +
                " WHERE p.province = '"+province+"'";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String,Object>> getTowmByCity(String city){
        String sql = "SELECT " +
                " p.`code`, " +
                " p.`name` " +
                " FROM " +
                " dm_town p " +
                " WHERE p.city = '"+city+"'";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
}

+ 36 - 19
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -223,26 +223,43 @@ public class PrescriptionInfoService extends BaseService {
                    Iterator iterator = pres.iterator();
                    while (iterator.hasNext()) {
                        com.alibaba.fastjson.JSONObject r = (com.alibaba.fastjson.JSONObject) iterator.next();
                        String dis = gxy;
                        if("1".equals(diagnosisCode)){
                            dis = gxy;
                        }else if("2".equals(diagnosisCode)){
                            dis = tnb;
                        }
                        com.alibaba.fastjson.JSONArray des = (com.alibaba.fastjson.JSONArray) r.getJSONArray("prescriptionDt");
                        boolean flag = false;
                        for (int i = 0; i < des.size(); i++) {
                            PrescriptionDiagnosis ds = des.getObject(i, PrescriptionDiagnosis.class);
                            //如果含有选择病症,标记为true
                            if (dis.equals(ds.getHealthProblem())) {
                                //含有选择的病症
                                flag = true;
                        if("3".equals(diagnosisCode)){
                            com.alibaba.fastjson.JSONArray des = (com.alibaba.fastjson.JSONArray) r.getJSONArray("prescriptionDt");
                            boolean flag = false;
                            for (int i = 0; i < des.size(); i++) {
                                PrescriptionDiagnosis ds = des.getObject(i, PrescriptionDiagnosis.class);
                                //如果含有选择病症,标记为true
                                if (gxy.equals(ds.getHealthProblem()) || tnb.equals(ds.getHealthProblem())) {
                                    //含有选择的病症
                                    flag = true;
                                }
                            }
                            //如果未含有选择的病症,则删除
                            if (!flag){
                                iterator.remove();
                            }
                        }else{
                            String dis = gxy;
                            if("1".equals(diagnosisCode)){
                                dis = gxy;
                            }else if("2".equals(diagnosisCode)){
                                dis = tnb;
                            }
    
                            com.alibaba.fastjson.JSONArray des = (com.alibaba.fastjson.JSONArray) r.getJSONArray("prescriptionDt");
                            boolean flag = false;
                            for (int i = 0; i < des.size(); i++) {
                                PrescriptionDiagnosis ds = des.getObject(i, PrescriptionDiagnosis.class);
                                //如果含有选择病症,标记为true
                                if (dis.equals(ds.getHealthProblem())) {
                                    //含有选择的病症
                                    flag = true;
                                }
                            }
                            //如果未含有选择的病症,则删除
                            if (!flag){
                                iterator.remove();
                            }
                        }
                        //如果未含有选择的病症,则删除
                        if (!flag){
                            iterator.remove();
                        }
                    }
                }

+ 103 - 135
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -5151,7 +5151,7 @@ public class StatisticsService extends BaseService {
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_town t " +
                        " LEFT JOIN ( " +
@ -5166,12 +5166,12 @@ public class StatisticsService extends BaseService {
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("2".equals(lowlevel)){
                 sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
@ -5187,12 +5187,12 @@ public class StatisticsService extends BaseService {
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("1".equals(lowlevel)){
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -5205,7 +5205,7 @@ public class StatisticsService extends BaseService {
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
        //区级维度
        }else if("3".equals(level)){
@ -5213,7 +5213,7 @@ public class StatisticsService extends BaseService {
                 sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
@ -5230,12 +5230,12 @@ public class StatisticsService extends BaseService {
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " AND t.town ='"+area+"'" +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("1".equals(lowlevel)){
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -5249,7 +5249,7 @@ public class StatisticsService extends BaseService {
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE LEFT(t.org_code,6) ='"+area+"' " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
        //机构级维度
        }else if("2".equals(level)){
@ -5257,7 +5257,7 @@ public class StatisticsService extends BaseService {
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -5271,7 +5271,7 @@ public class StatisticsService extends BaseService {
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE t.org_code ='"+area+"'" +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
        }
        rs = jdbcTemplate.queryForList(sql);
@ -5530,7 +5530,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM dm_town tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5543,7 +5543,7 @@ public class StatisticsService extends BaseService {
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5552,7 +5552,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM dm_town tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5565,7 +5565,7 @@ public class StatisticsService extends BaseService {
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5578,7 +5578,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5592,7 +5592,7 @@ public class StatisticsService extends BaseService {
                            " WHERE " +
                            " tw.city = '350200' " +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5601,7 +5601,7 @@ public class StatisticsService extends BaseService {
                    String sql = " SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5615,7 +5615,7 @@ public class StatisticsService extends BaseService {
                            " WHERE " +
                            " tw.city = '350200' " +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5627,7 +5627,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5638,7 +5638,7 @@ public class StatisticsService extends BaseService {
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
@ -5646,7 +5646,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5657,7 +5657,7 @@ public class StatisticsService extends BaseService {
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.id  " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
@ -5673,7 +5673,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5686,10 +5686,10 @@ public class StatisticsService extends BaseService {
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " ADN tw.city = '350200' " +
                            " tw.city = '350200' " +
                            " AND tw.town = '"+ area+"'" +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5698,7 +5698,7 @@ public class StatisticsService extends BaseService {
                    String sql = " SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5714,7 +5714,7 @@ public class StatisticsService extends BaseService {
                            " tw.city = '350200' " +
                            " AND tw.town = '"+ area+"'" +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -5727,7 +5727,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5740,7 +5740,7 @@ public class StatisticsService extends BaseService {
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  LEFT(tw.org_code,6) ='"+area+"' " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
@ -5748,7 +5748,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5761,7 +5761,7 @@ public class StatisticsService extends BaseService {
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  LEFT(tw.org_code,6) ='"+area+"' " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
@ -5776,7 +5776,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " ifnull(c.sum/100,0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
@ -5785,11 +5785,11 @@ public class StatisticsService extends BaseService {
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND p.hospital,6 ='"+area+"' " +
                            " AND p.hospital ='"+area+"' " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  tw.org_code ='"+area+"' " +
                            " ORDER BY sum DESC ";
                            " ORDER BY val DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
@ -5797,7 +5797,7 @@ public class StatisticsService extends BaseService {
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " ifnull(FORMAT(c.avg/100,2),0) val " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
@ -5810,7 +5810,7 @@ public class StatisticsService extends BaseService {
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  tw.org_code ='"+area+"' " +
                            " ORDER BY avg DESC ";
                            " ORDER BY c.avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
@ -5832,50 +5832,38 @@ public class StatisticsService extends BaseService {
        return sql;
    }
    public List<Map<String,Object>> getPrescriptionDispatchingTotal(String level,String area,String disease){
    public Map<String,Object> getPrescriptionDispatchingTotal(String level,String area,String disease){
        String sql = "SELECT " +
                " COUNT(1) total" +
                " FROM " +
                " wlyy_prescription p " ;
        sql = setLevelAndDisSql2(sql,disease, level, area);
        sql += " AND p.`status` > 50 " +
        sql += " AND p.`status` >= " +PrescriptionLog.PrescriptionLogStatus.pay_success.getValue()+
                " AND p.dispensary_type = ? ";
        List<Map<String,Object>> rs = new ArrayList();
        Map<String,Object> rs = new HashedMap();
        //自取数目
        List<Map<String,Object>> seltList = jdbcTemplate.queryForList(sql,new Object[]{1});
        if(seltList!=null&&seltList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("seltTotal",seltList.get(0).get("total"));
            rs.add(map);
            rs.put("seltTotal",seltList.get(0).get("total"));
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("seltTotal",0);
            rs.add(map);
            rs.put("seltTotal",0);
        }
        //快递配送
        List<Map<String,Object>> deliveryList = jdbcTemplate.queryForList(sql,new Object[]{2});
        if(deliveryList!=null&&deliveryList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("deliveryTotal",deliveryList.get(0).get("total"));
            rs.add(map);
            rs.put("deliveryTotal",deliveryList.get(0).get("total"));
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("deliveryTotal",0);
            rs.add(map);
            rs.put("deliveryTotal",0);
        }
        //健管师配送
        List<Map<String,Object>> healthDoctorList = jdbcTemplate.queryForList(sql,new Object[]{2});
        List<Map<String,Object>> healthDoctorList = jdbcTemplate.queryForList(sql,new Object[]{3});
        if(healthDoctorList!=null&&healthDoctorList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("doctorTotal",healthDoctorList.get(0).get("total"));
            rs.add(map);
            rs.put("doctorTotal",healthDoctorList.get(0).get("total"));
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("doctorTotal",0);
            rs.add(map);
            rs.put("doctorTotal",0);
        }
        return rs;
    }
@ -5971,7 +5959,7 @@ public class StatisticsService extends BaseService {
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_town t " +
                        " LEFT JOIN ( " +
@ -5986,12 +5974,12 @@ public class StatisticsService extends BaseService {
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("2".equals(lowlevel)){
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
@ -6007,12 +5995,12 @@ public class StatisticsService extends BaseService {
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("1".equals(lowlevel)){
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -6025,7 +6013,7 @@ public class StatisticsService extends BaseService {
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
            //区级维度
        }else if("3".equals(level)){
@ -6033,7 +6021,7 @@ public class StatisticsService extends BaseService {
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
@ -6050,12 +6038,12 @@ public class StatisticsService extends BaseService {
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " AND t.town ='"+area+"'" +
                        " ORDER BY num DESC";
                        " ORDER BY val DESC";
            }else if("1".equals(lowlevel)){
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -6069,7 +6057,7 @@ public class StatisticsService extends BaseService {
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE LEFT(t.org_code,6) ='"+area+"' " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
            //机构级维度
        }else if("2".equals(level)){
@ -6077,7 +6065,7 @@ public class StatisticsService extends BaseService {
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " ifnull(s.count,0) val  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
@ -6091,7 +6079,7 @@ public class StatisticsService extends BaseService {
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE t.org_code ='"+area+"'" +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
            }
        }
        rs = jdbcTemplate.queryForList(sql);
@ -6101,11 +6089,11 @@ public class StatisticsService extends BaseService {
        return rs;
    }
    public List<Map<String,Object>> getPrescriptionAgeTotal(String level,String area,String disease){
    public Map<String,Object> getPrescriptionAgeTotal(String level,String area,String disease){
        String sql = "SELECT " +
                " ( " +
                " ( SELECT count(pe.patient) 0age from (" +
                "  SELECT " +
                "   count(1) 0age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient ";
@ -6115,11 +6103,11 @@ public class StatisticsService extends BaseService {
                "   )>= 0 " +
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 6 " +
                "  ) <= 6 ) pe" +
                " ) 0age, " +
                " ( " +
                " ( SELECT count(pe.patient) 7age from (" +
                "  SELECT " +
                "   count(1) 7age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient ";
@ -6129,11 +6117,11 @@ public class StatisticsService extends BaseService {
                "   ) >= 7 " +
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 18 " +
                "  ) <= 18 ) pe" +
                " ) 7age, " +
                " ( " +
                " ( SELECT count(pe.patient) 19age from (" +
                "  SELECT " +
                "   count(1) 19age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient " ;
@ -6143,11 +6131,11 @@ public class StatisticsService extends BaseService {
                "   ) >= 19 " +
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 30 " +
                "  ) <= 30 ) pe" +
                " ) 19age, " +
                " ( " +
                " ( SELECT count(pe.patient) 31age from (" +
                "  SELECT " +
                "   count(1) 31age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient " ;
@ -6157,11 +6145,11 @@ public class StatisticsService extends BaseService {
                "   ) >= 31 " +
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 50 " +
                "  ) <= 50 ) pe" +
                " ) 31age, " +
                " ( " +
                " ( SELECT count(pe.patient) 51age from (" +
                "  SELECT " +
                "   count(1) 51age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient ";
@ -6171,27 +6159,27 @@ public class StatisticsService extends BaseService {
                "   ) >= 51 " +
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 64 " +
                "  ) <= 64 ) pe" +
                "  ) 51age, " +
                " ( " +
                " ( SELECT count(pe.patient) 65age from (" +
                "  SELECT " +
                "   count(1) 65age " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient " ;
        sql = setLevelAndDisSql2(sql,disease,level,area);
        sql +=  " AND  YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "    RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "   ) >= 65 " +
                "   ) >= 65 ) pe" +
                "  ) 65age, " +
                "  ( " +
                "  ( SELECT count(pe.patient) total from (" +
                "  SELECT " +
                "   count(1) total " +
                "   DISTINCT p.patient " +
                "  FROM " +
                "   wlyy_prescription p " +
                "  JOIN wlyy_patient pt ON pt. CODE = p.patient " ;
        sql = setLevelAndDisSql2(sql,disease,level,area);
        sql += "  ) total";
        sql += " ) pe ) total";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        if(rs!=null&&rs.size()>0){
@ -6210,7 +6198,7 @@ public class StatisticsService extends BaseService {
            rs.get(0).put("51ageRate",getAgeRate(age51,total));
            rs.get(0).put("65ageRate",getAgeRate(age65,total));
        }
        return rs;
        return rs.get(0);
    }
    public String getAgeRate(Long age,Long total){
@ -6233,10 +6221,8 @@ public class StatisticsService extends BaseService {
        return "0";
    }
    public List<Map<String,Object>> getPrescriptionAgeHistogram(String level,String area,String disease,String startDate,String endDate){
    public Map<String,Object> getPrescriptionAgeHistogram(String level,String area,String disease){
        startDate += " 00:00:00";
        endDate += " 23:59:59";
        String sql ="SELECT " +
                " ( " +
                "  SELECT " +
@ -6251,8 +6237,6 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 6 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 0age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6270,8 +6254,7 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 6 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                " ) c " +
                " ) 0people, " +
                " ( " +
                "  SELECT " +
@ -6286,8 +6269,6 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 18 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 7age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6306,8 +6287,7 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 18 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                " ) c " +
                " ) 7people, " +
                " ( " +
                "  SELECT " +
@ -6322,8 +6302,6 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 30 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 19age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6341,8 +6319,7 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 30 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                "  ) c " +
                "  ) 19people, " +
                "  ( " +
                "  SELECT " +
@ -6357,8 +6334,6 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 50 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 31age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6376,8 +6351,7 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 50 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                "  ) c " +
                "  ) 31people, " +
                "  ( " +
                "  SELECT " +
@ -6392,8 +6366,6 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 64 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 51age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6411,8 +6383,7 @@ public class StatisticsService extends BaseService {
                "  AND YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "   RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "  ) <= 64 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                "  ) c " +
                " ) 51people, " +
                " ( " +
                "  SELECT " +
@ -6424,8 +6395,6 @@ public class StatisticsService extends BaseService {
        sql +=  " AND  YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "    RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "   ) >= 65 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"' " +
                " ) 65age,( " +
                " SELECT " +
                " COUNT(c.patient)  " +
@ -6440,8 +6409,7 @@ public class StatisticsService extends BaseService {
        sql +=  " AND  YEAR (CURDATE()) - YEAR (birthday) - ( " +
                "    RIGHT (CURDATE(), 5) < RIGHT (birthday, 5) " +
                "   ) >= 65 " +
                "  AND p.create_time >='"+startDate+"'  " +
                "  AND p.create_time <='"+endDate+"') c " +
                "  ) c " +
                " ) 65people";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
@ -6470,7 +6438,7 @@ public class StatisticsService extends BaseService {
            rs.get(0).put("65ageRate",getAgeRateLine(age65,people65));
        }
        return rs;
        return rs.get(0);
    }
    public List<Map<String,Object>> getPrescriptionAgeLowLevel(String level,String lowlevel,String area,String disease) {
@ -6480,7 +6448,7 @@ public class StatisticsService extends BaseService {
                String sql = "SELECT " +
                        " tw.`code`, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " dm_town tw LEFT JOIN ( " +
                        " SELECT " +
@ -6501,14 +6469,14 @@ public class StatisticsService extends BaseService {
                        " ) c ON c.code = tw.code " +
                        " WHERE " +
                        " tw.city = '350200' " +
                        "   ORDER BY num DESC ";
                        "   ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                return rs;
            }else if("2".equals(lowlevel)){
                String sql = "SELECT " +
                        " tw.`code`, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " dm_hospital tw LEFT JOIN ( " +
                        " SELECT " +
@ -6530,14 +6498,14 @@ public class StatisticsService extends BaseService {
                        " WHERE " +
                        " tw.city = '350200' " +
                        " AND LENGTH(tw.code)=10 " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                return rs;
            }else if("1".equals(lowlevel)){
                String sql ="SELECT " +
                        " tw.id code, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " wlyy_admin_team tw LEFT JOIN ( " +
                        " SELECT " +
@ -6558,7 +6526,7 @@ public class StatisticsService extends BaseService {
                        " ) c ON c.code = tw.id " +
                        " WHERE " +
                        " 1=1  " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                statisticsAllService.translateTeamLeaderName2(rs);
                return rs;
@ -6568,7 +6536,7 @@ public class StatisticsService extends BaseService {
                String sql = "SELECT " +
                        " tw.`code`, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " dm_hospital tw LEFT JOIN ( " +
                        " SELECT " +
@ -6592,14 +6560,14 @@ public class StatisticsService extends BaseService {
                        " tw.city = '350200' " +
                        " AND tw.town ='"+area+"' " +
                        " AND LENGTH(tw.code)=10 " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                return rs;
            }else if("1".equals(lowlevel)){
                String sql ="SELECT " +
                        " tw.id code, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " wlyy_admin_team tw LEFT JOIN ( " +
                        " SELECT " +
@ -6622,7 +6590,7 @@ public class StatisticsService extends BaseService {
                        " WHERE " +
                        " 1=1  " +
                        " AND LEFT(tw.org_code,6) ='"+area+"' " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                statisticsAllService.translateTeamLeaderName2(rs);
                return rs;
@ -6632,7 +6600,7 @@ public class StatisticsService extends BaseService {
                String sql ="SELECT " +
                        " tw.id code, " +
                        " tw.`name`, " +
                        "  ifnull(c.total,0) num " +
                        "  ifnull(c.total,0) val " +
                        " FROM " +
                        " wlyy_admin_team tw LEFT JOIN ( " +
                        " SELECT " +
@ -6655,7 +6623,7 @@ public class StatisticsService extends BaseService {
                        " WHERE " +
                        " 1=1  " +
                        " AND tw.org_code ='"+area+"' " +
                        " ORDER BY num DESC ";
                        " ORDER BY val DESC ";
                List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                statisticsAllService.translateTeamLeaderName2(rs);
                return rs;

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -904,6 +904,9 @@ public class DateUtil {
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(!dEnd.after(calBegin.getTime())){
				break;
			}
			Map<String,Object> stt = new HashedMap();
			stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
			stt.put("avg",0);
@ -934,6 +937,9 @@ public class DateUtil {
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(!dEnd.after(calBegin.getTime())){
				break;
			}
			if(checkDateMonday(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
@ -966,6 +972,9 @@ public class DateUtil {
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(!dEnd.after(calBegin.getTime())){
				break;
			}
			if(checkFristDayOfDateMonth(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM"));

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -170,6 +170,7 @@ public class DoctorFollowUpController extends BaseController {
            return write(200, "开始随访记录成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "开始随访记录失败!" + e.getMessage());
        }
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -81,7 +81,7 @@ public class PrescriptionInfoController extends BaseController {
                                       @RequestParam(required = false)@ApiParam(name="recipeNo",value="医嘱号,第一次获取上一方时传入0,第二次获取上一方时传入第一次返回的医嘱号,以此类推")String recipeNo,
                                       @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                       @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                       @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病)")String diagnosisCode,
                                       @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病 3高血压或糖尿病)")String diagnosisCode,
                                       @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                       @RequestParam(required = false)@ApiParam(name="size",value="每页记录数")Integer size,
                                       @RequestParam(required = true)@ApiParam(name="patientCode",value="居民CODE")String patientCode){

+ 72 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.patient.prescription;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdressService;
import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
@ -34,6 +35,8 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
    private PrescriptionService prescriptionService;
    @Autowired
    private PrescriptionNoticesService noticesService;
    @Autowired
    private PrescriptionAdressService prescriptionAdressService;
    /**
@ -212,5 +215,74 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "发送失败!");
        }
    }
//===========================v1.3.9======================================================================
    @RequestMapping(value = "/getAdressList", method = RequestMethod.POST)
    @ApiOperation(value = "获取患者所有默认地址")
    public String getAdressList( @ApiParam(name = "patient", value = "居民code")
                                     @RequestParam(value = "patient", required = true)String patient){
        try {
            prescriptionAdressService.getAdressList(patient);
            return write(200, "发送成功!");
        } catch (Exception e) {
            return error(-1, "发送失败!");
        }
    }
    @RequestMapping(value = "/saveAdress", method = RequestMethod.POST)
    @ApiOperation(value = "保存地址")
    public String saveAdress(@ApiParam(name = "adressJosn", value = "实体json串")
                             @RequestParam(value = "adressJosn", required = true)String adressJosn){
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.saveAdress(adressJosn));
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/delAdress", method = RequestMethod.POST)
    @ApiOperation(value = "删除地址")
    public String delAdress(@ApiParam(name = "id", value = "主键")
                                @RequestParam(value = "id", required = true)Long id){
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.delAdress(id));
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/getProvince", method = RequestMethod.POST)
    @ApiOperation(value = "获取省会")
    public String getProvince(){
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getProvince());
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/getCityByProvince", method = RequestMethod.POST)
    @ApiOperation(value = "根据省会获取城市")
    public String getCityByProvince(@ApiParam(name = "province", value = "省会code")
                                        @RequestParam(value = "province", required = true)String province){
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getCityByProvince(province));
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
    @RequestMapping(value = "/getTowmByCity", method = RequestMethod.POST)
    @ApiOperation(value = "根据城市获取区")
    public String getTowmByCity(@ApiParam(name = "city", value = "城市code")
                                    @RequestParam(value = "city", required = true)String city){
        try {
            return write(200, "获取成功!", "data", prescriptionAdressService.getTowmByCity(city));
        } catch (Exception e) {
            return error(-1, "获取失败!");
        }
    }
}

+ 2 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -1825,11 +1825,9 @@ public class StatisticsController extends BaseController {
    @ApiOperation("年龄统计-中部部条形图")
    public String getPrescriptionAgeHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                              @ApiParam(name="area", value="级别编码") @RequestParam(required = true)String area,
                                              @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                              @ApiParam(name="startDate", value="开始时间") @RequestParam(required = true)String startDate,
                                              @ApiParam(name="endDate", value="结束时间") @RequestParam(required = true)String endDate){
                                              @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionAgeHistogram(level,area,disease,startDate,endDate));
            return write(200, "查询成功", "data", statisticsService.getPrescriptionAgeHistogram(level,area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");