修复出院浏览医生护士提交时部分病历出现提交失败的问题

病案室查看缺陷列表不需要默认按科室查询
 4/28 wzq
master
wzqgit 4 years ago
parent cc09a5b7df
commit 942cd1ddd9

@ -48,41 +48,41 @@ public class FontController {
@Autowired
private Zd_AssortService assortService;
/***************************提供第三方按多个分段id和记账号查询病历pdf***********************************/
/***************************提供第三方按多个分段id和记账号查询病历pdf***********************************/
/**
* idpdf
* idpdf
* */
@RequestMapping("showRecordByPatientId")
public String showRecordByPatientId( HttpServletResponse response, String assortIds, String patientId, String visitId, Model model){
response.setCharacterEncoding("utf-8");
System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式
if(StringUtils.isBlank(assortIds)){
return retrunErrorPage(model,"病案分类Id不能为空!");
return retrunErrorPage(model,"病案分类Id不能为空!");
}
if(StringUtils.isBlank(patientId)){
return retrunErrorPage(model,"记账号不能为空!");
return retrunErrorPage(model,"记账号不能为空!");
}
if(StringUtils.isBlank(visitId)){
return retrunErrorPage(model,"住院次数不能为空!");
return retrunErrorPage(model,"住院次数不能为空!");
}
List<Archive_Master> list = new ArrayList<>();
//判断工号是否存在
//判断工号是否存在
try {
/* String checkUserName = checkUserName(userName);
if(StringUtils.isNotBlank(checkUserName)){
return retrunErrorPage(model,checkUserName);
}*/
//判断分类id是否存在,协商assortIds = "00000000"为查询全部
//判断分类id是否存在,协商assortIds = "00000000"为查询全部
if(!allAddortIds.equals(assortIds)) {
String checkAssortIds = checkAssortIds(assortIds);
if (StringUtils.isNotBlank(checkAssortIds)) {
return retrunErrorPage(model, checkAssortIds);
}
}
//判断记账号是否存在
//判断记账号是否存在
list = archiveMasterService.selectByObject(patientId,visitId);
if(null == list || list.isEmpty()){
return retrunErrorPage(model,"病历不存在!");
return retrunErrorPage(model,"病历不存在!");
}
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
@ -95,7 +95,7 @@ public class FontController {
}
/**
*
*
* */
private String retrunErrorPage(Model model, String errorMsg){
System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式
@ -104,7 +104,7 @@ public class FontController {
}
/**
* id
* id
* */
private String checkAssortIds(String assortIds){
System.out.println(System.getProperty("file.encoding"));//当前文件的编码方式
@ -120,7 +120,7 @@ public class FontController {
if(null != assortList && !assortList.isEmpty()){
String[] split = assortIds.split(",");
for (String s : split) {
//定义分类存在
//定义分类存在
boolean exist = false;
if (StringUtils.isNotBlank(s)) {
for (Zd_Assort assort1 : assortList) {
@ -131,17 +131,17 @@ public class FontController {
}
}
if (!exist) {
return "病案分类Id有误!";
return "病案分类Id有误!";
}
}
}else{
return "病案分类Id有误!";
return "病案分类Id有误!";
}
return null;
}
/**
*
*
* @param masterId
* @return
*/
@ -150,7 +150,7 @@ public class FontController {
public String getPdfToPdf(String masterId){
try {
Archive_Master archiveMaster = archiveMasterService.selectById(masterId);
//转换科室数据字典
//转换科室数据字典
if(StringUtils.isNotBlank(archiveMaster.getDeptName())){
Emr_Dictionary dictionary = new Emr_Dictionary();
dictionary.setCode(archiveMaster.getDeptName());
@ -159,7 +159,7 @@ public class FontController {
if(null != dictionaries && !dictionaries.isEmpty()){
archiveMaster.setDeptName(dictionaries.get(0).getName());
}
//判断出院日期
//判断出院日期
String dischargeDateTime = archiveMaster.getDischargeDateTime();
if(StringUtils.isNotBlank(dischargeDateTime)){
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
@ -178,7 +178,7 @@ public class FontController {
}
/**
* showRecordIframe
* showRecordIframe
* */
/*@RequestMapping("showRecordIframe")
public String showRecordIframe(){
@ -186,7 +186,7 @@ public class FontController {
}*/
/**
* masterid
* masterid
* @return
* @throws Exception
*/
@ -198,19 +198,19 @@ public class FontController {
List<AssortTypeTree> treeList = new ArrayList<>();
if(StringUtils.isNotBlank(patientId) && StringUtils.isNotBlank(assortIds)){
List<Archive_Detail> list = new ArrayList<>();
//assortIds等于协商的全查的分类id全查
//assortIds等于协商的全查的分类id全查
try {
if(allAddortIds.equals(assortIds)){
list = archiveDetailService.selectTypeTreeByPatientIdAndAssortIds(patientId, null);
}else{
//否则按条件查
//分类id分别以单引号隔开
//否则按条件查
//分类id分别以单引号隔开
StringBuilder assortIdStr = new StringBuilder();
String[] split = assortIds.split(",");
for (String s : split) {
assortIdStr.append("'").append(s).append("',");
}
//去掉最后一个逗号
//去掉最后一个逗号
assortIdStr = new StringBuilder(assortIdStr.substring(0, assortIdStr.length() - 1));
list = archiveDetailService.selectTypeTreeByPatientIdAndAssortIds(patientId, assortIdStr.toString());
}
@ -220,18 +220,18 @@ public class FontController {
}
if(null != list && !list.isEmpty()){
Set<String> assortList = new LinkedHashSet<>();
//抽取首次病程记录
String strTemp = "首次病程";
//抽取首次病程记录
String strTemp = "首次病程";
String assortId = "11";
//定义护理记录里的首次护理记录排前头
String nurseTemp = "首次护理";
//定义护理记录里的首次护理记录排前头
String nurseTemp = "首次护理";
String nurseAssortId = "7";
Archive_Detail detailTemp = new Archive_Detail();
Archive_Detail nurseDetailVoTemp = new Archive_Detail();
//分类去重
//分类去重
for(Archive_Detail detail : list){
assortList.add(detail.getSubassort());
//获取title
//获取title
String title = detail.getTitle();
if(StringUtils.isNotBlank(title) && detail.getTitle().contains(strTemp)){
detailTemp = detail;
@ -240,41 +240,41 @@ public class FontController {
nurseDetailVoTemp = detail;
}
}
//组织树
//组织树
int id = 1;
//定义第一层的id为第二层父id
//定义第一层的id为第二层父id
int oneParentId = 0;
//定义第二层的id为第三层父id
//定义第二层的id为第三层父id
int twoParentId = 0;
AssortTypeTree tree = new AssortTypeTree();
//第一层,根目录全部影像资料
//第一层,根目录全部影像资料
tree.setId(id);
tree.setParentId(0);
tree.setName("全部影像资料");
tree.setName("全部影像资料");
tree.setChecked("true");
treeList.add(tree);
oneParentId = id;
id++;
for(String assortName : assortList){
AssortTypeTree tree1 = new AssortTypeTree();
//第二层,分类名称
//第二层,分类名称
tree1.setId(id);
tree1.setParentId(oneParentId);
twoParentId = id;
id++;
//定义该类的数量
//定义该类的数量
int count = 0;
//定义是否添加了首次病程
//定义是否添加了首次病程
boolean flag = false;
boolean nurseflag = false;
for(Archive_Detail detail : list){
if(StringUtils.isNoneBlank(detail.getSubassort()) && assortName.equals(detail.getSubassort())){
String assortid = detail.getAssortid();
if(StringUtils.isNotBlank(assortid) && assortid.equals(assortId)){
//是病程记录
//是病程记录
if(!flag && StringUtils.isNotBlank(detailTemp.getTitle())){
AssortTypeTree tree2 = new AssortTypeTree();
//第三层,资料名称
//第三层,资料名称
count++;
tree2.setId(id);
tree2.setParentId(twoParentId);
@ -287,10 +287,10 @@ public class FontController {
}
}
if(StringUtils.isNotBlank(assortid) && assortid.equals(nurseAssortId)){
//是护理记录
//是护理记录
if(!nurseflag && StringUtils.isNotBlank(nurseDetailVoTemp.getTitle())){
AssortTypeTree tree2 = new AssortTypeTree();
//第三层,资料名称
//第三层,资料名称
count++;
tree2.setId(id);
tree2.setParentId(twoParentId);
@ -304,7 +304,7 @@ public class FontController {
}
if(!detail.equals(detailTemp) && !detail.equals(nurseDetailVoTemp)) {
AssortTypeTree tree2 = new AssortTypeTree();
//第三层,资料名称
//第三层,资料名称
count++;
tree2.setId(id);
tree2.setParentId(twoParentId);
@ -326,7 +326,7 @@ public class FontController {
}
/**
* idPDFpdf
* idPDFpdf
* @param response
* @param detailIds
* @return
@ -342,13 +342,13 @@ public class FontController {
detail.setTitle(detailIds);
archiveDetailService.selectByIdStrFont(response,session,detail);
}else{
//存至session
//存至session
session.setAttribute("showRecord",null);
}
return Msg.success();
} catch (Exception e) {
ExceptionPrintUtil.printException(e);
return Msg.fail("查看出错了,请联系系统管理员");
return Msg.fail("查看出错了,请联系系统管理员");
//e.printStackTrace();
}
}

@ -376,15 +376,15 @@ public class beHospitaledController {
if(bol==1) {
archiveMaster.setIsscaned(archiveMasterVo.getIsscaned());
bol = archiveMasterService.updateByClo(archiveMaster);
if(archiveMaster.getCmtDoctor()==1) {
/*if(archiveMaster.getCmtDoctor()==1) {
result = "归档医生提交";
}else if(archiveMaster.getCmtNurse()==1){
result = "归档护士提交";
}
}*/
if(bol==1){
result+="成功!";
result="成功";
}else{
result+= "失败!";
result= "失败";
}
}

@ -6,9 +6,8 @@
*/
package com.emr.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
@ -17,7 +16,17 @@ import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfImportedPage;
import com.itextpdf.text.pdf.PdfReader;
import org.apache.commons.io.FileUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPageTree;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.springframework.beans.factory.annotation.Value;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
public class PDFUtils {
@ -179,6 +188,179 @@ public class PDFUtils {
}
/**
* base64PDF
* @param base64String
* @param httpServletResponse
*/
public static void base64StringToPDFToPage(String base64String, HttpServletResponse httpServletResponse){
BASE64Decoder decoder = new BASE64Decoder();
ByteArrayOutputStream baos = null;
ServletOutputStream sos = null;
try {
byte[] bytes = decoder.decodeBuffer(base64String);
baos = new ByteArrayOutputStream();
baos.write(bytes); //把byte写进输出流里
if (baos != null) {
httpServletResponse.setContentType("application/pdf");
httpServletResponse.setContentLength(baos.size());
httpServletResponse.setHeader("Expires", "0");
httpServletResponse.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
httpServletResponse.setHeader("Pragma", "public");
// 设置打印PDF的文件名
String fileName = "社保证明文件.pdf";
fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
httpServletResponse.setHeader("Content-Disposition", "filename=" + fileName);
sos = httpServletResponse.getOutputStream();
baos.writeTo(sos); //byte输出流写入servlet输出流
sos.flush();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
sos.close();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* base64PDF
* @param base64String
* 1.使BASE64Decoder
* 2.使ByteArrayInputStream
* 3.BufferedInputStream
* 4.使BufferedOutputStreamFileOutputSteam
*/
public static void base64StringToPDF(String base64String, String pdfPath/*File file*/){
File file = new File(pdfPath);// 将原来参数修改为字符串
BASE64Decoder decoder = new BASE64Decoder();
BufferedInputStream bin = null;
FileOutputStream fout = null;
BufferedOutputStream bout = null;
try {
//将base64编码的字符串解码成字节数组
byte[] bytes = decoder.decodeBuffer(base64String);
//创建一个将bytes作为其缓冲区的ByteArrayInputStream对象
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
//创建从底层输入流中读取数据的缓冲输入流对象
bin = new BufferedInputStream(bais);
//创建到指定文件的输出流
fout = new FileOutputStream(file);
//为文件输出流对接缓冲输出流对象
bout = new BufferedOutputStream(fout);
byte[] buffers = new byte[1024];
int len = bin.read(buffers);
while(len != -1){
bout.write(buffers, 0, len);
len = bin.read(buffers);
}
//刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题
bout.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
bout.close();
fout.close();
bin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* PDFBase64
* @param file
* @return
*/
public static String pdfToBase64(File file) {
BASE64Encoder encoder = new BASE64Encoder();
FileInputStream fin =null;
BufferedInputStream bin =null;
ByteArrayOutputStream baos = null;
BufferedOutputStream bout =null;
try {
fin = new FileInputStream(file);
bin = new BufferedInputStream(fin);
baos = new ByteArrayOutputStream();
bout = new BufferedOutputStream(baos);
byte[] buffer = new byte[1024];
int len = bin.read(buffer);
while(len != -1){
bout.write(buffer, 0, len);
len = bin.read(buffer);
}
//刷新此输出流并强制写出所有缓冲的输出字节
bout.flush();
byte[] bytes = baos.toByteArray();
return encoder.encodeBuffer(bytes).trim();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fin.close();
bin.close();
baos.close();
bout.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
/**
* pdfjpg
* @param pdfPath
* @param jpgPath
*/
public static void pdfToJpg(String pdfPath,String jpgPath){
long start = System.currentTimeMillis();
//pdf路径
InputStream stream = null;
try {
stream = new FileInputStream(new File(pdfPath));//URLUtil.getStream(url);
// 加载解析PDF文件
PDDocument doc = PDDocument.load(stream);
PDFRenderer pdfRenderer = new PDFRenderer(doc);
PDPageTree pages = doc.getPages();
int pageCount = pages.getCount();
for (int i = 0; i < pageCount; i++) {
BufferedImage bim = pdfRenderer.renderImageWithDPI(i, 200);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(bim, "jpg", os);
byte[] datas = os.toByteArray();
FileUtils.writeByteArrayToFile(new File(jpgPath),datas);
}
long end = System.currentTimeMillis();
long time = (end - start) / 1000;
System.out.println("pdf转jpg耗时 {}s"+time);
}catch (Exception e){
}
}
/**
* base64jpg
* @param val
* @param pdfFile
* @param jpgFile
*/
public static void base64ToJPG(String val,String pdfFile,String jpgFile){
base64StringToPDF(val,pdfFile);
pdfToJpg(pdfFile,jpgFile);
}
}

@ -238,7 +238,7 @@
this.pageSize = currPageSize;
}
var url = window.location.href;
/*var url = window.location.href;
var deptName = url.substring(url.lastIndexOf('&') + 1).replace("depts=", "");
var len = ($("#deptName").val()).length;
@ -247,6 +247,13 @@
if (deptNameT.indexOf("") == -1) {
deptName = $("#deptName").val().toString();
}
}*/
var deptName = $("#deptName").val();
if (deptName.indexOf("") != -1) {
deptName = "";
} else {
deptName = $("#deptName").val().toString();
}
var temp = {
@ -259,7 +266,7 @@
visitId:""+$("#visitId").val(),
name:""+$("#name").val(),
archivestate:"" + $("#archivestate").val(),
deptName: deptName.toString()
deptName: deptName
};
return temp;

@ -2961,7 +2961,7 @@
field: 'inpNo',
align: 'left',
valign: 'middle',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
//console.log(row);
var redFlag = row.numb;
var a = "";
@ -2972,14 +2972,14 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
},
{
title: '住院次数',
field: 'visitId',
align: 'center',
valign: 'middle',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (redFlag == 0) {
@ -2989,14 +2989,14 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
},
{
title: '姓名',
field: 'name',
align: 'left',
valign: 'middle',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (redFlag == 0) {
@ -3010,14 +3010,14 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
},
{
title: '性别',
field: 'sex',
align: 'center',
valign: 'middle',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (value == null || value == "null") {
@ -3030,7 +3030,7 @@
a = '<span style="color:red;">' + a + '</span>';
}
return a;
}
}*/
},
// {
// title: '身份证号',
@ -3044,7 +3044,7 @@
field: 'deptName',
align: 'left',
valign: 'middle',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (redFlag == 0) {
@ -3054,13 +3054,13 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
},
{
title: '出院日期',
field: 'dischargeDateTime',
align: 'center',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (value != null && value != "") {
@ -3073,7 +3073,7 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
},
{
title: '主管医生',
@ -3111,7 +3111,7 @@
title: '医生',
field: 'doctorName',
align: 'left',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
//调接口 参数:工号 返回:名字
var redFlag = row.numb;
var a = "";
@ -3125,14 +3125,14 @@
a = '<span style="color:red;">' + a + '</span>';
}
return a;
}
}*/
},
{
title: '医生提交日期',
field: 'cmtDoctorDate',
align: 'center',
visible: false,
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (value != null && value != "") {
@ -3147,7 +3147,7 @@
a = '<span style="color:red;">' + a + '</span>';
}
return a;
}
}*/
},
{
title: '护士是否提交',
@ -3179,7 +3179,7 @@
title: '护士',
field: 'nurseName',
align: 'left',
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (value == null || value == "null") {
@ -3192,14 +3192,14 @@
a = '<span style="color:red;">' + a + '</span>';
}
return a;
}
}*/
},
{
title: '护士提交日期',
field: 'cmtNurseDate',
align: 'center',
visible: false,
formatter: function (value, row, index) {
/*formatter: function (value, row, index) {
var redFlag = row.numb;
var a = "";
if (value != null && value != "") {
@ -3216,7 +3216,7 @@
a = '<span style="color:red;">' + value + '</span>';
}
return a;
}
}*/
}, {
title: '是否死亡',
field: 'deathFlag',
@ -3285,7 +3285,7 @@
}
} else {
//有缺陷显示红色
a = '<span style="color:red;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>' + value + '</span>';
a = '<span style="color:#8FBC8F;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>' + value + '</span>';
}
return a;
}
@ -3315,7 +3315,7 @@
if (redFlag == 0) {
a = '<span style="color:'+colorVal+'"><i class="glyphicon glyphicon-ok-circle" aria-hidden="true"></i>'+showVal+'</span>';
}else{
a = '<span style="color:red"><i class="glyphicon glyphicon-ok-circle" aria-hidden="true"></i>'+showVal+'</span>';
a = '<span style="color:'+colorVal+'"><i class="glyphicon glyphicon-ok-circle" aria-hidden="true"></i>'+showVal+'</span>';
}
return a;
}

Loading…
Cancel
Save