";
afterFitContent(contentId, zyReqHtml, titleId);
}
/**
* 处方详情构造方法后续事件,如所有的复选框默认勾选
* @param contentId
* @param zyReqHtml
* @param titleId
*/
function afterFitContent(contentId, zyReqHtml, titleId) {
$("#" + contentId).html(zyReqHtml);
$("#" + titleId).removeClass("hide").addClass("in");
//是否默认勾选处方回调
var checkboxFlag = localStorage.getItem("checkboxFlag");
if (checkboxFlag != null && (checkboxFlag == "0" || checkboxFlag == 0)) {
$("#" + titleId).find("input[type='checkbox']").prop("checked", true);
$("#" + contentId).find("input[type='checkbox']").each(function (index, obj) {
$(obj).prop("checked", true);
});
} else {
$("#" + titleId).find("input[type='checkbox']").prop("checked", false);
}
}
/**
* 模板、详情页行数据点击事件
* @param obj
*/
function rowDataClick(obj) {
$(obj).prev().click();
}
/**
* 模板、详情页治疗分类标题点击事件
* @param obj
* @param source 0 是标题的行点击事件 1 标题的checkbox本身触发
*/
function titleClick(obj, source) {
var contentObj = $(obj).parent().next();
var check = $(obj).prop("checked");
if (source == 0) {
var prev = $(obj).prev();
check = !$(prev).prop("checked");
$(prev).prop("checked", check)
}
if (contentObj != null) {
$(contentObj).children().each(function (index, object) {
//以下两个方法,单独调用一个可能不行
$(object).find("input[type='checkbox']").prop("checked", check) //如果鼠标点击选中了,执行后可以取消选中
});
}
}
/**
* 处方明细复选框点击事件
* @param obj
* @param source 0 是标题的行点击事件 1 标题的checkbox本身触发
*/
function prescriptionCfmxChosice(obj, source) {
var check = $(obj).prop("checked");
if (source == 0) {
var prev = $(obj).prev();
check = !$(prev).prop("checked");
//以下两个方法,单独调用一个可能不行
$(prev).prop("checked", check) //如果鼠标点击选中了,执行后可以取消选中
}
var conents = $(obj).parent().parent().nextAll();
if (conents == null || conents.length == 0) {
return;
}
$(conents).each(function (index, object) {
//以下两个方法,单独调用一个可能不行
$(object).find("div:eq(0)").find("input[type='checkbox']").prop("checked", check) //如果鼠标点击选中了,执行后可以取消选中
var contentObj = $(object).find("div:eq(1)");
if (contentObj != null) {
$(contentObj).children().each(function (contentIndex, contentObject) {
$(contentObject).find("input[type='checkbox']").prop("checked", check) //如果鼠标点击选中了,执行后可以取消选中
});
}
});
}
/**
* 简明病历标题点击事件
* @param obj
*/
function prescriptionJmblChosice(obj) {
var prev = $(obj).prev();
var check = !$(prev).prop("checked");
$(prev).prop("checked", check); //如果鼠标点击选中了,执行后可以取消选中
}
/**
* 医疗范文详情预览
* @param id
*/
function medicalModelModal(id) {
closeObjectWebui(false);
//是否默认勾选处方回调
var checkboxFlag = localStorage.getItem("checkboxFlag");
if (checkboxFlag != null && (checkboxFlag == "0" || checkboxFlag == 0)) {
$("#conciseRecordsYlfw").prop("checked", true);
$("#prescriptionSubsidiaryYlfw").prop("checked", true);
} else {
$("#conciseRecordsYlfw").prop("checked", false);
$("#prescriptionSubsidiaryYlfw").prop("checked", false);
}
$.ajax({
type: "GET",
url: '/thmz/getTemplateById?id=' + id,
contentType: "application/json;charset=UTF-8",
dataType: "json",
async: false,
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
var jsonData = JSON.parse(res.data.templateData);
$("#vmedicalModelName").text(res.data.name);
$("#idTemplate").val(res.data.id);
$("#zsTemplate").html(jsonData.mzBlRecord.emrChiefComplaint);
$("#xbsTemplate").html(jsonData.mzBlRecord.emrHpi);
$("#tgjcTemplate").html(jsonData.mzBlRecord.emrPe);
$("#jkjyTemplate").html(jsonData.mzBlRecord.emrJkjy);
var icdText = res.data.icdText;
$("#zdTemplate").html("");
$("#xypyContent").html("");
$("#xymjContent").html("");
$("#xyjeContent").html("");
$("#yczlContent").html("");
$("#zyzlContent").html("");
$("#zlyjContent").html("");
if (icdText != null) {
var arr = icdText.split(",");
var html = "";
for (var i = 0; i < arr.length; i++) {
if (i == 0) {
html += '
';
} else {
html += '
';
}
html += arr[i];
html += '
';
}
$("#zdTemplate").html(html);
}
var prescriptionDetail = jsonData.mzBlRecord.prescriptionDetail;
if (prescriptionDetail != null && prescriptionDetail != "") {
prescriptionDetail = JSON.parse(prescriptionDetail);
var xyPrescription = prescriptionDetail.xyPrescription;
if (xyPrescription != null) {
fitxyContent(xyPrescription.pyPrescription, "xypyContent", "xypyTitle", true);
fitxyContent(xyPrescription.mjPrescription, "xymjContent", "xymjTitle", true);
fitxyContent(xyPrescription.jePrescription, "xyjeContent", "xyjeTitle", true);
fitxyContent(xyPrescription.ycPrescription, "yczlContent", "yczlTitle", true);
} else {
$("#xypyTitle").removeClass("in").addClass("hide");
$("#xypyContent").html("");
$("#xymjTitle").removeClass("in").addClass("hide");
$("#xymjContent").html("");
$("#xyjeTitle").removeClass("in").addClass("hide");
$("#xyjeContent").html("");
$("#yczlTitle").removeClass("in").addClass("hide");
$("#yczlContent").html("");
}
var zyPrescription = prescriptionDetail.zyPrescription;
if (zyPrescription != null) {
fitzyContent(zyPrescription, "zyzlContent", "zyzlTitle", true);
} else {
$("#zyzlTitle").removeClass("in").addClass("hide");
$("#zyzlContent").html("");
}
var jcjyPrescription = prescriptionDetail.jcjyPrescription;
if (jcjyPrescription != null) {
fitJcjyContent(jcjyPrescription, "jcjyContent", "jcjyTitle", true);
} else {
$("#jcjyTitle").removeClass("in").addClass("hide");
$("#jcjyContent").html("");
}
var zlPrescription = prescriptionDetail.zlPrescription;
if (zlPrescription != null) {
fitJcjyContent(zlPrescription, "zlContent", "zlTitle", true);
} else {
$("#zlTitle").removeClass("in").addClass("hide");
$("#zlContent").html("");
}
var zyReqPrescription = prescriptionDetail.zyReqPrescription;
if (zyReqPrescription != null) {
fitZyReqContent(zyReqPrescription, "zyReqContent", "zyReqTitle", true);
} else {
$("#zyReqTitle").removeClass("in").addClass("hide");
$("#zyReqContent").html("");
}
} else {
$("#xypyTitle").removeClass("in").addClass("hide");
$("#xypyContent").html("");
$("#xymjTitle").removeClass("in").addClass("hide");
$("#xymjContent").html("");
$("#xyjeTitle").removeClass("in").addClass("hide");
$("#xyjeContent").html("");
$("#yczlTitle").removeClass("in").addClass("hide");
$("#yczlContent").html("");
$("#zyzlTitle").removeClass("in").addClass("hide");
$("#zyzlContent").html("");
$("#jcjyTitle").removeClass("in").addClass("hide");
$("#jcjyContent").html("");
$("#zlTitle").removeClass("in").addClass("hide");
$("#zlContent").html("");
$("#zyReqTitle").removeClass("in").addClass("hide");
$("#zyReqContent").html("");
}
} else {
errorMesage(res);
}
}
});
$("#medicalModelModal").modal();
}
/**
* 诊疗项目回写
* @param code
* @param mzChargeDetail
*/
function callBackZlDetail(code, mzChargeDetail) {
//诊疗项目
$.ajax({
type: "GET",
url: '/thmz/getZdChargeItemByCode?code=' + code,
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: false,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
//如果
if ($("#zlTab").find("li") == null || $("#zlTab").find("li").length == 0) {
initNavTabs(3, null, null);
}
$("#zlItem").val(res.data.name);
$("#zlItem").blur();
$("#descriptions").val(res.data.descriptions);
$("#zlItemPrice").val(res.data.chargeAmount);
$("#chargeUnit").val(res.data.chargeUnit);
$("#zl_current_code").val(res.data.code);
$("#zlRemark").val(mzChargeDetail.instructionText);
$("#dayZlNum").selectpicker('val', mzChargeDetail.orderDays);
$('#dayZlNum').selectpicker('refresh');
$("#orderFrequencyZl").selectpicker('val', mzChargeDetail.frequency);
$('#orderFrequencyZl').selectpicker('refresh');
if (mzChargeDetail.execDept != null && mzChargeDetail.execDept != "") {
$("#zlExecUnit").selectpicker('val', mzChargeDetail.execDept);
$('#zlExecUnit').selectpicker('refresh');
}
$("#itemQuantity").val(mzChargeDetail.drugQuan);
$("#totalNumZl").val(mzChargeDetail.quantity);
saveZlItem(false);
} else {
errorMesage(res);
}
}
});
}
/**
* 处方模板回调和历史处方调用自动重置组号
* @param type
*/
function resetNewGroupId(type) {
if (type == 1 || type == 2) {
var xyTabContents = $("#xyTabContent").find("div.tab-pane");
//西药设置
if (xyTabContents != null && xyTabContents.length > 0) {
groupIdMap = new Map();
gropuIdAndOrderNoMap = new Map();
var newGroupId = 1;
gropuIdAndOrderNoMap.put(1, 0);
var prevGroupId = null;
for (var i = 0; i < xyTabContents.length; i++) {
var formGroups = $(xyTabContents[i]).find("div.form-group");
if (formGroups != null && formGroups.length > 0) {
for (var j = 0; j < formGroups.length; j++) {
var tempGroupId = $(formGroups[j]).find("input.temporary_items_groupId").val();
if (prevGroupId != null && tempGroupId != prevGroupId) {
newGroupId++;
gropuIdAndOrderNoMap.put(newGroupId, i);
}
$(formGroups[j]).find("span.groupId").text(newGroupId);
$(formGroups[j]).find("input.temporary_items_groupId").val(newGroupId);
var map = groupIdMap.get(newGroupId + '');
if (map == null) {
map = new Map();
map.put("supplyType", $(formGroups[j]).find("input.temporary_items_supplyType").val());
map.put("orderFrequency", $(formGroups[j]).find("input.temporary_items_orderFrequency").val());
map.put("dayNum", $(formGroups[j]).find("input.temporary_items_dayNum").val());
groupIdMap.put(newGroupId + '', map);
}
if (prevGroupId == null || tempGroupId != prevGroupId) {
prevGroupId = tempGroupId;
}
}
}
}
resetGroupIdSelect();
}
}
}
/**
* 处方回写
* @param jsonData 处方数据
* @param type 回写类型 0 全部回写 1 医疗范文 2 就诊详情
*/
function editPrescription(jsonData, type) {
orderNoAndTableIdMap = new Map();
tableIdAndOrderNoMap = new Map();
var firstOrNot = jsonData.firstOrNot;
var conciseRecordsFlag = false;
if (type == 1) {
conciseRecordsFlag = $("#conciseRecordsYlfw").prop("checked");
} else if (type == 2) {
conciseRecordsFlag = $("#conciseRecordsJzxq").prop("checked");
}
if (firstOrNot == 0) {
$("#first").next().click();
} else if (firstOrNot == 1) {
$("#not").next().click();
}
if (type == 0 || conciseRecordsFlag) {
$("#symptom").val(jsonData.mzBlRecord.emrChiefComplaint);
$("#emrHpi").val(jsonData.mzBlRecord.emrHpi);
$("#emrPs").val(jsonData.mzBlRecord.emrPs);
$("#personalHistory").val(jsonData.mzBlRecord.personalHistory);
$("#familyHistory").val(jsonData.mzBlRecord.familyHistory);
$("#obstericalHistory").val(jsonData.mzBlRecord.obstericalHistory);
if (jsonData.mzBlRecord.weight != null && jsonData.mzBlRecord.weight != 0) {
$("#weight").val(jsonData.mzBlRecord.weight);
} else {
$("#weight").val("");
}
if (jsonData.mzBlRecord.temperature != null && jsonData.mzBlRecord.temperature != 0) {
$("#temperature").val(jsonData.mzBlRecord.temperature);
} else {
$("#temperature").val("");
}
if (jsonData.mzBlRecord.sphygmus != null && jsonData.mzBlRecord.sphygmus != 0) {
$("#sphygmus").val(jsonData.mzBlRecord.sphygmus);
} else {
$("#sphygmus").val("");
}
if (jsonData.mzBlRecord.breathe != null && jsonData.mzBlRecord.breathe != 0) {
$("#breathe").val(jsonData.mzBlRecord.breathe);
} else {
$("#breathe").val("");
}
if (jsonData.mzBlRecord.pressureHigh != null && jsonData.mzBlRecord.pressureHigh != 0) {
$("#pressure_high").val(jsonData.mzBlRecord.pressureHigh);
} else {
$("#pressure_high").val("");
}
if (jsonData.mzBlRecord.pressureFloor != null && jsonData.mzBlRecord.pressureFloor != 0) {
$("#pressure_floor").val(jsonData.mzBlRecord.pressureFloor);
} else {
$("#pressure_floor").val("");
}
if (jsonData.mzBlRecord.pressureHighLeft != null && jsonData.mzBlRecord.pressureHighLeft != 0) {
$("#pressure_high_left").val(jsonData.mzBlRecord.pressureHighLeft);
} else {
$("#pressure_high_left").val("");
}
if (jsonData.mzBlRecord.pressureFloorLeft != null && jsonData.mzBlRecord.pressureFloorLeft != 0) {
$("#pressure_floor_left").val(jsonData.mzBlRecord.pressureFloorLeft);
} else {
$("#pressure_floor_left").val("");
}
$("#tentativeDiagnosis").val(jsonData.mzBlRecord.tentativeDiagnosis);
$("#otherCheck").val(jsonData.mzBlRecord.emrPe);
var icdCode = jsonData.icdCode;
if (icdCode != null && icdCode != "" && icdCode.length > 0) {
$.ajax({
type: "GET",
url: '/thmz/getZdIcdByCodes?icdCode=' + icdCode,
contentType: "application/json;charset=UTF-8",
dataType: "json",
async: false,
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
if (res.data != null && res.data.length > 0) {
for (var i = 0; i < res.data.length; i++) {
fitDiagnoseValue(res.data[i].name, res.data[i].code);
}
}
} else {
errorMesage(res);
}
}
});
}
$("#healthEducation").val(jsonData.mzBlRecord.emrJkjy);
}
//西药选中的数据组
var xyArrays = [];
//中药选中的数据组
var zyArrays = [];
//辅助检查、检验选中的数据组
var jcjyArrays = [];
//诊疗选中的数据组
var zlArrays = [];
//住院选中的数据组
var zyReqArrays = [];
//组号与同组药数量的map
var groupOrderAndLengthMap = new Map();
//处方号与同处方号药数量的map
var orderNoAndLengthMap = new Map();
//住院回写
var zyReqCallBack = false;
if (type == 1) {
setCallBackArrays("xypyContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("xymjContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("xyjeContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("yczlContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("zyzlContent", zyArrays, null, null);
setCallBackArrays("jcjyContent", jcjyArrays, null, null);
setCallBackArrays("zlContent", zlArrays, null, null);
zyReqCallBack = $("#zyReqContent").find("input").prop("checked");
} else if (type == 2) {
setCallBackArrays("prescriptionDetail_xypyContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("prescriptionDetail_xymjContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("prescriptionDetail_xyjeContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("prescriptionDetail_yczlContent", xyArrays, groupOrderAndLengthMap, orderNoAndLengthMap);
setCallBackArrays("prescriptionDetail_zyzlContent", zyArrays, null, null);
setCallBackArrays("prescriptionDetail_jcjyContent", jcjyArrays, null, null);
setCallBackArrays("prescriptionDetail_zlContent", zlArrays, null, null);
zyReqCallBack = $("#prescriptionDetail_zyReqContent").find("input").prop("checked");
} else if (type == 0) {
zyReqCallBack = true;
}
var mzChargeDetailList = jsonData.mzChargeDetailList;
var mzZyReq = jsonData.mzZyReq;
//中药的公共参数是否已经设置了
var hadSetZyFullParams = false;
//西药,成药,医材,麻精,中药,诊疗
if (mzChargeDetailList != null && mzChargeDetailList.length > 0) {
//当前实际回写的组号
var currentOrderNo = null;
//处方号与药品类型关系
var orderAndGroupNoMap = new Map();
// mzChargeDetailList.sort(function (a, b) {
// return a.groupNo - b.groupNo
// });
for (var i = 0; i < mzChargeDetailList.length; i++) {
var mzChargeDetail = mzChargeDetailList[i];
var groupNo = mzChargeDetail.groupNo;
var code = mzChargeDetail.chargeItemCode;
var serial = mzChargeDetail.serial;
if (groupNo == "00") {
if (type != 0 && !isInArray(code, zlArrays)) {
continue;
}
callBackZlDetail(code, mzChargeDetail);
} else if (groupNo == "71" || groupNo == "91" || groupNo == "111" || groupNo == "131") {
// 71 西成药 91 医材 111 精一 131 精二
var groupOrder = mzChargeDetail.groupOrder;
if (groupOrder == null || groupOrder == 'null' || groupOrder == "") {
groupOrder = 1;
}
var orderNo = mzChargeDetail.orderNo;
orderAndGroupNoMap.put(orderNo, groupNo);
if (type != 0 && !isInArray(code + "_" + serial + "_" + groupOrder + "_" + orderNo, xyArrays)) {
continue;
}
var lastGroupOrder = parseInt($("#groupId > option:last").val());
while (lastGroupOrder < groupOrder) {
appendGroupOrder();
lastGroupOrder = parseInt($("#groupId > option:last").val());
}
//appendGroupOrder()
$("#groupId").selectpicker('val', groupOrder);
$('#groupId').selectpicker('refresh');
if (type == 1 || type == 2) {
//模板和历史轨迹回调的时候,如果前一个处方不满5个,就将后面的处方的药品添加到上一个处方中,但如果同一组药不能全部添加到上一个处方,就不会追加到该处方中
var orderNoLength = orderNoAndLengthMap.get(orderNo);
if (currentOrderNo == null) {
currentOrderNo = orderNo;
} else if (orderAndGroupNoMap.get(currentOrderNo) != orderAndGroupNoMap.get(orderNo)) {
var currentGroupNos = $("#xyTabContent").find("input.current_groupNo");
//查询还没有满5个的处方页
var tempOrderNo = null;
for (var k = 0; k < currentGroupNos.length; k++) {
if ($(currentGroupNos[k]).val() == groupNo) {
var next = $(currentGroupNos[k]).next();
if ($(next).children().length < 4) {
var parentId = $(currentGroupNos[k]).parent().attr("id");
tempOrderNo = tableIdAndOrderNoMap.get(parentId);
}
}
}
currentOrderNo = tempOrderNo;
} else if (currentOrderNo != orderNo && orderNoLength < 5) {
var currentOrderNoLength = orderNoAndLengthMap.get(currentOrderNo);
var groupOrderLength = groupOrderAndLengthMap.get(groupOrder);
if (groupOrderLength + currentOrderNoLength <= 5) {
currentOrderNoLength = currentOrderNoLength + 1;
orderNoLength = orderNoLength - 1;
groupOrderLength = groupOrderLength - 1;
orderNoAndLengthMap.put(currentOrderNo, currentOrderNoLength);
orderNoAndLengthMap.put(orderNo, orderNoLength);
groupOrderAndLengthMap.put(groupOrder, groupOrderLength);
orderNo = currentOrderNo;
if (currentOrderNoLength == 5) {
var currentGroupNos = $("#xyTabContent").find("input.current_groupNo");
//查询还没有满5个的处方页,
var tempOrderNo = null;
for (var k = 0; k < currentGroupNos.length; k++) {
if ($(currentGroupNos[k]).val() == groupNo) {
var next = $(currentGroupNos[k]).next();
//这里判断是4,是因为已经把组号设置了,所以要减去1
if ($(next).children().length < 4) {
var parentId = $(currentGroupNos[k]).parent().attr("id");
tempOrderNo = tableIdAndOrderNoMap.get(parentId);
}
}
}
currentOrderNo = tempOrderNo;
}
} else {
currentOrderNo = orderNo;
}
}
}
checkYpInfo(code, serial, groupNo, false, orderNo, type);
// 给药方式 同组药品给药方式相同
$("#supplyType").selectpicker('val', mzChargeDetail.supplyCode);
$('#supplyType').selectpicker('refresh');
$("#drugWin").val(mzChargeDetail.drugQuan);
$("#drugWinUnit").selectpicker('val', mzChargeDetail.drugUnit);
$('#drugWinUnit').selectpicker('refresh');
//天数 同组药品天数相同
$("#dayNum").selectpicker('val', mzChargeDetail.orderDays);
$('#dayNum').selectpicker('refresh');
//频次编码 同组药品频次编码相同
$("#orderFrequency").selectpicker('val', mzChargeDetail.frequency);
$('#orderFrequency').selectpicker('refresh');
if (mzChargeDetail.tryFlag == 1 || mzChargeDetail.tryFlag == "1") {
$("#tryResult").selectpicker('val', 100);
$('#tryResult').selectpicker('refresh');
} else if (mzChargeDetail.tryResult != null && mzChargeDetail.tryResult != "null" && mzChargeDetail.tryResult != "") {
$("#tryResult").selectpicker('val', mzChargeDetail.tryResult);
$('#tryResult').selectpicker('refresh');
}
$("#gross").val(mzChargeDetail.quantity);
$("#totalRetprice").val(Multiply(mzChargeDetail.quantity, $("#packRetprice").val()).toFixed(2));
$("#medicalAdvice").selectpicker('val', mzChargeDetail.instructionCode);
$('#medicalAdvice').selectpicker('refresh');
saveWesternMedicineWithCheck(false, orderNo);
$("#western_medicine_button").click();
$("#xyTab").find("li:eq(0) a").off("click").click();
} else {
if (type != 0 && !isInArray(code + "_" + serial, zyArrays)) {
continue;
}
//中药与颗粒剂
checkZyInfo(code, serial, groupNo, false);
//类型
$("#zyClassType").selectpicker('val', groupNo);
$('#zyClassType').selectpicker('refresh');
$("#zy_drugWin").val(mzChargeDetail.quantity);
$("#zyInstruction").selectpicker('val', mzChargeDetail.instructionCode);
$('#zyInstruction').selectpicker('refresh');
saveChineseMedicine(false);
if (!hadSetZyFullParams) {
hadSetZyFullParams = true;
$("input.zyfs").val(mzChargeDetail.drugWin);
// $("#zy_orderFrequency_1").selectpicker('val', mzChargeDetail.frequency);
// $('#zy_orderFrequency_1').selectpicker('refresh');
$("#useType_1").selectpicker('val', mzChargeDetail.cyFysm);
$('#useType_1').selectpicker('refresh');
$("#cyJssm").selectpicker('val', mzChargeDetail.cyJssm);
$('#cyJssm').selectpicker('refresh');
$("#cyJsl").val(mzChargeDetail.cyJsl);
$("#cyZql").val(mzChargeDetail.cyZql);
$("#cyFj").val(mzChargeDetail.cyFj);
$("#cyFfcs").val(mzChargeDetail.cyFfcs);
$("#cyMtjs").val(mzChargeDetail.cyMtjs);
$("#zy_supplyType_1").selectpicker('val', mzChargeDetail.cyDj);
$('#zy_supplyType_1').selectpicker('refresh');
}
$("#chinese_medicine_button").click();
}
}
}
//检验与检查
var mzYjReqList = jsonData.mzYjReqList;
if (mzYjReqList != null && mzYjReqList.length > 0) {
for (var i = 0; i < mzYjReqList.length; i++) {
var mzYjReq = mzYjReqList[i];
var code = mzYjReq.orderCode;
if (type != 0 && !isInArray(code, jcjyArrays)) {
continue;
}
var jcJyZltype = null;
if (mzYjReq.reqType == 2) {
jcJyZltype = 1;
$("#jyZdSample").selectpicker('val', mzYjReq.inspectStuff);
$('#jyZdSample').selectpicker('refresh');
} else if (mzYjReq.reqType == 3) {
jcJyZltype = 2;
$("#yshPart").selectpicker('val', mzYjReq.inspectPart);
$('#yshPart').selectpicker('refresh');
}
$("#jcJyZltype").val(jcJyZltype);
checkJcJyItemInfo(code, null, jcJyZltype, false);
$("#remark").val(mzYjReq.jyRemark);
if (mzYjReq.execDept != null && mzYjReq.execDept != "") {
$("#execUnit").selectpicker('val', mzYjReq.execDept);
$('#execUnit').selectpicker('refresh');
}
$("#jcJyItemChargeDetail").removeClass("hide").addClass("in");
saveJyJcItem(false);
$("#jcJyItemChargeDetail").removeClass("in").addClass("hide");
}
$("#yj_req_button").click();
}
//入院证
if (zyReqCallBack && mzZyReq != null && mzZyReq.reqDept != null && mzZyReq.reqDept != "") {
$("#inpatientWardBeHospitalized").selectpicker('val', mzZyReq.reqDept);
$('#inpatientWardBeHospitalized').selectpicker('refresh');
initSmallDeptByDept();
$("#admissStatus").selectpicker('val', mzZyReq.admissStatus);
$('#admissStatus').selectpicker('refresh');
$("#conditionCode").selectpicker('val', mzZyReq.conditionCode);
$('#conditionCode').selectpicker('refresh');
$("#routeOfAdmission").selectpicker('val', mzZyReq.routeOfAdmission);
$('#routeOfAdmission').selectpicker('refresh');
setTimeout(function () {
$("#smallWardBeHospitalized").selectpicker('val', mzZyReq.smallDept);
$('#smallWardBeHospitalized').selectpicker('refresh');
saveZyReq(false);
}, 500);
$("#zy_req_button").click();
}
setTimeout(function () {
//设置总金额 计算金额的时候,可能处方还没有回写完
calculateTotalAmount(false);
}, 1000);
//清空映射map
orderNoAndTableIdMap = null;
tableIdAndOrderNoMap = null;
resetNewGroupId(type);
}
/**
* 根据勾选内容设置选中集合
* @param id 区域id
* @param arrays 集合
* @param groupOrderAndLengthMap 组号与同组药数量的map
* @param orderNoAndLengthMap 处方号与同处方号药数量的map
*/
function setCallBackArrays(id, arrays, groupOrderAndLengthMap, orderNoAndLengthMap) {
var contents = $("#" + id).children();
if (contents == null || contents.length == 0) {
return;
}
$(contents).each(function (index, obj) {
var checked = $(obj).find("input").prop("checked");
var data_id = $(obj).attr("data-id");
if (checked && data_id != undefined && data_id != null && data_id != "null" && data_id != "") {
arrays[arrays.length] = data_id;
var dataArr = null;
//设置组号与同组药品数量关系
if (groupOrderAndLengthMap != null) {
dataArr = data_id.split("_");
if (dataArr != null && dataArr.length >= 3) {
var groupOrder = Number(dataArr[2]);
var length = groupOrderAndLengthMap.get(groupOrder);
if (length == null || length == "") {
length = 0;
}
length++;
groupOrderAndLengthMap.put(groupOrder, length);
}
}
//设置处方号与同处方号药品数量关系
if (orderNoAndLengthMap != null) {
if (dataArr == null) {
dataArr = data_id.split("_");
}
if (dataArr != null && dataArr.length >= 4) {
var orderNo = Number(dataArr[3]);
var length = orderNoAndLengthMap.get(orderNo);
if (length == null || length == "") {
length = 0;
}
length++;
orderNoAndLengthMap.put(orderNo, length);
}
}
}
});
}
/**
* 调用医疗范文
*/
function callTemplate() {
clearWorkSpaceExcludeUser(2);
$.ajax({
type: "GET",
url: '/thmz/increaseNumber?id=' + $("#idTemplate").val(),
contentType: "application/json;charset=UTF-8",
dataType: "json",
async: false,
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
var jsonData = JSON.parse(res.data.templateData);
editPrescription(jsonData, 1);
$("#templateId").val(res.data.id);
$("#templateName").val(res.data.name);
$("#templateKindType").selectpicker('val', res.data.templateKindType);
$("#templateKindType").selectpicker('refresh');
$("#templateType").selectpicker('val', res.data.templateType);
$("#templateType").selectpicker('refresh');
$('#operationType').selectpicker('val', 1);
$('#operationType').selectpicker('refresh');
$("#operationTypeDiv").removeClass("hide").addClass("in");
$("#medicalModelModal").modal("hide");
closePopover();
} else {
errorMesage(res);
}
}
});
}
/**
* 底层填充推荐方法
* @param paramsType
* @param appeal
* @param inputId
*/
function extracted(paramsType, appeal, inputId) {
if (paramsType == 13) {
var contentArr = appeal.split(",");
if (contentArr != null && contentArr.length > 0) {
for (var i = 0; i < contentArr.length; i++) {
var content = contentArr[i].replace(")", "").replace("(", "-");
var diagnoseArr = content.split("-");
if (diagnoseArr == null || diagnoseArr.length == 0) {
continue;
}
fitDiagnoseValue(diagnoseArr[0], diagnoseArr[1]);
}
}
} else {
$("#" + inputId).val(appeal);
}
}
/**
* 填充推荐
* @param appeal
* @param paramsType
* @param id
*/
function fitAppeal(appeal, paramsType, id) {
var inputId = "symptom";
var text = "主诉项已经录入,是否覆盖?";
if (paramsType == 5) {
inputId = "emrHpi";
text = "现病史项已经录入,是否覆盖?";
} else if (paramsType == 6) {
inputId = "emrPs";
text = "既往史项已经录入,是否覆盖?";
} else if (paramsType == 13) {
inputId = "diagnoseValue";
text = "诊断项已经录入,是否覆盖?";
}
var symptom = $("#" + inputId).val();
if (paramsType == 13 && (symptom == ",," || symptom == ",")) {
symptom = null;
}
if (symptom != null && symptom != "") {
$("#messageModal").modal();
$("#messageContent").html(text);
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
if (paramsType == 13) {
$("#" + inputId).val(null);
$("#diagnoseTags").html(null);
}
extracted(paramsType, appeal, inputId);
});
$("#cancelButton").off("click");
} else {
extracted(paramsType, appeal, inputId);
}
$.ajax({
type: "GET",
url: '/thmz/increaseTcCommonParamsNumber?id=' + id,
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
}
});
}
/**
* 初始嘱托下拉选
*/
function initInstructionSelect() {
//西药医嘱
$.ajax({
type: "GET",
url: '/thmz/getMzZdInstructionByType?instructionType=0',
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
res.data.forEach(function (item, index) {
var html = '';
$('#medicalAdvice').append(html);
});
$('#medicalAdvice').selectpicker('refresh');
} else {
errorMesage(res);
}
}
});
//中药医嘱
$.ajax({
type: "GET",
url: '/thmz/getMzZdInstructionByType?instructionType=1',
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
res.data.forEach(function (item, index) {
var html = '';
$('#zyInstruction').append(html);
});
$('#zyInstruction').selectpicker('refresh');
} else {
errorMesage(res);
}
}
});
}
/**
* 设置下拉选的尺寸
*/
function setSelectSize() {
$(".selectpicker").selectpicker({
dropuAuto: false,
size: 10
});
//select 从后台加载数据,并保留之前选择的内容
dynamicSelectWithOri("editZd", '/thmz/getAllZdIcdCommonParams?commonParams=');
}
/**
* 初始化性别下拉选
*/
function initGenderSelect() {
var gender = '';
$('#rapidAcceptsUserGender').html(gender);
$('#rapidAcceptsUserGender').selectpicker('refresh');
$('#editUserGender').html(gender);
$('#editUserGender').selectpicker('refresh');
//医疗范文状态
var templateStatus = '';
$('#templateStatus').html(templateStatus);
$('#templateStatus').selectpicker('refresh');
//医疗范文操作类型
var operationType = '';
$('#operationType').html(operationType);
$('#operationType').selectpicker('refresh');
//入院病情
var conditionCode = '';
$('#conditionCode').html(conditionCode);
$('#conditionCode').selectpicker('refresh');
//入院途径
var routeOfAdmission = '';
$('#routeOfAdmission').html(routeOfAdmission);
$('#routeOfAdmission').selectpicker('refresh');
//就诊人群类型
var mdtrtGrpType = '';
$('#mdtrtGrpType').html(mdtrtGrpType);
$('#mdtrtGrpType').selectpicker('refresh');
//外伤标志
var trumFlag = '';
$('#trumFlag').html(trumFlag);
$('#trumFlag').selectpicker('refresh');
//涉及第三方标志
var relTtpFlag = '';
$('#relTtpFlag').html(relTtpFlag);
$('#relTtpFlag').selectpicker('refresh');
//门诊急诊转诊标志
var otpErReflFlag = '';
$('#otpErReflFlag').html(otpErReflFlag);
$('#otpErReflFlag').selectpicker('refresh');
}
/**
* 初始化中药类型下拉选
*/
function initZyClassTypeSelect() {
var gender = '';
$('#zyClassType').html(gender);
$('#zyClassType').selectpicker('refresh');
//$('#zyClassType').selectpicker('val', "81");
// $('#zyClassType').selectpicker('refresh');
}
/**
* 初始化皮试结果下拉选
* @param categoriesFlag 0 口服 2 注射针剂
*/
function initTryResultSelect(categoriesFlag) {
var tryResult = '';
if (categoriesFlag == 2 || categoriesFlag == "2") {
tryResult += '';
}
tryResult += '';
//var tryResult = '';
$('#tryResult').html(tryResult);
$('#tryResult').selectpicker('refresh');
//口服药选择皮试结果
$("#tryResult").parent().parent().parent().removeClass("hide").addClass("in");
}
/**
* 初始化病人身份类别下拉选
*/
function initResponceTypeSelect() {
$.ajax({
type: "GET",
url: '/thmz/getMzResponceType',
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
res.data.forEach(function (item, index) {
var html = '';
$('#patientsNature').append(html);
$('#editUserPatientsNature').append(html);
// $('#responeTypeBeHospitalized').append(html);
});
$('#patientsNature').selectpicker('refresh');
$('#editUserPatientsNature').selectpicker('refresh');
} else {
errorMesage(res);
}
}
});
}
/**
* 所有的入院状态
*/
function iniAdmissStatus() {
$.ajax({
type: "GET",
url: '/thmz/getAdmissStatus',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#admissStatus').empty();
$('#admissStatus').html(html);
$('#admissStatus').selectpicker('destroy').selectpicker('refresh');
}
});
}
/**
* 入院登记的病区列表
*/
function initListDeptSelect() {
//科室列表
$.ajax({
type: "GET",
url: '/thmz/allInpatientWard',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (data) {
if (data == '401' || data == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(data.data, function (commentIndex, comment) {
html += '';
});
$('#inpatientWardBeHospitalized').empty();
$('#inpatientWardBeHospitalized').html(html);
$('#inpatientWardBeHospitalized').selectpicker('refresh');
initSmallDeptByDept();
}
});
}
/**
* 小科室列表
*/
function initSmallDeptByDept() {
let code = escape($('#inpatientWardBeHospitalized').val()).replace(/\+/g, '%2B');
//小科室列表
$.ajax({
type: "GET",
url: '/thmz/getSmallDeptByDept?code=' + code,
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#smallWardBeHospitalized').empty();
$('#smallWardBeHospitalized').html(html);
$('#smallWardBeHospitalized').selectpicker('destroy').selectpicker('refresh');
}
});
//病床数
$.ajax({
type: "GET",
url: '/thmz/getBedStatusNumByDept?code=' + code,
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
var data = res.data;
if (data == null) {
$("#totalBedNum").val(0);
$("#freeBedNum").val(0);
$("#occupationBedNum").val(0);
} else {
$("#totalBedNum").val(data.total);
$("#freeBedNum").val(data.free);
$("#occupationBedNum").val(data.occupation);
}
} else {
errorMesage(res);
}
}
});
}
/**
* 初始化门诊统筹下拉选
*/
function initMztcSelect() {
var selectHtml = '';
$('#zgmztczf').html(selectHtml);
$('#zgmztczf').selectpicker('refresh');
$('#grzhzf').html(selectHtml);
$('#grzhzf').selectpicker('refresh');
}
/**
* 初始化医疗范文范围下拉选
* @param templateTypeId
*/
function initTemplateTypeSelect(templateTypeId) {
$.ajax({
type: "GET",
url: '/thmz/getTemplateTypes',
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
res.data.forEach(function (item) {
var html = '';
$('#' + templateTypeId).append(html);
});
$('#' + templateTypeId).selectpicker('refresh');
// $('#'+templateTypeId).selectpicker('val', "0");
// $('#'+templateTypeId).selectpicker('refresh');
} else {
errorMesage(res);
}
}
});
}
/**
* 初始化医疗范文类型下拉选
* @param templateKindTypeId
*/
function initTemplateKindTypeSelect(templateKindTypeId) {
$.ajax({
type: "GET",
url: '/thmz/getTemplateKindTypes',
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
res.data.forEach(function (item) {
var html = '';
$('#' + templateKindTypeId).append(html);
});
$('#' + templateKindTypeId).selectpicker('refresh');
} else {
errorMesage(res);
}
}
});
}
/**
* 初始频次下拉选
* @param id
* @param async 是否是异步 true 异步 false 同步
*/
function initOrderFrequencys(id, async) {
$.ajax({
type: "GET",
url: '/thmz/getXyOrderFrequencys',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: async,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#' + id).empty();
$('#' + id).html(html);
$('#' + id).selectpicker('refresh');
}
});
}
/**
* 初始中药频次下拉选
* @param id
* @param async 是否是异步 true 异步 false 同步
*/
function initZyOrderFrequencys(id, async) {
$.ajax({
type: "GET",
url: '/thmz/getZyOrderFrequencys',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: async,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#' + id).empty();
$('#' + id).html(html);
$('#' + id).selectpicker('refresh');
}
});
}
/**
* 初始中药服用说明
*/
function initAllMzYshZdFysm() {
$.ajax({
type: "GET",
url: '/thmz/getAllMzYshZdFysm',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: false,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
if (comment.name.indexOf(",") < 0) {
//过滤组合的用法
html += '';
}
});
$('.useType').empty();
$('.useType').html(html);
$('.useType').selectpicker('refresh');
$('.useType').selectpicker('val', "2");
$('.useType').selectpicker('refresh');
}
});
}
/**
* 初始用药方式下拉选
*/
function initSupplyTypes() {
$.ajax({
type: "GET",
url: '/thmz/getSupplyTypes',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
if (comment.supplyOcc === "71") {
html += '';
}
});
$('#supplyType').empty();
$('#supplyType').html(html);
$('#supplyType').selectpicker('refresh');
}
});
}
/**
* 初始煎药方式下拉选
* @param async 是否是异步 true 异步 false 同步
*/
function initZySupplyTypes(id, async) {
setSelectSize();
$.ajax({
type: "GET",
url: '/thmz/getSupplyTypes',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: async,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
if (comment.supplyOcc === "81") {
// html += '';
html += '';
}
});
$('#' + id).empty();
$('#' + id).html(html);
$('#' + id).selectpicker('refresh');
}
});
}
/**
* 初始查检查部位
*/
function initYshPart() {
setSelectSize();
$.ajax({
type: "GET",
url: '/thmz/getYshPart',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#yshPart').empty();
$('#yshPart').html(html);
$('#yshPart').selectpicker('refresh');
}
});
}
/**
* 初始化验物下拉选
*/
function initJyZdSample() {
setSelectSize();
$.ajax({
type: "GET",
url: '/thmz/getJyZdSample',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#jyZdSample').empty();
$('#jyZdSample').html(html);
$('#jyZdSample').selectpicker('refresh');
}
});
}
/**
* 初始化当前医生说书科室
*/
function initClinicDeptNo() {
$.ajax({
type: "GET",
url: '/thmz/getUnitCodeByCurrentUser',
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
var html = '';
$.each(res.data, function (commentIndex, comment) {
html += '';
});
$('#clinicDeptNo').empty();
$('#clinicDeptNo').html(html);
$('#clinicDeptNo').selectpicker('refresh');
var userIdCode = localStorage.getItem("userIdCode");
var deptNo = localStorage.getItem(userIdCode);
if (deptNo != null && deptNo != "") {
$('#clinicDeptNo').selectpicker('val', deptNo);
$('#clinicDeptNo').selectpicker('refresh');
}
}
});
}
/**
* 保存当前药品到右边处方区域
* @param index 0 西药 1中药 2 诊疗和社备
*/
function saveMedicine(index) {
if (index == 0) {
saveWesternMedicineWithCheck(true, null);
} else if (index == 1) {
saveChineseMedicine(true);
}
}
/**
* 保存当前药品到右边处方区域 西药
* calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
* orderNoParmams
*/
function saveWesternMedicineWithCheck(calculateTotalAmountFlag, orderNoParmams) {
//是新增药品还是编辑 true 修改 默认false
var updateFlag = $("#western_medicine_update_flag").val();
if (updateFlag == "true" || updateFlag == true) {
saveWesternMedicine(calculateTotalAmountFlag);
} else {
//当前药房编码
var currentGroupNo = $("#current_groupNo").val();
if (currentGroupNo == "") {
errorMesageSimaple("您未选择任何药品");
return;
}
if ($("#xyTab").find("li") == null || $("#xyTab").find("li").length == 0) {
initNavTabs(0, currentGroupNo, orderNoParmams);
}
var tableId = $("#xyTab li.active").find("a").attr("href");
var childrens = $(tableId).find("div:eq(0)").children().length;
var thisGroupNo = $(tableId).find("input.current_groupNo").val();
var flag = childrens === 5;
if (!calculateTotalAmountFlag) {
flag = childrens === 5 && $(tableId).is(':last-child');
}
if (thisGroupNo != null && thisGroupNo != '' && currentGroupNo != thisGroupNo) {
//当前编辑的处方与选中的品类非同一处方能保存的
var currentGroupNos = $("#xyTabContent").find("input.current_groupNo");
//是否需要新增处方页,以保存医材处方
var needAddTable = true;
for (var i = 0; i < currentGroupNos.length; i++) {
if ($(currentGroupNos[i]).val() == currentGroupNo) {
var next = $(currentGroupNos[i]).next();
if (needAddTable && $(next).children().length < 5) {
var parentId = $(currentGroupNos[i]).parent().attr("id");
//切换处方
$("#xyTab").find("a[href='#" + parentId + "']").off("click").tab('show');
//$("#xyTab").find("a[href='#" + tableId + "']").off("click").click();
//因为存在没有满5个的处方页,直接保存到该页
needAddTable = false;
}
}
}
if (needAddTable) {
//91 医材
var message = "医材需要单独处方,是否需要新增医材处方?";
if (currentGroupNo == '71') {
message = "普通西成药需要单独处方,是否需要新增处方?"
} else if (currentGroupNo == '111') {
message = "麻、精一药物需要单独处方,是否需要新增处方?"
} else if (currentGroupNo == '131') {
message = "精二药物需要单独处方,是否需要新增处方?"
}
if (calculateTotalAmountFlag) {
$("#messageModal").modal();
$("#messageContent").html(message);
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
refreshNavTabs(0, currentGroupNo, orderNoParmams);
saveWesternMedicine(calculateTotalAmountFlag);
});
$("#cancelButton").off("click").on("click", function (t) {
return;
});
}
}
} else if (flag) {
if (calculateTotalAmountFlag) {
$("#messageModal").modal();
$("#messageContent").html("单张处方最多只能开具5个药品,是否需要新增处方?");
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
refreshNavTabs(0, currentGroupNo, orderNoParmams);
saveWesternMedicine(calculateTotalAmountFlag);
});
$("#cancelButton").off("click").on("click", function (t) {
return;
});
}
} else {
saveWesternMedicine(calculateTotalAmountFlag);
}
}
}
/**
* 保存当前药品到右边处方区域 西药
* calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveWesternMedicine(calculateTotalAmountFlag) {
//当前药房编码
var currentGroupNo = $("#current_groupNo").val();
//药品名称
var westernMedicineNamme = $("#western_medicine_name").val();
var tableId = $("#xyTab li.active").find("a").attr("href");
if (tableId == undefined) {
refreshNavTabs(0, currentGroupNo, null);
tableId = $("#xyTab li.active").find("a").attr("href");
}
var thisGroupNo = $(tableId).find("input.current_groupNo").val();
if (currentGroupNo != thisGroupNo) {
//91 医材
var type = "医材";
if (currentGroupNo == '71') {
type = "普通西成药"
} else if (currentGroupNo == '111') {
type = "麻、精一药物"
} else if (currentGroupNo == '131') {
type = "精二药物"
}
errorMesageSimaple("【" + westernMedicineNamme + "】是" + type + ",无法保存到当前处方,请切换或者新增相应的处方进行保存。");
return;
}
//当前处方选项卡下标
var xyTabIndex = $("#xyTab li.active").index();
//组号
var groupId = $("#groupId").val();
if (groupId == null || groupId == '') {
errorMesageSimaple("组号为空,请选择组号!");
return;
}
groupId = parseInt(groupId);
if (groupId == null || isNaN(groupId)) {
errorMesageSimaple("组号为空,请选择组号!");
return;
}
if (gropuIdAndOrderNoMap == null) {
gropuIdAndOrderNoMap = new Map();
}
var exitIndex = gropuIdAndOrderNoMap.get(groupId);
if (exitIndex == null) {
exitIndex = xyTabIndex;
gropuIdAndOrderNoMap.put(groupId, xyTabIndex);
}
if (xyTabIndex != exitIndex) {
var westernMedicineUpdateFlag = $("#western_medicine_update_flag").val();
var westernMedicineOriGroupId = $("#western_medicine_ori_group_id").val();
//非修改组号的情况下就需要切换组号
if (!((westernMedicineUpdateFlag == true || westernMedicineUpdateFlag == "true") && westernMedicineOriGroupId != groupId)) {
groupId = parseInt($("#groupId > option:last").val());
$("#groupId").selectpicker('val', groupId);
$('#groupId').selectpicker('refresh');
gropuIdAndOrderNoMap.put(groupId, xyTabIndex);
appendGroupOrder();
}
warningMesageSimaple("同一组药必须出现在同一个处方中,当前组号已经被其他处方使用,系统已自动为您重新分配组号!");
//return;
}
//当前药品编码
var currentCode = $("#western_medicine_current_code").val();
//当前药品规格
var currentSerial = $("#western_medicine_current_serial").val();
//用法编码
var supplyType = $("#supplyType").val();
//用法描述
var supplyTypeText = $('#supplyType option:selected').text();
supplyTypeText = supplyTypeText.substring(0, supplyTypeText.indexOf("["));
//药品默认单次使用剂量
var drugWinDb = $("#drugWinDb").val();
//处方实际单次使用剂量
var drugWin = $("#drugWin").val();
//剂量单位
var drugWinUnit = $('#drugWinUnit option:selected').text();
//drugWinUnit = drugWinUnit.substring(0, drugWinUnit.indexOf("("));
//天数
var dayNum = $("#dayNum").val();
//频次编码
var orderFrequency = $("#orderFrequency").val();
//频次描述
var orderFrequencyText = $('#orderFrequency option:selected').text();
orderFrequencyText = orderFrequencyText.substring(0, orderFrequencyText.indexOf("("));
//总量
var gross = $("#gross").val();
//包装单位
var packUnit = $("#packUnit").val();
if (packUnit == null) {
packUnit = "";
}
//医嘱码
var medicalAdvice = $("#medicalAdvice").val();
//医嘱内容
var medicalAdviceText = $('#medicalAdvice option:selected').text();
medicalAdviceText = medicalAdviceText.substring(0, medicalAdviceText.indexOf("("));
//金额
var totalRetprice = parseFloat($("#totalRetprice").val());
//单价
var packRetprice = $("#packRetprice").val();
//皮试结果
var tryResult = $("#tryResult").val();
//药品大类标志
var categoriesFlag = $("#categoriesFlag").val();
if (currentCode == null || currentCode == '') {
if(calculateTotalAmountFlag){
errorMesageSimaple("未选择任何药品!");
}
return;
}
if (currentGroupNo != '91') {
if (supplyType == null || supplyType == "") {
errorMesageSimaple("用法为空!");
return;
}
if (drugWin == null || drugWin == "") {
errorMesageSimaple("剂量为空!");
return;
}
if (dayNum == null || dayNum == "") {
errorMesageSimaple("天数为空!");
return;
}
if (orderFrequency == null || orderFrequency == "") {
errorMesageSimaple("频次为空!");
return;
}
}
if (gross == null || gross == "") {
errorMesageSimaple("总量为空!");
return;
}
var manufactoryName = $("#manufactoryName").val();
var html = '
';
html += '' + groupId + '' + '.';
html += westernMedicineNamme;
if (manufactoryName != null && manufactoryName != 'null' && manufactoryName != "") {
html += "(" + manufactoryName + ")"
}
html += ' ';
html += $("#specification").val();
html += ' X ';
//html += drugWinDb + drugWinUnit + ' 共';
html += gross + packUnit + " " + ' ';
html += '用法:' + supplyTypeText + ' ';
html += drugWin + drugWinUnit + ' ';
html += '频次:' + orderFrequencyText + ' ';
html += dayNum + '天 ';
if (tryResult != null && tryResult != 'null' && tryResult != "") {
if (tryResult == "100" || tryResult == 100) {
html += '皮试 ';
} else {
html += '皮试结果: ' + $('#tryResult option:selected').text();
}
}
if (medicalAdvice != null && medicalAdvice != '') {
html += '医嘱:' + medicalAdviceText;
}
html += ' ';
html += '';
html += ' ';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '
';
var tableId = $("#xyTab li.active").find("a").attr("href");
//是新增药品还是编辑 true 修改 默认false
var updateFlag = $("#western_medicine_update_flag").val();
if (updateFlag == undefined || updateFlag == null) {
updateFlag = false;
}
// //原药品金额 如果是修改则需要设置
// var temporaryItemsAmount = 0;
//当前需要被移除元素的下个兄弟节点
var nextObj = null;
//当前修改的药品是不是最后一个
var isLast = false;
var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
if (formGroups != null && formGroups.length > 0) {
//如果是修改,需要减去原来的费用
if (updateFlag == "true" || updateFlag == true) {
//药品有可能会修改,所以,判断的时候要用原药品编码
var updateOriCode = $("#update_ori_code").val();
//规格有可能会修改,所以,判断的时候要用原规格
var updateOriSerial = $("#update_ori_serial").val();
//组号有可能会修改,所以,判断的时候要用原组号
var westernMedicineOriGroupId = $("#western_medicine_ori_group_id").val();
for (var i = 0; i < formGroups.length; i++) {
var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
var temporaryItemsSerial = $(formGroups[i]).find("input.temporary_items_serial").val();
var temporaryItemsGroupId = $(formGroups[i]).find("input.temporary_items_groupId").val();
if (temporaryItemsCode === updateOriCode && temporaryItemsSerial === updateOriSerial && temporaryItemsGroupId == westernMedicineOriGroupId) {
//temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
if (formGroups.length > 1) {
nextObj = $(formGroups[i]).next();
}
isLast = (i + 1) === formGroups.length;
$(formGroups[i]).remove();
break;
}
}
} else {
//因为药品可以换组号,要保证相同组号的在一起
for (var i = 0; i < formGroups.length; i++) {
var temporaryItemsGroupId = parseInt($(formGroups[i]).find("input.temporary_items_groupId").val());
//如果当前的组号小与遍历到的组号,说明是原组号的下一个兄弟节点,新的药品插入到兄弟节点前就可以了
if (temporaryItemsGroupId > groupId) {
nextObj = $(formGroups[i]);
break;
}
}
}
}
//当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
if (nextObj == null || isLast) {
$(tableId).find("div:eq(0)").append(html);
} else {
$(nextObj).before(html);
}
//设置当前处方金额
//calculateCfAmount(tableId, totalRetprice, temporaryItemsAmount, 0, 0);
if (calculateTotalAmountFlag) {
//设置总金额
calculateTotalAmount(true);
resetGroupIdSelect();
}
//判断当前组号是不是最后一个,是最后一个组号,就需要新增组号
var groupIdLast = $("#groupId option:last-child").text();
if (groupId === groupIdLast) {
appendGroupOrder();
}
//设置药品的用法,频次,天数
var map = groupIdMap.get(groupId);
if (map == null) {
map = new Map();
map.put("supplyType", supplyType);
map.put("orderFrequency", orderFrequency);
map.put("dayNum", dayNum);
groupIdMap.put(groupId, map);
}
//设置当前药品的品类
$(tableId).find("input.current_groupNo").val($("#current_groupNo").val());
clearWesternMedicine(false);
resetGroupIdMap();
}
/**
* 上移
* @param obj
*/
function arrowUp(obj) {
var parentObject = $(obj).parent();
if ($(parentObject).prev() == null) {
return;
}
//当前元素的序号
var thisJcjyItemGroupId = null;
//前一个兄弟节点的序号
var prevJcjyItemGroupId = null;
//当是项目时有序号,进行序号调整
if ($(parentObject).find("span.jcjyItemGroupId") != null) {
thisJcjyItemGroupId = $(parentObject).find("span.jcjyItemGroupId").html();
prevJcjyItemGroupId = $(parentObject).prev().find("span.jcjyItemGroupId").html();
$(parentObject).find("span.jcjyItemGroupId").html(prevJcjyItemGroupId);
$(parentObject).prev().find("span.jcjyItemGroupId").html(thisJcjyItemGroupId);
}
$(parentObject).prev().before($(parentObject));
}
/**
* 下移
* @param obj
*/
function arrowDown(obj) {
var parentObject = $(obj).parent();
if ($(parentObject).next() == null) {
return;
}
//当前元素的序号
var thisJcjyItemGroupId = null;
//后一个兄弟节点的序号
var afterJcjyItemGroupId = null;
//当是项目时有序号,进行序号调整
if ($(parentObject).find("span.jcjyItemGroupId") != null) {
thisJcjyItemGroupId = $(parentObject).find("span.jcjyItemGroupId").html();
afterJcjyItemGroupId = $(parentObject).after().find("span.jcjyItemGroupId").html();
$(parentObject).find("span.jcjyItemGroupId").html(afterJcjyItemGroupId);
$(parentObject).after().find("span.jcjyItemGroupId").html(thisJcjyItemGroupId);
}
$(parentObject).next().after($(parentObject));
}
/**
* 修改西药
* @param obj
*/
function editWesternMedicine(obj) {
clearWesternMedicine(true);
//是新增药品还是编辑 true 修改 默认false
$("#western_medicine_update_flag").val(true);
var parentObject = $(obj).parent();
//组号
$("#groupId").val($(parentObject).find("input.temporary_items_groupId").val());
//组号有可能会修改,所以,判断的时候要用原组号
$("#western_medicine_ori_group_id").val($(parentObject).find("input.temporary_items_groupId").val());
$('#groupId').selectpicker('refresh');
//药品名称
$("#western_medicine_name").val($(parentObject).find("input.temporary_items_westernMedicineNamme").val());
var code = $(parentObject).find("input.temporary_items_code").val();
var serial = $(parentObject).find("input.temporary_items_serial").val();
//当前药品编码
$("#western_medicine_current_code").val(code);
//当前药品规格
$("#western_medicine_current_serial").val(serial);
//当前修改药品原始编码
$("#update_ori_code").val(code);
//当前修改的药品原始规格
$("#update_ori_serial").val(serial);
//用法编码
$("#supplyType").val($(parentObject).find("input.temporary_items_supplyType").val());
$('#supplyType').selectpicker('refresh');
//药品默认单次使用剂量
$("#drugWinDb").val($(parentObject).find("input.temporary_items_drugWinDb").val());
//处方实际单次使用剂量
$("#drugWin").val($(parentObject).find("input.temporary_items_drugWin").val());
//天数
$("#dayNum").val($(parentObject).find("input.temporary_items_dayNum").val());
$('#dayNum').selectpicker('refresh');
//频次编码
$("#orderFrequency").val($(parentObject).find("input.temporary_items_orderFrequency").val());
$('#orderFrequency').selectpicker('refresh');
//总量
$("#gross").val($(parentObject).find("input.temporary_items_gross").val());
//医嘱
$("#medicalAdvice").val($(parentObject).find("input.temporary_items_medicalAdvice").val());
$('#medicalAdvice').selectpicker('refresh');
//金额
$("#totalRetprice").val($(parentObject).find("input.temporary_items_amount").val());
//单价
$("#packRetprice").val($(parentObject).find("input.temporary_items_packRetprice").val());
//皮试结果
var tryResult = $(parentObject).find("input.temporary_items_tryResult").val();
//设置当前药品类型
$("#current_groupNo").val($(parentObject).find("input.temporary_items_currentGroupNo").val());
//设置当前药品大类
$("#categoriesFlag").val($(parentObject).find("input.temporary_items_categoriesFlag").val());
$.ajax({
type: "GET",
url: '/thmz/getYpZdDictByCodeAndSerial?code=' + code + "&serial=" + serial + "&deptNo=" + localStorage.getItem("currentDeptNo") + "&groupNo=71",
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
if (res.data != null) {
var drugWinHtml = '';
if (res.data.weight != null) {
if ($("#drugWin").val() == null || $("#drugWin").val() == '') {
$("#drugWin").val(res.data.weight);
$("#drugWinDb").val(res.data.weight);
}
drugWinHtml = '';
}
if (res.data.volum != null) {
if ($("#drugWin").val() == null || $("#drugWin").val() == '') {
$("#drugWin").val(res.data.volum);
$("#drugWinDb").val(res.data.volum);
}
drugWinHtml += '';
}
if (res.data.miniUnit != null && res.data.miniUnit != "") {
if ($("#drugWin").val() == null || $("#drugWin").val() == '') {
$("#drugWin").val(1);
$("#drugWinDb").val(1);
}
drugWinHtml += '';
}
$('#drugWinUnit').html(drugWinHtml);
$('#drugWinUnit').selectpicker('refresh');
//剂量单位
$("#drugWinUnit").val($(parentObject).find("input.temporary_items_drugWinUnit").val());
$('#drugWinUnit').selectpicker('refresh');
if (res.data.packUnitDesc != null && res.data.packUnitDesc != "") {
var html = '';
$('#packUnit').html(html);
$('#packUnit').selectpicker('refresh');
//包装单位
$("#packUnit").val($(parentObject).find("input.temporary_items_packUnit").val());
$('#packUnit').selectpicker('refresh');
}
if (res.data.psFlag != null && (res.data.psFlag == 1 || res.data.psFlag == "1")) {
if (res.data.categoriesFlag == 0 || res.data.categoriesFlag == "0" || res.data.categoriesFlag == 2 || res.data.categoriesFlag == "2") {
initTryResultSelect(res.data.categoriesFlag);
$("#tryResult").val(tryResult);
$('#tryResult').selectpicker('refresh');
}
}
$("#packSize").val(res.data.packSize);
//厂家名称
$("#manufactoryName").val(res.data.manufactoryName);
//规格
$("#specification").val(res.data.specification);
}
} else {
errorMesage(res);
}
}
});
}
/**
* 修改中药
* @param obj
*/
function editChineseMedicine(obj) {
//是新增药品还是编辑 true 修改 默认false
$("#chinese_medicine_update_flag").val(true);
var parentObject = $(obj).parent();
//当前药品编码
$("#chinese_medicine_current_code").val($(parentObject).find("input.temporary_items_code").val());
//当前药品规格
$("#chinese_medicine_current_serial").val($(parentObject).find("input.temporary_items_serial").val());
//当前修改药品原始编码
$("#update_ori_code").val($(parentObject).find("input.temporary_items_code").val());
//当前修改的药品原始规格
$("#update_ori_serial").val($(parentObject).find("input.temporary_items_serial").val());
//中药类型
$("#zyClassType").val($(parentObject).find("input.temporary_items_zyClassType").val());
$('#zyClassType').selectpicker('refresh');
//药品名称
$("#chinese_medicine_name").val($(parentObject).find("input.temporary_items_chineseMedicineNamme").val());
//单价
$("#zy_packRetprice").val($(parentObject).find("input.temporary_items_zyPackRetprice").val());
//处方实际单次使用剂量
$("#zy_drugWin").val($(parentObject).find("input.temporary_items_drugWin").val());
//医嘱码
$("#zyInstruction").val($(parentObject).find("input.temporary_items_zyInstruction").val());
$('#zyInstruction').selectpicker('refresh');
}
/**
* 修改辅助检查、检验项目
* @param obj
*/
function editJyJcItem(obj) {
//是新增药品还是编辑 true 修改 默认false
$("#jcjy_update_flag").val(true);
var parentObject = $(obj).parent();
//当前项目编码
$("#jcjy_current_code").val($(parentObject).find("input.temporary_items_code").val());
$("#update_ori_code").val($(parentObject).find("input.temporary_items_code").val());
//项目名称
$("#jcJyItem").val($(parentObject).find("input.temporary_items_jcJyItemName").val());
//单价
$("#jcjyItemPrice").val($(parentObject).find("input.temporary_items_amount").val());
//备注
$("#remark").val($(parentObject).find("input.temporary_items_remark").val());
var chargeUnit = $(parentObject).find("input.temporary_items_desc_value").val();
var jcJyZltype = $(parentObject).find("input.temporary_items_type").val();
//执行科室
var execUnit = $(parentObject).find("input.temporary_items_execUnit").val();
$("#execUnit").selectpicker('val', execUnit);
$('#execUnit').selectpicker('refresh');
if (jcJyZltype == 1 || jcJyZltype == "1") {
$("#jyZdSample").selectpicker('val', chargeUnit);
$('#jyZdSample').selectpicker('refresh');
$("#jyZdSampleDiv").removeClass("hide").addClass("in");
$("#yshPartDiv").removeClass("in").addClass("hide");
$("#jcJyItemChargeDetail").removeClass("hide").addClass("in");
} else if (jcJyZltype == 2 || jcJyZltype == "2") {
$("#yshPart").selectpicker('val', chargeUnit);
$('#yshPart').selectpicker('refresh');
$("#yshPartDiv").removeClass("hide").addClass("in");
$("#jyZdSampleDiv").removeClass("in").addClass("hide");
$("#jcJyItemChargeDetail").removeClass("hide").addClass("in");
}
$("#jcJyZltype").val(jcJyZltype);
}
/**
* 修改诊疗项目
* @param obj
*/
function editZlItem(obj) {
//是新增药品还是编辑 true 修改 默认false
$("#zl_update_flag").val(true);
var parentObject = $(obj).parent();
//当前项目编码
$("#zl_current_code").val($(parentObject).find("input.temporary_items_code").val());
$("#update_ori_code").val($(parentObject).find("input.temporary_items_code").val());
//项目名称
$("#zlItem").val($(parentObject).find("input.temporary_items_zlItemName").val());
//单价
$("#zlItemPrice").val($(parentObject).find("input.temporary_items_amount").val());
//备注
$("#zlRemark").val($(parentObject).find("input.temporary_items_remark").val());
var chargeUnit = $(parentObject).find("input.temporary_items_desc_value").val();
//数量
var itemQuantity = $(parentObject).find("input.temporary_items_itemQuantity").val();
//执行科室
var execUnit = $(parentObject).find("input.temporary_items_execUnit").val();
var descriptions = $(parentObject).find("input.temporary_items_code").val();
if (descriptions != null && descriptions != "" && descriptions != 'null') {
$("#descriptions").val(descriptions);
}
var dayZlNum = $(parentObject).find("input.temporary_items_dayZlNum").val();
if (dayZlNum != null && dayZlNum != "" && dayZlNum != 'null') {
$("#dayZlNum").selectpicker('val', dayZlNum);
$('#dayZlNum').selectpicker('refresh');
}
var orderFrequencyZl = $(parentObject).find("input.temporary_items_orderFrequencyZl").val();
if (orderFrequencyZl != null && orderFrequencyZl != "" && orderFrequencyZl != 'null') {
$("#orderFrequencyZl").selectpicker('val', orderFrequencyZl);
$('#orderFrequencyZl').selectpicker('refresh');
}
var totalNumZl = $(parentObject).find("input.temporary_items_totalNumZl").val();
if (totalNumZl != null && totalNumZl != "" && totalNumZl != 'null') {
$("#totalNumZl").val(totalNumZl);
}
$("#zlExecUnit").selectpicker('val', execUnit);
$('#zlExecUnit').selectpicker('refresh');
//描述
$("#chargeUnit").val(chargeUnit);
$("#itemQuantity").val(itemQuantity);
calculateZl(true);
}
/**
* 保存当前辅助检查、检验项目到右边处方区域 需要提示加价
* @param calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveJyJcItem(calculateTotalAmountFlag) {
//6岁内提示加价
var patientAge = $("#patientAge").text();
if (calculateTotalAmountFlag && patientAge != null && patientAge != "" && patientAge < 6) {
$.ajax({
type: "GET",
url: '/thmz/checkAdditionally?code=' + $("#jcjy_current_code").val() + "&jcJyZltype=" + $("#jcJyZltype").val(),
contentType: "application/json;charset=UTF-8",
dataType: "json",
async: false,
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
if (res.data != undefined && res.data != null && res.data.co != null && res.data.co == 1 && res.data.xlCode != null && res.data.xlCode != "") {
var xlCode = res.data.xlCode;
xlCode = Multiply(100, xlCode);
$("#messageModal").modal();
$("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,6岁以内的小朋友诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
saveJyJcItemReal(calculateTotalAmountFlag);
});
$("#cancelButton").off("click");
} else {
//虽然是不满6岁,但是也没有需要加收的项目,直接保存
saveJyJcItemReal(calculateTotalAmountFlag);
}
} else {
errorMesage(res);
}
}
});
} else {
saveJyJcItemReal(calculateTotalAmountFlag);
}
}
/**
* 保存当前项目到右边处方区域
* @param calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveJyJcItemReal(calculateTotalAmountFlag) {
var tableId = $("#jcjyTab li.active").find("a").attr("href");
//组号
var groupId = $(tableId).find("div:eq(0)").children().length + 1;
//项目名称
var jcJyItem = $("#jcJyItem").val();
//当前项目编码
var currentCode = $("#jcjy_current_code").val();
//当前项目价格
var jcjyItemPrice = $("#jcjyItemPrice").val();
//执行科室
var execUnit = $("#execUnit").val();
//执行科室
var execUnitName = $('#execUnit option:selected').text();
execUnitName = execUnitName.substring(0, execUnitName.indexOf("("));
//描述编码
var chargeUnitCode = null;
var chargeUnitName = "";
//检验物或者检查部位
var chargeUnit = null;
//备注
var remark = $("#remark").val();
//项目类型
var jcJyZltype = $("#jcJyZltype").val();
if (jcJyZltype == "1" || jcJyZltype == 1) {
//检验
chargeUnit = $('#jyZdSample option:selected').text();
chargeUnit = chargeUnit.substring(0, chargeUnit.indexOf("("));
chargeUnitCode = $('#jyZdSample').val();
chargeUnitName = " 检验物:";
} else if (jcJyZltype == "2" || jcJyZltype == 2) {
//检查
chargeUnit = $('#yshPart option:selected').text();
chargeUnit = chargeUnit.substring(0, chargeUnit.indexOf("("));
chargeUnitCode = $('#yshPart').val();
chargeUnitName = " 检查部位:";
}
if (currentCode == null || currentCode == '') {
if (calculateTotalAmountFlag == true) {
errorMesageSimaple("未选择任何项目!");
}
return;
}
//判断是否有重复的项目 返回true 说明有重复的
//彩超加收一个部位的不限制多开
if ("003913" != currentCode && verifyRepeat(currentCode, null, chargeUnitCode, 2)) {
return;
}
//原药品金额 如果是修改则需要设置
var temporaryItemsAmount = 0;
//当前需要被移除元素的下个兄弟节点
var nextObj = null;
//当前修改的药品是不是最后一个
var isLast = false;
//是新增药品还是编辑 true 修改 默认false
var updateFlag = $("#jcjy_update_flag").val();
if (updateFlag == undefined || updateFlag == null) {
updateFlag = false;
}
//如果是修改,需要减去原来的费用
//原组号
var oriGroupId = null;
if (updateFlag == "true" || updateFlag == true) {
var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
if (formGroups != null && formGroups.length > 0) {
var updateOriCode = $("#update_ori_code").val();
for (var i = 0; i < formGroups.length; i++) {
var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
if (temporaryItemsCode === updateOriCode) {
temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
if (formGroups.length > 1) {
nextObj = $(formGroups[i]).next();
}
isLast = (i + 1) === formGroups.length;
oriGroupId = $(formGroups[i]).find("span.jcjyItemGroupId").text();
$(formGroups[i]).remove();
break;
}
}
}
}
if (oriGroupId != null) {
groupId = oriGroupId;
}
var html = '
';
html += '' + groupId + '.'
html += jcJyItem + ' ';
if (jcJyZltype == "3" || jcJyZltype == 3) {
html += " 数量:" + itemQuantity;
}
if (execUnit != null && execUnit != "") {
html += " 执行科室:" + execUnitName;
}
if (chargeUnit != null && chargeUnit != '') {
html += chargeUnitName + chargeUnit;
}
if (remark != null && remark != '') {
html += ' 备注:' + remark;
}
html += ' ';
html += '';
html += ' ';
html += '';
if ($("#jcJyItemChargeDetail").hasClass("in")) {
html += '';
}
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '
';
//当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
if (nextObj == null || isLast) {
$(tableId).find("div:eq(0)").append(html);
} else {
$(nextObj).before(html);
}
//设置当前处方金额
//calculateCfAmount(tableId, jcjyItemPrice, temporaryItemsAmount, 2, 0);
if (calculateTotalAmountFlag) {
//设置总金额
calculateTotalAmount(true);
}
clearJyJcItem();
}
/**
* 保存当前诊疗项目到右边处方区域 需要提示加价
* @param calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveZlItem(calculateTotalAmountFlag) {
//6岁内提示加价
var patientAge = $("#patientAge").text();
if (calculateTotalAmountFlag && patientAge != null && patientAge != "" && patientAge < 6) {
$.ajax({
type: "GET",
url: '/thmz/checkAdditionally?code=' + $("#zl_current_code").val() + "&jcJyZltype=3",
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
async: false,
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
if (res.data != undefined && res.data != null && res.data.co != null && res.data.co == 1 && res.data.xlCode != null && res.data.xlCode != "") {
var xlCode = res.data.xlCode;
xlCode = Multiply(100, xlCode);
$("#messageModal").modal();
$("#messageContent").html("根据【湘医保发〔2020〕51 号】价格通知,6岁以内的小朋友诊疗费上调" + xlCode + "%,是否需要继续添加该项目?");
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
saveZlItemReal(calculateTotalAmountFlag);
});
$("#cancelButton").off("click");
} else {
//虽然是不满6岁,但是也没有需要加收的项目,直接保存
saveZlItemReal(calculateTotalAmountFlag);
}
} else {
errorMesage(res);
}
}
});
} else {
saveZlItemReal(calculateTotalAmountFlag);
}
}
/**
* 保存当前项目到右边处方区域
* @param calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveZlItemReal(calculateTotalAmountFlag) {
var tableId = $("#zlTab li.active").find("a").attr("href");
//组号
var groupId = $(tableId).find("div:eq(0)").children().length + 1;
//项目名称
var zlItem = $("#zlItem").val();
//当前项目编码
var currentCode = $("#zl_current_code").val();
//当前项目价格
var zlItemPrice = $("#zlItemPrice").val();
//单位
var chargeUnit = $("#chargeUnit").val();
//执行科室
var zlExecUnit = $("#zlExecUnit").val();
//执行科室
var zlExecUnitName = $('#zlExecUnit option:selected').text();
zlExecUnitName = zlExecUnitName.substring(0, zlExecUnitName.indexOf("("));
//单量
var itemQuantity = $("#itemQuantity").val();
//规格
var descriptions = $("#descriptions").val();
//天数
var dayZlNum = $("#dayZlNum").val();
//频次
var orderFrequencyZl = $("#orderFrequencyZl").val();
//总量
var totalNumZl = $("#totalNumZl").val();
//描述编码
var chargeUnitCode = chargeUnit;
//备注
var remark = $("#zlRemark").val();
if (calculateTotalAmountFlag == true) {
if (currentCode == null || currentCode == '') {
errorMesageSimaple("未选择任何项目!");
return;
}
if (totalNumZl == null || totalNumZl == "" || totalNumZl == "null") {
errorMesageSimaple("项目使用总量为空!");
return;
}
}
//判断是否有重复的项目 返回true 说明有重复的
if (verifyRepeat(currentCode, null, null, 3)) {
return;
}
//原药品金额 如果是修改则需要设置
var temporaryItemsAmount = 0;
//当前需要被移除元素的下个兄弟节点
var nextObj = null;
//当前修改的药品是不是最后一个
var isLast = false;
//是新增药品还是编辑 true 修改 默认false
var updateFlag = $("#zl_update_flag").val();
if (updateFlag == undefined || updateFlag == null) {
updateFlag = false;
}
//如果是修改,需要减去原来的费用
//原组号
var oriGroupId = null;
if (updateFlag == "true" || updateFlag == true) {
var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
if (formGroups != null && formGroups.length > 0) {
var updateOriCode = $("#update_ori_code").val();
for (var i = 0; i < formGroups.length; i++) {
var temporaryItemsCode = $(formGroups[i]).find("input.temporary_items_code").val();
if (temporaryItemsCode === updateOriCode) {
temporaryItemsAmount = $(formGroups[i]).find("input.temporary_items_amount").val();
if (formGroups.length > 1) {
nextObj = $(formGroups[i]).next();
}
isLast = (i + 1) === formGroups.length;
oriGroupId = $(formGroups[i]).find("span.zlItemGroupId").text();
$(formGroups[i]).remove();
break;
}
}
}
}
if (oriGroupId != null) {
groupId = oriGroupId;
}
var html = '
';
html += '' + groupId + '.'
html += zlItem + ' ';
if (descriptions != null && descriptions != "") {
html += " 规格:" + descriptions;
}
html += " 单量:" + itemQuantity;
if (chargeUnit != null && chargeUnit != '') {
html += chargeUnit;
}
if (dayZlNum != null && dayZlNum != "") {
html += " 天数:" + dayZlNum + "天";
}
if (orderFrequencyZl != null && orderFrequencyZl != "") {
html += " 频次:" + orderFrequencyZl;
}
if (totalNumZl != null && totalNumZl != "") {
html += " 总量:" + totalNumZl;
if (chargeUnit != null && chargeUnit != '') {
html += chargeUnit;
}
}
if (zlExecUnit != null && zlExecUnit != "") {
html += " 执行科室:" + zlExecUnitName;
}
if (remark != null && remark != '') {
html += ' 备注:' + remark;
}
html += ' ';
html += '';
html += ' ';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '
';
//当没有下一个兄弟节点或者当前编辑的药品是最后一个时,直接添加
if (nextObj == null || isLast) {
$(tableId).find("div:eq(0)").append(html);
} else {
$(nextObj).before(html);
}
//设置当前处方金额
//calculateCfAmount(tableId, jcjyItemPrice, temporaryItemsAmount, 2, 0);
if (calculateTotalAmountFlag) {
//设置总金额
calculateTotalAmount(true);
}
clearZlItem();
}
/**
* 临时保存住院证
* @param messageFlag 是否需要提醒已经存在的入院申请 true 提示
*/
function saveZyReq(messageFlag) {
//如果
if ($("#zyReqTab").find("li") == null || $("#zyReqTab").find("li").length == 0) {
initNavTabs(4, null, null);
}
var tableId = $("#zyReqTab li.active").find("a").attr("href");
//病区编码
var inpatientWardBeHospitalized = $("#inpatientWardBeHospitalized").val();
//小病室编码
var smallWardBeHospitalized = $("#smallWardBeHospitalized").val();
//入院状态编码
var admissStatus = $("#admissStatus").val();
//病区名称
var inpatientWardText = $('#inpatientWardBeHospitalized option:selected').text();
//小科室名称
var smallWardText = $('#smallWardBeHospitalized option:selected').text();
//入院状态名称
var admissStatusText = $('#admissStatus option:selected').text();
//入院病情代码
var conditionCode = $("#conditionCode").val();
//入院途径代码
var routeOfAdmission = $("#routeOfAdmission").val();
//入院病情代码
var conditionCodeText = $('#conditionCode option:selected').text();
//入院途径代码
var routeOfAdmissionText = $('#routeOfAdmission option:selected').text();
if (admissStatusText == null || admissStatusText == '') {
errorMesageSimaple("未选择入院状态!");
return;
}
if (conditionCode == null || conditionCode == '') {
errorMesageSimaple("未选择入院病情!");
return;
}
if (routeOfAdmission == null || routeOfAdmission == '') {
errorMesageSimaple("未选择入院途径!");
return;
}
if (inpatientWardBeHospitalized == null || inpatientWardBeHospitalized == '') {
errorMesageSimaple("未选择入院病区!");
return;
}
if (admissStatus == null || admissStatus == '') {
errorMesageSimaple("未选择入院状态!");
return;
}
if (messageFlag == "true" || messageFlag == true) {
var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
if (formGroups != null && formGroups.length > 0) {
$("#messageModal").modal();
$("#messageContent").html("当前病人已经有一个暂存的入院申请,是否需要替换该申请?");
$("#messageButton").off("click").on("click", function (t) {
$("#messageModal").modal("hide");
saveZyReq(false);
});
$("#cancelButton").off("click");
return;
}
}
var html = '
收住院';
if (inpatientWardText != null) {
html += " [" + inpatientWardText;
}
if (smallWardText != null) {
html += " (" + smallWardText + ") ";
}
if (inpatientWardText != null) {
html += "]";
}
if (admissStatusText != null) {
html += " " + admissStatusText;
}
if (conditionCodeText != null) {
html += " " + conditionCodeText;
}
if (routeOfAdmissionText != null) {
html += " " + routeOfAdmissionText;
}
html += ' 侯床';
//html += ' ';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '
';
$(tableId).find("div:eq(0)").html(html);
clearZyReq();
}
/**
* 删除药品或者项目
* @param index 0 西药 1 中药 2 检查检验 3诊疗
* @param obj 当前点击的对象
*/
function removeYpOrProject(index, obj) {
var tabId = null;
var className = null;
//西药
if (index == 0) {
tabId = "xyTab";
} else if (index == 1) {
//中成药
tabId = "zyTab";
} else if (index == 2) {
//辅助检查、检验
className = ".jcjyItemGroupId";
tabId = "jcjyTab";
} else if (index == 3) {
//诊疗
className = ".zlItemGroupId";
tabId = "zlTab";
} else if (index == 4) {
//入院
tabId = "zyReqTab";
}
var tableId = $("#" + tabId + " li.active").find("a").attr("href");
//var totalRetprice = $(obj).parent().find("input.temporary_items_amount").val();
//calculateCfAmount(tableId, totalRetprice, null, index, 1);
//医技和诊疗的序号调整一下
if (index == 2 || index == 3) {
var nextAll = $(obj).parent().nextAll();
if (nextAll != null && nextAll.length > 0) {
for (var i = 0; i < nextAll.length; i++) {
var index = $(nextAll[i]).find(className).text();
$(nextAll[i]).find(className).text(index - 1);
}
}
}
var temporaryItemsGroupId = $(obj).parent().find("input.temporary_items_groupId").val();
var temporaryItemsGroupIds = $(obj).parent().parent().find("input.temporary_items_groupId");
if (temporaryItemsGroupIds != null && temporaryItemsGroupIds.length > 0) {
var count = 0;
for (var i = 0; i < temporaryItemsGroupIds.length; i++) {
if (temporaryItemsGroupId == $(temporaryItemsGroupIds[i]).val()) {
count++;
}
}
//当前删除的药品组号是最后一个的时候,清空缓存
if (count == 1) {
groupIdMap.remove(temporaryItemsGroupId);
gropuIdAndOrderNoMap.remove(temporaryItemsGroupId);
}
}
$(obj).parent().remove();
if (index != 4) {
calculateTotalAmount(false);
}
var formGroups = $(tableId).find("div.cf_content").find("div.form-group");
if (formGroups == null || formGroups.length == 0) {
if (index == 0) {
//西药被清空后,重置药房类型编码
$(tableId).find("input.current_groupNo").val(null);
//当本处方内容都被删除完后,也删除处方table
$("#" + tabId).find("a[href=\"" + tableId + "\"]").parent().remove();
$(tableId).remove();
//切换处方 最后一个被选中
$("#" + tabId).find("li:last > a").off("click").tab('show');
} else if (index == 1) {
//当中药处方被清空完后,重置当前中药类型为空
$("#current_zyClassType").val(null);
}
}
if (index == 0) {
resetGroupIdMap();
}
}
/**
* 重置组号与用法、频率天数缓存关系
*/
function resetGroupIdMap() {
var temporaryItemsGroupIds = $("#xyTabContent").find("input.temporary_items_groupId");
if (temporaryItemsGroupIds != null && temporaryItemsGroupIds.length > 0) {
var list = [];
for (var i = 0; i < temporaryItemsGroupIds.length; i++) {
var groupId = $(temporaryItemsGroupIds[i]).val();
if (list.indexOf(groupId) < 0) {
list.push(groupId);
}
}
var keys = groupIdMap.keySet();
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (list.indexOf(key) < 0) {
groupIdMap.remove(key);
}
}
}
}
/**
* 清空西药
* @param flag 是否全部清空 因为 西药有分组,同一组的药品用药方式和频率以及天数一样,不能改变。所以不换组是不能改变 并且设置成不可编辑
*/
function clearWesternMedicine(flag) {
$("#addPDiv").css("margin-left", "125px");
$("#hlyyypsms").removeClass("in").addClass("hide");
$("#western_medicine_update_flag").val(false);
$("#western_medicine_ori_group_id").val(null);
$("#update_ori_code").val(null);
$("#update_ori_serial").val(null);
//药品名称
$("#western_medicine_name").val(null);
//当前药品编码
$("#western_medicine_current_code").val(null);
//当前药品规格
$("#western_medicine_current_serial").val(null);
//当前药房编码
$("#current_groupNo").val(null);
if (flag) {
//用法编码
$("#supplyType").selectpicker('val', null);
$('#supplyType').selectpicker('refresh');
//$("#supplyType").removeAttr("disabled");
//天数
$("#dayNum").selectpicker('val', null);
$('#dayNum').selectpicker('refresh');
// $("#dayNum").removeAttr("disabled");
//频次编码
$("#orderFrequency").selectpicker('val', null);
$('#orderFrequency').selectpicker('refresh');
// $("#orderFrequency").removeAttr("disabled");
}
//药品默认单次使用剂量
$("#drugWinDb").val(null);
//处方实际单次使用剂量
$("#drugWin").val(null);
//剂量单位
$("#drugWinUnit").selectpicker('val', null);
$('#drugWinUnit').selectpicker('refresh');
//总量
$("#gross").val(null);
//包装单位
$("#packUnit").selectpicker('val', null);
$('#packUnit').selectpicker('refresh');
//单价
$("#packRetprice").val(null);
//金额
$("#totalRetprice").val(null);
//医嘱
$("#medicalAdvice").selectpicker('val', null);
$('#medicalAdvice').selectpicker('refresh');
$("#tryResult").parent().parent().parent().removeClass("in").addClass("hide");
//皮试结果
$("#tryResult").selectpicker('val', null);
$('#tryResult').selectpicker('refresh');
//$("#gross").attr("readonly", "readonly");
$("#manufactoryName").val(null);
$("#specification").val(null);
$("#categoriesFlag").val(null);
}
/**
* 保存当前药品到右边处方区域 中药
* calculateTotalAmountFlag 是否计算总金额 回写的时候一次计算
*/
function saveChineseMedicine(calculateTotalAmountFlag) {
//药品名称
var chineseMedicineNamme = $("#chinese_medicine_name").val();
//当前药品编码
var currentCode = $("#chinese_medicine_current_code").val();
//当前药品规格
var currentSerial = $("#chinese_medicine_current_serial").val();
//处方实际单次使用剂量
var drugWin = $("#zy_drugWin").val();
//医嘱码
var zyInstruction = $("#zyInstruction").val();
//医嘱
var zyInstructionText = $('#zyInstruction option:selected').text();
//单价
var zyPackRetprice = parseFloat($("#zy_packRetprice").val());
//当前中药的总价
var totalRetprice = Multiply(drugWin, zyPackRetprice);
//中药类型
var zyClassType = $("#zyClassType").val();
//已经选中的药品类型, 中药不允许一个处方里有普通中药和颗粒剂
var currentYyClassType = $("#current_zyClassType").val();
if (currentYyClassType == null || currentYyClassType == "") {
//中药此时是第一次选择药品,不控制类型
$("#current_zyClassType").val(zyClassType);
} else if (currentYyClassType != zyClassType) {
errorMesageSimaple("同一个中药处方不允许同时出现普通中药和颗粒剂中药!");
return;
}
if (currentCode == null || currentCode == '') {
errorMesageSimaple("未选择任何药品!");
return;
}
var html = '
';
html += chineseMedicineNamme;
if (zyInstruction != null && zyInstruction != '') {
html += '[' + zyInstructionText + ']';
}
html += '';
html += drugWin + 'g';
html += ' ';
html += '';
html += ' ';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '';
html += '
';
var zlItemWebuiPopover = $('#zlItem').webuiPopover('destroy').webuiPopover(settings);
//主诉选中事件
$("#symptom").on("click", function (t) {
if ($(symptomWebuiPopover).css("display") == "block") {
$("#webuiPopover1 div.arrow").css("left", "23px");
var html = '主诉';
html += "
";
html += "
";
html += '
' +
'
' +
'内容: ' +
'
' +
'
' +
' ' +
'
' +
'
' +
'' +
'
' +
'
' +
' ' +
'
' +
'
';
$("#webuiPopover1 div.webui-popover-content").html(html);
$('#paramsType').selectpicker('refresh');
$("#paramsType").parent().css("width", "140px").css("height", "34px");
$("#webuiPopover1").css("z-index", "10");
if ($("#webuiPopover1").hasClass("in")) {
loadSymptom();
}
}
//加载智能接诊模块的主诉推荐
fitSymptomData();
});
//体格检查各输入框选中事件
$("#weight,#temperature,#sphygmus,#breathe,#pressure_high,#pressure_floor,#pressure_high_left,#pressure_floor_left").on("click", function (t) {
if ($("#webuiPopover2").css("display") == "block") {
$("#webuiPopover2").css("left", $("#webuiPopover1").css("left"));
if ($("#healthCheckupContentHtml").html() == null || $("#healthCheckupContentHtml").html() == "") {
$("#webuiPopover2 div.arrow").css("left", "23px");
var html = '体格检查';
html += "
";
html += "
";
$("#webuiPopover2 div.webui-popover-content").html(html);
$("#webuiPopover2").css("z-index", "10");
if ($("#webuiPopover2").hasClass("in")) {
loadHealthCheckup();
}
}
//loadSymptom();
} else {
$('#weight').webuiPopover('show');
$("#webuiPopover2").css("left", $("#webuiPopover1").css("left"));
if ($("#healthCheckupContentHtml").html() == null || $("#healthCheckupContentHtml").html() != "") {
$("#webuiPopover2 div.arrow").css("left", "23px");
var html = '体格检查';
html += "
";
html += "
";
$("#webuiPopover2 div.webui-popover-content").html(html);
$("#webuiPopover2").css("z-index", "10");
if ($("#webuiPopover2").hasClass("in")) {
loadHealthCheckup();
}
}
}
return false;
});
//诊断选中事件
$("#diagnose").on("click", function (t) {
$("#western_medicine_name").webuiPopover('hide');
$("#chinese_medicine_name").webuiPopover('hide');
$("#jcJyItem").webuiPopover('hide');
$("#zlItem").webuiPopover('hide');
if ($(diagnoseWebuiPopover).css("display") == "block") {
$("#webuiPopover3 div.arrow").css("left", "23px");
$("#webuiPopover3 a.close").css("margin-top", "15px");
var html = '诊断';
html += '
";
return {html: html, j: j};
}
// /**
// * 打印门诊指引单
// * @param patientId
// * @param times
// */
// function printGuideCard(patientId, times) {
//
// }
/**
* 打印门诊处方
* @param patientId
* @param times
* @param clnicId
* @param payMark
* @param printType 打印模式 1 预览打印 2 打印设置
*/
function printPrescription(patientId, times, clnicId, payMark, printType) {
$.ajax({
type: "GET",
url: '/thmz/getMzPrescriptionVo?patientId=' + patientId + '×=' + times + '&MzBlRecordFlag=false&payMark=' + payMark + '&clnicId=' + clnicId,
contentType: "application/json;charset=UTF-8",
dataType: "json",
headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
success: function (res) {
if (res == '401' || res == 401) {
window.location.href = '/thmz/login/view'
return;
}
if (res.code == 0) {
var prescriptionDetail = res.data.mzBlRecord.prescriptionDetail;
if (prescriptionDetail != null && prescriptionDetail != "") {
var prescriptionDetailJson = JSON.parse(prescriptionDetail);
//当前处方只开了住院证则只打印住院证
if (prescriptionDetailJson.xyPrescription.jePrescription.length == 0 && prescriptionDetailJson.xyPrescription.mjPrescription.length == 0 && prescriptionDetailJson.xyPrescription.pyPrescription.length == 0 && prescriptionDetailJson.xyPrescription.ycPrescription.length == 0 && prescriptionDetailJson.zlPrescription.length == 0 && prescriptionDetailJson.jcjyPrescription.length == 0 && prescriptionDetailJson.zyPrescription.length == 0 && prescriptionDetailJson.zyReqPrescription != null && prescriptionDetailJson.zyReqPrescription.length > 0) {
printZyReq(patientId, 1);
return;
}
var index = 0;
setPrint();
LODOP = getLodop();
LODOP.PRINT_INITA(6, 0, "148mm", "210mm", "长沙泰和医院处方笺");
LODOP.SET_PRINT_STYLE("FontSize", 9); //字体大小
//设置默认打印机
LODOP.SET_PRINTER_INDEX(printIndex);
LODOP.SET_SHOW_MODE("BKIMG_WIDTH", "148mm");
LODOP.SET_SHOW_MODE("BKIMG_HEIGHT", "210mm");
LODOP.SET_PRINT_PAGESIZE(1, "148mm", "210mm", "CreateCustomPage");
//LODOP.SET_SHOW_MODE("SETUP_ENABLESS",getCheckSS());
LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME", "门诊处方笺");//对新建的纸张重命名
//intDispMode:预览比例,数字型,0-适高 1-正常大小 2-适宽
//intToolMode:工具条和按钮,数字型 0-显示(上方)工具栏 1-显示(下方)按钮栏 2-两个都显示 3-两个都不显示
//blDirectPrint: 打印按钮是否“直接打印” 1-是 0-否(弹出界面“选机打印”)
//intWidth,intHeight 窗口的宽和高,整数型,单位是px
//strTitleButtonCaptoin 预览窗口和打印按钮的名称组合,字符型,用“点”分隔
//LODOP.SET_PREVIEW_WINDOW(intDispMode,intToolMode,blDirectPrint,intWidth,intHeight,strTitleButtonCaptoin)
LODOP.SET_PREVIEW_WINDOW(0, 2, 0, 700, 900, "");
//LODOP.SET_PRINT_STYLE("FontSize", 8); //字体大小
var strStyle = "";
var mzPatientMi = res.mzPatientMi;
var deptName = res.deptName;
$("#patientNamePrescription").text(mzPatientMi.name);
$("#patientGenderPrescription").text(mzPatientMi.gender);
$("#patientAgePrescription").text(mzPatientMi.ageString);
$("#patientIdPrescription").text(mzPatientMi.patientId);
$("#deptPrescription").text(deptName);
$("#doctorPrescription").text(res.doctorName);
$("#cfTime").text(res.opDate);
$("#socialNo").text(mzPatientMi.socialNo);
$("#zdPrescription").text(res.data.icdText);
$("#patientIdGuideCard").text(mzPatientMi.patientId);
$("#patientNameGuideCard").text(mzPatientMi.name);
$("#patientDateGuideCard").text(format(new Date(), "yyyy-MM-dd"));
//普药处方
var pyPrescription = prescriptionDetailJson.xyPrescription.pyPrescription;
if (pyPrescription != null && pyPrescription.length > 0) {
for (var i = 0; i < pyPrescription.length; i++) {
if (index > 0) {
LODOP.NewPageA();
}
var prescriptionDetail = pyPrescription[i].detail;
var __ret = setTableHtml(prescriptionDetail);
var html = __ret.html;
var j = __ret.j;
if (res.deptName != undefined && res.deptName != null) {
if (res.deptName.indexOf("儿") > 0) {
$("#typePrescription").text("儿科");
$("#cfTitle").text("儿科");
} else if (res.deptName.indexOf("急诊科") > 0) {
$("#typePrescription").text("急诊");
$("#cfTitle").text("急诊");
} else {
$("#typePrescription").text("普通处方");
$("#cfTitle").text("普通");
}
}
$("#prescriptionDetail").html(html);
$("#cfAmountPrint").text(pyPrescription[i].amount + "元 (不含注射费)");
LODOP.ADD_PRINT_HTM("0mm", "5mm", "140mm", "200mm", strStyle + document.getElementById("prescription_table").innerHTML);
index++;
}
}
//医材处方
var ycPrescription = prescriptionDetailJson.xyPrescription.ycPrescription;
if (ycPrescription != null && ycPrescription.length > 0) {
for (var i = 0; i < ycPrescription.length; i++) {
if (index > 0) {
LODOP.NewPageA();
}
var prescriptionDetail = ycPrescription[i].detail;
var __ret = setTableHtml(prescriptionDetail);
var html = __ret.html;
var j = __ret.j;
if (res.deptName != undefined && res.deptName != null) {
if (res.deptName.indexOf("儿") > 0) {
$("#typePrescription").text("儿科");
$("#cfTitle").text("儿科");
} else if (res.deptName.indexOf("急诊科") > 0) {
$("#typePrescription").text("急诊");
$("#cfTitle").text("急诊");
} else {
$("#typePrescription").text("医材处方");
$("#cfTitle").text("普通");
}
}
$("#prescriptionDetail").html(html);
$("#cfAmountPrint").text(ycPrescription[i].amount + "元 ");
LODOP.ADD_PRINT_HTM("0mm", "5mm", "140mm", "200mm", strStyle + document.getElementById("prescription_table").innerHTML);
index++;
}
}
//麻精处方
var mjPrescription = prescriptionDetailJson.xyPrescription.mjPrescription;
if (mjPrescription != null && mjPrescription.length > 0) {
for (var i = 0; i < mjPrescription.length; i++) {
if (index > 0) {
LODOP.NewPageA();
}
var prescriptionDetail = mjPrescription[i].detail;
var __ret = setTableHtml(prescriptionDetail);
var html = __ret.html;
var j = __ret.j;
$("#typePrescription").text("麻、精一处方");
$("#cfTitle").text("麻、精一");
$("#prescriptionDetail").html(html);
$("#cfAmountPrint").text(mjPrescription[i].amount + "元 (不含注射费)");
LODOP.ADD_PRINT_HTM("0mm", "5mm", "140mm", "200mm", strStyle + document.getElementById("prescription_table").innerHTML);
index++;
}
}
//精二处方
var jePrescription = prescriptionDetailJson.xyPrescription.jePrescription;
if (jePrescription != null && jePrescription.length > 0) {
for (var i = 0; i < jePrescription.length; i++) {
if (index > 0) {
LODOP.NewPageA();
}
var prescriptionDetail = jePrescription[i].detail;
var __ret = setTableHtml(prescriptionDetail);
var html = __ret.html;
var j = __ret.j;
$("#typePrescription").text("精二处方");
$("#cfTitle").text("精二");
$("#prescriptionDetail").html(html);
$("#cfAmountPrint").text(jePrescription[i].amount + "元 (不含注射费)");
LODOP.ADD_PRINT_HTM("0mm", "5mm", "140mm", "200mm", strStyle + document.getElementById("prescription_table").innerHTML);
index++;
}
}
//中药处方
if (prescriptionDetailJson.zyPrescription != null && prescriptionDetailJson.zyPrescription.length > 0) {
var zyPrescription = prescriptionDetailJson.zyPrescription[0].detail;
if (zyPrescription != null && zyPrescription.length > 0) {
var html = "";
for (var i = 0; i < zyPrescription.length; i++) {
if (i % 2 == 0) {
html += "
";
}
html += "
";
html += zyPrescription[i].name;
html += zyPrescription[i].quantity + "g";
if (zyPrescription[i].instructionText != null) {
html += "[" + zyPrescription[i].instructionText + "]";
}
if (i % 2 == 1) {
html += "
";
} else {
html += "";
}
}
if (zyPrescription.length % 2 != 0) {
html += "";
}
html += "
X " + prescriptionDetailJson.zyPrescription[0].zyfs + "付
";
var cyMtjs = prescriptionDetailJson.zyPrescription[0].cyMtjs;
if (cyMtjs == null || cyMtjs == "null") {
cyMtjs = "";
}
var cyJssm = prescriptionDetailJson.zyPrescription[0].cyJssm;
if (cyJssm == null || cyJssm == "null") {
cyJssm = "";
}
var cyJsl = prescriptionDetailJson.zyPrescription[0].cyJsl;
if (cyJsl == null || cyJsl == "null") {
cyJsl = "";
}
var cyZql = prescriptionDetailJson.zyPrescription[0].cyZql;
if (cyZql == null || cyZql == "null") {
cyZql = "";
}
var cyFj = prescriptionDetailJson.zyPrescription[0].cyFj;
if (cyFj == null || cyFj == "null") {
cyFj = "";
}
var cyFfcs = prescriptionDetailJson.zyPrescription[0].cyFfcs;
if (cyFfcs == null || cyFfcs == "null") {
cyFfcs = "";
}
var cyFysm = prescriptionDetailJson.zyPrescription[0].cyFysm;
if (cyFysm == null || cyFysm == "null") {
cyFysm = "";
}
var cyDj = prescriptionDetailJson.zyPrescription[0].cyDj;
if (cyDj == null || cyDj == "null") {
cyDj = "";
} else {
cyDj = "(" + cyDj + ")";
}
html += "