测试,优化

master
zengwh 4 years ago
parent f1c6987483
commit fc5e4a88bb

@ -852,8 +852,8 @@
$(".modal-dialog").draggable();//为模态对话框添加拖拽
})
</script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/searchCommomMethodqf.js"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/commomSearch/commomListqf.js?t=1"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/searchCommomMethodqf.js?time=2021-11-28"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/commomSearch/commomListqf.js?time=2021-11-28"></script>
<script type="text/javascript" src="${path}/static/js/dateUtil.js"></script>
<script type="text/javascript" src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js"></script>
<script type="text/javascript" src="${path}/static/js/commom.js"></script>

@ -180,7 +180,6 @@
<input type="hidden" id="showPrint" value="${CURRENT_USER.userAge}">
<input type="hidden" id="flag" value="file_path">
<input type="hidden" id="powerMenus" value="${power_menus}">
<input type="hidden" id="orderBys">
<input type="hidden" id="approves">
<!--该用户下载申请的审批过了且未过期的病案不可重复申请可查看的病案主键patientId-->
<input type="hidden" id="loads">
@ -189,6 +188,10 @@
<input type="hidden" id="tableThNames">
<input type="hidden" id="fields" value="${fields}">
<input type="hidden" id="fieldCns" value="${fieldCns}">
<input id="englishFields" hidden>
<input id="fromTableSql" hidden>
<input id="whereSql" hidden>
<input type="hidden" id="orderBys" value=" order by commomtable.name">
<!--查询总行数-->
<input type="hidden" id="rows">
<div class="row btns" style="clear:both;text-align: right">
@ -314,8 +317,8 @@
$(".modal-dialog").draggable();//为模态对话框添加拖拽
})
</script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/customSearchIframeqf.js"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/searchCommomMethodqf.js?time=2020-02-14"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/searchCommomMethodqf.js?time=2021-11-28"></script>
<script type="text/javascript" src="${path}/static/js/recordManage/templateSearch/customSearchIframeqf.js?time=2021-11-28"></script>
<script type="text/javascript" src="${path}/static/js/dateUtil.js"></script>
<script type="text/javascript" src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js"></script>
</body>

