|
@@ -1,18 +1,22 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.dto.data.AMedicalRecordDTO;
|
|
|
-import com.diagbot.entity.BehospitalInfo;
|
|
|
-import com.diagbot.entity.MedicalRecord;
|
|
|
-import com.diagbot.entity.MedicalRecordContent;
|
|
|
-import com.diagbot.entity.QcModelHospital;
|
|
|
+import com.diagbot.dto.data.AMrContentDTO;
|
|
|
+import com.diagbot.entity.*;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.BehospitalInfoServiceImpl;
|
|
|
import com.diagbot.service.impl.MedicalRecordContentServiceImpl;
|
|
|
import com.diagbot.service.impl.MedicalRecordServiceImpl;
|
|
|
import com.diagbot.service.impl.QcModelHospitalServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.ReadProperties;
|
|
|
import com.diagbot.util.TZDBConn;
|
|
|
+import com.diagbot.vo.AnalyzeApiVO;
|
|
|
+import com.diagbot.vo.data.AMedicalRecordContentVO;
|
|
|
import com.diagbot.vo.data.AMedicalRecordVO;
|
|
|
+import com.diagbot.vo.data.AMrContentVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@@ -45,6 +49,15 @@ public class AMedicalRecordFacade {
|
|
|
@Autowired
|
|
|
private AMedicalRecordContentFacade aMedicalRecordContentFacade;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BehospitalInfoFacade behospitalInfoFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QcAbnormalFacade qcAbnormalFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReadProperties readProperties;
|
|
|
+
|
|
|
|
|
|
private TZDBConn tzDBConn = new TZDBConn();
|
|
|
|
|
@@ -68,19 +81,104 @@ public class AMedicalRecordFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 数据引擎-通过接口更新病历记录
|
|
|
+ * 通过接口更新病历记录
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<AMedicalRecordDTO> executeMrRecord(List<AMedicalRecordVO> list) {
|
|
|
- List<MedicalRecord> medicalRecordList=Lists.newArrayList();
|
|
|
- List<AMedicalRecordDTO> medicalRecordDtoList=Lists.newArrayList();
|
|
|
- if(list!=null && list.size()>0){
|
|
|
- medicalRecordList=BeanUtil.listCopyTo(list,MedicalRecord.class);
|
|
|
- medicalRecordDtoList=BeanUtil.listCopyTo(list,AMedicalRecordDTO.class);
|
|
|
- execute(medicalRecordList);
|
|
|
+ public RespDTO<List<AMedicalRecordDTO>> executeMrRecordView(List<AMedicalRecordVO> list) {
|
|
|
+ if(list!=null && list.size()>0) {
|
|
|
+ //循环验证数据有效性
|
|
|
+ for (AMedicalRecordVO aMedicalRecordVO : list) {
|
|
|
+ if ("".equals(aMedicalRecordVO.getRecId())) {
|
|
|
+ return RespDTO.onError("请输入文书序号!");
|
|
|
+ } else if (aMedicalRecordVO.getHospitalId() == null) {
|
|
|
+ return RespDTO.onError("请输入医院编码!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getBehospitalCode())) {
|
|
|
+ return RespDTO.onError("请输入病人住院编码!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getRecTypeId())) {
|
|
|
+ return RespDTO.onError("请输入病历类别编号!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getRecTitle())) {
|
|
|
+ return RespDTO.onError("请输入病历标题!");
|
|
|
+ } else if (aMedicalRecordVO.getContents() == null || aMedicalRecordVO.getContents().size() == 0) {
|
|
|
+ return RespDTO.onError("请输入文书详情!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装载数据
|
|
|
+ initData(list);
|
|
|
+ List<AMedicalRecordDTO> medicalRecordDTOList = Lists.newArrayList();
|
|
|
+ medicalRecordDTOList = BeanUtil.listCopyTo(list, AMedicalRecordDTO.class);
|
|
|
+ return RespDTO.onSuc(medicalRecordDTOList);
|
|
|
+ }else{
|
|
|
+ return RespDTO.onError("未接收到数据!");
|
|
|
}
|
|
|
- return medicalRecordDtoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据引擎-通过接口更新病历记录
|
|
|
+ * @param aMrContentVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public RespDTO<Map<String, Object>> executeMrRecord(AMrContentVO aMrContentVO) {
|
|
|
+ if(aMrContentVO.getRecords()!=null && aMrContentVO.getRecords().size()>0){
|
|
|
+ AMrContentDTO aMrContentDTO=new AMrContentDTO();
|
|
|
+ //循环验证数据有效性
|
|
|
+ for (AMedicalRecordVO aMedicalRecordVO : aMrContentVO.getRecords()) {
|
|
|
+ if ("".equals(aMedicalRecordVO.getRecId())) {
|
|
|
+ return RespDTO.onError("请输入文书序号!");
|
|
|
+ } else if (aMedicalRecordVO.getHospitalId() == null) {
|
|
|
+ return RespDTO.onError("请输入医院编码!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getBehospitalCode())) {
|
|
|
+ return RespDTO.onError("请输入病人住院编码!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getRecTypeId())) {
|
|
|
+ return RespDTO.onError("请输入病历类别编号!");
|
|
|
+ } else if ("".equals(aMedicalRecordVO.getRecTitle())) {
|
|
|
+ return RespDTO.onError("请输入病历标题!");
|
|
|
+ } else if (aMedicalRecordVO.getContents() == null || aMedicalRecordVO.getContents().size() == 0) {
|
|
|
+ return RespDTO.onError("请输入文书详情!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //装载数据
|
|
|
+ initData(aMrContentVO.getRecords());
|
|
|
+
|
|
|
+ String behospitalCode =aMrContentVO.getRecords().get(0).getBehospitalCode();
|
|
|
+ Long hospitalId=aMrContentVO.getRecords().get(0).getHospitalId();
|
|
|
+ MedicalRecord medicalRecord=new MedicalRecord();
|
|
|
+ BeanUtil.copyProperties(aMrContentVO.getRecords().get(0),medicalRecord);
|
|
|
+ Long modeId=initModeId(medicalRecord);
|
|
|
+ if(aMrContentVO.getDockModeType().equals("1")){
|
|
|
+ if(modeId==0 || modeId==null){
|
|
|
+ return RespDTO.onError("无对应的文书类型");
|
|
|
+ }
|
|
|
+ //页面模式
|
|
|
+ String url=readProperties.getProcessQcUrl()+"?behospitalCode="+behospitalCode+"&hospitalId="+hospitalId+"&modeId="+modeId;
|
|
|
+ Map<String,Object> map=new HashMap<String,Object>();
|
|
|
+ map.put("url",url);
|
|
|
+ return RespDTO.onSuc(map);
|
|
|
+ }else if(aMrContentVO.getDockModeType().equals("2")){
|
|
|
+ AnalyzeApiVO analyzeApiVO=new AnalyzeApiVO();
|
|
|
+ analyzeApiVO.setBehospitalCode(behospitalCode);
|
|
|
+ analyzeApiVO.setHospitalId(hospitalId);
|
|
|
+ Map<String, Object> map=behospitalInfoFacade.analyzeApi(analyzeApiVO);
|
|
|
+ //接口引擎模式
|
|
|
+ return RespDTO.onSuc(map);
|
|
|
+ }
|
|
|
+ return RespDTO.onSuc("");
|
|
|
+ }else{
|
|
|
+ return RespDTO.onError("未接收到数据!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initData(List<AMedicalRecordVO> list){
|
|
|
+ List<MedicalRecord> medicalRecordList = Lists.newArrayList();
|
|
|
+ medicalRecordList = BeanUtil.listCopyTo(list, MedicalRecord.class);
|
|
|
+
|
|
|
+ execute(medicalRecordList);
|
|
|
+ list.stream().forEach(s -> {
|
|
|
+ List<MedicalRecordContent> contents = Lists.newArrayList();
|
|
|
+ contents = BeanUtil.listCopyTo(s.getContents(), MedicalRecordContent.class);
|
|
|
+
|
|
|
+ executeContent(contents);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public void execute(List<MedicalRecord> medicalRecordList){
|
|
@@ -88,6 +186,13 @@ public class AMedicalRecordFacade {
|
|
|
medicalRecordList.stream().forEach(s -> {
|
|
|
//初始化mode_id
|
|
|
Long modeId=initModeId(s);
|
|
|
+ //新增类型到监测表中
|
|
|
+ QcAbnormal qcAbnormal=new QcAbnormal();
|
|
|
+ qcAbnormal.setHospitalId(s.getHospitalId());
|
|
|
+ qcAbnormal.setBehospitalCode(s.getBehospitalCode());
|
|
|
+ qcAbnormal.setType(1);
|
|
|
+ qcAbnormal.setDescription(s.getRecTitle());
|
|
|
+ qcAbnormalFacade.save(qcAbnormal);
|
|
|
s.setModeId(modeId);
|
|
|
//新增或修改
|
|
|
saveOrUpdate(s);
|
|
@@ -95,75 +200,56 @@ public class AMedicalRecordFacade {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 页面推送-通过接口更新病历记录
|
|
|
- * @param list
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String,Object> executeMrRecordView(List<AMedicalRecordVO> list) {
|
|
|
- Map<String,Object> data=new HashMap<String,Object>();
|
|
|
- Long hospitalId=tzDBConn.HOSPITAL_ID;
|
|
|
- String behospitalCode=null;
|
|
|
- Long modeId=null;
|
|
|
- if (list != null && list.size() > 0){
|
|
|
- AMedicalRecordVO medicalRecordVO=list.get(0);
|
|
|
- MedicalRecord mrRecord=new MedicalRecord();
|
|
|
- BeanUtil.copyProperties(medicalRecordVO,mrRecord);
|
|
|
- //初始化mode_id
|
|
|
- modeId=initModeId(mrRecord);
|
|
|
- mrRecord.setModeId(modeId);
|
|
|
-
|
|
|
- //新增或修改病历记录
|
|
|
- saveOrUpdate(mrRecord);
|
|
|
-
|
|
|
- //更新病历内容
|
|
|
- if (medicalRecordVO.getContents() != null && medicalRecordVO.getContents().size() > 0) {
|
|
|
- List<MedicalRecordContent> mrContentList=Lists.newArrayList();
|
|
|
- mrContentList=BeanUtil.listCopyTo(medicalRecordVO.getContents(),MedicalRecordContent.class);
|
|
|
- aMedicalRecordContentFacade.execute(mrContentList);
|
|
|
- }
|
|
|
-
|
|
|
- behospitalCode=mrRecord.getBehospitalCode();
|
|
|
- hospitalId=mrRecord.getHospitalId();
|
|
|
-
|
|
|
- //查看病人住院记录是否存在或质控类型是否正常匹配,非0或非空
|
|
|
- QueryWrapper<BehospitalInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("behospital_code", behospitalCode);
|
|
|
- queryWrapper.eq("hospital_id", hospitalId);
|
|
|
- BehospitalInfo behospitalInfo = behospitalInfoServiceImpl.getOne(queryWrapper);
|
|
|
- if (behospitalInfo == null || behospitalInfo.getQcTypeId()==null && behospitalInfo.getQcTypeId()==0) {
|
|
|
- modeId=null;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- String url="?behospitalCode="+behospitalCode+"&hospitalId="+hospitalId;
|
|
|
- if(modeId ==null || modeId.equals("0")){
|
|
|
- data.put("url",null);
|
|
|
- }else{
|
|
|
- url+="";
|
|
|
- data.put("url",url);
|
|
|
+ public void executeContent(List<MedicalRecordContent> mrContentList){
|
|
|
+ if (mrContentList != null && mrContentList.size() > 0) {
|
|
|
+ mrContentList.stream().forEach(s -> {
|
|
|
+ QueryWrapper<MedicalRecordContent> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("rec_id", s.getRecId());
|
|
|
+ queryWrapper.eq("hospital_id", s.getHospitalId());
|
|
|
+ queryWrapper.eq("is_deleted",IsDeleteEnum.N);
|
|
|
+ MedicalRecordContent mrContent = medicalRecordContentServiceImpl.getOne(queryWrapper);
|
|
|
+ if (mrContent != null) {
|
|
|
+ s.setGmtModified(new Date());
|
|
|
+ medicalRecordContentServiceImpl.update(s,queryWrapper);
|
|
|
+ } else {
|
|
|
+ s.setGmtCreate(new Date());
|
|
|
+ medicalRecordContentServiceImpl.save(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- return data;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增或修改文书信息
|
|
|
+ * @param medicalRecord
|
|
|
+ */
|
|
|
private void saveOrUpdate(MedicalRecord medicalRecord){
|
|
|
QueryWrapper<MedicalRecord> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("rec_id", medicalRecord.getRecId());
|
|
|
+ queryWrapper.eq("hospital_id", medicalRecord.getHospitalId());
|
|
|
+ queryWrapper.eq("behospital_code", medicalRecord.getBehospitalCode());
|
|
|
+ queryWrapper.eq("is_deleted",IsDeleteEnum.N);
|
|
|
MedicalRecord mRecord = medicalRecordServiceImpl.getOne(queryWrapper);
|
|
|
if (mRecord != null) {
|
|
|
medicalRecord.setGmtModified(new Date());
|
|
|
- medicalRecordServiceImpl.updateById(medicalRecord);
|
|
|
+ medicalRecordServiceImpl.update(medicalRecord,queryWrapper);
|
|
|
} else {
|
|
|
medicalRecord.setGmtCreate(new Date());
|
|
|
medicalRecordServiceImpl.save(medicalRecord);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 初始化模型ID
|
|
|
+ * @param medicalRecord
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private Long initModeId(MedicalRecord medicalRecord){
|
|
|
Long modeId=Long.valueOf("0");
|
|
|
QueryWrapper<QcModelHospital> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("hospital_id",tzDBConn.HOSPITAL_ID);
|
|
|
+ wrapper.eq("hospital_id",medicalRecord.getHospitalId());
|
|
|
wrapper.eq("hospital_model_name",medicalRecord.getRecTitle());
|
|
|
+ //wrapper.eq("is_deleted",IsDeleteEnum.N);
|
|
|
QcModelHospital mode=qcModelHospitalServiceImpl.getOne(wrapper);
|
|
|
if(mode!=null){
|
|
|
modeId=mode.getStandModelId();
|