打印导检单

This commit is contained in:
张佳炜 2025-03-07 09:09:06 +08:00
parent 246cd830ef
commit 4d5bc05f35
4 changed files with 120 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.inspect.controller.admin.checkupresult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.inspect.controller.admin.checkupresult.vo.PrintRespVO;
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo.InspectPatientRespVO;
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo.InspectPatientSaveReqVO;
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatientitems.vo.InspectPatientitemsRespVO;
@ -91,4 +92,12 @@ public class CheckUpResultController {
return success(existUncheck);
}
@GetMapping("/printInfoOfMedicalSn")
@Operation(summary = "打印模板的数据")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<PrintRespVO> printInfoOfMedicalSn(@RequestParam("medicalSn") String medicalSn) {
PrintRespVO printRespVO = patientitemsService.printItemsOfMedicalSn(medicalSn);
return success(printRespVO);
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.inspect.controller.admin.checkupresult.vo;
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatientitems.InspectPatientitemsDO;
import lombok.Data;
import java.util.List;
@Data
public class PrintRespVO {
private String pName;
private String gender;
private String age;
private String phone;
private String medicalSn;
private String address;
private String mealFront;
private String mealAfter;
private String mealOther;
private String barcode;
private String qrcode;
private List<InspectPatientitemsDO> table;
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.inspect.service.inspectpatientitems;
import java.util.*;
import cn.iocoder.yudao.module.inspect.controller.admin.checkupresult.vo.PrintRespVO;
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatientitems.vo.*;
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatient.InspectPatientDO;
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatientitems.InspectPatientitemsDO;
@ -81,5 +83,5 @@ public interface InspectPatientitemsService {
List<InspectPatientitemsDO> groupNameItemsOfMedicalSn( String medicalSn );
PrintRespVO printItemsOfMedicalSn(String medicalSn);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.inspect.service.inspectpatientitems;
import cn.iocoder.yudao.module.inspect.controller.admin.checkupresult.vo.PrintRespVO;
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatient.InspectPatientDO;
import cn.iocoder.yudao.module.inspect.dal.mysql.inspectpatient.InspectPatientMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -10,6 +11,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatientitems.vo.*;
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatientitems.InspectPatientitemsDO;
@ -157,4 +160,72 @@ public class InspectPatientitemsServiceImpl implements InspectPatientitemsServic
return patientitemsMapper.groupNameItems(medicalSn);
}
@Override
public PrintRespVO printItemsOfMedicalSn(String medicalSn) {
PrintRespVO printRespVO = new PrintRespVO();
//获取患者信息
LambdaQueryWrapper<InspectPatientDO> lambdaQuery = new LambdaQueryWrapper<>();
lambdaQuery.eq(InspectPatientDO::getMedicalSn, medicalSn);
InspectPatientDO inspectPatientDO = patientMapper.selectOne(lambdaQuery);
printRespVO.setMedicalSn(inspectPatientDO.getMedicalSn());
printRespVO.setPName(inspectPatientDO.getPName());
printRespVO.setGender(inspectPatientDO.getGender());
printRespVO.setPhone(inspectPatientDO.getPhoneNum());
//没有校验身份证是否正确
if (inspectPatientDO.getCardId()!=null && !Objects.equals(inspectPatientDO.getCardId(), "")){
String age = String.valueOf(getAgeByIdCard(inspectPatientDO.getCardId()));
printRespVO.setAge(age);
}
// 地址
//获取检查项目
LambdaQueryWrapper<InspectPatientitemsDO> lambdaQuery2 = new LambdaQueryWrapper<>();
lambdaQuery2.eq(InspectPatientitemsDO::getMedicalSn, medicalSn);
List<InspectPatientitemsDO> list = patientitemsMapper.selectList(lambdaQuery2);
StringBuilder mealFront = new StringBuilder();
StringBuilder mealAfter = new StringBuilder();
StringBuilder mealOther = new StringBuilder();
for (InspectPatientitemsDO item : list) {
if (Objects.equals(item.getMealfrontorafter(), "") || item.getMealfrontorafter()==null){
mealOther.append("").append(item.getItemName()).append("");
} else if (item.getMealfrontorafter().equals("餐前")) {
mealFront.append("").append(item.getItemName()).append("");
} else if (item.getMealfrontorafter().equals("餐后")) {
mealAfter.append("").append(item.getItemName()).append("");
}
}
printRespVO.setMealAfter(mealAfter.toString());
printRespVO.setMealFront(mealFront.toString());
printRespVO.setMealOther(mealOther.toString());
printRespVO.setTable(list);
printRespVO.setBarcode("111222333");
printRespVO.setQrcode("333444555");
return printRespVO;
}
public int getAgeByIdCard(String idCard) {
String birthDateStr = idCard.substring(6, 14); // 身份证号码的7到14位为出生日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
Date birthDate;
try {
birthDate = formatter.parse(birthDateStr);
} catch (ParseException e) {
e.printStackTrace();
return -1; // 如果解析出生日期失败返回-1
}
Calendar birth = Calendar.getInstance();
birth.setTime(birthDate);
Calendar today = Calendar.getInstance();
int age = today.get(Calendar.YEAR) - birth.get(Calendar.YEAR);
if (today.get(Calendar.DAY_OF_YEAR) < birth.get(Calendar.DAY_OF_YEAR)) {
age -= 1; // 如果当前日期在生日之前年龄减一
}
return age;
}
}