@ -30,6 +30,221 @@ var date_format= /^(\d{4})-(0\d{1}|1[0-2])-(0\d{1}|[12]\d{1}|3[01])$/;
var commomtable = 'commomtable';
//拼接sql
function getSql() {
//表头集合
var tableThNames = '';
//select语句字符串
var selectNames = '';
//from语句字符串
var fromTableNames = '';
//数据字典转换语句
var dictionaryConvertStr = '';
//on语句字符串
var onNames = '';
//公共表名
var basicTable = '';
//查询字段数组
var selectArray = new Array();
var array = new Array();
//选中个数
var checks = 0;
//拼接显示字段
$("input[class=check]").each(function () {
//拼接表头集合
tableThNames += $(this).next('span').text() + ",";
var val = $(this).val();
//添加不重复的表名
if ($.inArray(val.split(".")[0], array) < 0) {
if (val.split(".")[0] != commomtable) {
array.push(val.split(".")[0]);
}
}
//转换数据字典
if (val == 't_diag.dis_thing') {
//转归情况
val = 't_dictionary_1.NAME AS dis_thing';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_1 ON dbo.t_diag.dis_thing = t_dictionary_1.CODE AND t_dictionary_1.parent_id = 'dis_diag_status'";
}
if (val == 't_operate.operate_class') {
//手术级别
val = 't_dictionary_2.NAME AS operate_class';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_2 ON t_operate.operate_class = t_dictionary_2.CODE AND t_dictionary_2.parent_id = 'operate_class'";
}
if (val == 't_operate.cut') {
//切口愈合等级
val = 't_dictionary_3.NAME AS cut';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_3 ON t_operate.cut = t_dictionary_3.CODE AND t_dictionary_3.parent_id = 'cut_heal_grade'";
}
if (val == 't_operate.anaesthesia_type') {
//麻醉方式
val = 't_dictionary_4.NAME AS anaesthesia_type';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_4 ON t_operate.anaesthesia_type = t_dictionary_4.CODE AND t_dictionary_4.parent_id = 'anaesthesia'";
}
/*if (val == 't_operate.ChosSurg') {
//是否择期手术
val = 't_dictionary_5.NAME AS chossurg';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_5 ON t_operate.ChosSurg = t_dictionary_5.CODE AND t_dictionary_5.parent_id = 'whether'";
}*/
if (val == 't_baby.babySex') {
//婴儿性别
val = 't_dictionary_6.NAME AS babySex';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_6 ON t_baby.sex = t_dictionary_6.CODE AND t_dictionary_6.parent_id = 'sex_code'";
}
if (val == 't_baby.childbirth_mothed') {
//分娩结果
val = 't_dictionary_7.NAME AS childbirthMothed';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_7 ON t_baby.childbirth_mothed = t_dictionary_7.CODE AND t_dictionary_7.parent_id = 'childbirthResult_code'";
}
if (val == 't_baby.diag_type') {
//婴儿转归
val = 't_dictionary_8.NAME AS diagType';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_8 ON t_baby.diag_type = t_dictionary_8.CODE AND t_dictionary_8.parent_id = 'childStatus_code'";
}
if (val == 't_baby.breathing') {
//婴儿呼吸
val = 't_dictionary_9.NAME AS breathing';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_9 ON t_baby.breathing = t_dictionary_9.CODE AND t_dictionary_9.parent_id = 'breath_code'";
}
if (val == 't_diag.diag_type') {
//诊断类型
val = 't_dictionary_10.NAME AS diagType';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_10 ON t_diag.diag_type = t_dictionary_10.CODE AND t_dictionary_10.parent_id = 'dis_diag_type'";
}
if (push_unique(val, selectArray)){
selectArray.push(val);
}
if ($(this).is(':checked')) {
checks++;
}
})
//拼接select语句
for (var i = 0; i < selectArray.length; i++){
//拼接select语句
selectNames += selectArray[i] + ",";
}
//where语句字符串
var whereNames = ' where ';
//拼接条件前括号
for (var i = 0; i < checks; i++) {
whereNames += "(";
}
//多表查询的情况
if (array.length != 0) {
basicTable = commomtable + '.patient_id = ';
}
var age = '';
var age_month = '';
var age_day = '';
var inpatientNo = '';
$("#block").children().find('div').each(function () {
var val = $(this).children().val();
var className = $(this).children().attr('class');
if (className == 'select2') {
//like 的情况
var isLike = whereNames.substring(whereNames.length - 5, whereNames.length);
if (isLike == 'LIKE ') {
if (val.indexOf('*') != -1) {
whereNames += "'" + val.replace('*', '_') + "') ";
} else {
whereNames += "'%" + val + "%') ";
}
} else {
whereNames += "'" + val + "') ";
}
} else if (className == 'select21') {
//双选的情况
var select22Val = $(this).children().eq(2).val();
//删除前面等号
whereNames = whereNames.substring(0, whereNames.length - 3);
//验证时间格式
if (date_format.test(val)) {
val += ' 00:00:00';
select22Val += ' 23:59:59';
whereNames += "between '" + val + "' and '" + select22Val + "') ";
} else {
//数字
if(inpatientNo != '' && inpatientNo == commomtable+'.inpatient_no'){
whereNames += "between '" + val + "' and '" + select22Val + "'))";
} else if(age != '' && age == commomtable+'.age'){
whereNames += "between " + val + " and " + (select22Val-1) + " OR ("+commomtable+".age = "+select22Val+" AND "+commomtable+".age_month = 0 AND "+commomtable+".age_day = 0))) ";
}else if(age_month != '' && age_month == commomtable+'.age_month'){
whereNames += "between " + val + " and " + (select22Val-1) + " AND "+commomtable+".age = 0 OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+select22Val+" AND "+commomtable+".age_day = 0))) ";
}else if(age_day != '' && age_day == commomtable+'.age_day'){
whereNames += "between " + val + " and " + select22Val + " AND "+commomtable+".age = 0 AND "+commomtable+".age_month = 0)) ";
}else{
whereNames += "between " + val + " and " + select22Val + ") ";
}
}
} else {
//转换字段
if (val == 't_baby.babySex') {
val = 't_baby.sex';
}
if(val == commomtable+'.age'){
age = val;
whereNames += "(";
}
if(val == commomtable+'.age_month'){
age_month = val;
whereNames += "(";
}
if(val == commomtable+'.age_day'){
age_day = val;
whereNames += "(";
}
if (val == commomtable+'.inpatient_no') {
inpatientNo = val;
whereNames += "(";
}
if (val == 'and') {
age = '';
age_month = '';
age_day = '';
inpatientNo = '';
}
whereNames += val + ' ';
}
})
for (var i = 0; i < array.length; i++) {
//拼接from语句
if (array.length != 0) {
fromTableNames += ' left join ' + array[i] + " on " + basicTable + array[i] + ".patient_id"
//查询结果均是诊断手术第一条
if (array[i] == 't_diag') {
fromTableNames += ' and t_diag.diag_no = 1 ';
} else if (array[i] == 't_operate') {
fromTableNames += ' and t_operate.operate_no = 1 ';
}
}
}
//拼接转换字典关联表语句
if (array.length != 0) {
fromTableNames += dictionaryConvertStr;
}
selectNames = selectNames.substring(0, selectNames.length - 1);
$("#tableThNames").val(tableThNames);
$("#englishFields").val(selectNames);
$("#fromTableSql").val(fromTableNames);
if (tableThNames != '') {
var fieldCns = '';
var fields = $("#fields").val().split(",");
tableThNames = tableThNames.split(",");
for (var i = 0; i < tableThNames.length; i++) {
if (fields[i] != '') {
//重新组织选项
//转换RH
if (fields[i] == 'RH') {
fields[i] = 'rh';
}
/*if (fields[i] == 'ChosSurg') {
fields[i] = 'chossurg';
}*/
fieldCns += fields[i] + ",";
}
}
$("#fieldCns").val(fieldCns);
}
var blockVal = $("#block").text();
if($.trim(blockVal) != '') {
//搜索框值不能为空
@ -40,244 +255,9 @@ function getSql() {
return false;
}
})
if(!flag){
$("#sql").val("");
}else {
//表头集合
var tableThNames = '';
//select语句字符串
var selectNames = 'select ' + commomtable + '.patient_id,CASE WHEN emr_apply_approve.id is null THEN 0 ELSE 1 END isShowDetail,CASE WHEN emr_apply_approve1.id IS NULL THEN 0 ELSE 1 END isDownload,CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus,';
//from语句字符串
var fromTableNames = ' from ';
//数据字典转换语句
var dictionaryConvertStr = '';
//on语句字符串
var onNames = '';
//公共表名
var basicTable = '';
//查询字段数组
var selectArray = new Array();
var array = new Array();
//选中个数
var checks = 0;
//拼接显示字段
$("input[class=check]").each(function () {
//拼接表头集合
tableThNames += $(this).next('span').text() + ",";
var val = $(this).val();
//添加不重复的表名
if ($.inArray(val.split(".")[0], array) < 0) {
if (val.split(".")[0] != commomtable) {
array.push(val.split(".")[0]);
}
}
//转换数据字典
if (val == 't_diag.dis_thing') {
//转归情况
val = 't_dictionary_1.NAME AS dis_thing';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_1 ON dbo.t_diag.dis_thing = t_dictionary_1.CODE AND t_dictionary_1.parent_id = 'dis_diag_status'";
}
if (val == 't_operate.operate_class') {
//手术级别
val = 't_dictionary_2.NAME AS operate_class';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_2 ON t_operate.operate_class = t_dictionary_2.CODE AND t_dictionary_2.parent_id = 'operate_class'";
}
if (val == 't_operate.cut') {
//切口愈合等级
val = 't_dictionary_3.NAME AS cut';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_3 ON t_operate.cut = t_dictionary_3.CODE AND t_dictionary_3.parent_id = 'cut_heal_grade'";
}
if (val == 't_operate.anaesthesia_type') {
//麻醉方式
val = 't_dictionary_4.NAME AS anaesthesia_type';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_4 ON t_operate.anaesthesia_type = t_dictionary_4.CODE AND t_dictionary_4.parent_id = 'anaesthesia'";
}
/*if (val == 't_operate.ChosSurg') {
//是否择期手术
val = 't_dictionary_5.NAME AS chossurg';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_5 ON t_operate.ChosSurg = t_dictionary_5.CODE AND t_dictionary_5.parent_id = 'whether'";
}*/
if (val == 't_baby.babySex') {
//婴儿性别
val = 't_dictionary_6.NAME AS babySex';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_6 ON t_baby.sex = t_dictionary_6.CODE AND t_dictionary_6.parent_id = 'sex_code'";
}
if (val == 't_baby.childbirth_mothed') {
//分娩结果
val = 't_dictionary_7.NAME AS childbirthMothed';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_7 ON t_baby.childbirth_mothed = t_dictionary_7.CODE AND t_dictionary_7.parent_id = 'childbirthResult_code'";
}
if (val == 't_baby.diag_type') {
//婴儿转归
val = 't_dictionary_8.NAME AS diagType';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_8 ON t_baby.diag_type = t_dictionary_8.CODE AND t_dictionary_8.parent_id = 'childStatus_code'";
}
if (val == 't_baby.breathing') {
//婴儿呼吸
val = 't_dictionary_9.NAME AS breathing';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_9 ON t_baby.breathing = t_dictionary_9.CODE AND t_dictionary_9.parent_id = 'breath_code'";
}
if (val == 't_diag.diag_type') {
//诊断类型
val = 't_dictionary_10.NAME AS diagType';
dictionaryConvertStr += " LEFT JOIN dbo.emr_dictionary AS t_dictionary_10 ON t_diag.diag_type = t_dictionary_10.CODE AND t_dictionary_10.parent_id = 'dis_diag_type'";
}
if (push_unique(val, selectArray)){
selectArray.push(val);
}
if ($(this).is(':checked')) {
checks++;
}
})
//拼接select语句
for (var i = 0; i < selectArray.length; i++){
//拼接select语句
selectNames += selectArray[i] + ",";
}
//where语句字符串
var whereNames = ' where ';
//拼接条件前括号
for (var i = 0; i < checks; i++) {
whereNames += "(";
}
//多表查询的情况
if (array.length != 0) {
basicTable = commomtable + '.patient_id = ';
}
//单表
fromTableNames += commomtable;
var age = '';
var age_month = '';
var age_day = '';
var inpatientNo = '';
$("#block").children().find('div').each(function () {
var val = $(this).children().val();
var className = $(this).children().attr('class');
if (className == 'select2') {
//like 的情况
var isLike = whereNames.substring(whereNames.length - 5, whereNames.length);
if (isLike == 'LIKE ') {
if (val.indexOf('*') != -1) {
whereNames += "'" + val.replace('*', '_') + "') ";
} else {
whereNames += "'%" + val + "%') ";
}
} else {
whereNames += "'" + val + "') ";
}
} else if (className == 'select21') {
//双选的情况
var select22Val = $(this).children().eq(2).val();
//删除前面等号
whereNames = whereNames.substring(0, whereNames.length - 3);
//验证时间格式
if (date_format.test(val)) {
val += ' 00:00:00';
select22Val += ' 23:59:59';
whereNames += "between '" + val + "' and '" + select22Val + "') ";
} else {
//数字
if(inpatientNo != '' && inpatientNo == commomtable+'.inpatient_no'){
whereNames += "between '" + val + "' and '" + select22Val + "'))";
} else if(age != '' && age == commomtable+'.age'){
whereNames += "between " + val + " and " + (select22Val-1) + " OR ("+commomtable+".age = "+select22Val+" AND "+commomtable+".age_month = 0 AND "+commomtable+".age_day = 0))) ";
}else if(age_month != '' && age_month == commomtable+'.age_month'){
whereNames += "between " + val + " and " + (select22Val-1) + " AND "+commomtable+".age = 0 OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+select22Val+" AND "+commomtable+".age_day = 0))) ";
}else if(age_day != '' && age_day == commomtable+'.age_day'){
whereNames += "between " + val + " and " + select22Val + " AND "+commomtable+".age = 0 AND "+commomtable+".age_month = 0)) ";
}else{
whereNames += "between " + val + " and " + select22Val + ") ";
}
}
} else {
//转换字段
if (val == 't_baby.babySex') {
val = 't_baby.sex';
}
if(val == commomtable+'.age'){
age = val;
whereNames += "(";
}
if(val == commomtable+'.age_month'){
age_month = val;
whereNames += "(";
}
if(val == commomtable+'.age_day'){
age_day = val;
whereNames += "(";
}
if (val == commomtable+'.inpatient_no') {
inpatientNo = val;
whereNames += "(";
}
if (val == 'and') {
age = '';
age_month = '';
age_day = '';
inpatientNo = '';
}
whereNames += val + ' ';
}
})
var userName = "'" +$("#userId").val()+ "'";
fromTableNames += ' left join emr_apply_approve on ' + commomtable + '.patient_id = emr_apply_approve.patient_id \n' +
'and emr_apply_approve.approve_state = 1 and emr_apply_approve.effe_time > GETDATE()-1 and emr_apply_approve.applyer = '+ userName +' and emr_apply_approve.apply_type != 3 ' +
' left join emr_apply_approve emr_apply_approve1 on ' + commomtable + '.patient_id = emr_apply_approve1.patient_id \n' +
'and emr_apply_approve1.approve_state = 1 and emr_apply_approve1.effe_time > GETDATE()-1 and emr_apply_approve1.applyer = '+ userName +' and emr_apply_approve1.apply_type = 3'+
' left join emr_lock on ' + commomtable + '.patient_id = emr_lock.patient_id and emr_lock.lock_state = 1';
for (var i = 0; i < array.length; i++) {
//拼接from语句
if (array.length != 0) {
fromTableNames += ' left join ' + array[i] + " on " + basicTable + array[i] + ".patient_id"
//查询结果均是诊断手术第一条
if (array[i] == 't_diag') {
fromTableNames += ' and t_diag.diag_no = 1 ';
} else if (array[i] == 't_operate') {
fromTableNames += ' and t_operate.operate_no = 1 ';
}
}
}
//拼接转换字典关联表语句
if (array.length != 0) {
fromTableNames += dictionaryConvertStr;
}
selectNames = selectNames.substring(0, selectNames.length - 1);
//console.log(dictionaryConvertStr)
//console.log(tableThNames)
//console.log(selectNames);
//console.log(fromTableNames);
//console.log(onNames);
//console.log(whereNames);
var orderBys = " order by " + commomtable + ".inpatient_no," + commomtable + ".admiss_times";
var sql = selectNames + fromTableNames + whereNames;
$("#orderBys").val(orderBys);
$("#sql").val(sql);
//console.log("sql = " + $("#sql").val());
//console.log(sql);
$("#tableThNames").val(tableThNames);
if (tableThNames != '') {
var fieldCns = '';
var fields = $("#fields").val().split(",");
tableThNames = tableThNames.split(",");
for (var i = 0; i < tableThNames.length; i++) {
if (fields[i] != '') {
//重新组织选项
//转换RH
if (fields[i] == 'RH') {
fields[i] = 'rh';
}
/*if (fields[i] == 'ChosSurg') {
fields[i] = 'chossurg';
}*/
fieldCns += fields[i] + ",";
}
}
$("#fieldCns").val(fieldCns);
}
if(flag){
$("#whereSql").val(whereNames);
}
}else{
$("#sql").val("");
}
}
@ -318,58 +298,6 @@ function search(){
toastr.warning("搜索条件不能为空!");
}
}
//导出excel功能
function exportExcel(){
var blockVal = $("#block").text();
if($.trim(blockVal) != ''){
//搜索框值不能为空
var flag = true;
$("#block").children().find('[class=inputDiv]').find('input').each(function(){
if($(this).val() == ''){
flag = false;
return false;
}
})
if(!flag){
toastr.warning("不能为空值,如不需要请取消选项!");
}else{
getSql();
var checks = $("#checks").val();
var sql = $("#sql").val();
var reg = new RegExp("%","g");//g,表示全部替换。
sql = sql.replace(reg,'%25');
var tableThNames = $("#tableThNames").val();
var fieldCns = $("#fieldCns").val();
var orderBys = $("#orderBys").val();
if(checks != '' ){
//按选择框选择导出
checks = checks.substring(0,checks.length - 1);
sql += ' AND '+commomtable+'.patient_id IN ('+checks+')';
sql += orderBys;
var url = path + "/template/exportExcel";
post(url,{"sql":sql,"tableThNames":tableThNames,"fieldCns":fieldCns});
}else {
if ($("#rows").val() > 5000) {
toastr.warning("数据量大,暂提供5000条以内数据导出!");
} else {
Common.confirm({
title: "提示",
message: "没有选中,您确定要按搜索栏条件导出?",
operate: function (reselt) {
if (reselt) {
sql += orderBys;
var url = path + "/template/exportExcel";
post(url, {"sql": sql, "tableThNames": tableThNames, "fieldCns": fieldCns});
}
}
})
}
}
}
}else{
toastr.warning("搜索条件不能为空!");
}
}
//查看详情
function showDetail(patientId){
//隐藏模板选项

@ -298,6 +298,7 @@ function exportExcel() {
if ($("#rows").val() > 5000 && checks == '') {
toastr.warning("数据量大,暂提供5000条以内数据导出!");
} else {
getSql();
var tableThNames = $("#tableThNames").val();
var fieldCns = $("#fieldCns").val();
if (checks != '') {
@ -305,9 +306,8 @@ function exportExcel() {
checks = checks.substring(0, checks.length - 1);
var whereSql = ' WHERE ' + commomtable + '.patient_id IN (' + checks + ')';
var url = path + "/template/exportExcel";
post(url, {"selectSql": $("#englishFields").val(),"whereSql":whereSql,"tableThNames": tableThNames, "fieldCns": fieldCns});
post(url, {"selectSql": $("#englishFields").val(),"fromTableSql":$("#fromTableSql").val(),"whereSql":whereSql,"tableThNames": tableThNames,orderBys:$("#orderBys").val(), "fieldCns": fieldCns});
} else {
getSql();
Common.confirm({
title: "提示",
message: "没有选中,您确定要按搜索栏条件导出?",

Loading…
Cancel
Save