|
@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.archives;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.yihu.wlyy.entity.patient.PatientEvent;
|
|
import com.yihu.wlyy.entity.patient.PatientEvent;
|
|
import com.yihu.wlyy.entity.patient.PatientEventImg;
|
|
import com.yihu.wlyy.entity.patient.PatientEventImg;
|
|
|
|
import com.yihu.wlyy.logs.BusinessLogs;
|
|
import com.yihu.wlyy.repository.patient.PatientEventDao;
|
|
import com.yihu.wlyy.repository.patient.PatientEventDao;
|
|
import com.yihu.wlyy.repository.patient.PatientEventImgDao;
|
|
import com.yihu.wlyy.repository.patient.PatientEventImgDao;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
@ -32,22 +33,17 @@ public class PatientEventService {
|
|
private PatientEventImgDao patientEventImgDao;
|
|
private PatientEventImgDao patientEventImgDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取就诊事件详情
|
|
* 获取就诊事件详情
|
|
*/
|
|
*/
|
|
public JSONObject getEventDetail(String id) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public JSONObject getEventDetail(String id) throws Exception {
|
|
JSONObject re = new JSONObject();
|
|
JSONObject re = new JSONObject();
|
|
PatientEvent event = patientEventDao.findOne(Long.valueOf(id));
|
|
PatientEvent event = patientEventDao.findOne(Long.valueOf(id));
|
|
if(event!=null)
|
|
|
|
{
|
|
|
|
re = new JSONObject(event);
|
|
|
|
|
|
if (event != null) {
|
|
|
|
re = new JSONObject(event);
|
|
List<PatientEventImg> list = patientEventImgDao.findByEventId(event.getId());
|
|
List<PatientEventImg> list = patientEventImgDao.findByEventId(event.getId());
|
|
re.put("eventImg",list);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
re.put("eventImg", list);
|
|
|
|
} else {
|
|
throw new Exception("不存在该就诊事件!");
|
|
throw new Exception("不存在该就诊事件!");
|
|
}
|
|
}
|
|
|
|
|
|
@ -59,19 +55,15 @@ public class PatientEventService {
|
|
* 删除就诊事件
|
|
* 删除就诊事件
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
public void deleteEvent(Long eventId) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public void deleteEvent(Long eventId) throws Exception {
|
|
PatientEvent event = patientEventDao.findOne(eventId);
|
|
PatientEvent event = patientEventDao.findOne(eventId);
|
|
if(event!=null)
|
|
|
|
{
|
|
|
|
|
|
if (event != null) {
|
|
List<PatientEventImg> list = patientEventImgDao.findByEventId(eventId);
|
|
List<PatientEventImg> list = patientEventImgDao.findByEventId(eventId);
|
|
if(list!=null && list.size()>0)
|
|
|
|
{
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
patientEventImgDao.delete(list);
|
|
patientEventImgDao.delete(list);
|
|
}
|
|
}
|
|
patientEventDao.delete(event);
|
|
patientEventDao.delete(event);
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
throw new Exception("不存在该就诊事件!");
|
|
throw new Exception("不存在该就诊事件!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -80,20 +72,16 @@ public class PatientEventService {
|
|
* 保存就诊事件详情
|
|
* 保存就诊事件详情
|
|
*/
|
|
*/
|
|
@Transactional
|
|
@Transactional
|
|
public void saveEventDetail(String data) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public void saveEventDetail(String data) throws Exception {
|
|
JSONObject json = new JSONObject(data);
|
|
JSONObject json = new JSONObject(data);
|
|
PatientEvent event = new PatientEvent();
|
|
PatientEvent event = new PatientEvent();
|
|
if(!StringUtils.isEmpty(json.optString("id")))
|
|
|
|
{
|
|
|
|
|
|
if (!StringUtils.isEmpty(json.optString("id"))) {
|
|
//判断是否存在
|
|
//判断是否存在
|
|
event =patientEventDao.findOne(json.getLong("id"));
|
|
|
|
if(event==null)
|
|
|
|
{
|
|
|
|
|
|
event = patientEventDao.findOne(json.getLong("id"));
|
|
|
|
if (event == null) {
|
|
throw new Exception("不存在该就诊事件!");
|
|
throw new Exception("不存在该就诊事件!");
|
|
}
|
|
}
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
} else {
|
|
event.setCreateTime(new Date());
|
|
event.setCreateTime(new Date());
|
|
}
|
|
}
|
|
event.setPatient(json.optString("patient"));
|
|
event.setPatient(json.optString("patient"));
|
|
@ -108,24 +96,21 @@ public class PatientEventService {
|
|
event.setDoctorName(json.optString("doctorName"));
|
|
event.setDoctorName(json.optString("doctorName"));
|
|
|
|
|
|
//保存就诊记录
|
|
//保存就诊记录
|
|
patientEventDao.save(event);
|
|
|
|
|
|
PatientEvent es = patientEventDao.save(event);
|
|
|
|
|
|
if(event.getId() != null) {
|
|
|
|
|
|
if (event.getId() != null) {
|
|
//修改时先删除原有图片
|
|
//修改时先删除原有图片
|
|
List<PatientEventImg> imgList = patientEventImgDao.findByEventId(event.getId());
|
|
List<PatientEventImg> imgList = patientEventImgDao.findByEventId(event.getId());
|
|
if(imgList!=null && imgList.size()>0)
|
|
|
|
{
|
|
|
|
|
|
if (imgList != null && imgList.size() > 0) {
|
|
patientEventImgDao.delete(imgList);
|
|
patientEventImgDao.delete(imgList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//保存就诊记录相关图片
|
|
//保存就诊记录相关图片
|
|
JSONArray array = json.getJSONArray("eventImg");
|
|
JSONArray array = json.getJSONArray("eventImg");
|
|
if(array!=null && array.length()>0)
|
|
|
|
{
|
|
|
|
|
|
if (array != null && array.length() > 0) {
|
|
List<PatientEventImg> imgList = new ArrayList<>();
|
|
List<PatientEventImg> imgList = new ArrayList<>();
|
|
for(int i=0;i<array.length();i++)
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
JSONObject item = array.getJSONObject(i);
|
|
JSONObject item = array.getJSONObject(i);
|
|
PatientEventImg img = new PatientEventImg();
|
|
PatientEventImg img = new PatientEventImg();
|
|
img.setCreateTime(new Date());
|
|
img.setCreateTime(new Date());
|
|
@ -143,21 +128,18 @@ public class PatientEventService {
|
|
}
|
|
}
|
|
patientEventImgDao.save(imgList);
|
|
patientEventImgDao.save(imgList);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
BusinessLogs.info(BusinessLogs.BusinessType.archive, es.getPatient(), new JSONObject(es));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 删除就诊事件图片
|
|
* 删除就诊事件图片
|
|
*/
|
|
*/
|
|
public void deleteEventImg(Long id) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public void deleteEventImg(Long id) throws Exception {
|
|
PatientEventImg eventImg = patientEventImgDao.findOne(id);
|
|
PatientEventImg eventImg = patientEventImgDao.findOne(id);
|
|
if(eventImg!=null)
|
|
|
|
{
|
|
|
|
|
|
if (eventImg != null) {
|
|
patientEventImgDao.delete(eventImg);
|
|
patientEventImgDao.delete(eventImg);
|
|
}
|
|
|
|
else{
|
|
|
|
throw new Exception("not exit image!id:"+id);
|
|
|
|
|
|
} else {
|
|
|
|
throw new Exception("not exit image!id:" + id);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@ -165,10 +147,9 @@ public class PatientEventService {
|
|
/**
|
|
/**
|
|
* 新增就诊事件图片
|
|
* 新增就诊事件图片
|
|
*/
|
|
*/
|
|
public void addEventImg(Long eventId,String imgType,String imgLabel,String imgUrl) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public void addEventImg(Long eventId, String imgType, String imgLabel, String imgUrl) throws Exception {
|
|
PatientEvent event = patientEventDao.findOne(eventId);
|
|
PatientEvent event = patientEventDao.findOne(eventId);
|
|
if(event!=null) {
|
|
|
|
|
|
if (event != null) {
|
|
PatientEventImg img = new PatientEventImg();
|
|
PatientEventImg img = new PatientEventImg();
|
|
|
|
|
|
img.setCreateTime(new Date());
|
|
img.setCreateTime(new Date());
|
|
@ -181,28 +162,24 @@ public class PatientEventService {
|
|
img.setImgUrl(imgUrl);
|
|
img.setImgUrl(imgUrl);
|
|
|
|
|
|
patientEventImgDao.save(img);
|
|
patientEventImgDao.save(img);
|
|
}
|
|
|
|
else{
|
|
|
|
throw new Exception("not exit event!id:"+eventId);
|
|
|
|
|
|
} else {
|
|
|
|
throw new Exception("not exit event!id:" + eventId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改就诊事件图片
|
|
* 修改就诊事件图片
|
|
*/
|
|
*/
|
|
public void editEventImg(Long id,String imgType,String imgLabel) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public void editEventImg(Long id, String imgType, String imgLabel) throws Exception {
|
|
PatientEventImg img = patientEventImgDao.findOne(id);
|
|
PatientEventImg img = patientEventImgDao.findOne(id);
|
|
if(img!=null)
|
|
|
|
{
|
|
|
|
|
|
if (img != null) {
|
|
// 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
|
|
// 图片类型(病历/处方/病理报告/检查报告/检验报告/其他)
|
|
img.setImgType(imgType);
|
|
img.setImgType(imgType);
|
|
// 图片标签
|
|
// 图片标签
|
|
img.setImgLabel(imgLabel);
|
|
img.setImgLabel(imgLabel);
|
|
patientEventImgDao.save(img);
|
|
patientEventImgDao.save(img);
|
|
}
|
|
|
|
else{
|
|
|
|
throw new Exception("not exit image!id:"+id);
|
|
|
|
|
|
} else {
|
|
|
|
throw new Exception("not exit image!id:" + id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|