新增获取样本码信息接口

This commit is contained in:
lxd 2025-04-10 15:44:37 +08:00
parent c1d49642f1
commit 261cdbdacb
2 changed files with 236 additions and 166 deletions

View File

@ -323,13 +323,12 @@ public class InspectPatientController {
patientitemsService.createPatientListitems(batch);
}
}
@PostMapping("/insertPatinetInfo")
@Operation(summary = "根据表单创建患者信息和项目信息")
public CommonResult<Boolean> insertPatinetInfo(@Valid @RequestBody InspectPatientSaveReqVO inspectPatientSaveReqVO)
{
public CommonResult<Boolean> insertPatinetInfo(@Valid @RequestBody InspectPatientSaveReqVO inspectPatientSaveReqVO) {
//验证身份证
if( patientService.validateIdCardExists(inspectPatientSaveReqVO.getCardId()))
{
if (patientService.validateIdCardExists(inspectPatientSaveReqVO.getCardId())) {
return success(false, "身份证号已存在");
}
@ -378,14 +377,13 @@ public class InspectPatientController {
// batchInsertPatientItems(dataList2);
return success(true);
}
@GetMapping("/createPatientitem")
@Operation(summary = "通过体检编号绑定检查项目信息")
public CommonResult<Boolean> createPatientitem(@RequestParam("medicalSn") String medicalSn)
{
public CommonResult<Boolean> 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<Boolean> syncinspectApplyTj(@RequestParam("medicalSn") String medicalSn) throws JsonProcessingException {
@ -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,31 +558,25 @@ 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)
{
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.setType(model);
if(reportData.getResults()!=null&&reportData.getResults().size()>0)
{
if (reportData.getResults() != null && reportData.getResults().size() > 0) {
// 获取 results 数组并遍历
List<ResultItem> results = reportData.getResults();
for (ResultItem result : results) {
@ -623,21 +612,18 @@ public class InspectPatientController {
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<ResultItem> results = reportData.getResults();
for (ResultItem result : results) {
@ -718,6 +704,7 @@ public class InspectPatientController {
patientService.medicalSnupdate(updateReqVO);
return success(true);
}
@PutMapping("/updatedoctorid")
@Operation(summary = "更新患者总检医生ID")
public CommonResult<Boolean> updatedoctorid(@Valid @RequestBody InspectPatientSaveReqVO updateReqVO) {
@ -738,11 +725,9 @@ public class InspectPatientController {
// 设置基本信息
BeanUtils.copyProperties(patientDO, inspectPatientReportVO);
// 先拿到ID 在查询签名
if(patientDO.getChiefinspectorid()!=null)
{
if (patientDO.getChiefinspectorid() != null) {
InspectDoctorDO doctorDO = doctorService.getDoctorid(patientDO.getChiefinspectorid());
if(doctorDO!=null&&doctorDO.getDoctorsign()!=null)
{
if (doctorDO != null && doctorDO.getDoctorsign() != null) {
inspectPatientReportVO.setSign(doctorDO.getDoctorsign());
}
}
@ -906,7 +891,8 @@ public class InspectPatientController {
// 添加新的匹配逻辑
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;
@ -919,14 +905,22 @@ public class InspectPatientController {
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!="")
{
if (base64 != null || base64 != "") {
InspectPatientSaveReqVO updateReqVO = new InspectPatientSaveReqVO();
updateReqVO.setMedicalSn(medicalSn);
updateReqVO.setHeadPicUrl(base64);
@ -1099,11 +1091,13 @@ public class InspectPatientController {
public CommonResult<InspectPatientDO> getPatientInfo(@RequestParam("medicalSn") String medicalSn) {
return success(patientService.getPatientInfo(medicalSn));
}
@GetMapping("/PatientBySearchKey")
@Operation(summary = "根据姓名、身份证号、体检编号获得患者信息")
public CommonResult<List<InspectPatientDO>> getPatientBySearchKey(@RequestParam("searchKey") String searchKey) {
return success(patientService.getPatientBySearchKey(searchKey));
}
@GetMapping("/getecgTj")
@Operation(summary = "获取体检ecg数据")
public CommonResult<Boolean> GetApiEcgInfo(@RequestParam("medicalSn") String medicalSn) {
@ -1116,23 +1110,21 @@ public class InspectPatientController {
pacsDataService.createPacsData(inspectPacs);
return success(true);
}
@GetMapping("/GetApiPatientInfo")
@Operation(summary = "获取公卫患者信息")
public CommonResult<InspectApiInfoVO> GetApiPatientInfo(@RequestParam("idCard") String idCard) throws JsonProcessingException {
ConfigDO config = configService.getConfigByKey("url.patientinfo");
String url = config.getValue();
InspectApiInfoVO inspectApiInfoVO = new InspectApiInfoVO();
if(url!=null)
{
if (url != null) {
String response = HttpUtils.post(url + "?" + "idCard=" + idCard);
if(response!=null)
{
if (response != null) {
// 解析 JSON 响应
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> responseMap = objectMapper.readValue(response, Map.class);
Map<String, Object> dataMap = (Map<String, Object>) 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<Map<String, Object>>
List<Map<String, Object>> dataList = objectMapper.convertValue(dataObj, new TypeReference<List<Map<String, Object>>>() {});
List<Map<String, Object>> dataList = objectMapper.convertValue(dataObj, new TypeReference<List<Map<String, Object>>>() {
});
InspectPatientSaveReqVO inspectPatientSaveReqVO = new InspectPatientSaveReqVO();
inspectPatientSaveReqVO.setMedicalSn(medicalSn);
@ -1377,6 +1368,7 @@ public class InspectPatientController {
return success(false, "更新报告URL失败" + e.getMessage());
}
}
@GetMapping("/getReportUrl")
@Operation(summary = "获取患者体检报告URL")
public CommonResult<Map<String, Object>> getReportUrl(@RequestParam("cardId") String cardId) {
@ -1427,13 +1419,57 @@ public class InspectPatientController {
return CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "查询异常:" + e.getMessage());
}
}
@PutMapping("/updateMedicalDateTime")
@Operation(summary = "更新体检日期")
public CommonResult<Boolean> updateMedicalDateTime(@RequestParam("medicalSn") String medicalSn,
@RequestParam(value = "medicalDateTime", required = false)
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date medicalDateTime)
{
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date medicalDateTime) {
patientService.updateMedicalDateTime(medicalSn, medicalDateTime);
return success(true);
}
@GetMapping("/GetbarcodeInfo")
@Operation(summary = "获取样本码信息")
public CommonResult<BarcodeInfoVO> 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<BarcodeInfoVO.Barcode> 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);
}
}

View File

@ -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<Barcode> barcodes;
@Data
public static class Barcode {
@Schema(description = "条形码编码")
private String code;
@Schema(description = "条形码名称")
private String name;
}
}