Переглянути джерело

Merge branch 'dev' of humingfen/patient-co-management into dev

yeshijie 7 роки тому
батько
коміт
78d80e29a2

+ 0 - 83
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationPlanningService.java

@ -1,83 +0,0 @@
package com.yihu.wlyy.service.third.rehabilitation;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import org.json.JSONObject;
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.stereotype.Service;
/**
 * 康复计划对接
 * @author humingfen on 2018/5/4.
 */
@Service
public class RehabilitationPlanningService {
    private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
    @Value("${rehabilitation.url}")
    private String baseUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HttpUtil httpUtil;
    /**
     * 查询单条
     * @param id
     * @return
     */
    public String getById(String id){
        String url = baseUrl+"planning/findPlanningById?id="+id;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 更新
     * @param jsonData
     * @return
     */
    public String update(String jsonData){
        String url = baseUrl+"planning/updatePlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 删除数据
     *
     */
    public void delete(String id) {
        String url = baseUrl+"planning/delPlanning";
        httpUtil.sendPost(url, id);
        /*if("true".equals(res.getString("obj"))){
            logger.info("删除成功!");
        }else {
            logger.error("删除失败,msg="+res.getString("errorMsg"));
        }*/
    }
    /**
     * 添加条件
     * 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<field>","value":"<value>"},<{...}>]
     * @param andOr
     * @param field
     * @param condition
     * @param value
     * @param jsonArray
     */
    /*private void field(String andOr,String field,String condition,String value,JSONArray jsonArray){
        JSONObject json = new JSONObject();
        json.put("andOr",andOr);
        json.put("field",field);
        json.put("condition",condition);
        json.put("value",value);
        jsonArray.add(json);
    }*/
}

+ 286 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/rehabilitation/RehabilitationService.java

@ -0,0 +1,286 @@
package com.yihu.wlyy.service.third.rehabilitation;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
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.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 康复计划对接
 * @author humingfen on 2018/5/4.
 */
@Service
public class RehabilitationService {
    private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
    @Value("${rehabilitation.url}")
    private String baseUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HttpUtil httpUtil;
    /**
     * 查看康复计划列表
     * @param patientId
     * @param programId
     * @param page
     * @param size
     * @return
     */
    public String getPlanning(String patientId, String programId, Integer page, Integer size) {
        String url = baseUrl + "planning/findPlanningPage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(StringUtils.isNotBlank(programId)) {
            if(url.contains("?")) {
                url += "&programId=" + programId;
            } else {
                url += "?programId=" + programId;
            }
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 根据id查询康复计划
     * @param id
     * @return
     */
    public String getPlanningById(String id){
        String url = baseUrl + "planning/findPlanningById?id="+id;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建康复计划
     * @param jsonData
     * @return
     */
    public String createPlanning(String jsonData) {
        String url = baseUrl + "planning/createPlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 更新康复计划数据
     * @param jsonData
     * @return
     */
    public String updatePlanning(String jsonData){
        String url = baseUrl + "planning/updatePlanning";
        JSONObject params = new JSONObject(jsonData);
        String response = httpClientUtil.postBody(url, params);
        return response;
    }
    /**
     * 删除康复计划数据
     *
     */
    public void delPlanning(String id) {
        String url = baseUrl + "planning/delPlanning";
        Map<String, String> params = new HashMap<String, String>();
        params.put("id", id);
        try {
            httpClientUtil.httpPost(url, params);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /*********************************** 就诊信息 ********************************************/
    /**
     * 根据居民id查看就诊信息
     * @param patientId
     * @return
     */
    public String getInformationByPatientId(String patientId) {
        String url = baseUrl + "information/findInformationByPatientId?patientId=" + patientId;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 查看就诊信息列表
     * @param patientId
     * @param hospital
     * @param page
     * @param size
     * @return
     */
    public String getInformation(String hospital, String patientId, Integer page, Integer size) {
        String url = baseUrl + "information/findInformationPage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(StringUtils.isNotBlank(hospital)) {
            if(url.contains("?")) {
                url += "&hospital=" + hospital;
            } else {
                url += "?hospital=" + hospital;
            }
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /*********************************** 治疗方案 ********************************************/
    /**
     * 治疗方案列表
     * @param name
     * @param page
     * @param size
     * @return
     */
    public String getTreatmentProgram(String name, Integer page, Integer size) {
        String url = baseUrl + "treatmentProgram/findTreatmentProgramPage";
        if(StringUtils.isNotBlank(name)) {
            url += "?name=" + name;
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建治疗方案
     * @param jsonData
     * @return
     */
    public String createTreatmentProgram(String jsonData) {
        String url = baseUrl + "treatmentProgram/createTreatmentProgram";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /**
     * 更新治疗方案
     * @param jsonData
     */
    public String updateTreatmentProgram(String jsonData) {
        String url = baseUrl + "treatmentProgram/updateTreatmentProgram";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /*********************************** 康复计划执行情况 *****************************************/
    /**
     * 康复计划执行情况列表
     * @param patientId
     * @param page
     * @param size
     * @return
     */
    public String getPerformance(String patientId, Integer page, Integer size) {
        String url = baseUrl + "performance/findPerformancePage";
        if(StringUtils.isNotBlank(patientId)) {
            url += "?patientId=" + patientId;
        }
        if(page != null) {
            if(url.contains("?")) {
                url += "&page=" + page;
            } else {
                url += "?page=" + page;
            }
        }
        if(size != null) {
            if(url.contains("?")) {
                url += "&size=" + size;
            } else {
                url += "?size=" + size;
            }
        }
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 根据居民id获取康复计划执行情况
     * @param patientId
     * @return
     */
    public String getPerformanceByPatientId(String patientId) {
        String url = baseUrl + "performance/findPerformanceByPatientId?patientId=" + patientId;
        String response = httpClientUtil.get(url, "UTF-8");
        return response;
    }
    /**
     * 创建康复计划执行情况
     * @param jsonData
     */
    public String createPerformance(String jsonData) {
        String url = baseUrl + "performance/createPerformance";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
    /**
     * 更新康复计划执行情况
     * @param jsonData
     */
    public String updatePerformance(String jsonData) {
        String url = baseUrl + "performance/updatePerformance";
        JSONObject params = new JSONObject(jsonData);
        return httpClientUtil.postBody(url, params);
    }
}

+ 224 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationController.java

@ -0,0 +1,224 @@
package com.yihu.wlyy.web.third.rehabilitation;
import com.yihu.wlyy.service.third.rehabilitation.RehabilitationService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author humingfen on 2018/5/4.
 */
@RestController
@RequestMapping(value = "/rehabilitation",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复计划")
public class RehabilitationController extends BaseController {
    @Autowired
    private RehabilitationService rehabilitationService;
    @RequestMapping(value = "/getPlanning", method = RequestMethod.GET)
    @ApiOperation("查看康复计划")
    public String getPlanning(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "programId", value = "康复计划id", defaultValue = "")
                                     @RequestParam(value = "programId", required = false) String programId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPlanning(patientId, programId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getPlanningById", method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String getPlanningById(@ApiParam(name = "id", value = "id", defaultValue = "")
                           @RequestParam(name = "id", required = true) String id) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPlanningById(id));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createPlanning", method = RequestMethod.POST)
    @ApiOperation("创建康复计划")
    public String createPlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData) {
        try{
            rehabilitationService.createPlanning(jsonData);
            return success("创建成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePlanning",method = RequestMethod.POST)
    @ApiOperation("更新康复计划数据")
    public String updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                     @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.updatePlanning(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/delPlanning",method = RequestMethod.POST)
    @ApiOperation("删除康复计划")
    public String delPlanning(@ApiParam(name = "id", value = "id", defaultValue = "")
                                 @RequestParam(name = "id", required = true) String id){
        try {
            rehabilitationService.delPlanning(id);
            return success("删除成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**************************************** 康复计划执行情况 *******************************/
    @RequestMapping(value = "/getPerformance", method = RequestMethod.GET)
    @ApiOperation("查看康复计划执行情况列表")
    public String getPerformance(@ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPerformance(patientId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getPerformanceByPatientId", method = RequestMethod.GET)
    @ApiOperation("根据居民Id查找康复计划执行情况信息")
    public String getPerformanceByPatientId(@ApiParam(name = "patientId", value = "patientId", defaultValue = "")
                                            @RequestParam(name = "patientId", required = true) String patientId) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getPerformanceByPatientId(patientId));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createPerformance", method = RequestMethod.POST)
    @ApiOperation("创建康复计划执行情况")
    public String createPerformance(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData) {
        try{
            rehabilitationService.createPerformance(jsonData);
            return success("创建成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePerformance",method = RequestMethod.POST)
    @ApiOperation("更新康复计划执行情况数据")
    public String updatePerformance(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                 @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.updatePerformance(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**************************************** 就诊信息 *************************************/
    @RequestMapping(value = "/getInformation", method = RequestMethod.GET)
    @ApiOperation("查看就诊信息")
    public String getInformation(@ApiParam(name = "hospital", value = "就诊医院名称", defaultValue = "")
                                     @RequestParam(value = "hospital", required = false) String hospital,
                                 @ApiParam(name = "patientId", value = "居民id", defaultValue = "")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                     @RequestParam(value = "page", required = false) Integer page,
                                 @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                     @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getInformation(hospital, patientId, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/getInformationByPatientId", method = RequestMethod.GET)
    @ApiOperation("根据居民Id查找就诊信息")
    public String getInformationByPatientId(@ApiParam(name = "patientId", value = "patientId", defaultValue = "")
                                            @RequestParam(name = "patientId", required = true) String patientId) {
        try {
            return write(200, "查询成功", "data", rehabilitationService.getInformationByPatientId(patientId));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**************************************** 治疗方案 *************************************/
    @RequestMapping(value = "/getTreatmentProgram", method = RequestMethod.GET)
    @ApiOperation("治疗方案列表")
    public String getTreatmentProgram(@ApiParam(name = "name", value = "方案名称", defaultValue = "")
                                          @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "page", value = "第几页", defaultValue = "")
                                          @RequestParam(value = "page", required = false) Integer page,
                                      @ApiParam(name = "size", value = "每页记录数", defaultValue = "")
                                          @RequestParam(value = "size", required = false) Integer size){
        try {
            return write(200, "查询成功", "data", rehabilitationService.getTreatmentProgram(name, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/createTreatmentProgram", method = RequestMethod.POST)
    @ApiOperation("创建治疗方案")
    public String createTreatmentProgram(@ApiParam(name = "jsonData", value = "json")
                                         @RequestParam(name = "jsonData", required = true)String jsonData){
        try {
            rehabilitationService.createTreatmentProgram(jsonData);
            return success("创建成功");
        }catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updateTreatmentProgram", method = RequestMethod.POST)
    @ApiOperation("更新治疗方案")
    public String updateTreatmentProgram(@ApiParam(name = "jsonData", value = "json")
                                         @RequestParam(name = "jsonData", required = true)String jsonData){
        try{
            rehabilitationService.updateTreatmentProgram(jsonData);
            return success("更新成功");
        }catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 0 - 63
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/rehabilitation/RehabilitationPlanningController.java

@ -1,63 +0,0 @@
package com.yihu.wlyy.web.third.rehabilitation;
import com.yihu.wlyy.service.third.rehabilitation.RehabilitationPlanningService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author humingfen on 2018/5/4.
 */
@RestController
@RequestMapping(value = "/rehabilitation",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复计划")
public class RehabilitationPlanningController extends BaseController {
    @Autowired
    private RehabilitationPlanningService rehabilitationPlanningService;
    @RequestMapping(value = "/findById",method = RequestMethod.GET)
    @ApiOperation("按id查询")
    public String findById(@ApiParam(name = "id",value = "id",defaultValue = "")
                           @RequestParam(name="id",required = true) String id) {
        try {
            return write(200, "查询成功", "data", rehabilitationPlanningService.getById(id));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/updatePlanning",method = RequestMethod.POST)
    @ApiOperation("修改康复计划数据")
    public String updatePlanning(@ApiParam(name = "jsonData", value = "json", defaultValue = "")
                                     @RequestParam(value = "jsonData", required = true)String jsonData){
        try {
            rehabilitationPlanningService.update(jsonData);
            return success("更新成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @RequestMapping(value = "/delPlanning",method = RequestMethod.POST)
    @ApiOperation("删除康复计划")
    public String delHealthIndex(@ApiParam(name = "id",value = "id",defaultValue = "")
                                 @RequestParam(name="id",required = true) String id){
        try {
            rehabilitationPlanningService.delete(id);
            return success("删除成功");
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}