123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- package com.diagbot.facade;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.serializer.SerializerFeature;
- import com.diagbot.biz.push.entity.Item;
- import com.diagbot.biz.push.entity.Lis;
- import com.diagbot.biz.push.entity.Pacs;
- import com.diagbot.dto.IndicationDTO;
- import com.diagbot.dto.PushDTO;
- import com.diagbot.dto.PushPlanDTO;
- import com.diagbot.dto.RespDTO;
- import com.diagbot.entity.TranDatadockingLog;
- import com.diagbot.util.*;
- import com.diagbot.vo.*;
- import com.diagbot.xm.vo.StructuralDataVo;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Component;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- /*
- * @Description:对外对接业务处理类
- * @Author:liuqq
- * @time: 2020/11/04 14:51
- **/
- @Component
- @Slf4j
- public class DataPageDockFacade {
- @Autowired
- private MrFacade mrFacade;
- @Autowired
- private PushFacade pushFacade;
- @Autowired
- private DataDockingLogFacade dataDockingLogFacade;
- @Value("${data-page.url}")
- private String dataPageUrl;
- private TZDBConn tzDBConn = new TZDBConn();
- private TZDBConn1 tzDBConn1 = new TZDBConn1();
- /**
- * @Description:静态知识开单合理性
- * @Author:liuqq
- * @time: ${DATE} ${TIME}
- **/
- public RespDTO<String> getStaticKnowledge(StaticKnowledgeHISVO staticKnowledgeHISVO) {
- // String hisName=StringUtils.isNotEmpty(staticKnowledgeHISVO.getHisName())?JSON.toJSONString(staticKnowledgeHISVO.getHisName(), SerializerFeature.BrowserCompatible):"";
- // String hisDetailName=StringUtils.isNotEmpty(staticKnowledgeHISVO.getHisName())?JSON.toJSONString(staticKnowledgeHISVO.getHisName(), SerializerFeature.BrowserCompatible):"";
- if (StringUtil.isNotEmpty(staticKnowledgeHISVO.getHisDetailName()) && staticKnowledgeHISVO.getType()==4) {
- staticKnowledgeHISVO.setHisName(staticKnowledgeHISVO.getHisDetailName());
- }
- String url = dataPageUrl + "/informationOut.html?hospitalId=" + staticKnowledgeHISVO.getHospitalId()
- + "&type=" + staticKnowledgeHISVO.getType()
- + "&hisName=" + URLEncoder.encode(staticKnowledgeHISVO.getHisName());
- URL urlString = null;
- try {
- urlString=new URL( url);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return RespDTO.onSuc(urlString);
- }
- /**
- * @Description:页面推送模式
- * @Author:liuqq
- * @time: ${DATE} ${TIME}
- **/
- public RespDTO<String> getDataService(DataPageDockVO dataPageDockVO) {
- //参数校验
- if (dataPageDockVO.getHospitalId() == null) {
- return RespDTO.onError("请输入医院id");
- } else if ("".equals(dataPageDockVO.getShowType())) {
- return RespDTO.onError("请输入展示类型,横版:ver,或竖版hor");
- } else if ("".equals(dataPageDockVO.getPlanCode())) {
- return RespDTO.onError("请输入方案编码");
- }
- String url = "";
- String pushMrId = "";
- PushJoinVO pushJoinVO = new PushJoinVO();
- BeanUtil.copyProperties(dataPageDockVO, pushJoinVO);
- // 将基本参数保存到redis
- String mrId = mrFacade.createMr(pushJoinVO);
- //开单合理性推理时,验证下是否有推送,无推送时,不给url,code为“-1”
- if (dataPageDockVO.getPlanCode().equals("order_rational") || dataPageDockVO.getPlanCode().equals("medical_lis") || dataPageDockVO.getPlanCode().equals("medical_pacs")) {
- IndicationPushVO indicationPushVO = new IndicationPushVO();
- //初始化开单合理性入参
- BeanUtil.copyProperties(dataPageDockVO, indicationPushVO);
- indicationPushVO.setRuleType("1,2,3,4");
- IndicationDTO indicationDTO = pushFacade.indicationPush(indicationPushVO);
- if (indicationDTO != null) {
- if (ListUtil.isNotEmpty(indicationDTO.getBillMsgList()) || ListUtil.isNotEmpty(indicationDTO.getHighRiskList())
- || ListUtil.isNotEmpty(indicationDTO.getCriticalValList()) || ListUtil.isNotEmpty(indicationDTO.getOtherList())) {
- pushMrId = mrFacade.createIndicationMr(indicationDTO);
- } else {
- return RespDTO.onError("无开单合理性提醒!");
- }
- } else {
- return RespDTO.onError("无开单合理性提醒!");
- }
- }
- if ("hor".equals(dataPageDockVO.getShowType())) {
- url = dataPageUrl + "/cdssHorizontal.html?pushMrId=" + pushMrId + "&mrId=" + mrId + "&hospitalId=" + dataPageDockVO.getHospitalId() + "&planCode=" + dataPageDockVO.getPlanCode();
- } else {
- url = dataPageUrl + "/cdss.html?pushMrId=" + pushMrId + "&mrId=" + mrId + "&hospitalId=" + dataPageDockVO.getHospitalId() + "&planCode=" + dataPageDockVO.getPlanCode();
- }
- return RespDTO.onSuc(url);
- }
- /**
- * @Description:病历推理
- * @Author:liuqq
- * @time: ${DATE} ${TIME}
- **/
- public PushDTO getEnginePush(DataEngineVO dataEngineVO) {
- PushVO pushVO = new PushVO();
- BeanUtil.copyProperties(dataEngineVO, pushVO);
- PushDTO pushDTO = pushFacade.push(pushVO);
- pushDTO.setDebug(null);
- pushDTO.setSymptom(null);
- pushDTO.setVital(null);
- pushDTO.setOperations(null);
- pushDTO.setMedicines(null);
- pushDTO.setComplications(null);
- pushDTO.setTreat(null);
- try {
- TranDatadockingLog tranDatadockingLog = new TranDatadockingLog();
- tranDatadockingLog.setHospitalId(dataEngineVO.getHospitalId());
- tranDatadockingLog.setParamIn(JSON.toJSONString(dataEngineVO));
- tranDatadockingLog.setParamOut(JSON.toJSONString(pushDTO));
- tranDatadockingLog.setRemark("数据引擎模式," + dataEngineVO.getPlanCode());
- tranDatadockingLog.setTransTime(new Date());
- dataDockingLogFacade.save(tranDatadockingLog);
- } catch (Exception e) {
- log.error("数据引擎模式,增加日志异常", e.getMessage());
- }
- return pushDTO;
- }
- /**
- * @Description: 开单合理性及检查、检查报告检阅
- * @Author:liuqq
- * @time: ${DATE} ${TIME}
- **/
- public RespDTO getEngineIndicationPush(DataEngineVO dataEngineVO) {
- IndicationPushVO indicationPushVO = new IndicationPushVO();
- BeanUtil.copyProperties(dataEngineVO, indicationPushVO);
- indicationPushVO.setRuleType("1,2,3,4");
- IndicationDTO indicationDTO = pushFacade.indicationPush(indicationPushVO);
- indicationDTO.setDebug(null);
- if (indicationDTO != null) {
- if (ListUtil.isNotEmpty(indicationDTO.getBillMsgList()) || ListUtil.isNotEmpty(indicationDTO.getHighRiskList())
- || ListUtil.isNotEmpty(indicationDTO.getCriticalValList()) || ListUtil.isNotEmpty(indicationDTO.getOtherList())) {
- return RespDTO.onSuc(indicationDTO);
- } else {
- return RespDTO.onError("无开单合理性提醒!");
- }
- } else {
- return RespDTO.onError("无开单合理性提醒!");
- }
- }
- public PushPlanDTO getOperationPlanPush(DataEngineVO dataEngineVO) {
- PushPlanVO pushPlanVO = new PushPlanVO();
- BeanUtil.copyProperties(dataEngineVO, pushPlanVO);
- PushPlanDTO pushPlanDTO = pushFacade.pushPlan(pushPlanVO);
- pushPlanDTO.setDebug(null);
- try {
- TranDatadockingLog tranDatadockingLog = new TranDatadockingLog();
- tranDatadockingLog.setHospitalId(dataEngineVO.getHospitalId());
- tranDatadockingLog.setParamIn(JSON.toJSONString(dataEngineVO));
- tranDatadockingLog.setParamOut(JSON.toJSONString(pushPlanDTO));
- tranDatadockingLog.setRemark("数据引擎模式," + dataEngineVO.getPlanCode());
- tranDatadockingLog.setTransTime(new Date());
- dataDockingLogFacade.save(tranDatadockingLog);
- } catch (Exception e) {
- log.error("数据引擎模式,增加日志异常", e.getMessage());
- }
- return pushPlanDTO;
- }
- //湘雅根据视图来取所需数据
- public RespDTO<String> getDataServiceXY(StructuralDataVo structuralDataVo) {
- if (structuralDataVo.getBehospitalCode().contains("_")){
- structuralDataVo.setBehospitalCode(structuralDataVo.getBehospitalCode().substring(0,structuralDataVo.getBehospitalCode().indexOf("_")));
- }
- DataPageDockVO dataPageDockVO = new DataPageDockVO();
- RespDTO<String> respDTO =new RespDTO<>();
- try {
- String where = " where behospitalCode = '" + structuralDataVo.getBehospitalCode() + "' and behospitalNum = '" + structuralDataVo.getFileCode() + "'";
- String DrugSql = " select * from drug " + " where behospitalCode = '" + structuralDataVo.getBehospitalCode() + "' and fileCode = '" + structuralDataVo.getFileCode() + "'";
- String DiagSql = " select * from diag "+" where behospitalCode = '" + structuralDataVo.getBehospitalCode() + "' and fileCode = '" + structuralDataVo.getFileCode() + "'";
- String InfoSql = " select * from medical_records where PATIENTID ='"+structuralDataVo.getBehospitalCode()+"' and VISITID = '"+structuralDataVo.getFileCode()+"'";
- String InfoSqlaa = " select * from medical_record " +where;
- String lisSql = " select * from assay_details " + where;
- String PacsSql = " select * from check_details " + where;
- String OpsSql = " select * from homepage_operation " + where;
- // //得到基本信息并赋予
- Map<String, String> map = tzDBConn1.getInfo(InfoSql);
- dataPageDockVO.setPlanCode(structuralDataVo.getPlanCode());
- dataPageDockVO.setHospitalId(structuralDataVo.getHospitalId());//医院id
- dataPageDockVO.setShowType(structuralDataVo.getShowType());//展示方式
- if (StringUtils.isNotEmpty(map.get("SEX"))){
- dataPageDockVO.setSex(Integer.valueOf(map.get("SEX").equals("男")?"1":map.get("SEX").equals("女")?"2":"3"));//性别
- }
- dataPageDockVO.setAge(StringUtils.isNotEmpty(map.get("AGE"))?map.get("AGE"):"18");//年龄
- dataPageDockVO.setMarriage(map.get("MARRIAGE"));//婚姻
- dataPageDockVO.setChief(map.get("CHIEF"));//主诉
- dataPageDockVO.setSymptom(map.get("SYMPTOM"));//现病史
- // dataPageDockVO.setChief("体温39.2,高热,植入钢板");//主诉
- // dataPageDockVO.setSymptom("体温39.2,高热,植入钢板");//现病史
- dataPageDockVO.setPasts(map.get("PASTS"));//既往史
- dataPageDockVO.setPersonal(map.get("PERSONAL"));//个人史
- dataPageDockVO.setMarital(map.get("MARITAL"));//婚育史
- dataPageDockVO.setFamily(map.get("FAMILY"));//家族史
- dataPageDockVO.setMenstrual(map.get("MENSTRUAL"));//月经史
- dataPageDockVO.setVital(map.get("VITAL"));//查体
- System.out.println(JSON.toJSONString(dataPageDockVO) + "-------------------------------------信息");
- //获取Order信息并赋予
- List<Lis> lisOrder = structuralDataVo.getLisOrder();
- if (lisOrder.size()>0){
- lisOrder.forEach(lis -> {
- lis.setDetailName("");
- lis.setUniqueName("");
- });
- }
- dataPageDockVO.setPacsOrder(structuralDataVo.getPacsOrder());
- dataPageDockVO.setLisOrder(lisOrder);
- dataPageDockVO.setOperationOrder(structuralDataVo.getOperationOrder());
- dataPageDockVO.setDrugOrder(structuralDataVo.getDrugOrder());
- dataPageDockVO.setDiseaseName(structuralDataVo.getDiseaseName());
- dataPageDockVO.setDiagOrder(structuralDataVo.getDiagOrder());
- System.out.println(JSON.toJSONString(dataPageDockVO) + "-------------------------------------Order");
- //获取历史信息并赋予
- //根据方案编码来判断是否是多参考值 如果是根据repNo来获取他们的值
- if (structuralDataVo.getPlanCode().equals("medical_lis")){
- if (StringUtils.isNotEmpty(structuralDataVo.getRepNo())){
- lisSql= lisSql+" and repNo='"+structuralDataVo.getRepNo()+"'";
- }
- dataPageDockVO.setLis(tzDBConn.getLis(lisSql));
- dataPageDockVO.setDiag(tzDBConn.getDiag(DiagSql));
- }else if (structuralDataVo.getPlanCode().equals("medical_pacs")){
- if (StringUtils.isNotEmpty(structuralDataVo.getRepNo())){
- PacsSql= PacsSql+" and repNo='"+structuralDataVo.getRepNo()+"'";
- }
- dataPageDockVO.setPacs(tzDBConn.getPacs(PacsSql));
- dataPageDockVO.setDiag(tzDBConn.getDiag(DiagSql));
- }else {
- dataPageDockVO.setPacs(tzDBConn.getPacs(PacsSql));
- dataPageDockVO.setLis(tzDBConn.getLis(lisSql));
- dataPageDockVO.setDrug(tzDBConn.getDrug(DrugSql));
- dataPageDockVO.setDiag(tzDBConn.getDiag(DiagSql));
- dataPageDockVO.setOperation(tzDBConn.getOperation(OpsSql));
- }
- System.out.println(JSON.toJSONString(dataPageDockVO) + "---------------------------------------历史数据");
- respDTO= this.getDataService(dataPageDockVO);
- //保存入参到库里 方便以后查看
- TranDatadockingLog tranDatadockingLog = new TranDatadockingLog();
- tranDatadockingLog.setDoctorCode("正常入参");
- tranDatadockingLog.setHospitalId(dataPageDockVO.getHospitalId());
- tranDatadockingLog.setSexType(JSON.toJSONString(structuralDataVo));
- tranDatadockingLog.setParamIn(JSON.toJSONString(dataPageDockVO));
- tranDatadockingLog.setParamOut(JSON.toJSONString(respDTO));
- tranDatadockingLog.setRemark("方案编码," + dataPageDockVO.getPlanCode());
- tranDatadockingLog.setInquiryCode("病人住院号: " + structuralDataVo.getBehospitalCode()+"_"+structuralDataVo.getFileCode());
- tranDatadockingLog.setTransTime(new Date());
- dataDockingLogFacade.save(tranDatadockingLog);
- } catch (Exception e) {
- TranDatadockingLog tranDatadockingLog = new TranDatadockingLog();
- tranDatadockingLog.setSexType("获取数据失败," + JSON.toJSONString(structuralDataVo));
- tranDatadockingLog.setRemark("错误异常," + e.getMessage());
- tranDatadockingLog.setParamIn(JSON.toJSONString(dataPageDockVO));
- tranDatadockingLog.setParamOut(JSON.toJSONString(respDTO));
- tranDatadockingLog.setInquiryCode("病人住院号: " + structuralDataVo.getBehospitalCode()+"_"+structuralDataVo.getFileCode());
- tranDatadockingLog.setTransTime(new Date());
- dataDockingLogFacade.save(tranDatadockingLog);
- } finally {
- tzDBConn.close();
- }
- return respDTO;
- }
- }
|