|
@@ -1,281 +0,0 @@
|
|
|
-package com.diagbot.facade.databack;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.dto.data.AMedicalRecordDTO;
|
|
|
-import com.diagbot.dto.data.AMrContentDTO;
|
|
|
-import com.diagbot.entity.*;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.facade.BehospitalInfoFacade;
|
|
|
-import com.diagbot.facade.QcAbnormalFacade;
|
|
|
-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.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;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@Component
|
|
|
-public class AMedicalRecordFacade {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier("medicalRecordServiceImpl")
|
|
|
- private MedicalRecordServiceImpl medicalRecordServiceImpl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier("qcModelHospitalServiceImpl")
|
|
|
- private QcModelHospitalServiceImpl qcModelHospitalServiceImpl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier("medicalRecordContentServiceImpl")
|
|
|
- private MedicalRecordContentServiceImpl medicalRecordContentServiceImpl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- @Qualifier("behospitalInfoServiceImpl")
|
|
|
- private BehospitalInfoServiceImpl behospitalInfoServiceImpl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private AMedicalRecordContentFacade aMedicalRecordContentFacade;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BehospitalInfoFacade behospitalInfoFacade;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private QcAbnormalFacade qcAbnormalFacade;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ReadProperties readProperties;
|
|
|
-
|
|
|
-
|
|
|
- private TZDBConn tzDBConn = new TZDBConn();
|
|
|
-
|
|
|
- /**
|
|
|
- * 终末质控-同步前一天的病历记录
|
|
|
- */
|
|
|
- public void executeMrRecord() {
|
|
|
- //String sql="select * from mr_medicalrecords where cjcxrq>=dateadd(day,-2,getdate()) and cjcxrq<=getdate()";
|
|
|
- String sql="select * from mr_medicalrecords where cjcxrq>=(select CONVERT(varchar,GETDATE()-1,23)) and cjcxrq<(select CONVERT(varchar,GETDATE(),23)) ORDER BY cjcxrq DESC";
|
|
|
- List<MedicalRecord> medicalRecordList = tzDBConn.getMedicalRecord(sql);
|
|
|
- execute(medicalRecordList);
|
|
|
- }
|
|
|
-
|
|
|
- public void executeMrRecordPast() {
|
|
|
- String sql="select * from mr_medicalrecords where cjcxrq>=dateadd(day,-2,getdate()) and cjcxrq<=getdate()";
|
|
|
- List<MedicalRecord> medicalRecordList = tzDBConn.getMedicalRecord(sql);
|
|
|
- execute(medicalRecordList);
|
|
|
- }
|
|
|
-
|
|
|
- public void executeMrRecordPort(){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 通过接口更新病历记录
|
|
|
- * @param list
|
|
|
- * @return
|
|
|
- */
|
|
|
- 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("未接收到数据!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 数据引擎-通过接口更新病历记录
|
|
|
- * @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);
|
|
|
- }else{
|
|
|
- if(modeId==0 || modeId==null){
|
|
|
- return RespDTO.onError("无对应的文书类型");
|
|
|
- }
|
|
|
- //页面模式
|
|
|
- String url=readProperties.getProcessQcUrl()+"?behospitalCode="+behospitalCode+"&hospitalId="+hospitalId+"&modeId="+modeId;
|
|
|
-
|
|
|
- AnalyzeApiVO analyzeApiVO=new AnalyzeApiVO();
|
|
|
- analyzeApiVO.setBehospitalCode(behospitalCode);
|
|
|
- analyzeApiVO.setHospitalId(hospitalId);
|
|
|
- Map<String, Object> map=behospitalInfoFacade.analyzeApi(analyzeApiVO);
|
|
|
-
|
|
|
- map.put("url",url);
|
|
|
-
|
|
|
- return RespDTO.onSuc(map);
|
|
|
- }
|
|
|
- }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){
|
|
|
- if (medicalRecordList != null && medicalRecordList.size() > 0) {
|
|
|
- medicalRecordList.stream().forEach(s -> {
|
|
|
- //初始化mode_id
|
|
|
- Long modeId=initModeId(s);
|
|
|
- if(modeId==Long.valueOf("0")){
|
|
|
- //新增类型到监测表中
|
|
|
- QcAbnormal qcAbnormal=new QcAbnormal();
|
|
|
- qcAbnormal.setHospitalId(s.getHospitalId());
|
|
|
- qcAbnormal.setBehospitalCode(s.getBehospitalCode());
|
|
|
- qcAbnormal.setType(1);
|
|
|
- qcAbnormal.setDescription(s.getRecTitle());
|
|
|
- qcAbnormal.setGmtCreate(new Date());
|
|
|
- qcAbnormalFacade.save(qcAbnormal);
|
|
|
- }
|
|
|
- s.setModeId(modeId);
|
|
|
- //新增或修改
|
|
|
- saveOrUpdate(s);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增或修改文书信息
|
|
|
- * @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.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",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();
|
|
|
- }else{
|
|
|
- modeId=Long.valueOf("0");
|
|
|
- }
|
|
|
- return modeId;
|
|
|
- }
|
|
|
-}
|