From 261cdbdacbe45b59cc6d3fbd0c4880bb3242d689 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Thu, 10 Apr 2025 15:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E6=A0=B7?= =?UTF-8?q?=E6=9C=AC=E7=A0=81=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InspectPatientController.java | 368 ++++++++++-------- .../inspectpatient/vo/BarcodeInfoVO.java | 34 ++ 2 files changed, 236 insertions(+), 166 deletions(-) create mode 100644 yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/BarcodeInfoVO.java diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java index 7759d74..e0ad08d 100644 --- a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/InspectPatientController.java @@ -207,7 +207,7 @@ public class InspectPatientController { String datePart = currentDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")); // 生成一个6位的序列号 int sequenceNumber = counter.incrementAndGet() % 1000000; // 确保序列号是6位数 - String MedicalSn = datePart+String.format("%06d", sequenceNumber); + String MedicalSn = datePart + String.format("%06d", sequenceNumber); //患者信息 InspectPatientSaveReqVO rowData = new InspectPatientSaveReqVO(); @@ -268,7 +268,7 @@ public class InspectPatientController { // 分批插入患者信息 batchInsertPatients(dataList); // 分批插入患者项目信息 - // batchInsertPatientItems(dataList2); + // batchInsertPatientItems(dataList2); return success("上传成功"); @@ -323,26 +323,25 @@ public class InspectPatientController { patientitemsService.createPatientListitems(batch); } } + @PostMapping("/insertPatinetInfo") @Operation(summary = "根据表单创建患者信息和项目信息") - public CommonResult insertPatinetInfo(@Valid @RequestBody InspectPatientSaveReqVO inspectPatientSaveReqVO) - { + public CommonResult insertPatinetInfo(@Valid @RequestBody InspectPatientSaveReqVO inspectPatientSaveReqVO) { //验证身份证 - if( patientService.validateIdCardExists(inspectPatientSaveReqVO.getCardId())) - { - return success(false,"身份证号已存在"); - } + if (patientService.validateIdCardExists(inspectPatientSaveReqVO.getCardId())) { + return success(false, "身份证号已存在"); + } //检查项目 - // List dataList2 = new ArrayList<>(); + // List dataList2 = new ArrayList<>(); //检查套餐信息 - // List doList = exammoduleService.selectItemsByExamModuleID(1001); + // List doList = exammoduleService.selectItemsByExamModuleID(1001); // 获取当前日期并格式化为 yyyyMMdd 格式 LocalDate currentDate = LocalDate.now(); String datePart = currentDate.format(DateTimeFormatter.ofPattern("yyyyMMdd")); // 生成一个6位的序列号 int sequenceNumber = counter.incrementAndGet() % 1000000; // 确保序列号是6位数 - String sequencePart = datePart+String.format("%06d", sequenceNumber); + String sequencePart = datePart + String.format("%06d", sequenceNumber); //患者信息 InspectPatientSaveReqVO rowData = new InspectPatientSaveReqVO(); rowData.setMedicalSn(sequencePart); @@ -378,14 +377,13 @@ public class InspectPatientController { // batchInsertPatientItems(dataList2); return success(true); } + @GetMapping("/createPatientitem") @Operation(summary = "通过体检编号绑定检查项目信息") - public CommonResult createPatientitem(@RequestParam("medicalSn") String medicalSn) - { + public CommonResult createPatientitem(@RequestParam("medicalSn") String medicalSn) { //如果这个患者存在患者项目数据则不进行插入 boolean exists = patientitemsService.existsByMedicalSn(medicalSn); - if(exists) - { + if (exists) { return success(true); } //检查项目 @@ -414,14 +412,14 @@ public class InspectPatientController { rowData2.setMealfrontorafter(inspectitemsDO.getMealfrontorafter()); dataList2.add(rowData2); } - if(dataList2.size()>0) - { + if (dataList2.size() > 0) { // 分批插入患者项目信息 batchInsertPatientItems(dataList2); } return success(true); } + @GetMapping("/syncinspectApplyTj") @Operation(summary = "发送检验申请单") public CommonResult syncinspectApplyTj(@RequestParam("medicalSn") String medicalSn) throws JsonProcessingException { @@ -491,7 +489,7 @@ public class InspectPatientController { // 将 Java 对象转换为 JSON 字符串 String jsonRequestBody = objectMapper.writeValueAsString(patient); - + // 保存日志 InspectApplylogSaveReqVO logVO = new InspectApplylogSaveReqVO(); logVO.setTime(LocalDateTime.now()); @@ -499,14 +497,14 @@ public class InspectPatientController { logVO.setIdcard(patientDO.getCardId()); logVO.setJson(jsonRequestBody); applylogService.createApplylog(logVO); - + //获取配置项地址 ConfigDO config = configService.getConfigByKey("url.applytj"); // 发送 POST 请求 String url = config.getValue(); String response = HttpUtils.postJson(url, jsonRequestBody); - + // 记录接口返回值 InspectApplylogSaveReqVO responseLogVO = new InspectApplylogSaveReqVO(); responseLogVO.setTime(LocalDateTime.now()); @@ -514,7 +512,7 @@ public class InspectPatientController { responseLogVO.setIdcard(patientDO.getCardId()); responseLogVO.setJson(response); applylogService.createApplylog(responseLogVO); - + InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO(); updateReqVO.setMedicalSn(patientDO.getMedicalSn()); updateReqVO.setHospitalNo("121526004609160793");//乌兰察布第四医院 暂时写死 @@ -540,22 +538,19 @@ public class InspectPatientController { switch (type) { case "XCG": model = "cbc"; - if(patientDO.getXcgcode()!=null) - { + if (patientDO.getXcgcode() != null) { barCode = patientDO.getXcgcode(); } break; case "NCG": model = "rt"; - if(patientDO.getNcgcode()!=null) - { + if (patientDO.getNcgcode() != null) { barCode = patientDO.getNcgcode(); } break; case "SHQX": model = "bt"; - if(patientDO.getShqx()!=null) - { + if (patientDO.getShqx() != null) { barCode = patientDO.getShqx(); } break; @@ -563,81 +558,72 @@ public class InspectPatientController { ConfigDO config = configService.getConfigByKey("url.reporttj"); String url = config.getValue(); //查询是否已经存在记录 存在则不进行同步操作 - if(pacsDataService.IspacsDataExist(medicalSn, model)) - { - if(!pacsDataService.IspacsDataitemExist(medicalSn, model)) - { + if (pacsDataService.IspacsDataExist(medicalSn, model)) { + if (!pacsDataService.IspacsDataitemExist(medicalSn, model)) { //没有对应的item值 更新 - String response = HttpUtils.get(url + "?" + "barCode=" + barCode + "&" + "hospitalCode=" + patientDO.getHospitalNo()); - if (response != null) - { - // 解析 JSON 响应 - ObjectMapper objectMapper = new ObjectMapper(); - try { - ReportResponse reportResponse = objectMapper.readValue(response, ReportResponse.class); - if ("操作成功".equals(reportResponse.getMsg()) && reportResponse.getCode() == 200) - { - ReportData reportData = reportResponse.getData(); - // 获取 reportPath - String reportPath = reportData.getReportPath(); - if(!reportPath.contains("报告暂未出")) - { - StringBuilder sb = new StringBuilder(); - InspectPacsDataSaveReqVO inspectPacs = new InspectPacsDataSaveReqVO(); - inspectPacs.setCode(patientDO.getMedicalSn()); - inspectPacs.setType(model); - if(reportData.getResults()!=null&&reportData.getResults().size()>0) - { - // 获取 results 数组并遍历 - List results = reportData.getResults(); - for (ResultItem result : results) { - // 判断 Item Tips 并输出相应的结果 - String itemTips = result.getItemTips(); - String tipsDescription = ""; - if ("1".equals(itemTips)) { - tipsDescription = "偏低"; - } else if ("4".equals(itemTips)) { - tipsDescription = "偏高"; - } + String response = HttpUtils.get(url + "?" + "barCode=" + barCode + "&" + "hospitalCode=" + patientDO.getHospitalNo()); + if (response != null) { + // 解析 JSON 响应 + ObjectMapper objectMapper = new ObjectMapper(); + try { + ReportResponse reportResponse = objectMapper.readValue(response, ReportResponse.class); + if ("操作成功".equals(reportResponse.getMsg()) && reportResponse.getCode() == 200) { + ReportData reportData = reportResponse.getData(); + // 获取 reportPath + String reportPath = reportData.getReportPath(); + if (!reportPath.contains("报告暂未出")) { + StringBuilder sb = new StringBuilder(); + InspectPacsDataSaveReqVO inspectPacs = new InspectPacsDataSaveReqVO(); + inspectPacs.setCode(patientDO.getMedicalSn()); + inspectPacs.setType(model); + if (reportData.getResults() != null && reportData.getResults().size() > 0) { + // 获取 results 数组并遍历 + List results = reportData.getResults(); + for (ResultItem result : results) { + // 判断 Item Tips 并输出相应的结果 + String itemTips = result.getItemTips(); + String tipsDescription = ""; + if ("1".equals(itemTips)) { + tipsDescription = "偏低"; + } else if ("4".equals(itemTips)) { + tipsDescription = "偏高"; + } - sb.append("【"+result.getItemName() +":"+tipsDescription+" ,结果:" + result.getItemValue() + result.getItemUnit() +","+"参考值("+result.getReferenceRange()+ ")】"+"\n"); - } - inspectPacs.setItem(sb.toString()); - } + sb.append("【" + result.getItemName() + ":" + tipsDescription + " ,结果:" + result.getItemValue() + result.getItemUnit() + "," + "参考值(" + result.getReferenceRange() + ")】" + "\n"); + } + inspectPacs.setItem(sb.toString()); + } - pacsDataService.updatePacsDataitem(inspectPacs); - } + pacsDataService.updatePacsDataitem(inspectPacs); + } - } - } catch (IOException e) { - e.printStackTrace(); - return success(true); - } - } - } - return success(true); - } + } + } catch (IOException e) { + e.printStackTrace(); + return success(true); + } + } + } + return success(true); + } String response = HttpUtils.get(url + "?" + "barCode=" + barCode + "&" + "hospitalCode=" + patientDO.getHospitalNo()); if (response != null) { // 解析 JSON 响应 ObjectMapper objectMapper = new ObjectMapper(); try { ReportResponse reportResponse = objectMapper.readValue(response, ReportResponse.class); - if ("操作成功".equals(reportResponse.getMsg()) && reportResponse.getCode() == 200) - { + if ("操作成功".equals(reportResponse.getMsg()) && reportResponse.getCode() == 200) { ReportData reportData = reportResponse.getData(); // 获取 reportPath String reportPath = reportData.getReportPath(); - if(!reportPath.contains("报告暂未出")) - { + if (!reportPath.contains("报告暂未出")) { StringBuilder sb = new StringBuilder(); InspectPacsDataSaveReqVO inspectPacs = new InspectPacsDataSaveReqVO(); inspectPacs.setCode(patientDO.getMedicalSn()); inspectPacs.setData(reportPath); inspectPacs.setType(model); inspectPacs.setPersonName(patientDO.getPName()); - if(reportData.getResults()!=null&&reportData.getResults().size()>0) - { + if (reportData.getResults() != null && reportData.getResults().size() > 0) { // 获取 results 数组并遍历 List results = reportData.getResults(); for (ResultItem result : results) { @@ -650,7 +636,7 @@ public class InspectPatientController { tipsDescription = "偏高"; } - sb.append("【"+result.getItemName() +":"+tipsDescription+" ,结果:" + result.getItemValue() + result.getItemUnit() +","+"参考值("+result.getReferenceRange()+ ")】"+"\n"); + sb.append("【" + result.getItemName() + ":" + tipsDescription + " ,结果:" + result.getItemValue() + result.getItemUnit() + "," + "参考值(" + result.getReferenceRange() + ")】" + "\n"); } inspectPacs.setItem(sb.toString()); } @@ -718,6 +704,7 @@ public class InspectPatientController { patientService.medicalSnupdate(updateReqVO); return success(true); } + @PutMapping("/updatedoctorid") @Operation(summary = "更新患者总检医生ID") public CommonResult updatedoctorid(@Valid @RequestBody InspectPatientSaveReqVO updateReqVO) { @@ -730,19 +717,17 @@ public class InspectPatientController { public CommonResult getReport(@RequestParam("medicalSn") String medicalSn) { // 获取患者基本信息 InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn); - + // 创建报告VO对象 InspectPatientReportVO inspectPatientReportVO = new InspectPatientReportVO(); - + if (patientDO != null) { // 设置基本信息 BeanUtils.copyProperties(patientDO, inspectPatientReportVO); // 先拿到ID 在查询签名 - if(patientDO.getChiefinspectorid()!=null) - { - InspectDoctorDO doctorDO= doctorService.getDoctorid( patientDO.getChiefinspectorid()); - if(doctorDO!=null&&doctorDO.getDoctorsign()!=null) - { + if (patientDO.getChiefinspectorid() != null) { + InspectDoctorDO doctorDO = doctorService.getDoctorid(patientDO.getChiefinspectorid()); + if (doctorDO != null && doctorDO.getDoctorsign() != null) { inspectPatientReportVO.setSign(doctorDO.getDoctorsign()); } } @@ -750,14 +735,14 @@ public class InspectPatientController { List allItems = patientitemsService.GetPatientItemList(medicalSn); // 获取PACS数据 List pacsDataList = pacsDataService.GetpacsData(medicalSn); - + List dataList = new ArrayList<>(); - + // 1. 首先处理所有基础检查项目 if (allItems != null) { for (InspectPatientitemsDO item : allItems) { InspectPatientReportDataVO itemData = new InspectPatientReportDataVO(); - + // 设置基本项目信息 itemData.setItemCode(item.getItemCode()); itemData.setItemName(item.getItemName()); @@ -768,7 +753,7 @@ public class InspectPatientController { itemData.setInspecttime(item.getInspecttime()); itemData.setType(item.getItemName()); itemData.setItemStatus(item.getItemStatus()); - + // 尝试转换数值结果 if (item.getItemResult() != null) { try { @@ -777,7 +762,7 @@ public class InspectPatientController { // 如果不是数值,保持为null } } - + // 2. 查找并关联PACS数据 if (pacsDataList != null) { for (InspectPacsDataDO pacsData : pacsDataList) { @@ -788,24 +773,24 @@ public class InspectPatientController { } } } - + dataList.add(itemData); } } - + // 3. 处理可能存在的独立PACS数据 if (pacsDataList != null) { for (InspectPacsDataDO pacsData : pacsDataList) { // 检查该PACS数据是否已经被关联 boolean alreadyLinked = false; for (InspectPatientReportDataVO existingData : dataList) { - if (existingData.getPacsDataType() != null && - existingData.getPacsDataType().equals(pacsData.getType())) { + if (existingData.getPacsDataType() != null && + existingData.getPacsDataType().equals(pacsData.getType())) { alreadyLinked = true; break; } } - + // 如果未被关联,创建新的数据项 if (!alreadyLinked) { InspectPatientReportDataVO pacsOnlyData = new InspectPatientReportDataVO(); @@ -817,11 +802,11 @@ public class InspectPatientController { } } } - + // 设置排序后的数据列表 inspectPatientReportVO.setData(sortReportData(dataList)); } - + return success(inspectPatientReportVO); } @@ -839,18 +824,18 @@ public class InspectPatientController { orderMap.put("TZ", 6); // 体重 orderMap.put("YW", 7); // 腰围 orderMap.put("BMI", 8); // BMI - + dataList.sort((a, b) -> { String codeA = a.getItemCode(); String codeB = b.getItemCode(); - + // 获取排序值,默认为100(放在基础检查项目后面) int orderA = getOrderValue(codeA, orderMap); int orderB = getOrderValue(codeB, orderMap); - + return Integer.compare(orderA, orderB); }); - + return dataList; } @@ -859,13 +844,13 @@ public class InspectPatientController { */ private int getOrderValue(String itemCode, Map orderMap) { if (itemCode == null) return 100; - + for (Map.Entry entry : orderMap.entrySet()) { if (itemCode.startsWith(entry.getKey())) { return entry.getValue(); } } - + return 100; } @@ -876,9 +861,9 @@ public class InspectPatientController { if (pacsType == null || (itemCode == null && itemName == null)) { return false; } - + pacsType = pacsType.toUpperCase(); - + // 根据项目代码匹配 if (itemCode != null) { String upperItemCode = itemCode.toUpperCase(); @@ -887,13 +872,13 @@ public class InspectPatientController { if (pacsType.equals("NC") && upperItemCode.contains("NCG")) return true; if ((pacsType.equals("EC") || pacsType.equals("ECG")) && upperItemCode.contains("ECG")) return true; if (pacsType.equals("US") && upperItemCode.contains("US")) return true; - + // 添加新的匹配逻辑 if (pacsType.equals("CBC") && upperItemCode.contains("XCG")) return true; if (pacsType.equals("RT") && upperItemCode.contains("NCG")) return true; if (pacsType.equals("BT") && upperItemCode.contains("SHQX")) return true; } - + // 根据项目名称匹配 if (itemName != null) { String upperItemName = itemName.toUpperCase(); @@ -902,13 +887,14 @@ public class InspectPatientController { if (pacsType.equals("NC") && upperItemName.contains("尿常规")) return true; if ((pacsType.equals("EC") || pacsType.equals("ECG")) && upperItemName.contains("心电图")) return true; if (pacsType.equals("US") && upperItemName.contains("超声")) return true; - + // 添加新的匹配逻辑 if (pacsType.equals("CBC") && upperItemName.contains("血常规")) return true; if (pacsType.equals("RT") && upperItemName.contains("尿常规")) return true; - if (pacsType.equals("BT") && (upperItemName.contains("生化") || upperItemName.contains("SHQX"))) return true; + if (pacsType.equals("BT") && (upperItemName.contains("生化") || upperItemName.contains("SHQX"))) + return true; } - + return false; } @@ -917,16 +903,24 @@ public class InspectPatientController { */ private String getPacsItemName(String pacsType) { if (pacsType == null) return "未知检查"; - + switch (pacsType.toUpperCase()) { - case "XCG": return "血常规"; - case "NCG": return "尿常规"; - case "ECG": return "心电图"; - case "US": return "超声检查"; - case "BT": return "生化"; - case "RT": return "尿常规"; - case "CBC": return "血常规"; - default: return pacsType; + case "XCG": + return "血常规"; + case "NCG": + return "尿常规"; + case "ECG": + return "心电图"; + case "US": + return "超声检查"; + case "BT": + return "生化"; + case "RT": + return "尿常规"; + case "CBC": + return "血常规"; + default: + return pacsType; } } @@ -1054,13 +1048,11 @@ public class InspectPatientController { } list.add(inspectPatientitemsSaveReqVO); patientitemsService.updatePatientitemInfo(list); - if(dataMap.get("personimg")!=null) - { + if (dataMap.get("personimg") != null) { - String headurl = dataMap.get("personimg").toString(); - String base64 = HttpUtils.getImageAsBase64(headurl); - if(base64!=null|| base64!="") - { + String headurl = dataMap.get("personimg").toString(); + String base64 = HttpUtils.getImageAsBase64(headurl); + if (base64 != null || base64 != "") { InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO(); updateReqVO.setMedicalSn(medicalSn); updateReqVO.setHeadPicUrl(base64); @@ -1099,11 +1091,13 @@ public class InspectPatientController { public CommonResult getPatientInfo(@RequestParam("medicalSn") String medicalSn) { return success(patientService.getPatientInfo(medicalSn)); } + @GetMapping("/PatientBySearchKey") @Operation(summary = "根据姓名、身份证号、体检编号获得患者信息") - public CommonResult> getPatientBySearchKey(@RequestParam("searchKey") String searchKey) { + public CommonResult> getPatientBySearchKey(@RequestParam("searchKey") String searchKey) { return success(patientService.getPatientBySearchKey(searchKey)); } + @GetMapping("/getecgTj") @Operation(summary = "获取体检ecg数据") public CommonResult GetApiEcgInfo(@RequestParam("medicalSn") String medicalSn) { @@ -1116,23 +1110,21 @@ public class InspectPatientController { pacsDataService.createPacsData(inspectPacs); return success(true); } + @GetMapping("/GetApiPatientInfo") @Operation(summary = "获取公卫患者信息") public CommonResult GetApiPatientInfo(@RequestParam("idCard") String idCard) throws JsonProcessingException { ConfigDO config = configService.getConfigByKey("url.patientinfo"); String url = config.getValue(); - InspectApiInfoVO inspectApiInfoVO =new InspectApiInfoVO(); - if(url!=null) - { + InspectApiInfoVO inspectApiInfoVO = new InspectApiInfoVO(); + if (url != null) { String response = HttpUtils.post(url + "?" + "idCard=" + idCard); - if(response!=null) - { + if (response != null) { // 解析 JSON 响应 ObjectMapper objectMapper = new ObjectMapper(); Map responseMap = objectMapper.readValue(response, Map.class); Map dataMap = (Map) responseMap.get("data"); - if (dataMap != null) - { + if (dataMap != null) { if (dataMap.get("idCard") != null) { inspectApiInfoVO.setIdCard(dataMap.get("idCard").toString()); } @@ -1157,9 +1149,7 @@ public class InspectPatientController { if (dataMap.get("telephone") != null) { inspectApiInfoVO.setTelephone(dataMap.get("telephone").toString()); } - } - else - { + } else { return success("没有查询到相关信息"); } } @@ -1184,7 +1174,8 @@ public class InspectPatientController { Object dataObj = responseMap.get("data"); if (dataObj != null) { // 将 data 字段解析为一个 List> - List> dataList = objectMapper.convertValue(dataObj, new TypeReference>>() {}); + List> dataList = objectMapper.convertValue(dataObj, new TypeReference>>() { + }); InspectPatientSaveReqVO inspectPatientSaveReqVO = new InspectPatientSaveReqVO(); inspectPatientSaveReqVO.setMedicalSn(medicalSn); @@ -1287,9 +1278,9 @@ public class InspectPatientController { @PutMapping("/updatePrintStatus") @Operation(summary = "更新打印状态") - public CommonResult updatePrintStatus(@RequestParam("medicalSn") String medicalSn, - @RequestParam(value = "printtime", required = false) - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date printtime) { + public CommonResult updatePrintStatus(@RequestParam("medicalSn") String medicalSn, + @RequestParam(value = "printtime", required = false) + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date printtime) { patientService.isprintupdate(medicalSn, printtime); return success(true); } @@ -1303,24 +1294,24 @@ public class InspectPatientController { if (patientDO == null) { return success("未找到该患者信息"); } - + // 检查患者的检查状态 if (patientDO.getStatus() == null || patientDO.getStatus() != 1) { return success("患者未完成检查,无法生成报告"); } - + // 构建请求JSON Map requestBody = new HashMap<>(); requestBody.put("medicalSn", medicalSn); - + // 将Map转换为JSON字符串 ObjectMapper objectMapper = new ObjectMapper(); String jsonRequestBody = objectMapper.writeValueAsString(requestBody); - + // 发送POST请求 String url = "http://114.55.171.231:48085/api/report/generate"; String response = HttpUtils.postJson(url, jsonRequestBody); - if(response!=null) { + if (response != null) { // 解析响应,如果成功则保存PDF URL try { Map responseMap = objectMapper.readValue(response, Map.class); @@ -1344,7 +1335,7 @@ public class InspectPatientController { e.printStackTrace(); } } - + return success(response); } catch (Exception e) { e.printStackTrace(); @@ -1354,50 +1345,51 @@ public class InspectPatientController { @PutMapping("/updateReportUrl") @Operation(summary = "更新患者体检报告URL") - public CommonResult updateReportUrl(@RequestParam("medicalSn") String medicalSn, - @RequestParam("pdfUrl") String pdfUrl) { + public CommonResult updateReportUrl(@RequestParam("medicalSn") String medicalSn, + @RequestParam("pdfUrl") String pdfUrl) { try { // 获取患者信息 InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn); if (patientDO == null) { return success(false, "未找到该患者信息"); } - + // 更新pdfurl字段 InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO(); updateReqVO.setMedicalSn(medicalSn); updateReqVO.setPdfurl(pdfUrl); - + // 调用服务更新数据 patientService.updatePatientPdfUrl(updateReqVO); - + return success(true); } catch (Exception e) { e.printStackTrace(); return success(false, "更新报告URL失败:" + e.getMessage()); } } + @GetMapping("/getReportUrl") @Operation(summary = "获取患者体检报告URL") public CommonResult> getReportUrl(@RequestParam("cardId") String cardId) { try { // 根据身份证查询患者信息 InspectPatientDO patientDO = patientService.getPatientByCardId(cardId); - + // 如果找不到患者记录或者pdfurl为空,返回暂无报告 if (patientDO == null) { return CommonResult.error(404, "未找到患者记录"); } - + if (patientDO.getPdfurl() == null || patientDO.getPdfurl().trim().isEmpty()) { return CommonResult.error(404, "暂无报告"); } - + // 提取体检编号的日期部分 String pdfUrl = patientDO.getPdfurl(); String reportDate = ""; String medicalSn = patientDO.getMedicalSn(); - + // 使用medicalDateTime字段获取日期 LocalDateTime medicalDateTime = patientDO.getMedicalDateTime(); if (medicalDateTime != null) { @@ -1413,13 +1405,13 @@ public class InspectPatientController { } } } - + // 构建返回的数据 Map resultMap = new HashMap<>(); resultMap.put("url", pdfUrl); resultMap.put("date", reportDate); resultMap.put("medicalSn", medicalSn); - + // 返回结果 return CommonResult.success(resultMap, "成功"); } catch (Exception e) { @@ -1427,13 +1419,57 @@ public class InspectPatientController { return CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "查询异常:" + e.getMessage()); } } + @PutMapping("/updateMedicalDateTime") @Operation(summary = "更新体检日期") public CommonResult updateMedicalDateTime(@RequestParam("medicalSn") String medicalSn, - @RequestParam(value = "medicalDateTime", required = false) - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date medicalDateTime) - { + @RequestParam(value = "medicalDateTime", required = false) + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date medicalDateTime) { patientService.updateMedicalDateTime(medicalSn, medicalDateTime); return success(true); } + @GetMapping("/GetbarcodeInfo") + @Operation(summary = "获取样本码信息") + public CommonResult GetbarcodeInfo(@RequestParam("medicalSn") String medicalSn) { + + // 获取患者信息 + InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn); + if (patientDO == null) { + return success("未找到该患者信息"); + } + if(patientDO.getNcgcode()==null || patientDO.getXcgcode()==null|| patientDO.getShqx()==null) + { + return success("条码不存在"); + } + BarcodeInfoVO barcodeInfoVO = new BarcodeInfoVO(); + barcodeInfoVO.setName(patientDO.getPName()); + barcodeInfoVO.setGender(patientDO.getGender()); + int age = StrUtils.calculateAgeFromIdCard(patientDO.getCardId()); + barcodeInfoVO.setAge(age); + // 设置当前时间字符串 + LocalDateTime currentDateTime = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String currentDateTimeStr = currentDateTime.format(formatter); + barcodeInfoVO.setExaminationDate(currentDateTimeStr); + // 初始化条形码集合 + List barcodes = new ArrayList<>(); + BarcodeInfoVO.Barcode ncgbarcode = new BarcodeInfoVO.Barcode(); + ncgbarcode.setCode(patientDO.getNcgcode()); + ncgbarcode.setName("尿常规"); + barcodes.add(ncgbarcode); + + BarcodeInfoVO.Barcode xcgbarcode = new BarcodeInfoVO.Barcode(); + xcgbarcode.setCode(patientDO.getXcgcode()); + xcgbarcode.setName("血常规"); + barcodes.add(xcgbarcode); + + BarcodeInfoVO.Barcode shqxbarcode = new BarcodeInfoVO.Barcode(); + shqxbarcode.setCode(patientDO.getShqx()); + shqxbarcode.setName("生化"); + barcodes.add(shqxbarcode); + barcodeInfoVO.setBarcodes(barcodes); + + return success(barcodeInfoVO); + } + } \ No newline at end of file diff --git a/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/BarcodeInfoVO.java b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/BarcodeInfoVO.java new file mode 100644 index 0000000..a0232e9 --- /dev/null +++ b/yudao-module-inspect/yudao-module-inspect-biz/src/main/java/cn/iocoder/yudao/module/inspect/controller/admin/inspectpatient/vo/BarcodeInfoVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +@Data +public class BarcodeInfoVO { + + @Schema(description = "姓名") + private String name; + + @Schema(description = "性别") + private String gender; + + @Schema(description = "年龄") + private Integer age; + + @Schema(description = "体检日期") + private String examinationDate; + + @Schema(description = "条形码集合") + private List barcodes; + + @Data + public static class Barcode { + @Schema(description = "条形码编码") + private String code; + + @Schema(description = "条形码名称") + private String name; + } +}