报告模板
This commit is contained in:
parent
013939aec4
commit
389b30af27
@ -57,9 +57,32 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- freemarker -->
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.34</version>
|
||||
</dependency>
|
||||
|
||||
<!-- playwright -->
|
||||
<dependency>
|
||||
<groupId>com.microsoft.playwright</groupId>
|
||||
<artifactId>playwright</artifactId>
|
||||
<version>1.50.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pdfbox -->
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.27</version>
|
||||
</dependency>
|
||||
|
||||
<!-- poi -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
@ -14,11 +14,15 @@ import cn.iocoder.yudao.module.inspect.service.inspectpacsdata.InspectPacsDataSe
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectpatientitems.InspectPatientitemsService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.mysql.cj.result.Row;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import org.apache.poi.sl.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -26,6 +30,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@ -47,16 +54,19 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo.*;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatient.InspectPatientDO;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectpatient.InspectPatientService;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Tag(name = "管理后台 - 患者信息")
|
||||
@ -75,31 +85,31 @@ public class InspectPatientController {
|
||||
private ExammoduleService exammoduleService;
|
||||
@Resource
|
||||
private InspectPatientitemsService patientitemsService;
|
||||
@Resource
|
||||
private RestTemplate httpRestTemplate;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建患者信息")
|
||||
public CommonResult<Integer> createPatient(@Valid @RequestBody InspectPatientSaveReqVO createReqVO) {
|
||||
|
||||
//处理头像
|
||||
if(createReqVO.getHeadimage()!=null||createReqVO.getHeadimage()!="")
|
||||
{
|
||||
if (createReqVO.getHeadimage() != null || createReqVO.getHeadimage() != "") {
|
||||
//获取配置项地址
|
||||
ConfigDO path = configService.getConfigByKey("path.url");
|
||||
ConfigDO config = configService.getConfigByKey("path.specific");
|
||||
FileUtils.saveBase64ToFile2(createReqVO.getHeadimage(),path.getValue(),createReqVO.getMedicalSn(),"png");
|
||||
createReqVO.setHeadPicUrl(config.getValue()+createReqVO.getMedicalSn()+".png");
|
||||
FileUtils.saveBase64ToFile2(createReqVO.getHeadimage(), path.getValue(), createReqVO.getMedicalSn(), "png");
|
||||
createReqVO.setHeadPicUrl(config.getValue() + createReqVO.getMedicalSn() + ".png");
|
||||
}
|
||||
|
||||
return success(patientService.createPatient(createReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/getUSPatientInfo")
|
||||
@Operation(summary = "对外根据体检编号获取患者信息")
|
||||
public CommonResult<InspectPatientInfoVO> getUSPatientInfo(@RequestParam("medicalSn") String medicalSn)
|
||||
{
|
||||
InspectPatientInfoVO patientInfoVO=new InspectPatientInfoVO();
|
||||
InspectPatientDO patientDO= patientService.getPatientInfo(medicalSn);
|
||||
if(patientDO!=null)
|
||||
{
|
||||
public CommonResult<InspectPatientInfoVO> getUSPatientInfo(@RequestParam("medicalSn") String medicalSn) {
|
||||
InspectPatientInfoVO patientInfoVO = new InspectPatientInfoVO();
|
||||
InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO != null) {
|
||||
patientInfoVO.setJianchaid(patientDO.getCardId());
|
||||
patientInfoVO.setJianchabh(patientDO.getMedicalSn());
|
||||
patientInfoVO.setName(patientDO.getPName());
|
||||
@ -134,7 +144,7 @@ public class InspectPatientController {
|
||||
Workbook workbook = new XSSFWorkbook(inputStream)) {
|
||||
|
||||
// +获取第一个Sheet
|
||||
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0);
|
||||
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0);
|
||||
if (sheet == null) {
|
||||
return success("Sheet为空");
|
||||
}
|
||||
@ -155,7 +165,7 @@ public class InspectPatientController {
|
||||
}
|
||||
|
||||
// 验证列标题(可选)
|
||||
String[] expectedHeaders = {"姓名", "身份证号", "出生日期","性别","联系电话","住址"};
|
||||
String[] expectedHeaders = {"姓名", "身份证号", "出生日期", "性别", "联系电话", "住址"};
|
||||
for (String expectedHeader : expectedHeaders) {
|
||||
if (!headerMap.containsValue(expectedHeader)) {
|
||||
return success("列标题不符合预期");
|
||||
@ -164,7 +174,7 @@ public class InspectPatientController {
|
||||
|
||||
// 读取数据行 需要插入患者信息和患者项目信息
|
||||
//检查套餐信息
|
||||
List<InspectitemsDO> doList= exammoduleService.selectItemsByExamModuleID(1001);
|
||||
List<InspectitemsDO> doList = exammoduleService.selectItemsByExamModuleID(1001);
|
||||
//患者信息
|
||||
List<InspectPatientSaveReqVO> dataList = new ArrayList<>();
|
||||
//检查项目
|
||||
@ -174,7 +184,7 @@ public class InspectPatientController {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long uniqueNumber = counter.incrementAndGet();
|
||||
String MedicalSn = Long.toString(timestamp) + String.format("%04d", uniqueNumber % 10000);
|
||||
//患者信息
|
||||
//患者信息
|
||||
InspectPatientSaveReqVO rowData = new InspectPatientSaveReqVO();
|
||||
|
||||
rowData.setMedicalSn(MedicalSn);
|
||||
@ -203,7 +213,7 @@ public class InspectPatientController {
|
||||
rowData.setPhoneNum(getCellValue(cell));
|
||||
break;
|
||||
case "住址":
|
||||
rowData.setDomicileaddress(getCellValue(cell));
|
||||
rowData.setDomicileaddress(getCellValue(cell));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -212,8 +222,7 @@ public class InspectPatientController {
|
||||
rowData.setCreateTime(LocalDateTime.now());
|
||||
dataList.add(rowData);
|
||||
//填写项目信息
|
||||
for (InspectitemsDO inspectitemsDO:doList)
|
||||
{
|
||||
for (InspectitemsDO inspectitemsDO : doList) {
|
||||
//套餐信息
|
||||
InspectPatientitemsSaveReqVO rowData2 = new InspectPatientitemsSaveReqVO();
|
||||
rowData2.setMedicalSn(MedicalSn);
|
||||
@ -243,8 +252,8 @@ public class InspectPatientController {
|
||||
return success("读取Excel文件失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 判断当前值类型
|
||||
*/
|
||||
private String getCellValue(Cell cell) {
|
||||
@ -268,8 +277,8 @@ public class InspectPatientController {
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量执行患者数据
|
||||
* */
|
||||
* 批量执行患者数据
|
||||
* */
|
||||
private void batchInsertPatients(List<InspectPatientSaveReqVO> dataList) {
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < dataList.size(); i += batchSize) {
|
||||
@ -278,9 +287,10 @@ public class InspectPatientController {
|
||||
patientService.createPatientList(batch);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 批量执行患者项目数据
|
||||
* */
|
||||
* 批量执行患者项目数据
|
||||
* */
|
||||
private void batchInsertPatientItems(List<InspectPatientitemsSaveReqVO> dataList2) {
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < dataList2.size(); i += batchSize) {
|
||||
@ -289,40 +299,40 @@ public class InspectPatientController {
|
||||
patientitemsService.createPatientListitems(batch);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/syncinspectApplyTj")
|
||||
@Operation(summary = "发送检验申请单")
|
||||
public CommonResult<Boolean> syncinspectApplyTj(@RequestParam("medicalSn") String medicalSn) throws JsonProcessingException {
|
||||
//获取患者信息
|
||||
InspectPatientDO patientDO= patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO!=null)
|
||||
{
|
||||
InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO != null) {
|
||||
// 创建 ObjectMapper 实例
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 创建 Java 对象
|
||||
// 创建 Java 对象
|
||||
Map<String, Object> patient = new HashMap<>();
|
||||
patient.put("patientName", patientDO.getPName());
|
||||
patient.put("idCard", patientDO.getCardId());
|
||||
patient.put("hospitalCode", "121526004609160793");
|
||||
patient.put("sampleSource", "TJ");
|
||||
patient.put("patientGender", patientDO.getGender()=="女"?"1":"0");
|
||||
patient.put("patientGender", patientDO.getGender() == "女" ? "1" : "0");
|
||||
patient.put("patientAge", StrUtils.calculateAgeFromIdCard(patientDO.getCardId()));
|
||||
patient.put("patientAgeUnit", "S");
|
||||
patient.put("barCodeStatus", 3);
|
||||
|
||||
List<Map<String, String>> billingItemList = new ArrayList<>();
|
||||
String checkBarCode1= DateUtils.generateUniqueCode();
|
||||
String checkBarCode1 = DateUtils.generateUniqueCode();
|
||||
Map<String, String> item1 = new HashMap<>();
|
||||
item1.put("groupCode", "XCG");
|
||||
item1.put("checkBarCode", checkBarCode1);
|
||||
billingItemList.add(item1);
|
||||
|
||||
String checkBarCode2= DateUtils.generateUniqueCode();
|
||||
String checkBarCode2 = DateUtils.generateUniqueCode();
|
||||
Map<String, String> item2 = new HashMap<>();
|
||||
item2.put("groupCode", "NCG");
|
||||
item2.put("checkBarCode", checkBarCode2);
|
||||
billingItemList.add(item2);
|
||||
|
||||
String checkBarCode3= DateUtils.generateUniqueCode();
|
||||
String checkBarCode3 = DateUtils.generateUniqueCode();
|
||||
Map<String, String> item3 = new HashMap<>();
|
||||
item3.put("groupCode", "SHQX");
|
||||
item3.put("checkBarCode", checkBarCode3);
|
||||
@ -347,46 +357,42 @@ public class InspectPatientController {
|
||||
|
||||
}
|
||||
|
||||
return success(true);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/getReportTj")
|
||||
@Operation(summary = "获取检验报告")
|
||||
public CommonResult<Boolean> getReportTj(@RequestParam("medicalSn") String medicalSn,@RequestParam("type") String type)
|
||||
{
|
||||
public CommonResult<Boolean> getReportTj(@RequestParam("medicalSn") String medicalSn, @RequestParam("type") String type) {
|
||||
//获取患者信息
|
||||
InspectPatientDO patientDO= patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO!=null)
|
||||
{
|
||||
String model= "";
|
||||
String barCode= "";
|
||||
switch (type)
|
||||
{
|
||||
InspectPatientDO patientDO = patientService.getPatientInfo(medicalSn);
|
||||
if (patientDO != null) {
|
||||
String model = "";
|
||||
String barCode = "";
|
||||
switch (type) {
|
||||
case "XCG":
|
||||
model="cbc";
|
||||
barCode=patientDO.getXcgcode();
|
||||
model = "cbc";
|
||||
barCode = patientDO.getXcgcode();
|
||||
break;
|
||||
case "NCG":
|
||||
model="rt";
|
||||
barCode=patientDO.getNcgcode();
|
||||
model = "rt";
|
||||
barCode = patientDO.getNcgcode();
|
||||
break;
|
||||
case "SHQX":
|
||||
model="bt";
|
||||
barCode=patientDO.getShqx();
|
||||
model = "bt";
|
||||
barCode = patientDO.getShqx();
|
||||
break;
|
||||
}
|
||||
ConfigDO config = configService.getConfigByKey("url.reporttj");
|
||||
String url = config.getValue();
|
||||
String response = HttpUtils.get(url+"?"+"barCode="+barCode+"&"+"hospitalCode="+patientDO.getHospitalNo());
|
||||
if(response!=null)
|
||||
{
|
||||
String response = HttpUtils.get(url + "?" + "barCode=" + barCode + "&" + "hospitalCode=" + patientDO.getHospitalNo());
|
||||
if (response != null) {
|
||||
// 解析 JSON 响应
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
Map<String, Object> responseMap = objectMapper.readValue(response, Map.class);
|
||||
String msg = (String) responseMap.get("msg");
|
||||
if(!msg.contains("报告暂未出"))
|
||||
{
|
||||
InspectPacsDataSaveReqVO inspectPacs= new InspectPacsDataSaveReqVO();
|
||||
if (!msg.contains("报告暂未出")) {
|
||||
InspectPacsDataSaveReqVO inspectPacs = new InspectPacsDataSaveReqVO();
|
||||
inspectPacs.setCode(patientDO.getMedicalSn());
|
||||
inspectPacs.setData(msg);
|
||||
inspectPacs.setType(model);
|
||||
@ -401,24 +407,22 @@ public class InspectPatientController {
|
||||
}
|
||||
|
||||
}
|
||||
return success(true);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/getUSTj")
|
||||
@Operation(summary = "获取超声报告")
|
||||
public CommonResult<Boolean> GetApiPacsInfo(@RequestParam("medicalSn") String medicalSn)
|
||||
{
|
||||
public CommonResult<Boolean> GetApiPacsInfo(@RequestParam("medicalSn") String medicalSn) {
|
||||
ConfigDO config = configService.getConfigByKey("url.ustj");
|
||||
String url = config.getValue();
|
||||
String response = HttpUtils.get(url+"?"+"examid="+medicalSn+"&"+"orgSN="+"1001");
|
||||
if(response!=null)
|
||||
{
|
||||
String response = HttpUtils.get(url + "?" + "examid=" + medicalSn + "&" + "orgSN=" + "1001");
|
||||
if (response != null) {
|
||||
// 解析 JSON 响应
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
Map<String, Object> responseMap = objectMapper.readValue(response, Map.class);
|
||||
Map<String, Object> dataMap = (Map<String, Object>) responseMap.get("data");
|
||||
if(dataMap!=null &&dataMap.get("pdfurl")!=null)
|
||||
{
|
||||
if (dataMap != null && dataMap.get("pdfurl") != null) {
|
||||
|
||||
// 获取 pdfurl 和 pname
|
||||
String pdfurl = (String) dataMap.get("pdfurl");
|
||||
@ -441,37 +445,35 @@ public class InspectPatientController {
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新患者信息")
|
||||
public CommonResult<Boolean> updatePatient(@Valid @RequestBody InspectPatientSaveReqVO updateReqVO) {
|
||||
patientService.updatePatient(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/GetApiYbjcInfo")
|
||||
@Operation(summary = "同步一般检查结果项")
|
||||
public CommonResult<Boolean> GetApiYbjcInfo(@RequestParam("medicalSn") String medicalSn,@RequestParam("cardId") String cardId)
|
||||
{
|
||||
public CommonResult<Boolean> GetApiYbjcInfo(@RequestParam("medicalSn") String medicalSn, @RequestParam("cardId") String cardId) {
|
||||
ConfigDO config = configService.getConfigByKey("url.ybjc");
|
||||
String url = config.getValue();
|
||||
String response = HttpUtils.get(url+"?"+"idCard="+cardId);
|
||||
if(response!=null)
|
||||
{
|
||||
String response = HttpUtils.get(url + "?" + "idCard=" + cardId);
|
||||
if (response != null) {
|
||||
// 解析 JSON 响应
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
Map<String, Object> responseMap = objectMapper.readValue(response, Map.class);
|
||||
Map<String, Object> dataMap = (Map<String, Object>) responseMap.get("data");
|
||||
if(dataMap!=null &&dataMap.get("healthexaminid")!=null)
|
||||
{
|
||||
if (dataMap != null && dataMap.get("healthexaminid") != null) {
|
||||
List<InspectPatientitemsSaveReqVO> list = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
InspectPatientitemsSaveReqVO inspectPatientitemsSaveReqVO = null;
|
||||
switch (key)
|
||||
{
|
||||
switch (key) {
|
||||
case "temperature":
|
||||
inspectPatientitemsSaveReqVO = new InspectPatientitemsSaveReqVO();
|
||||
inspectPatientitemsSaveReqVO = new InspectPatientitemsSaveReqVO();
|
||||
inspectPatientitemsSaveReqVO.setMedicalSn(medicalSn);
|
||||
inspectPatientitemsSaveReqVO.setItemCode("TW001");
|
||||
inspectPatientitemsSaveReqVO.setItemResult(value.toString());
|
||||
@ -524,17 +526,14 @@ public class InspectPatientController {
|
||||
}
|
||||
InspectPatientitemsSaveReqVO inspectPatientitemsSaveReqVO = new InspectPatientitemsSaveReqVO();
|
||||
//单独判断收缩压和舒张压 分左右手
|
||||
if(dataMap.get("bplshrink")!=null&&dataMap.get("bpldiastole")!=null)
|
||||
{
|
||||
if (dataMap.get("bplshrink") != null && dataMap.get("bpldiastole") != null) {
|
||||
inspectPatientitemsSaveReqVO.setMedicalSn(medicalSn);
|
||||
inspectPatientitemsSaveReqVO.setItemCode("XY001");
|
||||
inspectPatientitemsSaveReqVO.setItemResult(dataMap.get("bplshrink")+"/"+dataMap.get("bpldiastole"));
|
||||
}
|
||||
else
|
||||
{
|
||||
inspectPatientitemsSaveReqVO.setItemResult(dataMap.get("bplshrink") + "/" + dataMap.get("bpldiastole"));
|
||||
} else {
|
||||
inspectPatientitemsSaveReqVO.setMedicalSn(medicalSn);
|
||||
inspectPatientitemsSaveReqVO.setItemCode("XY001");
|
||||
inspectPatientitemsSaveReqVO.setItemResult(dataMap.get("bprshrink")+"/"+dataMap.get("bprdiastole"));
|
||||
inspectPatientitemsSaveReqVO.setItemResult(dataMap.get("bprshrink") + "/" + dataMap.get("bprdiastole"));
|
||||
}
|
||||
list.add(inspectPatientitemsSaveReqVO);
|
||||
patientitemsService.updatePatientitemInfo(list);
|
||||
@ -547,6 +546,7 @@ public class InspectPatientController {
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除患者信息")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@ -562,25 +562,26 @@ public class InspectPatientController {
|
||||
InspectPatientDO patient = patientService.getPatient(id);
|
||||
return success(BeanUtils.toBean(patient, InspectPatientRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/getpatientjson")
|
||||
@Operation(summary = "根据体检获得患者信息")
|
||||
public CommonResult<InspectPatientDO> getPatientInfo(@RequestParam("medicalSn") String medicalSn)
|
||||
{
|
||||
public CommonResult<InspectPatientDO> getPatientInfo(@RequestParam("medicalSn") String medicalSn) {
|
||||
return success(patientService.getPatientInfo(medicalSn));
|
||||
}
|
||||
|
||||
@GetMapping("/getecgTj")
|
||||
@Operation(summary = "获取体检ecg数据")
|
||||
public CommonResult<Boolean> GetApiEcgInfo(@RequestParam("medicalSn") String medicalSn)
|
||||
{
|
||||
public CommonResult<Boolean> GetApiEcgInfo(@RequestParam("medicalSn") String medicalSn) {
|
||||
ConfigDO config = configService.getConfigByKey("url.ecgtj");
|
||||
String url = config.getValue();
|
||||
InspectPacsDataSaveReqVO inspectPacs = new InspectPacsDataSaveReqVO();
|
||||
inspectPacs.setCode(medicalSn);
|
||||
inspectPacs.setData(url+"/"+medicalSn+".jpg");
|
||||
inspectPacs.setData(url + "/" + medicalSn + ".jpg");
|
||||
inspectPacs.setType("ecg");
|
||||
pacsDataService.createPacsData(inspectPacs);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得患者信息分页")
|
||||
public CommonResult<PageResult<InspectPatientRespVO>> getPatientPage(@Valid InspectPatientPageReqVO pageReqVO) {
|
||||
@ -592,13 +593,69 @@ public class InspectPatientController {
|
||||
@Operation(summary = "导出患者信息 Excel")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportPatientExcel(@Valid InspectPatientPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<InspectPatientDO> list = patientService.getPatientPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "患者信息.xls", "数据", InspectPatientRespVO.class,
|
||||
BeanUtils.toBean(list, InspectPatientRespVO.class));
|
||||
BeanUtils.toBean(list, InspectPatientRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/createPatientInspectDataReport")
|
||||
@Operation(summary = "创建患者体检报告单")
|
||||
public CommonResult<Map<String, Object>> createPatientInspectDataReport(String medicalSn) {
|
||||
Map<String, Object> outRes = patientService.createPatientInspectDataReport(medicalSn);
|
||||
return success(outRes);
|
||||
}
|
||||
|
||||
@GetMapping("/getPatientInspectDataReport")
|
||||
@Operation(summary = "获取患者体检报告单")
|
||||
public CommonResult<Map<String, Object>> getPatientInspectDataReport(String medicalSn) {
|
||||
patientService.getPatientInspectDataReport(medicalSn);
|
||||
return success(null);
|
||||
}
|
||||
|
||||
@GetMapping("/getPdfconvertToImg")
|
||||
@Operation(summary = "pdf数据转图片数据")
|
||||
public ResponseEntity<InputStreamResource> getPdfconvertToImg(@RequestParam String pdfUrl) {
|
||||
ResponseEntity<InputStreamResource> out = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
PDDocument document = null;
|
||||
try {
|
||||
byte[] inputStream = null;
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3562.0 Safari/537.36");
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
ResponseEntity<byte[]> response = httpRestTemplate.exchange(pdfUrl, HttpMethod.GET, entity, byte[].class);
|
||||
if (response.getStatusCode().is2xxSuccessful())
|
||||
inputStream = response.getBody();
|
||||
if (inputStream != null) {
|
||||
document = PDDocument.load(inputStream);
|
||||
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
||||
|
||||
BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 150);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
javax.imageio.ImageIO.write(bim, "PNG", baos);
|
||||
byte[] imageBytes = baos.toByteArray();
|
||||
|
||||
HttpHeaders headers_ret = new HttpHeaders();
|
||||
headers_ret.setContentType(MediaType.IMAGE_PNG);
|
||||
headers_ret.setContentLength(imageBytes.length);
|
||||
//headers_ret.add(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=image.png");
|
||||
|
||||
out = ResponseEntity
|
||||
.ok()
|
||||
.headers(headers_ret)
|
||||
.body(new InputStreamResource(new ByteArrayInputStream(imageBytes)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
out = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
} finally {
|
||||
try {
|
||||
if (document != null)
|
||||
document.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.inspectpatient;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo.*;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatient.InspectPatientDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -22,10 +23,11 @@ public interface InspectPatientService {
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createPatient(@Valid InspectPatientSaveReqVO createReqVO);
|
||||
|
||||
/*
|
||||
*
|
||||
* 批量插入患者信息数据
|
||||
* */
|
||||
*
|
||||
* 批量插入患者信息数据
|
||||
* */
|
||||
boolean createPatientList(List<InspectPatientSaveReqVO> listcreateReqVO);
|
||||
|
||||
/**
|
||||
@ -49,13 +51,15 @@ public interface InspectPatientService {
|
||||
* @return 患者信息
|
||||
*/
|
||||
InspectPatientDO getPatient(Integer id);
|
||||
|
||||
/*
|
||||
* 根据体检编号获取患者信息的json
|
||||
* */
|
||||
* 根据体检编号获取患者信息的json
|
||||
* */
|
||||
InspectPatientDO getPatientInfo(String medicalSn);
|
||||
|
||||
/*
|
||||
* 根据体检编号更新数据
|
||||
* */
|
||||
* 根据体检编号更新数据
|
||||
* */
|
||||
Integer updatePatientInfo(InspectPatientSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
@ -75,5 +79,13 @@ public interface InspectPatientService {
|
||||
//通过审核
|
||||
void updateAudit(String medicalSn, Integer auditStatus, String inspectionOpinion);
|
||||
|
||||
/**
|
||||
* 创建患者体检报告单
|
||||
*/
|
||||
Map<String, Object> createPatientInspectDataReport(String medicalSn);
|
||||
|
||||
/**
|
||||
* 获取患者体检报告单
|
||||
*/
|
||||
Map<String, Object> getPatientInspectDataReport(String medicalSn);
|
||||
}
|
@ -1,8 +1,26 @@
|
||||
package cn.iocoder.yudao.module.inspect.service.inspectpatient;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.service.config.ConfigService;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpacsdata.InspectPacsDataDO;
|
||||
import cn.iocoder.yudao.module.inspect.dal.dataobject.inspectpatientitems.InspectPatientitemsDO;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectpacsdata.InspectPacsDataService;
|
||||
import cn.iocoder.yudao.module.inspect.service.inspectpatientitems.InspectPatientitemsService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.microsoft.playwright.Browser;
|
||||
import com.microsoft.playwright.BrowserType;
|
||||
import com.microsoft.playwright.Page;
|
||||
import com.microsoft.playwright.Playwright;
|
||||
import com.microsoft.playwright.options.LoadState;
|
||||
import com.microsoft.playwright.options.Margin;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import cn.iocoder.yudao.module.inspect.controller.admin.inspectpatient.vo.*;
|
||||
@ -12,8 +30,15 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.inspect.dal.mysql.inspectpatient.InspectPatientMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import java.util.List;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@ -29,6 +54,15 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
@Resource
|
||||
private InspectPatientMapper patientMapper;
|
||||
|
||||
@Resource
|
||||
private InspectPatientitemsService patientitemsService;
|
||||
|
||||
@Resource
|
||||
private InspectPacsDataService pacsDataService;
|
||||
|
||||
@Resource
|
||||
private ConfigService configService;
|
||||
|
||||
@Override
|
||||
public Integer createPatient(InspectPatientSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
@ -37,12 +71,12 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
// 返回
|
||||
return patient.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPatientList(List<InspectPatientSaveReqVO> listcreateReqVO)
|
||||
{
|
||||
public boolean createPatientList(List<InspectPatientSaveReqVO> listcreateReqVO) {
|
||||
// 插入
|
||||
List<InspectPatientDO> patient = BeanUtils.toBean(listcreateReqVO, InspectPatientDO.class);
|
||||
return patientMapper.insertBatch(patient);
|
||||
return patientMapper.insertBatch(patient);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,25 +106,25 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
public InspectPatientDO getPatient(Integer id) {
|
||||
return patientMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InspectPatientDO getPatientInfo(String medicalSn)
|
||||
{
|
||||
public InspectPatientDO getPatientInfo(String medicalSn) {
|
||||
QueryWrapper<InspectPatientDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("medicalSn", medicalSn);
|
||||
InspectPatientDO patientDO= patientMapper.selectOne(queryWrapper);
|
||||
InspectPatientDO patientDO = patientMapper.selectOne(queryWrapper);
|
||||
|
||||
return patientDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updatePatientInfo(InspectPatientSaveReqVO updateReqVO)
|
||||
{
|
||||
public Integer updatePatientInfo(InspectPatientSaveReqVO updateReqVO) {
|
||||
LambdaUpdateWrapper<InspectPatientDO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(InspectPatientDO::getMedicalSn, updateReqVO.getMedicalSn())
|
||||
.set(InspectPatientDO::getHospitalNo, updateReqVO.getHospitalNo())
|
||||
.set(InspectPatientDO::getXcgcode, updateReqVO.getXcgcode())
|
||||
.set(InspectPatientDO::getNcgcode, updateReqVO.getNcgcode())
|
||||
.set(InspectPatientDO::getShqx, updateReqVO.getShqx());
|
||||
return patientMapper.update(null, updateWrapper);
|
||||
return patientMapper.update(null, updateWrapper);
|
||||
|
||||
}
|
||||
|
||||
@ -116,7 +150,7 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAudit(String medicalSn,Integer auditStatus, String inspectionOpinion) {
|
||||
public void updateAudit(String medicalSn, Integer auditStatus, String inspectionOpinion) {
|
||||
LambdaUpdateWrapper<InspectPatientDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(InspectPatientDO::getMedicalSn, medicalSn);
|
||||
lambdaUpdateWrapper.set(InspectPatientDO::getAuditStatus, auditStatus);
|
||||
@ -124,6 +158,440 @@ public class InspectPatientServiceImpl implements InspectPatientService {
|
||||
int updatedRows = patientMapper.update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
//患者体检报告单相关
|
||||
@Value("classpath:playwright-browsers")
|
||||
private org.springframework.core.io.Resource playwrightBrowsers;
|
||||
|
||||
private List<BufferedImage> createPDF_playwright(String htmlContent) {
|
||||
List<BufferedImage> _out = new ArrayList<>();
|
||||
try {
|
||||
Playwright playwright = null;
|
||||
Browser browser = null;
|
||||
Page page = null;
|
||||
Map<String, String> map = new HashMap();
|
||||
map.put("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "1");
|
||||
map.put("PLAYWRIGHT_BROWSERS_PATH", playwrightBrowsers.getFile().getPath());
|
||||
try {
|
||||
playwright = Playwright.create(new Playwright.CreateOptions().setEnv(map));
|
||||
browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(true)
|
||||
.setArgs(Arrays.asList("--start-maximized", "--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--js-flags=--max-old-space-size=3048", "--renderer-process-limit=6", "--shared-memory-size=3048"))
|
||||
.setFirefoxUserPrefs(new java.util.HashMap<String, Object>() {{
|
||||
put("javascript.options.mem.max", 3048);
|
||||
}}));
|
||||
|
||||
page = browser.newPage();
|
||||
page.setContent(htmlContent.trim());
|
||||
page.waitForLoadState(LoadState.NETWORKIDLE);
|
||||
|
||||
Page.PdfOptions pdfOptions = new Page.PdfOptions().setFormat("A4")
|
||||
.setMargin(new Margin()
|
||||
.setTop("0")
|
||||
.setRight("0")
|
||||
.setBottom("0")
|
||||
.setLeft("0"))
|
||||
.setPrintBackground(true);
|
||||
|
||||
byte[] _outByte = page.pdf(pdfOptions);
|
||||
if (_outByte != null && _outByte.length > 0) {
|
||||
PDDocument document = null;
|
||||
try {
|
||||
document = PDDocument.load(new ByteArrayInputStream(_outByte));
|
||||
PDFRenderer pdfRenderer = new PDFRenderer(document);
|
||||
BufferedImage image = null;
|
||||
for (int pageNO = 0; pageNO < document.getNumberOfPages(); pageNO++) {
|
||||
image = pdfRenderer.renderImageWithDPI(pageNO, 400);
|
||||
_out.add(image);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
_out = null;
|
||||
} finally {
|
||||
try {
|
||||
if (document != null) document.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
_out = null;
|
||||
} finally {
|
||||
try {
|
||||
if (page != null && !page.isClosed()) page.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (browser != null) browser.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (playwright != null) playwright.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
} catch (Exception exOut) {
|
||||
_out = null;
|
||||
} finally {
|
||||
System.gc();
|
||||
}
|
||||
if (!(_out != null && _out.size() > 0)) _out = null;
|
||||
return _out;
|
||||
}
|
||||
|
||||
private void replaceTextInRun(List<XWPFRun> runs, Set<String> keys, Map<String, Object> map) {
|
||||
if (runs != null && runs.size() > 0) {
|
||||
for (XWPFRun run : runs) {
|
||||
if (run != null) {
|
||||
String text = run.getText(0);
|
||||
if (text != null) {
|
||||
for (String key : keys) {
|
||||
Object replacement = map.get(key);
|
||||
key = "${{" + key + "}}";
|
||||
if (text.contains(key)) {
|
||||
String replacementStr = replacement.toString();
|
||||
text = text.replace(key, replacementStr);
|
||||
run.setText(text, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void replaceTextInDocument(XWPFDocument document, Map<String, Object> map) {
|
||||
if (document == null || map == null || map.size() <= 0)
|
||||
return;
|
||||
|
||||
Set<String> keys = map.keySet();
|
||||
|
||||
if (document.getParagraphs() != null)
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
replaceTextInRun(paragraph.getRuns(), keys, map);
|
||||
}
|
||||
|
||||
if (document.getTables() != null)
|
||||
for (XWPFTable table : document.getTables()) {
|
||||
if (table.getRows() != null)
|
||||
for (XWPFTableRow row : table.getRows()) {
|
||||
if (row.getTableCells() != null)
|
||||
for (XWPFTableCell cell : row.getTableCells()) {
|
||||
if (cell.getParagraphs() != null)
|
||||
for (XWPFParagraph paragraph : cell.getParagraphs()) {
|
||||
replaceTextInRun(paragraph.getRuns(), keys, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getHeaderList() != null)
|
||||
for (XWPFHeader xwpfHeader : document.getHeaderList()) {
|
||||
if (xwpfHeader.getParagraphs() != null)
|
||||
for (XWPFParagraph paragraph : xwpfHeader.getParagraphs()) {
|
||||
replaceTextInRun(paragraph.getRuns(), keys, map);
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getFooterList() != null)
|
||||
for (XWPFFooter xwpfFooter : document.getFooterList()) {
|
||||
if (xwpfFooter.getParagraphs() != null)
|
||||
for (XWPFParagraph paragraph : xwpfFooter.getParagraphs()) {
|
||||
replaceTextInRun(paragraph.getRuns(), keys, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String calculateAge(String birthdate) {
|
||||
String age = "";
|
||||
if (birthdate == null || birthdate.trim().isEmpty()) {
|
||||
return age;
|
||||
}
|
||||
|
||||
birthdate = birthdate.trim();
|
||||
LocalDateTime birth;
|
||||
LocalDateTime today = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
birth = LocalDateTime.parse(birthdate, formatter);
|
||||
} catch (Exception ex) {
|
||||
return age;
|
||||
}
|
||||
|
||||
int yearsDiff = today.getYear() - birth.getYear();
|
||||
boolean hasBirthdayPassed = false;//检查生日是否已过
|
||||
if (today.getMonthValue() > birth.getMonthValue()) {
|
||||
hasBirthdayPassed = true;
|
||||
} else if (today.getMonthValue() == birth.getMonthValue()) {
|
||||
if (today.getDayOfMonth() > birth.getDayOfMonth())
|
||||
hasBirthdayPassed = true;
|
||||
}
|
||||
if (!hasBirthdayPassed) {
|
||||
yearsDiff--;
|
||||
}
|
||||
if (yearsDiff <= 0)
|
||||
yearsDiff = 1;
|
||||
age = String.valueOf(yearsDiff);
|
||||
|
||||
return age;
|
||||
}
|
||||
|
||||
private String formatLocalDateTimeToString(LocalDateTime localDateTime, String pattern) {
|
||||
//pattern yyyy-MM-dd HH:mm:ss
|
||||
if (localDateTime == null || (pattern == null || pattern.trim().equals("")))
|
||||
return "";
|
||||
pattern = pattern.trim();
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return localDateTime.format(formatter);
|
||||
} catch (Exception ex) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String safeTrimString(Object objectValue) {
|
||||
String _out = "";
|
||||
if (objectValue != null)
|
||||
_out = objectValue.toString().trim();
|
||||
return _out.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> createPatientInspectDataReport(String medicalSn) {
|
||||
Map<String, Object> outRes = new HashMap<String, Object>() {{
|
||||
put("code", 200);
|
||||
put("msg", "");
|
||||
}};
|
||||
XWPFDocument document = null;
|
||||
FileInputStream fis = null;
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
//参数校验
|
||||
if (medicalSn == null || medicalSn.trim().equals("")) {
|
||||
throw new Exception("体检编号不能为空!");
|
||||
} else
|
||||
medicalSn = medicalSn.trim();
|
||||
|
||||
//主要参数
|
||||
InspectPatientDO patientInfo = getPatientInfo(medicalSn);
|
||||
List<InspectPatientitemsDO> patientItemList_all = patientitemsService.GetPatientItemList(medicalSn);
|
||||
List<InspectPatientitemsDO> patientItemList = patientItemList_all;
|
||||
if (patientItemList != null && patientItemList.size() > 0) {
|
||||
patientItemList = patientItemList.stream()
|
||||
.filter(item -> item.getGroupname() != null && item.getGroupname().trim().equals("一般检查"))
|
||||
.sorted(Comparator.comparing(InspectPatientitemsDO::getItemName))
|
||||
.collect(Collectors.toList());
|
||||
if (!(patientItemList != null && patientItemList.size() > 0))
|
||||
patientItemList = null;
|
||||
}
|
||||
List<Map<String, Object>> pacsDataImages = new ArrayList<>();
|
||||
List<InspectPacsDataDO> pacsDataImages_base = pacsDataService.GetpacsData(medicalSn);
|
||||
List<Map<String, Object>> pacsDataImages_config = new ArrayList<>(Arrays.asList(
|
||||
new HashMap<String, Object>() {{
|
||||
put("type", "us");
|
||||
put("title", "超声检查");
|
||||
}},
|
||||
new HashMap<String, Object>() {{
|
||||
put("type", "ecg");
|
||||
put("title", "心电图");
|
||||
}},
|
||||
new HashMap<String, Object>() {{
|
||||
put("type", "cbc");
|
||||
put("title", "血常规");
|
||||
}},
|
||||
new HashMap<String, Object>() {{
|
||||
put("type", "rt");
|
||||
put("title", "尿常规");
|
||||
}},
|
||||
new HashMap<String, Object>() {{
|
||||
put("type", "bt");
|
||||
put("title", "生化检查");
|
||||
}}
|
||||
));
|
||||
if (pacsDataImages_base != null && pacsDataImages_base.size() > 0) {
|
||||
List<Map<String, Object>> pacsDataImages_part = null;
|
||||
List<InspectPacsDataDO> temp = null;
|
||||
for (Map<String, Object> config : pacsDataImages_config) {
|
||||
pacsDataImages_part = new ArrayList<>();
|
||||
temp = pacsDataImages_base.stream()
|
||||
.filter(item -> item.getType() != null && item.getType().trim().toLowerCase().equals(config.get("type").toString().trim()))
|
||||
.sorted(Comparator.comparing(InspectPacsDataDO::getData))
|
||||
.collect(Collectors.toList());
|
||||
if (!(temp != null && temp.size() > 0))
|
||||
temp = null;
|
||||
else {
|
||||
for (InspectPacsDataDO temp_item : temp) {
|
||||
pacsDataImages_part.add(new HashMap<String, Object>() {{
|
||||
put("content", temp_item);
|
||||
put("type", config.get("type").toString().trim());
|
||||
put("title", config.get("title").toString().trim());
|
||||
}});
|
||||
}
|
||||
if (pacsDataImages_part != null && pacsDataImages_part.size() > 0) {
|
||||
Map<String, Object> summaryData = new HashMap<String, Object>() {{
|
||||
put("patientItem", null);
|
||||
}};
|
||||
InspectPatientitemsDO patientItem = patientItemList_all.stream()
|
||||
.filter(item -> item.getGroupname() != null && item.getGroupname().toLowerCase().trim().equals(config.get("type").toString().trim()))
|
||||
.sorted(Comparator.comparing(InspectPatientitemsDO::getItemName))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
pacsDataImages_part.get(0).put("startNode", true);
|
||||
pacsDataImages_part.get(pacsDataImages_part.size() - 1).put("endNode", true);
|
||||
pacsDataImages_part.get(pacsDataImages_part.size() - 1).put("summaryData", summaryData);
|
||||
if (patientItem != null) {
|
||||
summaryData.put("patientItem", patientItem);
|
||||
}
|
||||
pacsDataImages.addAll(pacsDataImages_part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(pacsDataImages != null && pacsDataImages.size() > 0))
|
||||
pacsDataImages = null;
|
||||
|
||||
//其它参数
|
||||
ConfigDO configInfo_bgmb = configService.getConfigByKey("url.bgmb");
|
||||
ConfigDO configInfo_bgcf = configService.getConfigByKey("url.bgcf");
|
||||
String ageStr = "";
|
||||
String pnameStr = "";
|
||||
if (patientInfo != null) {
|
||||
ageStr = calculateAge(formatLocalDateTimeToString(patientInfo.getBirthday(), "yyyy-MM-dd HH:mm:ss"));
|
||||
pnameStr = safeTrimString(patientInfo.getPName());
|
||||
}
|
||||
|
||||
//word主体
|
||||
fis = new FileInputStream(configInfo_bgmb.getValue() + "\\main.docx");
|
||||
document = new XWPFDocument(fis);
|
||||
XWPFParagraph paragraph = null;
|
||||
XWPFRun run = null;
|
||||
|
||||
//word预加载
|
||||
if (document == null) {
|
||||
throw new Exception("模板加载失败!");
|
||||
}
|
||||
if (patientInfo == null) {
|
||||
throw new Exception("患者基本数据加载为空!");
|
||||
}
|
||||
Map<String, Object> rootPage = new HashMap<>();
|
||||
{
|
||||
rootPage.put("ageStr", ageStr);
|
||||
rootPage.put("employer", "");
|
||||
rootPage.put("pName", "");
|
||||
rootPage.put("gender", "");
|
||||
rootPage.put("phoneNum", "");
|
||||
rootPage.put("medicalDateTime", "");
|
||||
rootPage.put("medicalSn", "");
|
||||
if (patientInfo != null) {
|
||||
//rootPage.put("ageStr", ageStr);
|
||||
//rootPage.put("employer", "");
|
||||
rootPage.put("pName", safeTrimString(patientInfo.getPName()));
|
||||
rootPage.put("gender", safeTrimString(patientInfo.getGender()));
|
||||
rootPage.put("phoneNum", safeTrimString(patientInfo.getPhoneNum()));
|
||||
rootPage.put("medicalDateTime", formatLocalDateTimeToString(patientInfo.getMedicalDateTime(), "yyyy-MM-dd"));
|
||||
rootPage.put("medicalSn", safeTrimString(patientInfo.getMedicalSn()));
|
||||
}
|
||||
}
|
||||
replaceTextInDocument(document, rootPage);
|
||||
|
||||
//centerBody
|
||||
List<BufferedImage> centerBody = null;
|
||||
try {
|
||||
Configuration cfg = new Configuration(Configuration.VERSION_2_3_32);
|
||||
cfg.setDirectoryForTemplateLoading(new File(configInfo_bgmb.getValue()));
|
||||
cfg.setDefaultEncoding("UTF-8");
|
||||
Template temp = cfg.getTemplate("index.ftl");
|
||||
Writer outHtml = new StringWriter();
|
||||
|
||||
Map<String, Object> root = new HashMap<>();
|
||||
root.put("patientInfo", patientInfo);
|
||||
root.put("patientInfo_ageStr", ageStr);
|
||||
root.put("patientInfo_pnameStr", pnameStr);
|
||||
root.put("patientInfo_birthdayStr", "");
|
||||
if (patientInfo != null) {
|
||||
root.put("patientInfo_birthdayStr", formatLocalDateTimeToString(patientInfo.getBirthday(), "yyyy-MM"));
|
||||
}
|
||||
root.put("patientItemList", patientItemList);
|
||||
root.put("pacsDataImages", pacsDataImages);
|
||||
temp.process(root, outHtml);
|
||||
|
||||
if (outHtml != null && outHtml.toString() != null && !outHtml.toString().trim().equals(""))
|
||||
centerBody = createPDF_playwright(outHtml.toString());
|
||||
} catch (Exception ex) {
|
||||
centerBody = null;
|
||||
throw ex;
|
||||
}
|
||||
if (centerBody != null) {
|
||||
int paragraphIndex = -1;
|
||||
ByteArrayOutputStream baos = null;
|
||||
for (BufferedImage image : centerBody) {
|
||||
paragraphIndex++;
|
||||
if (true || paragraphIndex >= 1) {
|
||||
XWPFParagraph pageBreakParagraph = document.createParagraph();
|
||||
XWPFRun pageBreakRun = pageBreakParagraph.createRun();
|
||||
pageBreakRun.addBreak(BreakType.PAGE);
|
||||
}
|
||||
|
||||
paragraph = document.createParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
run = paragraph.createRun();
|
||||
|
||||
baos = new ByteArrayOutputStream();
|
||||
ImageIO.write(image, "png", baos);
|
||||
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
int MAX_WIDTH_PIXELS = (int) ((210.0 - 28.18) * 36000);
|
||||
if (true) {
|
||||
double ratio = (double) MAX_WIDTH_PIXELS / width;
|
||||
width = MAX_WIDTH_PIXELS;
|
||||
height = (int) (height * ratio);
|
||||
}
|
||||
//据推测dpi默认96
|
||||
//Units.pixelToEMU(width) return pixels * 9525;
|
||||
run.addPicture(
|
||||
new ByteArrayInputStream(baos.toByteArray()),
|
||||
XWPFDocument.PICTURE_TYPE_PNG,
|
||||
"image.png",
|
||||
width,
|
||||
height
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("模板内容数据为空!");
|
||||
}
|
||||
|
||||
//保存word
|
||||
String fosPath_file = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".docx";
|
||||
String fosPath = configInfo_bgcf.getValue() + "\\" + fosPath_file;
|
||||
outRes.put("msg", "https://pacs.gw12320.com/video/" + fosPath_file);
|
||||
fos = new FileOutputStream(fosPath);
|
||||
document.write(fos);
|
||||
File file = new File(fosPath);
|
||||
file.setReadOnly();
|
||||
} catch (Exception ex) {
|
||||
outRes.put("code", -200);
|
||||
outRes.put("msg", "");
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null)
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (document != null)
|
||||
document.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
if (fis != null)
|
||||
fis.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return outRes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPatientInspectDataReport(String medicalSn) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -38,87 +38,87 @@
|
||||
</dependency>
|
||||
|
||||
<!-- 会员中心。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-member-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-member-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 数据报表。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-report-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-report-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 工作流。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-bpm-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-bpm-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- 支付服务。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-pay-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-pay-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 微信公众号模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-mp-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-mp-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 商城相关模块。默认注释,保证编译速度-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-promotion-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-product-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-trade-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-statistics-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-promotion-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-product-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-trade-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-statistics-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- CRM 相关模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-crm-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-crm-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- ERP 相关模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-erp-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-erp-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- AI 大模型相关模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-ai-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-ai-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- IoT 物联网相关模块。默认注释,保证编译速度 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-iot-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||
<!-- <artifactId>yudao-module-iot-biz</artifactId>-->
|
||||
<!-- <version>${revision}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- spring boot 配置所需依赖 -->
|
||||
<dependency>
|
||||
@ -153,6 +153,14 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
@ -219,8 +219,10 @@ yudao:
|
||||
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
|
||||
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
|
||||
security:
|
||||
permit-all_urls:
|
||||
permit-all-urls:
|
||||
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,不需要登录
|
||||
- /files/** # files静态资源
|
||||
- /admin-api/inspect/patient/getPdfconvertToImg # pdf数据转图片数据
|
||||
websocket:
|
||||
enable: true # websocket的开关
|
||||
path: /infra/ws # 路径
|
||||
@ -259,6 +261,8 @@ yudao:
|
||||
- /admin-api/pay/notify/** # 支付回调通知,不携带租户编号
|
||||
- /jmreport/* # 积木报表,无法携带租户编号
|
||||
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
|
||||
- /files/** # files静态资源
|
||||
- /admin-api/inspect/patient/getPdfconvertToImg # pdf数据转图片数据
|
||||
ignore-tables:
|
||||
- system_tenant
|
||||
- system_tenant_package
|
||||
|
Loading…
Reference in New Issue
Block a user