在处方打印处增加患者信息

This commit is contained in:
叶锦涛
2025-11-05 16:07:37 +08:00
parent 7bbc50ef47
commit 3deac74898
2 changed files with 96 additions and 45 deletions

View File

@@ -165,7 +165,8 @@
"widthHeightSync": false,
"qrCodeLevel": 0,
"fontSize": 9,
"field": "genderEnum_enumText"
"field": "gender",
"formatter": "function(title,value,options,templateData,target,paperNo){ return templateData.gender || templateData.sex || templateData.genderCode_dictText || '-' }"
},
"printElementType": {
"title": "文本",
@@ -219,7 +220,8 @@
"widthHeightSync": false,
"qrCodeLevel": 0,
"fontSize": 9,
"field": "encounterNo"
"field": "visitNo",
"formatter": "function(title,value,options,templateData,target,paperNo){ return templateData.visitNo || templateData.patientNo || templateData.outpatientNo || templateData.encounterNo || '-' }"
},
"printElementType": {
"title": "文本",
@@ -255,7 +257,8 @@
"widthHeightSync": false,
"qrCodeLevel": 0,
"fontSize": 9,
"field": "conditionName"
"field": "diagnosis",
"formatter": "function(title,value,options,templateData,target,paperNo){ return templateData.diagnosis || templateData.diagnosisName || templateData.diagnose || templateData.conditionName || '-' }"
},
"printElementType": {
"title": "文本",
@@ -273,7 +276,8 @@
"widthHeightSync": false,
"qrCodeLevel": 0,
"fontSize": 9,
"field": "phone"
"field": "mobile",
"formatter": "function(title,value,options,templateData,target,paperNo){ return templateData.mobile || templateData.patientPhone || templateData.phone || templateData.contactPhone || '-' }"
},
"printElementType": {
"title": "文本",
@@ -291,7 +295,8 @@
"widthHeightSync": false,
"qrCodeLevel": 0,
"fontSize": 9,
"field": "reqTime"
"field": "createTime",
"formatter": "function(title,value,options,templateData,target,paperNo){ return templateData.createTime || templateData.createDate || templateData.orderDate || templateData.confirmTime || templateData.reqTime || '-' }"
},
"printElementType": {
"title": "文本",

View File

@@ -844,14 +844,30 @@ async function previewAndPrint() {
printContainer.style.top = '-9999px';
printContainer.style.width = '800px';
// 添加打印样式,确保只打印药品信息
// 添加打印样式,包含患者信息和药品信息
const style = document.createElement('style');
style.textContent = `
/* 确保打印样式应用于药品信息 */
/* 确保打印样式应用于患者信息和药品信息 */
.print-content {
font-family: Arial, sans-serif;
font-size: 12px;
}
/* 患者信息表格样式 */
.patient-info-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 15px;
}
.patient-info-table td {
padding: 4px 8px;
border: 1px solid #ddd;
font-size: 12px;
}
.patient-info-table .label {
font-weight: bold;
background-color: #f9f9f9;
}
/* 药品表格样式 */
.medicine-table {
width: 100%;
border-collapse: collapse;
@@ -885,70 +901,100 @@ async function previewAndPrint() {
// 设置容器ID以便CSS选择
printContainer.id = 'print-container';
// 构建药品信息表格
let medicineHtml = '<div class="print-content">';
// 构建包含患者信息和药品信息的打印内容
let printHtml = '<div class="print-content">';
result.forEach((prescription, index) => {
if (!prescription) return;
const prescriptionList = Array.isArray(prescription.prescriptionList) ? prescription.prescriptionList : [];
// 只保留必要的药品信息
medicineHtml += '<div class="prescription-medicines">';
medicineHtml += '<h4>处方 ' + (index + 1) + '</h4>';
printHtml += '<div class="prescription-medicines">';
printHtml += '<h4>处方 ' + (index + 1) + '</h4>';
// 添加患者信息表格
printHtml += '<table class="patient-info-table">';
printHtml += '<tr>';
printHtml += '<td class="label">姓名:</td>';
printHtml += '<td>' + (prescription.patientName || '-') + '</td>';
printHtml += '<td class="label">性别:</td>';
printHtml += '<td>' + (prescription.genderEnum_enumText || prescription.gender || '-') + '</td>';
printHtml += '<td class="label">年龄:</td>';
printHtml += '<td>' + (prescription.age || '-') + '</td>';
printHtml += '<td class="label">处方号:</td>';
printHtml += '<td>' + (prescription.prescriptionNo || '-') + '</td>';
printHtml += '</tr>';
printHtml += '<tr>';
printHtml += '<td class="label">门诊号:</td>';
printHtml += '<td>' + (prescription.encounterNo || '-') + '</td>';
printHtml += '<td class="label">开具日期:</td>';
printHtml += '<td>' + (prescription.reqTime || prescription.adviceDate || prescription.createTime || '-') + '</td>';
printHtml += '<td class="label">医生:</td>';
printHtml += '<td>' + (prescription.doctorName || '-') + '</td>';
printHtml += '<td class="label">科室:</td>';
printHtml += '<td>' + (prescription.departmentName || '-') + '</td>';
printHtml += '</tr>';
printHtml += '<tr>';
printHtml += '<td class="label">临床诊断:</td>';
printHtml += '<td colspan="3">' + (prescription.conditionName || '-') + '</td>';
printHtml += '<td class="label">电话:</td>';
printHtml += '<td colspan="3">' + (prescription.phone || prescription.mobile || prescription.patientPhone || '-') + '</td>';
printHtml += '</tr>';
printHtml += '</table>';
// 添加药品信息表格
if (prescriptionList.length > 0) {
medicineHtml += '<table class="medicine-table">';
medicineHtml += '<thead>';
medicineHtml += '<tr>';
medicineHtml += '<th>药品名称</th>';
medicineHtml += '<th>规格</th>';
medicineHtml += '<th>单价</th>';
medicineHtml += '<th>数量</th>';
medicineHtml += '<th>金额</th>';
medicineHtml += '<th>用法用量</th>';
medicineHtml += '</tr>';
medicineHtml += '</thead>';
medicineHtml += '<tbody>';
printHtml += '<table class="medicine-table">';
printHtml += '<thead>';
printHtml += '<tr>';
printHtml += '<th>药品名称</th>';
printHtml += '<th>规格</th>';
printHtml += '<th>单价</th>';
printHtml += '<th>数量</th>';
printHtml += '<th>金额</th>';
printHtml += '<th>用法用量</th>';
printHtml += '</tr>';
printHtml += '</thead>';
printHtml += '<tbody>';
prescriptionList.forEach((item) => {
medicineHtml += '<tr>';
medicineHtml += '<td>' + (item.medicineName || item.itemName || 'N/A') + '</td>';
medicineHtml += '<td>' + (item.totalVolume || item.spec || '') + '</td>';
medicineHtml += '<td>' + (item.unitPrice || item.price || '0.00') + '</td>';
medicineHtml += '<td>' + (item.quantity || 'N/A') + ' ' + (item.unitCode_dictText || item.unit || '') + '</td>';
medicineHtml += '<td>' + (item.totalPrice || '0.00') + '</td>';
printHtml += '<tr>';
printHtml += '<td>' + (item.medicineName || item.itemName || 'N/A') + '</td>';
printHtml += '<td>' + (item.totalVolume || item.spec || '') + '</td>';
printHtml += '<td>' + (item.unitPrice || item.price || '0.00') + '</td>';
printHtml += '<td>' + (item.quantity || 'N/A') + ' ' + (item.unitCode_dictText || item.unit || '') + '</td>';
printHtml += '<td>' + (item.totalPrice || '0.00') + '</td>';
// 组合用法用量信息
const usageInfo = [];
if (item.dose && item.doseUnitCode_dictText) usageInfo.push(item.dose + item.doseUnitCode_dictText);
if (item.methodCode_dictText || item.usage) usageInfo.push(item.methodCode_dictText || item.usage);
if (item.frequency) usageInfo.push(item.frequency);
medicineHtml += '<td>' + usageInfo.join('<br/>') + '</td>';
medicineHtml += '</tr>';
printHtml += '<td>' + usageInfo.join('<br/>') + '</td>';
printHtml += '</tr>';
});
medicineHtml += '</tbody>';
medicineHtml += '<tfoot>';
medicineHtml += '<tr>';
medicineHtml += '<td colspan="4" style="text-align: right; font-weight: bold;">总计:</td>';
medicineHtml += '<td colspan="2" style="font-weight: bold;">' + (prescription.medTotalAmount || '0.00') + '</td>';
medicineHtml += '</tr>';
medicineHtml += '</tfoot>';
medicineHtml += '</table>';
printHtml += '</tbody>';
printHtml += '<tfoot>';
printHtml += '<tr>';
printHtml += '<td colspan="4" style="text-align: right; font-weight: bold;">总计:</td>';
printHtml += '<td colspan="2" style="font-weight: bold;">' + (prescription.medTotalAmount || '0.00') + '</td>';
printHtml += '</tr>';
printHtml += '</tfoot>';
printHtml += '</table>';
} else {
medicineHtml += '<p>暂无药品信息</p>';
printHtml += '<p>暂无药品信息</p>';
}
// 分页符(最后一个处方除外)
if (index < result.length - 1) {
medicineHtml += '<div class="page-break"></div>';
printHtml += '<div class="page-break"></div>';
}
medicineHtml += '</div>';
printHtml += '</div>';
});
medicineHtml += '</div>';
printContainer.innerHTML = medicineHtml;
printHtml += '</div>';
printContainer.innerHTML = printHtml;
// 添加到文档
document.body.appendChild(printContainer);