|
@ -0,0 +1,367 @@
|
|
|
package com.yihu.jw.hospital.module.health.controller;
|
|
|
|
|
|
|
|
|
import com.yihu.jw.entity.base.health.PatientHealthRecordDiet;
|
|
|
import com.yihu.jw.entity.base.health.PatientHealthRecordMedication;
|
|
|
import com.yihu.jw.entity.base.health.PatientHealthRecordSports;
|
|
|
import com.yihu.jw.hospital.module.common.BaseController;
|
|
|
import com.yihu.jw.hospital.module.health.service.PatientHealthRecordService;
|
|
|
import com.yihu.jw.hospital.module.jw.service.JwArchivesService;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.service.PatientRecordService;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
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;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
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 George
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/doctor/health_record")
|
|
|
@Api(description = "健康记录")
|
|
|
public class DoctorHealthRecordController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private PatientHealthRecordService patientHealthRecordService;
|
|
|
@Autowired
|
|
|
private JwArchivesService jwArchivesService;
|
|
|
@Value("${demo.flag}")
|
|
|
private Boolean demoFlag;
|
|
|
@Autowired
|
|
|
private PatientRecordService patientRecordService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 患者最近填写的运动、用药、饮食内容
|
|
|
*
|
|
|
* @param patient 患者标识
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "recent", method = RequestMethod.GET)
|
|
|
@ApiOperation("根据患者标志获取最近的保健记录")
|
|
|
public String recent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
|
|
|
@RequestParam(value = "patient", required = true) String patient) {
|
|
|
try {
|
|
|
JSONObject json = patientHealthRecordService.findRecentByPatient(patient);
|
|
|
if (json != null) {
|
|
|
return write(200, "查询成功", "data", json);
|
|
|
} else {
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 运动记录查询接口
|
|
|
*
|
|
|
* @param patient 患者标识
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "list_sports", method = RequestMethod.POST)
|
|
|
@ApiOperation("获取患者运动记录")
|
|
|
public String sports(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
|
|
|
@RequestParam(value = "patient", required = true) String patient,
|
|
|
@ApiParam(name = "start", value = "开始时间", defaultValue = "2017-05-15 00:00:00")
|
|
|
@RequestParam(value = "start", required = true) String start,
|
|
|
@ApiParam(name = "end", value = "结束时间", defaultValue = "2017-05-15 12: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 {
|
|
|
Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(patient, start, end, page, pagesize);
|
|
|
if (data != null) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
for (PatientHealthRecordSports record : data) {
|
|
|
if (record == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", record.getId());
|
|
|
// 设置记录标识
|
|
|
json.put("code", record.getCode());
|
|
|
// 设置记录日期
|
|
|
json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
|
|
|
json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
|
|
|
// 设置运动时长(分钟)
|
|
|
json.put("sports_time", record.getSportsTime());
|
|
|
// 设置运动强度
|
|
|
json.put("sports_type", record.getSportsTypeName());
|
|
|
// 设置运动类型
|
|
|
json.put("sports", record.getSportsName());
|
|
|
array.put(json);
|
|
|
}
|
|
|
return write(200, "查询成功", "list", array);
|
|
|
} else {
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用药记录查询接口
|
|
|
*
|
|
|
* @param patient 患者标识
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "list_medication", method = {RequestMethod.GET})
|
|
|
@ApiOperation("获取患者用药记录")
|
|
|
public String medication(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
|
|
|
@RequestParam(value = "patient", required = true) String patient,
|
|
|
@ApiParam(name = "start", value = "开始")
|
|
|
@RequestParam(required = false) String start,
|
|
|
@ApiParam(name = "end", value = "结束")
|
|
|
@RequestParam(required = false) String end,
|
|
|
@ApiParam(name = "page", value = "第几页", defaultValue = "1")
|
|
|
@RequestParam(required = false) Integer page,
|
|
|
@ApiParam(name = "sortDate", value = "日期")
|
|
|
@RequestParam(required = false) String sortDate,
|
|
|
@ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "10")
|
|
|
@RequestParam(required = true) int pagesize) {
|
|
|
try {
|
|
|
Page<PatientHealthRecordMedication> data = null;
|
|
|
if (!StringUtils.isEmpty(sortDate)) {
|
|
|
data = patientHealthRecordService.findMedicationByPatient(patient, DateUtil.strToDateLong(sortDate), page, pagesize);
|
|
|
} else {
|
|
|
data = patientHealthRecordService.findMedicalByPatientPage(patient, start, end, page, pagesize);
|
|
|
}
|
|
|
|
|
|
if (data != null) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
for (PatientHealthRecordMedication record : data) {
|
|
|
if (record == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", record.getId());
|
|
|
// 设置记录标识
|
|
|
json.put("code", record.getCode());
|
|
|
// 设置记录日期
|
|
|
json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
|
|
|
json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
|
|
|
// 药品名称
|
|
|
json.put("medicines", record.getMedicinesName());
|
|
|
array.put(json);
|
|
|
}
|
|
|
return write(200, "查询成功", "list", array);
|
|
|
} else {
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 饮食记录查询接口
|
|
|
*
|
|
|
* @param patient 患者标识
|
|
|
* @param page 页码
|
|
|
* @param pagesize 分页大小
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "list_diet", method = RequestMethod.POST)
|
|
|
@ApiOperation("饮食记录查询接口")
|
|
|
public String diet(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
|
|
|
@RequestParam(value = "patient", required = true) String patient,
|
|
|
@ApiParam(name = "start", value = "开始")
|
|
|
@RequestParam(required = true) String start,
|
|
|
@ApiParam(name = "end", value = "结束")
|
|
|
@RequestParam(required = false) String end,
|
|
|
@ApiParam(name = "page", value = "第几页", defaultValue = "1")
|
|
|
@RequestParam(required = true) int page,
|
|
|
@ApiParam(name = "pagesize", value = "每页记录数", defaultValue = "10")
|
|
|
@RequestParam(required = true) int pagesize) {
|
|
|
try {
|
|
|
Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(patient, start, end, page, pagesize);
|
|
|
if (data != null) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
for (PatientHealthRecordDiet record : data) {
|
|
|
if (record == null) {
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("id", record.getId());
|
|
|
// 设置记录标识
|
|
|
json.put("code", record.getCode());
|
|
|
// 设置记录日期
|
|
|
json.put("record_date", DateUtil.dateToStrShort(record.getRecordDate()));
|
|
|
json.put("sortDate", DateUtil.dateToStrLong(record.getSortDate()));
|
|
|
// 设置饮食内容
|
|
|
json.put("content", record.getContent());
|
|
|
// 设置图片URL,多图以逗号分隔
|
|
|
json.put("images", record.getImages());
|
|
|
array.put(json);
|
|
|
}
|
|
|
return write(200, "查询成功", "list", array);
|
|
|
} else {
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// @RequestMapping(value = "list_medical", method = RequestMethod.POST)
|
|
|
// @ApiOperation("查询居民健康体检列表")
|
|
|
// public String medical(@ApiParam(name = "patient", value = "患者代码", defaultValue = "P20160901001")
|
|
|
// @RequestParam(value = "patient", required = true) String patient,
|
|
|
// @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
|
|
|
// @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
|
|
|
// @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
|
|
|
// @RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
|
|
// try {
|
|
|
//
|
|
|
// if (demoFlag) {
|
|
|
// String res = patientRecordService.getJosnFileResullt("list_medical");
|
|
|
// return res;
|
|
|
// } else {
|
|
|
// Patient p = patientService.findByCode(patient);
|
|
|
// if (p != null) {
|
|
|
// JSONArray re = jwArchivesService.getEhrSickMedicalList(p.getIdcard(), pageIndex, pageSize);
|
|
|
// return write(200, "查询成功", "list", re);
|
|
|
// } else {
|
|
|
// return error(-1, "患者不存在");
|
|
|
// }
|
|
|
// }
|
|
|
// } catch (ServiceException se) {
|
|
|
// return write(-1, se.getMessage());
|
|
|
// } catch (Exception e) {
|
|
|
// return errorResult(e);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
@RequestMapping(value = "medical_detail", method = RequestMethod.POST)
|
|
|
@ApiOperation("查询居民健康体检详情信息")
|
|
|
public String medical_detail(@ApiParam(name = "medicalNo", value = "体检ID", defaultValue = "1249652")
|
|
|
@RequestParam(value = "medicalNo", required = true) String medicalNo) {
|
|
|
try {
|
|
|
if (demoFlag) {
|
|
|
String res = patientRecordService.getJosnFileResullt("medical_detail");
|
|
|
return res;
|
|
|
} else {
|
|
|
JSONObject json = jwArchivesService.getEhrSickMedicalRecord(medicalNo);
|
|
|
return write(200, "查询成功", "medical_detail", json);
|
|
|
}
|
|
|
} catch (ServiceException se) {
|
|
|
return write(-1, se.getMessage());
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据区域查询体检详情信息
|
|
|
*/
|
|
|
// @ApiOperation("根据区域查询体检详情信息")
|
|
|
// @PostMapping(value = "areaMedicalDetail")
|
|
|
// public String areaMedicalDetail(@ApiParam(name = "areaCode", value = "区域code", defaultValue = "350205")
|
|
|
// @RequestParam(value = "areaCode", required = false) String areaCode,
|
|
|
// @ApiParam(name = "patientId", value = "用户id", defaultValue = "")
|
|
|
// @RequestParam(value = "patientId", required = false) String patientId) {
|
|
|
// try {
|
|
|
// //查询出区域的签约人
|
|
|
// if (StringUtils.isBlank(areaCode) && StringUtils.isBlank(patientId)) {
|
|
|
// return write(-1, "参数为空");
|
|
|
// }
|
|
|
// String result = patientRecordService.areaMedicalDetail(areaCode, patientId, demoFlag);
|
|
|
// return result;
|
|
|
// } catch (ServiceException se) {
|
|
|
// System.out.println(se);
|
|
|
// return write(-1, se.getMessage());
|
|
|
// } catch (Exception e) {
|
|
|
// System.out.println(e);
|
|
|
// return errorResult(e);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 保存体检详情信息
|
|
|
*/
|
|
|
// @ApiOperation("保存体检详情信息")
|
|
|
// @PostMapping(value = "saveMedicalDetail")
|
|
|
// public String saveMedicalDetail(@ApiParam(name = "medicalNo", value = "体检号", defaultValue = "10891028")
|
|
|
// @RequestParam(value = "medicalNo", required = false) String medicalNo,
|
|
|
// @ApiParam(name = "findType", value = "查询类型 1查本地2查远程", defaultValue = "1")
|
|
|
// @RequestParam(value = "findType", required = false) String findType,
|
|
|
// @ApiParam(name = "findAll", value = "是否查全部,yes是 temp走补录", defaultValue = "yes")
|
|
|
// @RequestParam(value = "findAll", required = false) String findAll) {
|
|
|
// try {
|
|
|
// //查询出区域的签约人
|
|
|
// if (StringUtils.isBlank(medicalNo) && StringUtils.isBlank(findAll)) {
|
|
|
// return write(-1, "参数为空");
|
|
|
// }
|
|
|
// String result = patientRecordService.saveMedicalDetailMethod(findType, findAll);
|
|
|
// return result;
|
|
|
//
|
|
|
// } catch (ServiceException se) {
|
|
|
// System.out.println(se);
|
|
|
// return write(-1, se.getMessage());
|
|
|
// } catch (Exception e) {
|
|
|
// System.out.println(e);
|
|
|
// return errorResult(e);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
|
|
* patient/archives/event
|
|
|
* /smjk/GetResidentEventListJson
|
|
|
* 接口地址 /base/CallEhrInterface
|
|
|
*/
|
|
|
// @ApiOperation("保存健康档案信息")
|
|
|
// @PostMapping(value = "saveHealthRecord")
|
|
|
// public String saveHealthRecord(
|
|
|
// @ApiParam(name = "idcard", value = "身份证号", defaultValue = "") @RequestParam(value = "idcard", required = false) String idcard) {
|
|
|
// try {
|
|
|
// String result = patientRecordService.saveHealthRecord(idcard);
|
|
|
// return result;
|
|
|
// } catch (ServiceException se) {
|
|
|
// System.out.println(se);
|
|
|
// return write(-1, se.getMessage());
|
|
|
// } catch (Exception e) {
|
|
|
// System.out.println(e);
|
|
|
// return errorResult(e);
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
@RequestMapping(value = "dietDetail", method = RequestMethod.GET)
|
|
|
@ApiOperation("饮食记录详情接口")
|
|
|
public String dietDetail(@ApiParam(name = "id", value = "饮食记录ID")
|
|
|
@RequestParam(value = "id") Long dietId) {
|
|
|
try {
|
|
|
JSONObject json = patientHealthRecordService.findById(dietId);
|
|
|
if (json.getInt("status") == 200) {
|
|
|
return write(200, "查询成功!", "data", json.getJSONObject("data"));
|
|
|
} else {
|
|
|
return error(-1, json.getString("msg"));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return errorResult(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|