From 00fa67521aa20edd3f823314399c5b599403afd1 Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Wed, 19 Jul 2023 09:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81=E7=9A=84=E5=AE=9D=E5=AE=9D?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=EF=BC=8C=E5=85=A8=E9=83=A8=E6=8E=A8=E7=BB=99?= =?UTF-8?q?=E6=AF=8D=E4=BA=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/docus/server/AppRunBootstrap.java | 5 ++ .../collection/mapper/TBasicMapper.java | 28 ++++++++ .../collection/service/ITBasicService.java | 15 +++++ .../service/impl/TBasicServiceImpl.java | 28 ++++++++ .../report/listener/ReportDownListener.java | 67 ++++++++++++------- src/main/resources/mapper/TBasicMapper.xml | 20 ++++++ 6 files changed, 137 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/docus/server/AppRunBootstrap.java b/src/main/java/com/docus/server/AppRunBootstrap.java index c69d7c7..eda64c5 100644 --- a/src/main/java/com/docus/server/AppRunBootstrap.java +++ b/src/main/java/com/docus/server/AppRunBootstrap.java @@ -1,6 +1,8 @@ package com.docus.server; +import cn.hutool.extra.spring.SpringUtil; +import com.docus.server.collection.service.ITBasicService; import lombok.extern.slf4j.Slf4j; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; @@ -21,6 +23,9 @@ public class AppRunBootstrap { props.setProperty("UseSunHttpHandler", "true"); System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); SpringApplication.run(AppRunBootstrap.class, args); + ITBasicService basicService = SpringUtil.getBean(ITBasicService.class); + System.out.println(basicService.getIsBabyBasic("039baa8c5a8243fd93ec58a5517b5e6")); + System.out.println(basicService.getSdRyParentPatientInfo("00048819bea942f590368415d38cf41x")); } } diff --git a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java index 9bd03dc..9478e60 100644 --- a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java @@ -58,4 +58,32 @@ public interface TBasicMapper{ * @return db操作影响行 */ Integer saveNisRemoveFilesCount(@Param("patientId") String patientId,@Param("count") int removeCount); + + /** + * 查询顺德人医索引 + * @param patientId 病案主键 + * @return 顺德人医索引 + */ + String getSdRyIndex(@Param("patientId") String patientId); + + /** + * 根据宝宝的患者索引 查询母亲的患者索引 + * @param babyIndex 宝宝患者索引 + * @return 母亲的患者索引 + */ + String getParentSdRyIndex(@Param("babyIndex")String babyIndex); + + /** + * 根据患者索引,查询病案主键 + * @param sdRyIndex 患者索引 + * @return 病案主键 + */ + String getPatientIdBySdRyIndex(@Param("sdRyIndex")String sdRyIndex); + + /** + * 根据病案主键查询基础信息 + * @param patientId + * @return 基础数据 + */ + TBasic getByPatientId(@Param("patientId") String patientId); } diff --git a/src/main/java/com/docus/server/collection/service/ITBasicService.java b/src/main/java/com/docus/server/collection/service/ITBasicService.java index da3ee74..d1b2ac0 100644 --- a/src/main/java/com/docus/server/collection/service/ITBasicService.java +++ b/src/main/java/com/docus/server/collection/service/ITBasicService.java @@ -1,6 +1,7 @@ package com.docus.server.collection.service; import com.docus.server.collection.dto.TBasicDto; +import com.docus.server.collection.entity.TBasic; public interface ITBasicService { @@ -10,4 +11,18 @@ public interface ITBasicService { public void updateAdmissTBasic(TBasicDto dto) throws Exception; + /** + * 根据病案主键,查询母亲信息 + * @param babyPatientId 病案主键 + * @return 母亲基础信息 + */ + TBasic getSdRyParentPatientInfo(String babyPatientId); + + /** + * 根据病案主键,查询是否是婴儿患者 + * 病案号中包含B的是婴儿 + * @param patientId 病案主键 + * @return 是否婴儿患者 + */ + boolean getIsBabyBasic(String patientId); } diff --git a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java index 80e06aa..de85dae 100644 --- a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java +++ b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java @@ -275,6 +275,34 @@ public class TBasicServiceImpl implements ITBasicService { tBasicMapper.update(tBasic); tBasicMapper.updateExtend(tBasicExtend); } + + + @Override + public TBasic getSdRyParentPatientInfo(String babyPatientId) { + // 宝宝索引 + String babyIndex=tBasicMapper.getSdRyIndex(babyPatientId); + if (Func.isBlank(babyIndex)){ + return null; + } + // 宝宝索引查妈妈索引 + String parentSdRyIndex= tBasicMapper.getParentSdRyIndex(babyIndex); + if(Func.isBlank(parentSdRyIndex)){ + return null; + } + // 通过索引查病案主键 + String parentPatientId=tBasicMapper.getPatientIdBySdRyIndex(parentSdRyIndex); + if(Func.isBlank(parentPatientId)){ + return null; + } + // 通过病案主键查基础信息 + return tBasicMapper.getByPatientId(parentPatientId); + } + + @Override + public boolean getIsBabyBasic(String patientId) { + TBasic tBasic= tBasicMapper.getByPatientId(patientId); + return Func.isNotEmpty(tBasic) && Func.isNotBlank(tBasic.getInpatientNo()) && tBasic.getInpatientNo().toUpperCase().contains("B"); + } } diff --git a/src/main/java/com/docus/server/report/listener/ReportDownListener.java b/src/main/java/com/docus/server/report/listener/ReportDownListener.java index b7d5364..b164055 100644 --- a/src/main/java/com/docus/server/report/listener/ReportDownListener.java +++ b/src/main/java/com/docus/server/report/listener/ReportDownListener.java @@ -6,6 +6,8 @@ import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.docus.infrastructure.web.api.CommonResult; import com.docus.infrastructure.web.api.ResultCode; +import com.docus.server.collection.entity.TBasic; +import com.docus.server.collection.service.ITBasicService; import com.docus.server.report.api.DownPlatformService; import com.docus.server.report.api.dto.ReportDownDto; import com.docus.server.report.api.dto.ReportDownPatientDto; @@ -24,10 +26,7 @@ import sun.misc.BASE64Encoder; import javax.annotation.Resource; import java.io.FileInputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 上报下载监听 @@ -43,12 +42,31 @@ public class ReportDownListener { @Resource private AfReportRecordMapper afReportRecordMapper; + @Resource + private ITBasicService itBasicService; + @EventListener @Async("threadPoolExecutor") public void threePartyPushReportDown(ThreePartyPushReportDownEvent threePartyPushReportDownEvent) { // 根据任务id获取上报记录信息 AfReportRecord afReportRecord = afReportRecordMapper.getReportRecordInfoByTaskId(threePartyPushReportDownEvent.getTaskId()); + // 病案是否是婴儿 + boolean isBaby = itBasicService.getIsBabyBasic(afReportRecord.getPatientId()); + if (isBaby) { + // 如果是婴儿查找母亲的信息 + TBasic parentPatientInfo = itBasicService.getSdRyParentPatientInfo(afReportRecord.getPatientId()); + if (Objects.isNull(parentPatientInfo)) { + log.warn("住院号:{},住院次数:{},病案主键:{} 是婴儿病案,未关联查询到母亲信息,不进行下载!", afReportRecord.getInpatientNo(), afReportRecord.getAdmissTimes(), afReportRecord.getPatientId()); + return; + } + // 婴儿的报告要推给母亲,修改为母亲信息 + afReportRecord.setPatientId(parentPatientInfo.getPatientId()); + afReportRecord.setInpatientNo(parentPatientInfo.getInpatientNo()); + afReportRecord.setAdmissTimes(parentPatientInfo.getAdmissTimes()); + afReportRecord.setJzh(parentPatientInfo.getJzh()); + } + // 组织基础信息数据 ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(afReportRecord); @@ -75,7 +93,6 @@ public class ReportDownListener { } - @EventListener @Async("threadPoolExecutor") public void taskConsumptionReporDown(TaskConsumptionReportDownEvent taskConsumptionReportDownEvent) { @@ -102,17 +119,16 @@ public class ReportDownListener { } - public static void main(String[] args) throws IOException { BASE64Encoder encoder = new BASE64Encoder(); - String url="http://192.168.161.102:9291/api/downplatform/scansionReportBatch"; + String url = "http://192.168.161.102:9291/api/downplatform/scansionReportBatch"; // String url="http://127.0.0.1:9291/api/downplatform/scansionReportBatch"; - Map bodyMap=new HashMap<>(); - Map patientMap=new HashMap<>(); - patientMap.put("patientid","8099350542"); - List> scanfiles=new ArrayList<>(); + Map bodyMap = new HashMap<>(); + Map patientMap = new HashMap<>(); + patientMap.put("patientid", "8099350542"); + List> scanfiles = new ArrayList<>(); // FileInputStream inputStream = new FileInputStream("d://wyb.png"); @@ -130,31 +146,30 @@ public class ReportDownListener { // scanfile1Map.put("serialnum","嘉时测试图片1"); - FileInputStream inputStream2 = new FileInputStream("d://jianli_02.jpg"); System.out.println(inputStream2.available()); byte[] bytes2 = new byte[inputStream2.available()]; - inputStream2.read(bytes2,0,inputStream2.available()); + inputStream2.read(bytes2, 0, inputStream2.available()); inputStream2.close(); String base642 = encoder.encode(bytes2); - Map scanfile2Map=new HashMap<>(); - scanfile2Map.put("assortid","docustestAssortID"); - scanfile2Map.put("downurl",base642); - scanfile2Map.put("filestoragetype",1); - scanfile2Map.put("filetitle","嘉时测试图片2"); - scanfile2Map.put("filetype","2"); - scanfile2Map.put("serialnum","嘉时测试图片2"); + Map scanfile2Map = new HashMap<>(); + scanfile2Map.put("assortid", "docustestAssortID"); + scanfile2Map.put("downurl", base642); + scanfile2Map.put("filestoragetype", 1); + scanfile2Map.put("filetitle", "嘉时测试图片2"); + scanfile2Map.put("filetype", "2"); + scanfile2Map.put("serialnum", "嘉时测试图片2"); // // scanfiles.add(scanfile1Map); scanfiles.add(scanfile2Map); - bodyMap.put("patient",patientMap); - bodyMap.put("ip","wybtest"); - bodyMap.put("collectorid","docus测试扫描"); - bodyMap.put("scanfiles",scanfiles); - bodyMap.put("scanusercode","docus测试"); - bodyMap.put("scanusername","docus测试"); + bodyMap.put("patient", patientMap); + bodyMap.put("ip", "wybtest"); + bodyMap.put("collectorid", "docus测试扫描"); + bodyMap.put("scanfiles", scanfiles); + bodyMap.put("scanusercode", "docus测试"); + bodyMap.put("scanusername", "docus测试"); HttpRequest post = HttpUtil.createPost(url); post.timeout(5 * 1000); post.header("Content-Type", "application/json; charset=utf-8"); diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 4e1fbbc..be397bc 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -177,4 +177,24 @@ from `docus_medicalrecord`.`t_basic_extend` WHERE patient_id=#{patientId} + + + +