Browse Source

代码修改

LAPTOP-KB9HII50\70708 11 months ago
parent
commit
829d253d00

+ 56 - 91
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java

@ -15,7 +15,6 @@ import com.yihu.jw.hospital.module.health.service.PatientHealthIndexService;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
@ -33,7 +32,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 患者端:设备管理控制类
@ -66,17 +68,20 @@ public class PatientDeviceController extends BaseController {
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDeviceLogService patientDeviceLogService;
    @Autowired
    private MessageDao messageDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    @ApiOperation("获取居民标准体征预警值")
    @RequestMapping(value = "getDeviceStandard", method = RequestMethod.GET)
    public String getDeviceStandard(@ApiParam(name = "type", value = "类型1血糖,2血压", defaultValue = "1")
    public String getDeviceStandard(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                        @RequestParam(value = "patientId", required = false) String patientId,
                                    @ApiParam(name = "type", value = "类型1血糖,2血压", defaultValue = "1")
                                    @RequestParam(value = "type", required = true) Integer type){
        try {
            JSONObject json = patientHealthIndexService.getealthStandard(type,getRepUID());
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONObject json = patientHealthIndexService.getealthStandard(type,patientId);
            return write(200,"获取成功","data",json);
        } catch (Exception ex) {
            error(ex);
@ -116,14 +121,18 @@ public class PatientDeviceController extends BaseController {
                               @RequestParam String deviceSN,
                               @RequestParam String categoryCode,
                               @RequestParam String userType,
                               @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                   @RequestParam(value = "patientId", required = false) String patientId,
                               @RequestParam(required = false) String newDeviceSN,
                               @RequestParam(required = false) String hospital,
                               @RequestParam(required = false) String hospitalName,
                               @RequestParam(required = false) String checkDoctorName) {
        try {
//            String user = getUID();
            String user = getRepUID();
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            String user = patientId;
            if (StringUtils.isNotEmpty(newDeviceSN)) {
//                校验新的sn码 1.是否被占用 2.是否是真的设备码
@ -133,10 +142,6 @@ public class PatientDeviceController extends BaseController {
                    if (device != null) {
                        throw new Exception("sn码" + newDeviceSN + "已被使用!");
                    }
//                    if(!patientDeviceService.checkDeviceSn(newDeviceSN)){
//                        return error(-1,"设备不存在");
//                    }
                }
                if ("1".equals(categoryCode)) {
//                        先修改患者设备绑定表
@ -174,19 +179,22 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"06B52305030267\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                             @RequestParam(value = "patientId", required = false) String patientId,
                             @ApiParam(name="isScan",value="是否扫一扫 1是0否,默认否",required = false)
                             @RequestParam(value="isScan",required = false) String isScan) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            if(StringUtils.isBlank(device.getDeviceSn())){
                return write(-1,"sn码不能为空!");
            }
            // 设置患者标识
            if(StringUtils.isBlank(device.getUser())){
                device.setUser(getRepUID());
                device.setUser(patientId);
            }
//            device.setUser(getUID());
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
            boolean flag = (Boolean)checkMap.get("flag");
@ -195,11 +203,11 @@ public class PatientDeviceController extends BaseController {
                return write(-1,"设备不存在或者数据存在错误!");
            }
            BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
            if(!getUID().equals(getRepUID())&&device.getId()==null){
                device.setAgent(getRepUID());
                device.setAgentName(patient.getName());
            }
            BasePatientDO patient = patientService.findById(patientId).orElse(null);
//            if(!getUID().equals(patientId)&&device.getId()==null){
//                device.setAgent(patientId);
//                device.setAgentName(patient.getName());
//            }
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                patientDeviceService.saveDevice(device,isScan);
@ -252,10 +260,15 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
    public String getDeviceByPatient(@ApiParam(name = "id", value = "分页起始id", defaultValue = "0")
                                     @RequestParam(value = "id", required = true) long id,
                                     @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<DevicePatientDevice> list = patientDeviceService.findByPatient(getRepUID(), id, pagesize);
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            Page<DevicePatientDevice> list = patientDeviceService.findByPatient(patientId, id, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
@ -293,13 +306,15 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "PatientDeviceIdcard", method = RequestMethod.GET)
    public String getDeviceUser(@ApiParam(name = "type", value = "设备类型", defaultValue = "1")
                                @RequestParam(value = "type", required = true) String type,
                                @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                @RequestParam(value = "patientId", required = false) String patientId,
                                @ApiParam(name = "device_sn", value = "设备SN码", defaultValue = "15L000002")
                                @RequestParam(value = "device_sn", required = true) String deviceSn) {
        try {
//            if (!"11".equals(type)&&deviceDetailService.findByDeviceSn(deviceSn)==null){
//                return write(-1,"设备不存在!");
//            }
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(patientId, deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
@ -314,50 +329,27 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "sendDeviceReviewMessage",method = RequestMethod.POST)
    public String sendDeviceReviewMessage(@ApiParam(name = "id", value = "删除设备关联ID")
                                              @RequestParam(value = "id", required = true) String id,
                                          @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                          @RequestParam(value = "patientId", required = false) String patientId,
                                          @ApiParam(name = "reson", value = "解绑理由")
                                          @RequestParam(value = "reson", required = true) String reson){
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
//                if (!StringUtils.equals(pd.getUser(), getUID())) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                if (!StringUtils.equals(pd.getUser(), patientId)) {
                    return error(-1, "只允许删除自己的设备!");
                }
                //居民自主解绑设备时发送消息给医生
                BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
                BasePatientDO patient = patientService.findById(patientId).orElse(null);
                String messageContent =  "您的居民"+patient.getName()+"申请解绑智能设备:"+pd.getDeviceName()+",请及时处理";
//                if ("1".equals(pd.getCategoryCode())){
//                    messageContent +="血糖仪,点击下方查看居民详情";
//                }else if ("2".equals(pd.getCategoryCode())){
//                    messageContent +="血压计,点击下方查看居民详情";
//                }else if ("4".equals(pd.getCategoryCode())){
//                    messageContent +="智能手表,点击下方查看居民详情";
//                }
                
                JSONObject contentObj = new JSONObject();
                contentObj.put("reason",reson);
                contentObj.put("messageContent",messageContent);
                contentObj.put("patientName",patient.getName());
                
/*                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent(contentObj.toString());
                message.setRead(1);//设置未读
                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
                message.setSender("admin");//设置发送的用户
                message.setSenderName("系统");
                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                message.setSenderPhoto("");
                message.setTitle("解绑设备审核消息");
                message.setType(302);//解绑设备消息
                message.setReadonly(1);//是否只读消息
                message.setSex(1);
                message.setRelationCode(id);
                message.setOver("1");//未处理
                message.setData("");
                message.setDel("1");
                messageDao.save(message);*/
    
                pd.setApplyStatus(1);//审核中
                pd.setApplyReason(reson);
@ -379,47 +371,20 @@ public class PatientDeviceController extends BaseController {
    @ApiOperation("设备删除")
    @RequestMapping(value = "DeletePatientDevice",method = {RequestMethod.GET,RequestMethod.POST})
    public String delete(@ApiParam(name = "id", value = "删除设备关联ID")
                         @RequestParam(value = "id", required = true) String id) {
                         @RequestParam(value = "id", required = true) String id,
                         @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                         @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
//                if (!StringUtils.equals(pd.getUser(), getUID())) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                if (!StringUtils.equals(pd.getUser(), patientId)) {
                    return error(-1, "只允许删除自己的设备!");
                }
                // 删除设备
                patientDeviceService.deleteDevice(id, getRepUID());
//                patientDeviceService.deleteDevice(id, getUID());
                //居民自主解绑设备时发送消息给医生
                BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
                String messageContent =  "您的居民"+patient.getName()+"解绑了";
                if ("1".equals(pd.getCategoryCode())){
                    messageContent +="血糖仪,点击下方查看居民详情";
                }else if ("2".equals(pd.getCategoryCode())){
                    messageContent +="血压计,点击下方查看居民详情";
                }else if ("4".equals(pd.getCategoryCode())){
                    messageContent +="智能手表,点击下方查看居民详情";
                }
/*                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent(messageContent);
                message.setRead(1);//设置未读
                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
                message.setSender("admin");//设置发送的用户
                message.setSenderName("系统");
                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                message.setSenderPhoto("");
                message.setTitle("解绑设备消息");
                message.setType(301);//解绑设备消息
                message.setReadonly(1);//是否只读消息
                message.setSex(1);
                message.setRelationCode(patient.getCode());
                message.setOver("1");//未处理
                message.setData("");
                message.setDel("1");
                messageDao.save(message);*/
                patientDeviceService.deleteDevice(id, patientId);
                //全部解绑后去判断就更新设备表中是否绑定字段
                patientDeviceLogService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
                deviceDetailService.unBindUpdateIsBinding(pd.getDeviceSn());

+ 33 - 104
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthController.java

@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@ -25,9 +24,6 @@ public class PatientHealthController extends BaseController {
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 更改接口(包括手动记录的修改和所有的删除)
@ -61,11 +57,14 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "/getRecentData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者最近的各项健康信息")
    public String getRecentData() {
    public String getRecentData(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                    @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            List list = new ArrayList();
            String patient = getRepUID();
//            String patient = getUID();
            String patient = patientId;
//            健康指标类型(1血糖,2血压,3体重,4腰围)
            Map map = healthIndexService.findDataByPatient(patient, 1);
            Map map1 = healthIndexService.findDataByPatient(patient, 2);
@ -241,9 +240,13 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "recent", method = RequestMethod.GET)
    @ApiOperation("患者最近填写的健康指标")
    public String recent() {
    public String recent(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                             @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            JSONArray array = healthIndexService.findRecentByPatient(getRepUID());
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray array = healthIndexService.findRecentByPatient(patientId);
            if (array != null) {
                return write(200, "查询成功", "list", array);
            } else {
@ -259,10 +262,14 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "last", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取患者最后填写的健康指标(新)")
    public String last() {
    public String last(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                           @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            Map<String, Object> map = new HashMap<>();
            String patient = getRepUID();
            String patient = patientId;
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatienIot(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
@ -293,40 +300,6 @@ public class PatientHealthController extends BaseController {
        }
    }
    @RequestMapping(value = "last_new", method = RequestMethod.GET)
    @ApiOperation("获取患者最后填写的健康指标(新)-展会")
    public String last_new() {
        try {
            Map<String, Object> map = new HashMap<>();
            String patient = getRepUID();
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatienIot(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
            }
            DevicePatientHealthIndex xy = healthIndexService.findLastByPatienIot(patient, 2);
            if (xy != null) {
                map.put("xy", xy);
            }
            DevicePatientHealthIndex tz = healthIndexService.findLastByPatienIot(patient, 3);
            if (tz != null) {
                map.put("tz", tz);
            }
            DevicePatientHealthIndex sg = healthIndexService.findLastByPatienIot(patient, 4);
            if (sg != null) {
                map.put("sg", sg);
            }
            DevicePatientHealthIndex xl = healthIndexService.findLastByPatienIot(patient, 5);
            if (xl != null) {
                map.put("xl", xl);
            }
            return write(200, "查询成功", "data", map);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
    @ApiOperation("新增患者指标")
    public String addPatientHealthIndex(@ApiParam(name = "data", value = "指标数据", defaultValue = "{\"gi\":\"5.5\",\"gi_type\":\"1\"}")
@ -345,10 +318,6 @@ public class PatientHealthController extends BaseController {
            if (type.equals("1") || type.equals("2")) {
                healthIndexService.verifyHealthIndex(obj.getId());
            }
            //判断居民的体征预警状态
//            healthIndexService.handlePatientStandarStatus(obj);
            return success("新增患者指标成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
@ -378,36 +347,17 @@ public class PatientHealthController extends BaseController {
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                                   @RequestParam(value = "patientId", required = false) String patientId,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    @RequestMapping(value = "chart_new", method = RequestMethod.POST)
    @ApiOperation("根据患者标志获取健康指标(图表)-展会")
    public String getHealthIndexChartByPatient_new(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            if (jsonArray.length()==0) {
                return success("查询成功!");
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray jsonArray = healthIndexService.findChartByPatient(patientId, type, gi_type, begin, end);
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
@ -424,6 +374,8 @@ public class PatientHealthController extends BaseController {
                                          @RequestParam(value = "start", required = true) String start,
                                          @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value = "end", required = true) String end,
                                          @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                              @RequestParam(value = "patientId", required = false) String patientId,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                          @RequestParam(value = "page", required = true) int page,
                                          @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
@ -432,10 +384,10 @@ public class PatientHealthController extends BaseController {
            JSONObject jsonObject2 = new JSONObject();
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
                List<Object> list = healthIndexService.findIndexByPatient2(patientId, type, start, end, page, pagesize);
                jsonObject2.put("data",list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
                jsonArray = healthIndexService.findIndexByPatient(patientId, type, start, end, page, pagesize);
                JSONArray jsonArray1 = new JSONArray();
                jsonObject2.put("data",jsonArray);
            }
@ -446,41 +398,18 @@ public class PatientHealthController extends BaseController {
        }
    }
    @RequestMapping(value = "list_new", method = RequestMethod.POST)
    @ApiOperation("患者获取健康指标-展会")
    public String getHealthIndexByPatient_new(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重/身高,4腰围)", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,
                                          @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value = "end", required = true) String end,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                          @RequestParam(value = "page", required = true) int page,
                                          @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
                                          @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    @RequestMapping(value = "standard", method = RequestMethod.GET)
    @ApiOperation("患者健康指标预警值查询")
    public String standard() {
    public String standard(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                               @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray standardArray = new JSONArray();
            JSONArray userArray = new JSONArray();
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getRepUID());
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(patientId);
            Iterator<PatientHealthStandard> iterator = null;
            if (iterable != null) {
                iterator = iterable.iterator();

+ 49 - 16
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthRecordController.java

@ -10,6 +10,7 @@ import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -165,13 +166,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_sports", method ={ RequestMethod.POST})
	@ApiOperation("添加运动记录")
	public String addSports(String record_date, double sportsTime, String sportsType, String sports) {
	public String addSports(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
								@RequestParam(value = "patientId", required = false) String patientId,
							String record_date, double sportsTime, String sportsType, String sports) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordSports record = new PatientHealthRecordSports();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setSportsTime(sportsTime);
@ -195,13 +200,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_medication", method ={ RequestMethod.POST})
	@ApiOperation("添加用药记录")
	public String addMedication(String record_date, String medicines, String medicines_name) {
	public String addMedication(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
									@RequestParam(value = "patientId", required = false) String patientId,
								String record_date, String medicines, String medicines_name) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordMedication record = new PatientHealthRecordMedication();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setMedicines(medicines);
@ -226,12 +235,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_diet", method ={ RequestMethod.POST})
	@ApiOperation("添加饮食记录接口")
	public String add(String record_date, String content, @RequestParam(required = false) String images) {
	public String add(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
						  @RequestParam(value = "patientId", required = false) String patientId,
					  String record_date, String content, @RequestParam(required = false) String images) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordDiet record = new PatientHealthRecordDiet();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setContent(content);
@ -253,9 +267,13 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "recent", method ={ RequestMethod.GET})
	@ApiOperation("最近填写的运动、用药、饮食内容")
	public String recent() {
	public String recent(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
							 @RequestParam(value = "patientId", required = false) String patientId) {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(getRepUID());
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			JSONObject json = patientHealthRecordService.findRecentByPatient(patientId);
			if (json != null) {
				return write(200, "查询成功", "data", json);
			} else {
@ -274,9 +292,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_sports", method ={RequestMethod.GET})
	@ApiOperation("运动记录查询接口")
	public String sports(String start,String end,int page, int pagesize) {
	public String sports(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
							 @RequestParam(value = "patientId", required = false) String patientId,
						 String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getRepUID(), start,end,page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(patientId, start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordSports record : data) {
@ -315,9 +338,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_medication", method ={RequestMethod.GET})
	@ApiOperation("用药记录查询接口")
	public String medication(String start,String end,int page, int pagesize) {
	public String medication(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
								 @RequestParam(value = "patientId", required = false) String patientId,
							 String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getRepUID(), start, end, page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(patientId, start, end, page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordMedication record : data) {
@ -352,9 +380,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_diet", method ={ RequestMethod.GET})
	@ApiOperation("饮食记录查询接口")
	public String diet(String start,String end,int page,int pagesize) {
	public String diet(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
						   @RequestParam(value = "patientId", required = false) String patientId,
					   String start,String end,int page,int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getRepUID(),start,end,page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(patientId,start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordDiet record : data) {