require_once ('/var/www/vhosts/jamm-net.com/httpsdocs/init.php'); ?>
if( !isset( $_SESSION ) ) session_start();
require_once( '/var/www/vhosts/jamm-net.com/httpsdocs/DBClass.php' );
require_once( '/var/www/vhosts/jamm-net.com/httpsdocs/webdata/utility.php' );
function get_draw_detail( $type ){
$ret = "";
switch($type) {
case 'dis_medlist.php':
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db);
$sql_arr = get_dis_sql('dis_medlist',$_SESSION['PERIOD']);
///////////////////////////内用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist1.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist1.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( "
%s %s %s %s 関連内用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['target'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////注射開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist2.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist2.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s 関連注射薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['target'],LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////内用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist3.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist3.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s 関連外用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['target'],LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
$ret .= '';
$ret .= get_button_img('back','前のページに戻る');
$ret .= '';
break;
case 'dis_agespan.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_agespan.csv";
$csvname = $_SESSION['LOGINID']."_dis_agespan.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$sql_arr = get_dis_sql('dis_agespan',$_SESSION['PERIOD']);
$ret .= sprintf( " %s %s %s %s %s %s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['icd10'],$disp_arr['icdname'],$disp_arr['pattype']);
$ret .= '
';
$ret .= '';
break;
case 'dis_icd_combination.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_combination.csv";
$csvname = $_SESSION['LOGINID']."_dis_combination.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$sql_arr = get_dis_sql('dis_combination',$_SESSION['PERIOD']);
$ret .= sprintf( " %s %s %s %s %s %s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['icd10'],$disp_arr['icdname'],$disp_arr['pattype']);
$ret .= '
';
$ret .= '';
break;
case 'dis_combination.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_combination.csv";
$csvname = $_SESSION['LOGINID']."_dis_combination.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$sql_arr = get_dis_sql('dis_combination',$_SESSION['PERIOD']);
$ret .= sprintf( " %s %s %s %s %s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['target'],$disp_arr['pattype']);
$ret .= '
';
$ret .= '';
break;
case 'dis_icd_medlist.php':
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db);
$sql_arr = get_dis_sql('dis_medlist2',$_SESSION['PERIOD']);
///////////////////////////内用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist1.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist1.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 関連内用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['icd10'],$disp_arr['icdname'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////注射開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist2.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist2.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 関連注射薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['icd10'],$disp_arr['icdname'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////内用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_medlist3.csv";
$csvname = $_SESSION['LOGINID']."_dis_medlist3.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 関連外用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['icd10'],$disp_arr['icdname'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
$ret .= '';$ret .= get_button_img('back','前のページに戻る');
$ret .= '';
$db->Close();
break;
case 'dis_detail.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_detail.csv";
$csvname = $_SESSION['LOGINID']."_dis_detail.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$ret .= sprintf( " %s %s %s %s %s
",$disp_arr['period'],$disp_arr['datatype'],$disp_arr['visittype'],$disp_arr['target'],$disp_arr['pattype']);
$ret .= '
';
$ret .= '';
break;
case 'dis_result.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_dis_result.csv";
$csvname = $_SESSION['LOGINID']."_dis_result.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$ret .= sprintf( " %s %s %s %s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['listtype']);
$ret .= '
';
$ret .= '';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
break;
case 'med_agespan.php':
$db = new DB();
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_agespan.csv";
$csvname = $_SESSION['LOGINID']."_med_agespan.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$sql_arr = get_med_sql('med_agespan',$_SESSION['PERIOD']);
$ret .= sprintf( " %s %s %s %s %s 処方年齢層(5歳区切り)
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target']);
$ret .= '
';
$ret .= '';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
break;
case 'med_specific.php':
$db = new DB();
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_specific1.csv";
$csvname = $_SESSION['LOGINID']."_med_specific1.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db);
$sql_arr = get_med_sql('med_specific',$_SESSION['PERIOD']);
///////////////////////////////////////////Make Freq. List Start
$ret .= sprintf( " %s %s %s %s %s %s分布
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['medname'],$disp_arr['csv_freq']);
$ret .= '
';
$ret .= '
';
$db->FreeResult();
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////////////////////Make Freq. List End
///////////////////////////////////////////Make Qt. List Start
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_specific2.csv";
$csvname = $_SESSION['LOGINID']."_med_specific2.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 規格単位「%s」 処方量分布
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['medname'],$disp_arr['specunit']);
$ret .= '
';
$ret .= '';
$db->FreeResult();
///////////////////////////////////////////Make Qt. List End
$ret .= '';$ret .= get_button_img('back','前のページに戻る');
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
break;
case 'med_combination.php':
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db);
$sql_arr = get_med_sql('med_combination',$_SESSION['PERIOD']);
///////////////////////////内用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_combination1.csv";
$csvname = $_SESSION['LOGINID']."_med_combination1.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 内用併用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////内用終了
///////////////////////////注射開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_combination2.csv";
$csvname = $_SESSION['LOGINID']."_med_combination2.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 注射併用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////注射終了
///////////////////////////外用開始
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_combination3.csv";
$csvname = $_SESSION['LOGINID']."_med_combination3.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 外用併用薬剤 上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target'], LISTRANK);
$ret .= '
';
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////外用終了
$ret .= '';$ret .= get_button_img('back','前のページに戻る');
$ret .= '';
$db->Close();
break;
case 'med_dislist.php':
$db = new DB();
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_dislist.csv";
$csvname = $_SESSION['LOGINID']."_med_dislist.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db);
$sql_arr = get_med_sql('med_dislist',$_SESSION['PERIOD']);
///////////////////////////////////////////Make Disease List Start
$ret .= sprintf( " %s %s %s %s %s 関連傷病上位%s位
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target'],LISTRANK);
$ret .= '
';
$ret .= '';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
break;
case 'med_detail.php':
$db = new DB();
///対象名称取得
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
///////////////////////////////////////////Make Graph Start
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_detail1.csv";
$csvname = $_SESSION['LOGINID']."_med_detail1.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
if( $_SESSION['PERIOD'] > 9999 ){
$sql = sprintf("SELECT * FROM M_Period WHERE PeriodID<=%s ORDER BY PeriodID DESC LIMIT 12 ",$_SESSION['PERIOD']);
} else {
$sql = sprintf("SELECT * FROM M_Period WHERE PeriodID<=%s ORDER BY PeriodID DESC LIMIT 12 ",strval($_SESSION['PERIOD']+1)."03");
}
$result = $db->QueryEx( $sql );
$monthly_periodid = array();
$monthly_dispperiod = array();
$monthly_csvperiod = array();
$monthly_freq = array();
$max_freq = 0;
$db2 = new DB();
while ( $result ) {
$monthly_periodid[] = $result['PeriodID'];
$monthly_csvperiod[] = convert_sjis($result['DispPeriod']);
$monthly_dispperiod[] = sprintf("%s/%s",substr($result['PeriodID'],2,2),substr($result['PeriodID'],4,2));
$sql_arr = get_med_sql('med_detail1',$result['PeriodID']);
$ret = $db2->QueryEx($sql_arr[0]);
while ($ret) {
$monthly_freq[] = $ret['t_freq'];
if( $max_freq < $ret['t_freq'] ){
$max_freq = $ret['t_freq'];
}
$ret = $db2->QueryEx();
}
$db2->FreeResult();
$result = $db->QueryEx();
}
$db->FreeResult();
$db2->Close();
$ret .= sprintf( " %s %s %s %s %s %s月次推移グラフ%s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target'],$disp_arr['csv_freq'],$disp_arr['graphunit']);
$ret .= '
';
$ret .= '';
$csv_header = "年月,".$disp_arr['csv_freq']."\n";
fwrite($fp, $csv_header);
$cnt = count($monthly_periodid);
$bar_len = 0;
$td_num = ' | ';
$td_bar = '
| ';
$td_period = '
| ';
for ($i = $cnt ; $i < 12 ; $i++) {
$td_period .= ' | ';
$td_num .= ' | ';
$td_bar .= ' | ';
}
for ($i = $cnt-1 ; $i >= 0 ; $i--) {
$bar_len = sprintf("%.1f",$monthly_freq[$i]/$max_freq*350);
$td_period .= ''.$monthly_dispperiod[$i]." | ";
$tmp_freq = get_disp_num($monthly_freq[$i]);
$html_freq = "";
for ( $j = 0 ; $j < strlen($tmp_freq) ; $j++ ){
if( $j < strlen($tmp_freq)-1 ){
if( substr($tmp_freq,$j,1)=="," || substr($tmp_freq,$j,1)=="." ){
$html_freq .= ''.substr($tmp_freq,$j,1).'
';
}else{
$html_freq .= substr($tmp_freq,$j,1).'
';
}
}else{
$html_freq .= substr($tmp_freq,$j,1);
}
}
$td_bar.= "$html_freq | ";
$td_num .= ''.$tmp_freq.' | ';
$csv_data = sprintf("%s,%d\n",$monthly_csvperiod[$i],$monthly_freq[$i]);
fwrite($fp, $csv_data);
}
$td_num .= "
";
$td_bar .= "";
$td_period .= "";
///$ret .= $td_num;
$ret .= $td_bar;
$ret .= $td_period;
$ret .= '
';
flock($fp, LOCK_UN);
fclose( $fp );
///////////////////////////////////////////Make Graph End
///////////////////////////////////////////List a Breakdown Start
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_detail2.csv";
$csvname = $_SESSION['LOGINID']."_med_detail2.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$ret .= sprintf( " %s %s %s %s %s 内訳
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['medtype'],$disp_arr['target']);
$ret .= '
';
$ret .= "';
break;
case 'med_result.php':
$csvfile = CSV_DIR.$_SESSION['LOGINID']."_med_result.csv";
$csvname = $_SESSION['LOGINID']."_med_result.csv";
$fp = fopen( $csvfile, "w" );
flock($fp, LOCK_EX);
$db = new DB();
$disp_arr = get_disp_array( $_SESSION['PERIOD'], $_SESSION['LISTTOP'], $db );
$ret .= sprintf( " %s %s %s %s %s %s %s
",$disp_arr['period'],$disp_arr['visittype'],$disp_arr['datatype'],$disp_arr['listtype'],$disp_arr['medtype'],$disp_arr['87cd'],$disp_arr['listtop']);
$ret .= '
';
$ret .= "';
flock($fp, LOCK_UN);
fclose( $fp );
$db->Close();
break;
default :
break;
}
return $ret;
}
?>
Output has already been sent to the browser at /var/www/vhosts/jamm-net.com/httpsdocs/webdata/detail_data.php:1763.
Please make sure the command $xajax->processRequest() is placed before this.