StringinitSelectSql="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";
if(StringUtils.isNotBlank(selectSql)){
initSelectSql+=","+selectSql;
}
StringinitFromTableSql=" from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id 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 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 ";
@ -249,11 +249,8 @@ var commomtable1 = 'commomtable1';
functiongetSql(){
functiongetSql(){
varinputValue=getInputValue();
varinputValue=getInputValue();
if(inputValue!=''){
if(inputValue!=''){
//select语句字符串
varselectNames='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,';
selectNames+=$("#englishFields").val();
//from语句字符串
//from语句字符串
varfromTableNames=' from ';
varfromTableNames='';
//where语句字符串
//where语句字符串
varwhereNames=' where ';
varwhereNames=' where ';
//判断是否多表
//判断是否多表
@ -264,8 +261,6 @@ function getSql() {
returnfalse;
returnfalse;
}
}
})
})
//单表
fromTableNames+=commomtable;
//拼接where语句
//拼接where语句
varname='';
varname='';
//姓名
//姓名
@ -334,6 +329,8 @@ function getSql() {
whereNames+="("+commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+($("#age2").val()-1)+" or ("+commomtable+"."+name+"="+$("#age2").val()+" and "+commomtable+".age_month=0 and "+commomtable+".age_day=0)) AND ";
whereNames+="("+commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+($("#age2").val()-1)+" or ("+commomtable+"."+name+"="+$("#age2").val()+" and "+commomtable+".age_month=0 and "+commomtable+".age_day=0)) AND ";
}elseif($("#age2").val()<$("#age1").val()){
}elseif($("#age2").val()<$("#age1").val()){
whereNames+="("+commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+($("#age1").val()-1)+" or ("+commomtable+"."+name+"="+$("#age1").val()+" and "+commomtable+".age_month=0 and "+commomtable+".age_day=0)) AND ";
whereNames+="("+commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+($("#age1").val()-1)+" or ("+commomtable+"."+name+"="+$("#age1").val()+" and "+commomtable+".age_month=0 and "+commomtable+".age_day=0)) AND ";
}elseif($("#age1").val()==$("#age2").val()){
whereNames+="("+commomtable+"."+name+" = "+$("#age1").val()+" and "+commomtable+".age_month=0 and "+commomtable+".age_day=0) AND ";
}
}
}elseif(ageType=='2'){
}elseif(ageType=='2'){
//周
//周
@ -342,16 +339,21 @@ function getSql() {
whereNames+="("+'age = 0 AND '+commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+($("#age2").val()-1)+" OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+$("#age2").val()+" AND "+commomtable+".age_day = 0)) AND ";
whereNames+="("+'age = 0 AND '+commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+($("#age2").val()-1)+" OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+$("#age2").val()+" AND "+commomtable+".age_day = 0)) AND ";
}elseif($("#age2").val()<$("#age1").val()){
}elseif($("#age2").val()<$("#age1").val()){
whereNames+="("+'age = 0 AND '+commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+($("#age1").val()-1)+" OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+$("#age1").val()+" AND "+commomtable+".age_day = 0)) AND ";
whereNames+="("+'age = 0 AND '+commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+($("#age1").val()-1)+" OR ("+commomtable+".age = 0 AND "+commomtable+".age_month = "+$("#age1").val()+" AND "+commomtable+".age_day = 0)) AND ";
}elseif($("#age1").val()==$("#age2").val()){
whereNames+="("+commomtable+"."+name+" = "+$("#age1").val()+" and "+commomtable+".age=0 and "+commomtable+".age_day=0) AND ";
}
}
}elseif(ageType=='3'){
}elseif(ageType=='3'){
//天
//天
name='age_day';
name='age_day';
whereNames+='(age = 0 AND age_month = 0 AND ';
if($("#age1").val()<$("#age2").val()){
if($("#age1").val()<$("#age2").val()){
whereNames+=commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+$("#age2").val()+" AND ";
whereNames+=commomtable+"."+name+" BETWEEN "+$("#age1").val()+" AND "+$("#age2").val()+" AND ";
}elseif($("#age2").val()<$("#age1").val()){
}elseif($("#age2").val()<$("#age1").val()){
whereNames+=commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+$("#age1").val()+" AND ";
whereNames+=commomtable+"."+name+" BETWEEN "+$("#age2").val()+" AND "+$("#age1").val()+" AND ";
varinitSql="select commomtable.patient_id,CASE WHEN emr_apply_approve.id is null THEN 0 ELSE 1 END isShowDetail,CASE\n"+
/*
"WHEN emr_apply_approve1.id IS NULL THEN\n"+
varinitSql="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,commomtable.inpatient_no,commomtable.admiss_id,commomtable.admiss_times,commomtable.name,commomtable.sex,commomtable.age,commomtable.age_month,commomtable.home_addr,commomtable.admiss_date,commomtable.dis_date,commomtable.dis_dept,commomtable.main_diag_code,commomtable.main_diag_name,commomtable.main_dis_thing,commomtable.admiss_days,commomtable.attending,commomtable.other_diag_name,commomtable.pathology_name,commomtable.poisoning_name,commomtable.is_oper from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id 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 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 ";
"\t0\n"+
*/
"ELSE\n"+
"\t1\n"+
"END isDownload,CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus,commomtable.inpatient_no,commomtable.admiss_id,commomtable.admiss_times,commomtable.name,commomtable.sex,commomtable.age,commomtable.age_month,commomtable.home_addr,commomtable.admiss_date,commomtable.dis_date,commomtable.dis_dept,commomtable.main_diag_code,commomtable.main_diag_name,commomtable.main_dis_thing,commomtable.admiss_days,commomtable.attending,commomtable.other_diag_name,commomtable.pathology_name,commomtable.poisoning_name,commomtable.is_oper from commomtable left join emr_apply_approve on commomtable.patient_id = emr_apply_approve.patient_id 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 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 ";