function playSound(fname){const sound=new Audio();sound.src='/fukuro2026/audio/'+fname;sound.play().catch(function(error){console.log('Error attempting to play the video:',error);});} function playSoundForQuery(val){let fname='';if(val==='ふくろ'||val==='ふくろくん'){fname='fukurokun_yonda.wav';}if(fname){playSound(fname);}} function playSoundEasy(){let fname='fukurokun_desu.wav';const rand=Math.floor(Math.random()*10);if(rand < 3){const now=new Date();const hour=now.getHours();if(hour >= 6&&hour <= 8){fname='fukurokun_ohayo.wav';}else if(hour===12){fname='fukurokun_onakasuita.wav';}else if(hour >= 21&&hour <= 23){fname='fukurokun_nemui.wav';}}playSound(fname);} function onloadWithUrlParams(){query_coef='';query_surcharge='';query_los='';query_dpccode='';query_dpc0code='';query_byomei='';query_icd10='';if(query_coef) document.getElementById('coef').value=query_coef;if(query_surcharge) document.getElementById('surcharge').value=query_surcharge;if(query_los) document.getElementById('los').value=query_los;if(query_dpccode){queryDPCcode(query_dpccode);playSoundEasy();}if(query_byomei) queryByomeiOne(query_byomei);if(query_icd10) findICD10(query_icd10);const fig0_sel_index='';if(fig0_sel_index!==''){ssi('fig0_sel',parseInt(fig0_sel_index,10));}} appendOnload(onloadWithUrlParams); function createHttpRequest(){let xmlhttp=null;if(window.ActiveXObject){try {xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');} catch (e){try {xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');} catch (e2){}}}else if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else {}if(xmlhttp===null){alert('Giving up :(Cannot create an XMLHTTP instance ).');}return xmlhttp;} function sendRequest(xmlhttp,method,url,async,callback,domid,more_param){if(more_param==null) more_param=null;const ua=navigator.userAgent;const safari=ua.indexOf('Safari')!==-1;let a=navigator.userAgent.split('Gecko/')[1];const mozes=(a?a.split(' ')[0]:0) >= 20011128;if(window.opera||safari||mozes){xmlhttp.onload=function (){callback(xmlhttp,domid,more_param);};}else {xmlhttp.onreadystatechange=function (){if(xmlhttp.readyState===4){if(xmlhttp.status===200 ||'Web'==='Win'&&xmlhttp.status===0){callback(xmlhttp,domid,more_param);}else {alert('There was a problem with the request.');}}};}xmlhttp.open(method,url,async);xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp.send(null);} function g(domId){return document.getElementById(domId).value;} function s(domId,value){document.getElementById(domId).value=value;} function setDisplay(domId,display){document.getElementById(domId).style.display=display;} function setVisibility(domId,visibility){document.getElementById(domId).style.visibility=visibility;} function isVisible(domId){return document.getElementById(domId).style.visibility!=='hidden';} function setInnerHTML(domId,innerHTML){document.getElementById(domId).innerHTML=innerHTML;} function getSelectedOption(domId){const dom=document.getElementById(domId);return dom.options[dom.selectedIndex];} function getOption(domId,selectedIndex){return document.getElementById(domId).options[selectedIndex];} function getSelectedIndex(domId){return document.getElementById(domId).selectedIndex;} function setSelectedIndex(domId,selectedIndex){return document.getElementById(domId).selectedIndex=selectedIndex;} let freeword_t=0; let prev_freeword=''; let misc_types=['④手術・処置等1','⑤手術・処置等2','⑥副傷病','⑦重症度等']; let pstype_labels={ffs: '出来高評価',pps: '包括評価',ccp: 'CCPマトリクス',drg: '短期滞在'}; let note_types=['icd','ff1','cdg','gigi','drg','adv','rece','compli']; if('Web'==='Win') note_types=note_types.filter(type => type!=='rece'); let note_titles={icd: '部位不明・詳細不明ICD10コード(2026年)',ff1: '様式1への記載が必要な項目(2026年)',cdg: 'DPC/PDPS傷病名コーディングテキスト(2026年)',gigi: '疑義解釈Q&A(2026年)',drg: '短期滞在手術等基本料3の対象手術・検査',adv: '包括評価対象外になる先進手術・高額薬剤(2026年)',rece: '手術・処置等に該当するレセプト項目',compli: '副傷病に該当するICD10コード',misc: 'メッセージ'}; let note_pdfs={icd: '',ff1: '',cdg: '',gigi: '',drg: '',adv: '',rece: '',compli: ''}; let note_attentions={rece: '※girasol社にてまとめた主なレセプト項目です。
分岐に該当するか否かを機械的に判断できない場合(例えば化学療法薬については抗腫瘍目的であるか等)があることをご了解下さい。'}; let query_dpccode=''; let query_dpc0code=''; let query_coef=null; let query_surcharge=null; let query_los=null; let query_byomei=null; function getWinXOffset(){if(window.scrollX){return window.scrollX;}if(window.pageXOffset){return window.pageXOffset;}if(document.documentElement&&document.documentElement.scrollLeft){return document.documentElement.scrollLeft;}else if(document.body&&document.body.scrollLeft){return document.body.scrollLeft;}else {return 0;}} function getWinYOffset(){if(window.scrollY){return window.scrollY;}if(window.pageYOffset){return window.pageYOffset;}if(document.documentElement&&document.documentElement.scrollTop){return document.documentElement.scrollTop;}else if(document.body&&document.body.scrollTop){return document.body.scrollTop;}else {return 0;}} function clearAll(){prev_freeword='';s('freeword','( DPC6桁やICD10や病名、分岐に関わる手技や薬剤を「コード」または「名称」で検索できます )');s('disease_info','');setInnerHTML('byomei_info','');s('icd10_info','');s('mdc6_info','');s('icd10raw','');s('disease','');s('icd10','');s('icd10_name','');s('mdc6','');s('mdc6_name','');setDisplay('mdc_info_disease','none');setDisplay('mdc_info_byomei','none');setDisplay('ccp_list','none');setDisplay('icd10_list','none');setDisplay('disease_list','none');setDisplay('compli_list','none');clearCondOptions();clearSeri1Options();clearOpeOptions();clearMiscAll();renderFieldMenu();hideCandidates();clearDpcInfo();clearRelated();contentsChanged();} function clearAllExceptFreeword(){s('disease_info','');setInnerHTML('byomei_info','');s('icd10_info','');s('mdc6_info','');s('icd10raw','');s('disease','');s('icd10','');s('icd10_name','');s('mdc6','');s('mdc6_name','');setDisplay('ccp_list','none');setDisplay('icd10_list','none');setDisplay('disease_list','none');setDisplay('compli_list','none');clearCondOptions();clearSeri1Options();clearOpeOptions();clearMiscAll();renderFieldMenu();hideCandidates();clearDpcInfo();clearRelated();contentsChanged();} function clearDpcOptions(){clearCondOptions();clearSeri1Options();clearOpeOptions();clearMiscAll();renderFieldMenu();hideCandidates();clearDpcInfo();contentsChanged();} function onFocusFreeword(){let elem=document.getElementById('freeword');if(elem.value==='( DPC6桁やICD10や病名、分岐に関わる手技や薬剤を「コード」または「名称」で検索できます )'){elem.value='';}else if(true){elem.setSelectionRange(0,10000);}else {elem.select();}if(!isSearchMainGoing()){hideCandidates();}} function onKeyUpFreeword(e,type){if(e&&e.keyCode&&e.keyCode===13){if(g('freeword')===prev_freeword){if(isSearchMainGoing()){const pd=document.getElementById('candidates_pd');if(pd&&pd.options.length===1){pd.selectedIndex=0;pd.dispatchEvent(new Event('change',{bubbles: false,cancelable: false}));return false;}}}queryFreeword(type);return false;}if(g('freeword').length >= 2){setTimeout(function (){const date=new Date();if(date.getTime()-freeword_t>800-20){queryFreeword(type);}},800);}const date=new Date();freeword_t=date.getTime();} function queryFreeword(type){query_dpccode='';query_dpc0code='';let val=g('freeword');let val_trim=val.replace(/^[\s ]+/g,'');val_trim=val_trim.replace(/[\s ]$/g,'');if(val_trim!==val){s('freeword',val_trim);val=val_trim;}if(true){ playSoundForQuery(val);}prev_freeword=val;if(val.length===0||(val.length===1&&escape(val)===val)||val==='( DPC6桁やICD10や病名、分岐に関わる手技や薬剤を「コード」または「名称」で検索できます )'){hideCandidates();return;}if(val.match(/^[0-90-9][0-9X0-9X]+$/i)||val.match(/^[0-90-9][0-9X0-9X]{6}[0-9A-Z0-9A-Z]+$/i)||val.match(/^[A-ZA-Z][0-90-9]+$/i)){let val_hankaku=val.replace(/[A-Z0-9]/ig,function (s){return String.fromCharCode(s.charCodeAt(0)-0xFEE0)});if(val_hankaku!==val){val=val_hankaku;}}if(!type&&isVisible('candidates')){let arr=['disease','icd10','mdc6'];let elem=document.getElementById('candidates_tab');for (let i=0;i < arr.length;i++){if(hasClass(elem,arr[i])){type=arr[i];if(type==='mdc6'&&val.match(/^[0-9]{5}[0-9x][0-9a-z]{8}/i)){type='dpccode';}}}}if(!type||type==='default'){if(val.match(/^[0-9]{5}[0-9x][0-9a-z]{8}/i)){type='dpccode';}else if(val.match(/^[A-Z][0-9]([0-9\$])*$/i)||val.match(/^M!{1,4}$/i)){type='icd10';}else {type='mdc6';}}queryFreewordInChildWindow(type,val);let logging=true;switch (type){case 'disease':queryDisease(val,logging);break;case 'byomei':queryByomei(val,logging);break;case 'icd10':queryICD10(val,logging);break;case 'dpccode':queryDPCcode(val);break;case 'opepro':queryOpePro(val,logging,false);break;case 'drg':queryDrg(val,logging);break;case 'mdc6':default:queryMDC6(val,'','',logging);break;}} function queryFreewordInChildWindow(type,val,is_force){if(!(window.childWindow)||window.childWindow.closed){if(is_force){window.childWindow=window.open('/fukuro2024/','fukuro2024');setTimeout(function (){queryFreewordInChildWindow(type,val);},1200);}}if(window.childWindow&&!(window.childWindow.closed)){let anotherElem=window.childWindow.document.getElementById('freeword');if(anotherElem){anotherElem.value=val;window.childWindow.queryFreeword(type);}}} function queryDisease(val,logging){if(val===undefined){val=g('disease');}if(val.length < 1||val==='( 傷病名を日本語で入力して検索できます )'){hideCandidates();return;}let pos=val.indexOf(':');if(pos>0){val=val.substring(0,pos);}let url='/fukuro2026/query.php?type=disease_candidates&val='+val+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}queryExec(url,'freeword',val);} function queryDiseaseCount(val){if(val===''||val===undefined){return;}let url='/fukuro2026/query.php?type=disease_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'disease_candidates_count');} function diseaseSelect(disName,icd10,icd10_2013){clearAllExceptFreeword();s('icd10raw',icd10);s('disease_info',disName+':'+icd10+((icd10_2013)?(' 〔'+icd10_2013+'@ICD2013〕'):'').split('<').join('<').split('>').join('>'));s('disease',disName+':'+icd10+((icd10_2013)?(' 〔'+icd10_2013+'@ICD2013〕'):'').split('<').join('<').split('>').join('>'));setDisplay('mdc_info_disease','block');if(icd10){s('icd10',icd10);findICD10(icd10);}} function queryByomei(val,logging){if(val===undefined){val=g('byomei');}if(val.length < 1||val==='( 日本語の傷病名からレセ病名の組み合わせを検索できます )'){hideCandidates();return;}let pos=val.indexOf(':');if(pos>0){val=val.substring(0,pos);}let url='/fukuro2026/query.php?type=byomei_candidates&val='+val+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}queryExec(url,'freeword',val);} function queryByomeiOne(val,logging){if(val===undefined){val=g('byomei');}if(val.length < 1||val==='( 日本語の傷病名からレセ病名の組み合わせを検索できます )'){hideCandidates();return;}let pos=val.indexOf(':');if(pos>0){val=val.substring(0,pos);}let url='/fukuro2026/query.php?type=byomei&val='+val+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}queryExec(url,'freeword',val);} function queryByomeiCount(val){if(val===''||val===undefined){return;}let url='/fukuro2026/query.php?type=byomei_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'byomei_candidates_count');} function byomeiSelect(byomei,byomeisComposition,codesComposition,disName,icd10,icd10_2013){if(icd10){diseaseSelect(disName,icd10,icd10_2013);}else{clearAllExceptFreeword();}let byomeisArr=byomeisComposition.split('/');let codesArr=codesComposition.split('/');let byomei_info='';for (let i=0;i < byomeisArr.length;i++){let _byomei=byomeisArr[i];let _code=codesArr[i];switch (_code.length){case 7:byomei_info+=''+_byomei+''+_code+'';break;case 4:byomei_info+=''+_byomei+''+_code+'';break;default:byomei_info+=''+_byomei+'';break;}}setDisplay('mdc_info_byomei','block');setInnerHTML('byomei_info',byomei_info);} function findICD10(icd10){hideCandidates();if(icd10.length < 2){return;}const xmlhttp=createHttpRequest();if(xmlhttp===null){return null;}const url='/fukuro2026/query.php?type=icd&val='+icd10+'&encoding_hint=ぷ';sendRequest(xmlhttp,'GET',url,true,callBackICD10,null,null);} function callBackICD10(xmlhttp){if(xmlhttp.responseText){const arr=(xmlhttp.responseText).split(':');ICD10SelectExec(arr[0],arr[1],arr[2],arr[3]);}else {ICD10SelectExec();}} function queryICD10(val,logging){if(val.length===0){return;}let url='/fukuro2026/query.php?type=icd_candidates&val='+val+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}queryExec(url,'freeword',val);} function queryICD10Count(val){if(val===''||val===undefined){return;}let url='/fukuro2026/query.php?type=icd_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'icd10_candidates_count');} function ICD10Select(icd10,icd10name,mdc6,mdc6name){clearAllExceptFreeword();ICD10SelectExec(icd10,icd10name,mdc6,mdc6name);} function ICD10SelectExec(icd10,icd10name,mdc6,mdc6name){if(icd10name&&icd10name.indexOf('【※コーディング注意】')>-1){addClass('icd10_info','alert');}else {removeClass('icd10_info','alert');}if(icd10){s('icd10_info',icd10+':'+icd10name.split('<').join('<').split('>').join('>'));s('icd10_name',icd10+':'+icd10name.split('<').join('<').split('>').join('>'));s('icd10',icd10);setDisplay('disease_list','inline-block');}else {s('icd10_info','(DPC6桁に紐付くICD10コードが見つかりません )');s('icd10_name','');s('icd10','');setDisplay('disease_list','none');clearDpcOptions();findRelated();}MDC6SelectExec(mdc6,mdc6name);} function queryListDisease(){if(isVisible('candidates')){hideCandidates();return;}let val=g('icd10_info');if(val===''){hideCandidates();return;}const pos=val.indexOf(':');if(pos < 2){hideCandidates();return;}val=val.substring(0,pos);const url='/fukuro2026/query.php?type=disease_list&val='+val;queryExec(url,'icd10_info');} function queryMDC6(val,givenOpepro='',drgId='',logging){if(val===undefined){val=g('mdc6_name');}if(val===''||val==='( DPC6桁のコード または 名称 を入力して検索できます )'){hideCandidates();return;}if(val.match(/^[01][0-9]{4}[0-9x]$/)){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}let url='/fukuro2026/query.php?type=mdc6&val='+val+'&opepro='+givenOpepro+'&drgId='+drgId+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}sendRequest(xmlhttp,'GET',url,true,callBackMDC6,null,null);}else {if(val.match(/^MDC[0-1][0-9]$/i)){val=val.substring(3,5);}const pos=val.indexOf(':');if(pos===6){val=val.substring(0,6);}let url='/fukuro2026/query.php?type=mdc6_candidates&val='+val+'&encoding_hint=ぷ';if(logging){url=url+'&logging=1';}queryExec(url,'freeword',val);}} function callBackMDC6(xmlhttp){eval(xmlhttp.responseText);if(mdc6!==''&&mdc6name!==''){MDC6Select(mdc6,mdc6name,drgId,opepro,codingMdc6);}else {const url='/fukuro2026/query.php?type=mdc6_candidates&val='+query+'&encoding_hint=ぷ';queryExec(url,'freeword');}} function queryMDC6Count(val){if(val===''||val===undefined){return;}const url='/fukuro2026/query.php?type=mdc6_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'mdc6_candidates_count');} function MDC6Select(mdc6,mdc6name,drgId,opepro,codingMdc6){clearAllExceptFreeword();if(drgId&&opepro){s('drgId',drgId.toString());const index=opepro.indexOf('|');s('drg_opepro',(index >= 0)?opepro.slice(index+1):opepro);s('given_opepro',opepro);}else {s('given_opepro',opepro);}MDC6SelectExec(mdc6,mdc6name,codingMdc6);} function MDC6SelectExec(mdc6,mdc6name,codingMdc6){if(mdc6){s('mdc6',mdc6);s('mdc6_info',mdc6+':'+unescapeHtml(mdc6name));s('mdc6_name',mdc6+':'+mdc6name);setDisplay('icd10_list','inline-block');setDisplay('compli_list','inline-block');}else {s('mdc6','');s('mdc6_info','');s('mdc6_name','');setDisplay('icd10_list','none');setDisplay('compli_list','none');}hideCandidates();if(codingMdc6){s('mdc6',codingMdc6);mdc6=codingMdc6;}findCond(mdc6);showListCcpLink(mdc6);} function showListCcpLink(mdc6){if(mdc6===''){hideCandidates();return;}const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const url='/fukuro2026/query.php?type=ccp_count&val='+mdc6;sendRequest(xmlhttp,'GET',url,true,callBackShowListCcpLink,null,null);} function callBackShowListCcpLink(xmlhttp){let ccp_count=parseInt(xmlhttp.responseText,10);setDisplay('ccp_list',(ccp_count>0)?'inline-block':'none');} function queryListCCP(val){if(isVisible('candidates')){hideCandidates();}if(val===void 0){val=g('mdc6_info');if(val===''){hideCandidates();return;}const pos=val.indexOf(':');if(pos!==6){hideCandidates();return;}val=val.substring(0,6);}if(window.childWindow!==undefined){if(window.childWindow.queryListICD10) window.childWindow.queryListICD10();}const url='/fukuro2026/query.php?type=listccp&val='+val;queryExec(url,'mdc6_info');} function queryListICD10(){if(isVisible('candidates')){hideCandidates();return;}let val=g('mdc6_info');val=(val===undefined)?'':val.toString();if(val===''){hideCandidates();return;}const pos=val.indexOf(':');if(pos!==6){hideCandidates();return;}if(window.childWindow!==undefined){if(window.childWindow.queryListICD10) window.childWindow.queryListICD10();}val=val.substring(0,6);const url='/fukuro2026/query.php?type=listicd&val='+val;queryExec(url,'mdc6_info');} function queryListCompliMDC6(){if(isVisible('candidates')){hideCandidates();return;}let val=g('mdc6_info');val=(val===undefined)?'':val.toString();if(val===''){hideCandidates();return;}const pos=val.indexOf(':');if(pos!==6){hideCandidates();return;}if(window.childWindow!==undefined){if(window.childWindow.queryListCompliMDC6) window.childWindow.queryListCompliMDC6();}val=val.substring(0,6);const url='/fukuro2026/query.php?type=listcomplimdc6&val='+val;queryExec(url,'mdc6_info');} function queryListMDC2(){queryExec('/fukuro2026/query.php?type=mdc2&val=','freeword');} function queryOpePro(val,logging,no_count){if(val===''){hideCandidates();return;}const url='/fukuro2026/query.php?type=opepro&val='+val+'&encoding_hint=ぷ';if(no_count){queryExec(url,'freeword',{'val': val,'no_count': no_count});}else {queryExec(url,'freeword',val);}} function queryOpeProWithoutCount(val,logging){queryOpePro(val,logging,true);} function queryOpeProCount(val){if(val===''||val===undefined){return;}const url='/fukuro2026/query.php?type=opepro_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'opepro_candidates_count');} function queryDrg(val,logging){if(val===''){hideCandidates();return;}const url='/fukuro2026/query.php?type=drg&val='+val+'&encoding_hint=ぷ';queryExec(url,'freeword',val);} function queryDrgCount(val){if(val===''||val===undefined){return;}const url='/fukuro2026/query.php?type=drg_count&val='+val+'&encoding_hint=ぷ';queryExecCount(url,'drg_candidates_count');} function DrgSelect(drgId,opepro,typicalDpc){const mdc6=typicalDpc.substring(0,6);query_dpccode=typicalDpc;queryMDC6(mdc6,opepro,drgId)} function queryDPCcode(val,givenOpepro=''){if(val!==undefined&&val!==''){if(val.match(/^[0-9]{5}[0-9x][0-9a-z]{8}/i)){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}query_dpccode=val;sendRequest(xmlhttp,'GET','/fukuro2026/query.php?type=dpc&val='+val+'&opepro='+givenOpepro,true,callBackDPCcode,null,null);}else if(val.match(/^[01][0-9]{4}[0-9x]/)){queryMDC6(val,givenOpepro);}return;}hideCandidates();} function callBackDPCcode(xmlhttp){eval(xmlhttp.responseText);if(dpcname===''&&is_pps===-1){if(drgId!==''&&opepro!==''){const mdc6=dpc.substring(0,6);MDC6Select(mdc6,mdc6name,drgId,opepro);return;}queryMDC6(dpc,opepro ?? '');return;}if(query_dpccode!==dpc) query_dpccode=dpc;const mdc6=dpc.substring(0,6);MDC6Select(mdc6,mdc6name,drgId,opepro);} function findCond(mdc6){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}if(!mdc6){mdc6=g('mdc6');}sendRequest(xmlhttp,'GET','/fukuro2026/query.php?type=cond&val='+mdc6,true,callBackCond,null,null);} function callBackCond(xmlhttp,domid){clearCondOptions();const el=document.getElementById('cond_pd');eval(xmlhttp.responseText);if(data.length>0){let f=0;for (let i=0;i < data.length;i++){let dataVal=data[i].value;dataVal=(dataVal===undefined)?'':dataVal.toString();el.options[i]=new Option(dataVal+':'+data[i].label,data[i].value);if(query_dpccode!==''){if(dataVal===query_dpccode.substring(6,7)){f=i;}}}s('cond',data[f].value);setSelectedIndex('cond_pd',f);el.style.visibility='visible';setVisibility('cond_caption','visible');let str=getOption('cond_pd',f).text;if(str.indexOf(':')>-1){const arr=str.split(':');str=arr[1];}s('cond_label',str);}else {el.style.visibility='hidden';setVisibility('cond_caption','hidden');s('cond_label','定義なし');}findSeri1();} function clearCondOptions(){const el=document.getElementById('cond_pd');for (let i=el.length;i>0;i--){el.options[i-1]=null;}el.style.visibility='hidden';setVisibility('cond_caption','hidden');s('cond','x');s('cond_label','');} function condSelect(){query_dpccode='';s('cond',getSelectedOption('cond_pd').value);s('cond_label',getSelectedOption('cond_pd').text);findSeri1();} function findSeri1(mdc6){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}if(!mdc6){mdc6=g('mdc6');}const cond=g('cond');const url='/fukuro2026/query.php?type=seri1&val='+mdc6+'&cond='+cond;sendRequest(xmlhttp,'GET',url,true,callBackSeri1,null,null);} function callBackSeri1(xmlhttp,domid){clearSeri1Options();const el=document.getElementById('seri1_pd');eval(xmlhttp.responseText);if(data.length>0){let f=0;for (let i=0;i < data.length;i++){el.options[i]=new Option(data[i].value+':'+data[i].label,data[i].value);if(query_dpccode!==''){if(data[i].value!==undefined&&data[i].value.toString()===query_dpccode.substring(7,8)){f=i;}}}s('seri1',data[f].value);setSelectedIndex('seri1_pd',f);el.style.visibility='visible';setVisibility('seri1_caption','visible');let str=getOption('seri1_pd',f).text;if(str.indexOf(':')>-1){str=str.split(':')[1];}s('seri1_label',str);}else {el.style.visibility='hidden';setVisibility('seri1_caption','hidden');s('seri1_label','定義なし');}findOpe();} function clearSeri1Options(){const el=document.getElementById('seri1_pd');for (let i=el.length;i>0;i--){el.options[i-1]=null;}el.style.visibility='hidden';setVisibility('seri1_caption','hidden');s('seri1','x');s('seri1_label','');} function seri1Select(){query_dpccode='';const option=getSelectedOption('seri1_pd');s('seri1',option.value);s('seri1_label',option.text);findOpe();} function findOpe(){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const dpc=g('mdc6')+g('cond')+g('seri1');if(dpc.length!==8){clearOpeOptions();return;}const url='/fukuro2026/query.php?type=ope&val='+dpc;sendRequest(xmlhttp,'GET',url,true,callBackOpe,null,null);} function callBackOpe(xmlhttp,domid){clearOpeOptions();const el=document.getElementById('ope_pd');eval(xmlhttp.responseText);el.size=(data.length < 2)?2:data.length;let i,f;if(data.length>0){let givenOpepro=g('given_opepro');const pos=givenOpepro.indexOf('|');if(pos >= 0){if(givenOpepro.slice(0,pos)==='ope'){givenOpepro=givenOpepro.slice(pos+1);}}const ope=query_dpccode!==''?query_dpccode.substring(8,10):undefined;f=-1;for (i=0;i < data.length;i++){if(data[i].value!==undefined&&data[i].value!==null&&data[i].value!==''){if(ope){if(data[i].value.toString()===ope){if(ope!=='97'&&f < 0) f=i;if(givenOpepro&&data[i].label.startsWith(givenOpepro+'  ')){f=i;}}}el.options[i]=new Option(data[i].value+'  '+data[i].label,data[i].value);}}if(f >= 0){s('ope',data[f].value);setSelectedIndex('ope_pd',f);const str=getOption('ope_pd',f).text;const arr=str.split('  ');s('ope_label',arr[2]+'|'+arr[1]);s('dpc_ope',arr[1]);}el.style.visibility=(el.options.length>0)?'visible':'hidden';document.ope_form.elements[0].style.visibility='visible';if(f < 0){if(ope===undefined||ope!=='97'){document.ope_form.elements[0].checked=true;s('ope','99');s('ope_label','なし|なし');}else {document.ope_form.elements[1].checked=true;s('ope','97');s('ope_label','あり|その他Kコード');}}setVisibility('ope99_caption','visible');document.ope_form.elements[1].style.visibility='visible';setVisibility('ope97_caption','visible');}else {el.style.visibility='hidden';for (i=0;i < document.ope_form.elements.length;i++){document.ope_form.elements[i].style.visibility='hidden';}s('ope_label','なし|なし');}clearMiscAll();if(query_dpccode!==''){s('misc',query_dpccode.substring(10,14));}findMisc();} function clearOpeOptions(){const el=document.getElementById('ope_pd');for (let i=el.length;i>0;i--){el.options[i-1]=null;}document.ope_form.elements[0].checked=false;document.ope_form.elements[0].style.visibility='hidden';setVisibility('ope99_caption','hidden');document.ope_form.elements[1].checked=false;document.ope_form.elements[1].style.visibility='hidden';setVisibility('ope97_caption','hidden');s('ope','xx');s('ope_label','');document.getElementById('ope_pd').size=0;setVisibility('ope_pd','hidden');s('dpc_ope','');} function opeSelect(){query_dpccode='';s('ope',getSelectTagValueById('ope_pd'));document.ope_form.elements[0].checked=false;document.ope_form.elements[1].checked=false;if(getSelectedIndex('ope_pd') >= 0){const arr=(getSelectedOption('ope_pd').text).split('  ');s('dpc_ope',arr[1]);s('ope_label',arr[2]+'|'+arr[1]);}else {s('dpc_ope','');s('ope_label','|');}clearMiscAll();findMisc();} function opeClick(ope){query_dpccode='';s('ope',ope);setSelectedIndex('ope_pd',-1);s('dpc_ope','');switch (ope){case 99:s('ope_label','なし|なし');break;case 97:s('ope_label','あり|その他Kコード');break;}clearMiscAll();findMisc();} function findMisc(target,ioum){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const mdc6=g('mdc6');const idx=g('cond')+g('seri1')+g('ope');if(mdc6.length!==6&&idx.length!==4){clearMiscAll();return;}const misc=g('misc');if(target===undefined){target='-1';}if(ioum===undefined){ioum='0';}const url='/fukuro2026/query.php?type=misc&val='+mdc6+'&idx='+idx+'&misc='+misc+'&target='+target+'&ioum='+ioum;sendRequest(xmlhttp,'GET',url,true,callBackMisc,null,null);} function callBackMisc(xmlhttp,domid){eval(xmlhttp.responseText);const el=document.getElementById('misc_pd');if(typeof ioum==='undefined'){let currentSelectedIndex=(target < 0)?-1:g('misc'+target);s('misc',misc);s('misc_tab',target);if(typeof data != 'undefined'&&data.length>0){el.size=(data.length < 2)?2:data.length;for (let i=0;i < data.length;i++){el.options[i]=new Option(data[i].value+'  '+data[i].label,data[i].value);if(currentSelectedIndex===i){el.selectedIndex=i;}}}else {el.size=0;s('misc','xxxx');}if(currentSelectedIndex < 0&&target >= 0){const givenOpepro=g('given_opepro');const pos=givenOpepro.indexOf('|');if(pos >= 0){const type=givenOpepro.slice(0,pos);if(type==='pro1'||type==='pro2'){const findMe=givenOpepro.slice(pos+1);for (let i=0;i < data.length;i++){const pd_value=data[i].label.substring(0,data[i].label.indexOf('  '));if(pd_value===findMe){currentSelectedIndex=i;el.selectedIndex=i;break;}}}}if(query_dpccode!==''&¤tSelectedIndex < 0){for (let i=0;i < data.length;i++){let selected=false;if(target===0){if(data[i].value===query_dpccode.substring(10,11)&&query_dpccode.substring(10,11)!=='0'){s('dpc_pro1',data[i].label.substring(0,data[i].label.indexOf('  ')));selected=true;}}else if(target===1){if(data[i].value===query_dpccode.substring(11,12)&&query_dpccode.substring(11,12)!=='0'){s('dpc_pro2',data[i].label.substring(0,data[i].label.indexOf('  ')));selected=true;}}else if(target===2){if(data[i].value===query_dpccode.substring(12,13)&&query_dpccode.substring(12,13)!=='0'){s('dpc_compli',data[i].label.substring(0,data[i].label.indexOf('  ')));selected=true;}}else if(target===3){if(data[i].value===query_dpccode.substring(13,14)){selected=true;}}if(selected){currentSelectedIndex=i;el.selectedIndex=i;break;}}}else {for (let i=0;i < data.length;i++){if(currentSelectedIndex < 0 &&(misc.substring(target,target+1)!=='0'||target===3)&&data[i].value!==undefined&&data[i].value.toString()===misc.substring(target,target+1)){s('misc'+target,i);currentSelectedIndex=i;el.selectedIndex=i;break;}}}}if(currentSelectedIndex < 0){document.misc_form.elements[0].checked=true;el.selectedIndex=-1;}renderFieldMenu();if(0 <= target){document.misc_form.elements[0].style.visibility=(target < 3)?'visible':'hidden';setVisibility('misc_caption',(target < 3)?'visible':'hidden');setVisibility('misc_pd','visible');}else {document.misc_form.elements[0].style.visibility='hidden';setVisibility('misc_caption','hidden');setVisibility('misc_pd','hidden');}}else {s('misc',misc);renderFieldMenu();}renderDpcInfo();} function renderFieldMenu(){const type=parseInt(g('misc_tab'),10);const misc=g('misc');let str='';for (let i=0;i < misc_types.length;i++){if(i>0){str+=' ';}if(type===i){str+=''+misc_types[i]+'';}else if(i < misc.length&&misc.substring(i,i+1)!=='x'){str+=''+misc_types[i]+'';}else {str+=''+misc_types[i]+'';}}setInnerHTML('fld_menu',str);} function findMiscLabel(){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const dpc=g('dpc');if(dpc===''||dpc.length < 14){for (let i=0;i < 4;i++){s('misc'+i+'_label','');}return;}const url='/fukuro2026/query.php?type=miscname&val='+dpc+'&idx0='+g('misc0')+'&idx1='+g('misc1')+'&idx2='+g('misc2')+'&idx3='+g('misc3');sendRequest(xmlhttp,'GET',url,true,callBackMiscLabel,null,null);} function callBackMiscLabel(xmlhttp,domid){eval(xmlhttp.responseText);for (let i=0;i < 4;i++){const arr=data[i].split('  ');const domId='misc'+i+'_label';switch (misc.substring(i,i+1)){case 'x':if(i < 3){s(domId,'0\tなし');}if(i===3){s(domId,'定義なし');}break;case '0':if(i < 3){s(domId,'0\tなし');}if(i===3){s(domId,arr[2]);}break;default:if(i < 3){s(domId,arr[0]+'\t'+arr[2]);}if(i===3){s(domId,arr[2]);}}}storeDpcInfoStr();} function clearMiscAll(){clearMiscOptions(true);clearMiscVars();clearMiscSels();} function clearMiscOptions(is_hidden){const el=document.getElementById('misc_pd');for (let i=el.length;i>0;i--){el.options[i-1]=null;}document.misc_form.elements[0].checked=false;if(is_hidden){document.misc_form.elements[0].style.visibility='hidden';setVisibility('misc_caption','hidden');document.getElementById('misc_pd').size=0;setVisibility('misc_pd','hidden');}} function clearMiscVars(){s('misc','');s('misc_tab','-1');} function clearMiscSels(misc_tab){for (let i=0;i < 4;i++){if(misc_tab===undefined||misc_tab < i){s('misc'+i,'-1');s('misc'+i+'_label','');if(i <= 1){s('dpc_pro'+(i+1),'');}if(i===2){s('dpc_compli','');}}}} function miscSelect(){query_dpccode='';const misc_tab=parseInt(g('misc_tab'),10);const cur_idx=getSelectedIndex('misc_pd');s('misc'+misc_tab,cur_idx);const v=getSelectTagValueById('misc_pd');document.misc_form.elements[0].checked=false;s('misc',getMiscValue(v,misc_tab));const code=(cur_idx >= 0)?getSelectedOption('misc_pd').text.split('  ')[1]:'';if(misc_tab <= 1){s('dpc_pro'+(misc_tab+1),code);}if(misc_tab===2){s('dpc_compli',code);}clearMiscSels(misc_tab);findMisc(misc_tab,1);} function miscClick(){query_dpccode='';const misc_tab=parseInt(g('misc_tab'),10);const id='misc'+misc_tab;if(g(id)==='-1'){return;}s(id,'-1');setSelectedIndex('misc_pd',-1);document.misc_form.elements[0].checked=true;s('misc',getMiscValue(0,misc_tab));if(misc_tab <= 1){s('dpc_pro'+(misc_tab+1),'');}if(misc_tab===2){s('dpc_compli','');}clearMiscSels(misc_tab);findMisc(misc_tab,1);} function getMiscValue(v,misc_tab){let cur=g('misc');return cur.substring(0,misc_tab)+v+cur.substring(parseInt(misc_tab,10)+1);} function storeMiscInfoStr(misc,key,str){if(misc < 0||misc>3) return;const id='misc'+misc+'_label';const arr=str.split('  ');switch (key){case 'x':s(id,(misc < 3)?'0\tなし':'定義なし');break;case '0':s(id,(parseInt(misc,10)===3)?'0\t'+arr[2]:'0\tなし');break;default:s(id,arr[0]+'\t'+arr[2]);}} function setFig0TypeSelect(val){const el=document.getElementById('fig0_sel');if(val===undefined){val=el.options[el.selectedIndex].value;}else {if(el.selectedIndex!==val){el.selectedIndex=val;}}s('dpc0','');s('dpc0choices','');setVisibility('dpc0contents',(val < 2)?'visible':'hidden');updateSurchargeFldVisibility();} function setDpcInfoPanel(type){switch (type){case 'adv':setDpcInfoPanelAs('包括対象外','対象術式等','  -  ','  -  ','hidden',true);setDpcInfoPanelOfDrg(false);break;case 'drg':setDpcInfoPanelAs('短手3DPC','対象術式等','包括期間','包括点数','hidden',true);setDpcInfoPanelOfDrg(true);break;case 'dpc':case 'ffs':default:const atachAlertClass=(type==='ffs');setDpcInfoPanelAs('DPCコード','DPC名称','入院期間','日当点','visible',atachAlertClass);setDpcInfoPanelOfDrg(false);}} function setDpcInfoPanelAs(label,name,span,score,scoreAreaVisibility,atachAlertClass){setInnerHTML('label_dpc',label);setInnerHTML('label_dpcname',name);setInnerHTML('label_span',span);setInnerHTML('label_score',score);for (let i=1;i <= 3;i++){setVisibility('item_span'+i,scoreAreaVisibility);setVisibility('item_score'+i,scoreAreaVisibility);}if(atachAlertClass){addClass('dpccode','alert');addClass('dpcname','alert');}else {removeClass('dpccode','alert');removeClass('dpcname','alert');}} function setDpcInfoPanelOfDrg(isDrg){document.getElementById('item_score2').style.width=isDrg?'16em':document.getElementById('item_score1').style.width;setInnerHTML('label_score2',isDrg?'物価対応料':'');document.getElementById('label_score2').style.paddingRight=isDrg?'1em':'';if(isDrg){setVisibility('item_span1','visible');setVisibility('item_score1','visible');setVisibility('item_score2','visible');}updateSurchargeFldVisibility();} function updateScoreFigs(){setDpcScoreFig();} function setDpcScoreFig(){const dpc=g('dpc');let dpc0=g('dpc0');const drgId=g('drgId');const adv=g('adv');const pps_type=g('pps_type');let coef=g('coef');let coef0=coef;if(coef.indexOf('/') >= 0){const coefs=coef.split('/',2);coef=coefs[0];coef0=coefs[1];}const elSurcharge=document.getElementById('surcharge');let surcharge=elSurcharge.value;if(elSurcharge.offsetParent===null||elSurcharge.style.display==='none'){surcharge='0';}let surcharge0=surcharge;if(surcharge.indexOf('/') >= 0){const surcharges=surcharge.split('/',2);surcharge=surcharges[0];surcharge0=surcharges[1];}const los=g('los');const with_fy0=getSelectedOption('fig0_sel').value;const show_diff=getSelectedOption('fig_diff_sel').value;const el=document.getElementById('los_score_fig');const elDl=document.getElementById('dpcfig_download');const elUrl=document.getElementById('dpcfig_url');const windowWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;const fig_w=windowWidth-110;if(query_dpc0code!==''){dpc0=query_dpc0code;}const dpc0_key=(with_fy0==='0')?'dpc0' :'dpc1';if(with_fy0!=='0'){coef0=coef;surcharge0=surcharge;}let is_adv_ope=queryIsAdvOpe();let url='';let elemDIUrl='';if(dpc!==''&&pps_type==='1'&&adv===''&&is_adv_ope!==1){url='/fukuro2026/query.php?type=chart&val='+dpc+'&'+dpc0_key+'='+dpc0+'&coef='+coef+'&coef0='+coef0+'&surcharge='+surcharge+'&surcharge0='+surcharge0+'&los='+los+'&show_diff='+show_diff;el.src=url+'&width='+fig_w;elemDIUrl=url+'&out_mode=dl&out_fname='+dpc+'.png';}else if(drgId!==''&&adv===''){const drgDpc=g('dpccode');url='/fukuro2026/query.php?type=chart&val=&drg='+drgDpc+'&'+dpc0_key+'='+dpc0+'&coef='+coef+'&coef0='+coef0+'&surcharge0='+surcharge0+'&los='+los+'&show_diff='+show_diff;el.src=url+'&width='+fig_w;elDl.setAttribute('href',url+'&out_mode=dl&out_fname='+drgDpc+'.png');elemDIUrl=url+'&out_mode=dl&out_fname='+drgDpc+'.png';}else {el.src='./img/dot.png';}if(elemDIUrl===''||'Web'==='Win'){elDl.removeAttribute('href');elDl.style.display='none';}else {elDl.setAttribute('href',elemDIUrl);elDl.style.display='block';}elUrl.setAttribute('href',url);elUrl.innerHTML=url;} function getDpccode(){const dpc=g('mdc6') +g('cond') +g('seri1') +g('ope') +g('misc');return (dpc.length===14)?dpc:'';} function renderDpcInfo(){const dpc=getDpccode();s('dpc',dpc);const ret=autoSelectSpecial(dpc);if(!ret){findDpcInfo();}} function findDpcInfo(){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const dpc=g('dpc');if(dpc===undefined||dpc===''||dpc.length < 14){return;}const url='/fukuro2026/query.php?type=dpc&val='+dpc;sendRequest(xmlhttp,'GET',url,true,callBackDpcInfo,null,null);} function callBackDpcInfo(xmlhttp,domid){eval(xmlhttp.responseText);let is_adv_ope=queryIsAdvOpe();setDpcInfoPanel(is_pps===1&&is_adv_ope!==1?'dpc':'ffs');s('dpccode',dpc);s('dpcname',dpcname);s('pps_type',is_pps?1:0);s('adv_candidates',advs.join('|'));let with_fy0=getSelectedOption('fig0_sel').value;with_fy0=(with_fy0!==undefined)?with_fy0.toString():'';let choices_html='';if(with_fy0==='0'){s('dpc0',(query_dpc0code!=='')?query_dpc0code :(dpc0s.length>0?dpc0s[0]:''));for (let i=0,len=dpc0s.length;i < len;i++){const dpc0=dpc0s[i];const dpc0name=dpc0names[i];const dpc0comment=dpc0comments[i];const dpc0ppstype=dpc0ppstypes[i];const dpc0pps=(dpc0ppstype>0)?'':'【出来高】 ';const onclick0=(query_dpc0code?'query_dpc0code=\'\';':'')+'document.getElementById(\'dpc0\').value=\''+dpc0+'\';updateScoreFigs(false);';const title0='《2024年制度》 '+dpc0pps+dpc0+': '+dpc0name+((dpc0comment)?'  «'+dpc0comment+'»':'');let dpc0label=dpc0;if(dpc0ppstype!==undefined&&dpc0ppstype.toString()==='0'){dpc0label=''+dpc0label+'';}choices_html=choices_html+((i>0)?' | ':'')+''+dpc0label+'';choices_html+=getDpc0Link(dpc0,dpc0pps);}}else if(with_fy0==='1'){s('dpc0',(query_dpc0code!=='')?query_dpc0code :'');let len=0;let dpc1='';for (dpc1 in dpc1s){len++;}if(dpc1s!==undefined&&len>0){let i=0;for (dpc1 in dpc1s){const dpc1_diff_name=dpc1s[dpc1];const dpc1ppstype=dpc1ppstypes[dpc1];const dpc1pps=(dpc1ppstype>0)?'':'【出来高】 ';const onclick='document.getElementById(\'dpc0\').value=\''+dpc1+'\';updateScoreFigs(true);';const title1='《2026年制度》 '+dpc1pps+dpc1;let dpc1label=dpc1;if(dpc1ppstype!==undefined&&dpc1ppstype.toString()==='0'){dpc1label=''+dpc1label+'';}choices_html=choices_html+((i>0)?' | ':'')+dpc1_diff_name+':'+dpc1label+'';i++;}}}else if(with_fy0==='2'){}setInnerHTML('dpc0choices',choices_html);s('adv','');s('adv_opepro','');if(is_pps===1&&is_adv_ope!==1){let prevSpan=0;for (let i=0;i < 3;i++){let spanValue='-';if(typeof(span[i])==='number'){if(i===0||prevSpan+1===span[i]){spanValue=span[i].toString();}else if(prevSpan < span[i]){spanValue=(prevSpan+1).toString()+' ~ '+span[i].toString();}prevSpan=span[i];}s('span'+(i+1),spanValue);s('score'+(i+1),(score[i]===''||score[i]===0||score[i]==='0')?'-':score[i].toString());}if(ccp_name){let label=pstype_labels['ccp']+' / '+ccp_name+'';if(ccp_type){let title='CCPマトリクス表を見る';let url=getHtmlPdfLink('pdf/'+ccp_pdf,title,null,'icon_ccp_table.png');label+=' '+url;}showPstype('ccp',label);}else {showPstype('pps');}updateScoreFigs();}else {for (let i=0;i < 3;i++){s('span'+(i+1),'');s('score'+(i+1),'');}if(is_pps===0){showPstype('ffs');}updateScoreFigs();}calcDpcYen();updateRelated();contentsChanged();findMiscLabel();} function getDpc0Link(dpc0){if(dpc0.length===14){const onclick='queryFreewordInChildWindow(\'dpccode\',\''+dpc0+'\',true);';const tooltip='旧制度のふくろくん2024で「'+dpc0+'」を見る';return ' ';}return '';} function clearDpcInfo(){s('dpc','');s('dpc0','');setInnerHTML('dpc0choices','');s('pps_type','');s('adv_candidates','');clearPstype();s('dpccode','');removeClass('dpccode','alert');s('dpcname','');removeClass('dpcname','alert');for (let i=1;i <= 3;i++){s('span'+i,'');s('score'+i,'');}s('total_yen','');updateScoreFigs();s('dpc_info','');s('dpc_ope','');s('dpc_pro1','');s('dpc_pro2','');s('adv','');s('adv_opepro','');clearDrgId();s('given_opepro','');} function storeDpcInfoStr(){const dpc=g('dpc');const ppsTypeStr=g('pps_type');const ppsTypeNum=parseInt(ppsTypeStr,10);if(dpc===undefined||dpc===''||ppsTypeNum===-1||ppsTypeStr===''){return;}const dpcname=g('dpcname');const span=new Array(3);const score=new Array(3);for (let i=0;i < 3;i++){span[i]=g('span'+(i+1));let arr2=span[i].split(' ~ ');span[i]=(arr2.length>1)?parseInt(arr2[1],10):parseInt(span[i],10);score[i]=g('score'+(i+1));}const seri1_label=g('seri1_label');let arr=g('ope_label').split('|');const ope_label=arr[0];const opecode_label=arr[1];const pro1_label=g('misc0_label');const pro2_label=g('misc1_label');const compli_label=g('misc2_label');const seri2_label=g('misc3_label');s('dpc_info','通し番号\t000\n' +'診断群分類番号\t'+dpc+'\n' +'診断群分類名称\t'+dpcname+'\n' +'入院期間Ⅰ\t'+((ppsTypeNum===1)?span[0]:'')+'\n' +'入院期間Ⅱ\t'+((ppsTypeNum===1)?span[1]:'')+'\n' +'入院期間Ⅲ\t'+((ppsTypeNum===1)?span[2]:'')+'\n' +'入院期間Ⅰ以下の点数\t'+((ppsTypeNum===1)?score[0]:'')+'点\n' +'入院期間Ⅰを超えⅡ以下の点数\t'+((ppsTypeNum===1)?score[1]:'')+'点\n' +'入院期間Ⅱを超えⅢ以下の点数\t'+((ppsTypeNum===1)?score[2]:'')+'点\n' +'年齢、出生時体重等\t'+seri1_label+'\n' +'手術\t'+ope_label+'\n' +'手術Kコード\t'+opecode_label+'\n' +'手術・処置等1\t'+pro1_label+'\n' +'手術・処置等2\t'+pro2_label+'\n' +'副傷病\t'+compli_label+'\n' +'重症度等\t'+seri2_label+'\n');} function getDpcInfoStr(){return g('dpc_info');} function getDpcDayYenTableStr(){const dpc=g('dpc');const adv=g('adv');const drgId=g('drgId');const dpccode=g('dpccode');const dpcname=g('dpcname');let coef=1;let coefStr=g('coef');if(coefStr.indexOf('/')!==-1){let buf=coefStr.split('/');coef=parseFloat(buf[0]);}else{coef=parseFloat(coefStr||'1');}if(coef <= 0){coef=1;}if(coef < 0||coef>10) coef=1;let surchargeStr=g('surcharge');if(surchargeStr.indexOf('/')!==-1){let buf=surchargeStr.split('/');surchargeStr=buf[0];}let surcharge=parseInt(surchargeStr||'0',10);if(surcharge < 0||surcharge>10000) surcharge=580;if(adv!==''){return dpccode+'\n'+dpcname+'\n';}else if(drgId!==undefined&&drgId.toString()===''){const pps_type=g('pps_type');if(dpc===undefined||dpc===''||pps_type===undefined||pps_type.toString()==='-1'||pps_type.toString()===''){return '';}const span=new Array(3);const score=new Array(3);for (let i=0;i < 3;i++){span[i]=g('span'+(i+1));if(span[i]==='-'){span[i]=span[i-1];}else {let arr=span[i].split(' ~ ');span[i]=(arr.length>1)?parseInt(arr[1],10):parseInt(span[i],10);}score[i]=g('score'+(i+1));if(score[i]==='-'){score[i]=score[i-1];}}let tbl_str=dpccode+'\n'+dpcname+'\n'+'医療機関別係数\t'+coef+'\n'+'物価対応料\t'+surcharge+'\n'+'経過日数\t入院期間\t日当点の金額\t初日からの累計金額\t日当点の金額(係数と物価対応料込み)\t初日からの累計金額(係数と物価対応料込み)\n';const max_span=Math.max.apply(null,span);let los_class;let yen;let sum_yen=0;let sum_surcharge=0;for (let day=1;day <= max_span;day++){los_class=0;if(day>span[1]){los_class=2;}else if(day>span[0]){los_class=1;}yen=score[los_class]*10;sum_yen+=yen;sum_surcharge+=surcharge;tbl_str+=day+'日目\t期間'+((los_class===2)?'Ⅲ':((los_class===1)?'Ⅱ':'Ⅰ'))+'\t'+yen+'\t'+sum_yen+'\t'+(Math.round(yen*coef)+surcharge)+'\t'+(Math.round(sum_yen*coef)+sum_surcharge)+'\n';}return tbl_str;}else {const span=g('span'+(1));const score=g('score'+(1));const yen=score*10;let tbl_str=dpccode+'\n'+dpcname+'\n'+'経過日数\t各日の金額\t初日からの累計金額\n'+'1日目\t'+yen+'\t'+yen+'\n';for (let day=2;day <= span;day++){tbl_str+=day+'日目\t'+0+'\t'+yen+'\n';}return tbl_str;}} function showPstype(pstype,label){if(typeof (label)==='undefined'){label=pstype_labels[pstype];}let htmlText=(pstype==='drg')?''+label :''+label;const advCandidates=g('adv_candidates');if(pstype==='pps'&&advCandidates!==''){let tooltipText='以下の薬剤を使用した場合、適用・用法により出来高請求となる場合があります  '+advCandidates.split('|').join('  ');htmlText+='高額薬剤の指定あり';}htmlText+='';setInnerHTML('is_pps',htmlText);} function clearPstype(){setInnerHTML('is_pps','');} function queryIsAdvOpe(){let out=0;const ope=g('dpc_ope');const pro1=g('dpc_pro1');const pro2=g('dpc_pro2');const val=ope?ope:pro1?pro1:pro2?pro2:null;if(val){const url='/fukuro2026/query.php?type=is_adv_ope&val='+val;const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const _func=function (xmlhttp,domid){out=callBackIsAdvOpe(xmlhttp,domid);};sendRequest(xmlhttp,'GET',url,false,_func,null,null);}return out;} function callBackIsAdvOpe(xmlhttp,domid){eval(xmlhttp.responseText);if(is_adv_ope===1){setInnerHTML('is_pps',''+pstype_labels['ffs'] +'先進手術を選択' +'');}return is_adv_ope;} function calcDpcYen(){const los=g('los');const dpc=g('dpc');const drgId=g('drgId');let coef=1;let coefStr=g('coef');if(coefStr.indexOf('/')!==-1){let buf=coefStr.split('/');coef=parseFloat(buf[0]);}else{coef=parseFloat(coefStr||'1');}if(coef <= 0){coef=1;}if(coef < 0||coef>10) coef=1;let surchargeStr=g('surcharge');if(surchargeStr.indexOf('/')!==-1){let buf=surchargeStr.split('/');surchargeStr=buf[0];}let surcharge=parseInt(surchargeStr||'0',10);if(surcharge < 0||surcharge>10000) surcharge=580;let total_yen=0;if(drgId!==''){total_yen=10*(parseInt(g('score1'),10)+parseInt(g('score2'),10));}else if(los>0&&dpc!==''){const span=new Array(3);const score=new Array(3);for (let i=0;i < 3;i++){let s=g('span'+(i+1));if(s==='-'){span[i]=span[i-1];}else {span[i]=parseInt(s.substring(s.lastIndexOf('~')+1),10);}s=g('score'+(i+1));if(s==='-'){score[i]=0;}else {score[i]=parseInt(s.substring(s.lastIndexOf('~')+1),10);}}if(span[0]>0){total_yen=Math.round((10*score[0]*coef+surcharge)*((los <= span[0])?los:span[0]));if(span[1]>0&&los>span[0]){total_yen+=Math.round((10*score[1]*coef+surcharge)*(((los <= span[1])?los:span[1])-span[0]));if(span[2]>0&&los>span[1]){total_yen+=Math.round((10*score[2]*coef+surcharge)*(((los <= span[2])?los:span[2])-span[1]));}}}}s('total_yen',((total_yen>0)?total_yen:''));} function clearDrgId(){s('drgId','');s('drg_opepro','');} function findDrgInfo(){const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const drgId=g('drgId');const url='/fukuro2026/query.php?type=drgInfo&val='+drgId;sendRequest(xmlhttp,'GET',url,true,callBackDrgInfo,null,null);} function callBackDrgInfo(xmlhttp,domid){eval(xmlhttp.responseText);storeDrgInfoStr(drgId,drgName,iroha,opepro,span,score,surcharge);if(drgId===''){s('dpccode','《 短期滞在手術等基本料3による包括 》');s('dpcname','該当する項目が見つかりません');s('pps_type',pstype);s('span1','');s('score1','');s('span2','');s('score2','');showPstype('drg');}else {s('dpccode',g('mdc6')+'xxxDRG'+drgId.padStart(2,'0'));s('dpcname',drgName);s('pps_type',pstype);s('span1',span);s('score1',score);s('score2',surcharge);showPstype('drg','短手3 : '+code+' : '+opepro);}setDpcInfoPanel('drg');updateScoreFigs();calcDpcYen();updateRelated('ad');} function storeDrgInfoStr(drgId,drgName,iroha,opepro,span,score,surcharge){if(drgId===undefined){return;}s('dpc_info','《 短期滞在手術基本料による包括評価 》\n' +iroha+': '+drgName+' ('+opepro+')\n' +'期間:'+span+'日\n' +'包括点数:'+score+'点\n' +'物価対応料:'+surcharge+'点\n' +'※入院日から'+(span+1)+'日目以降に対象手術/処置を実施した場合は包括対象外\n');} function updateRelated(info_type){clearRelated(info_type);findRelated(info_type);} function findRelated(info_type){if(info_type===undefined){info_type='all';}const icd10raw=g('icd10raw');const icd10=(icd10raw==='')?g('icd10'):icd10raw;const dpc=g('dpc');const opepro=g('dpc_ope')+',' +g('dpc_pro1')+',' +g('dpc_pro2')+',' +g('adv_opepro')+',' +g('drg_opepro');const compli=g('dpc_compli');const drgId=g('drgId');const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const url='/fukuro2026/query.php?type=related&val='+info_type+'|'+icd10+'|'+dpc+'|'+opepro+'|'+compli+'|'+drgId;sendRequest(xmlhttp,'GET',url,true,callBackRelated,null,null);} function findAdvAllDpc(adv_name){const info_type='adv_alldpc';const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const url='/fukuro2026/query.php?type=related&val='+info_type+'|'+adv_name;sendRequest(xmlhttp,'GET',url,true,callBackRelated,null,null);} function findDrgAllDpc(drgName){const info_type='drg_alldpc';const xmlhttp=createHttpRequest();if(xmlhttp==null){return null;}const url='/fukuro2026/query.php?type=related&val='+info_type+'|'+drgName;sendRequest(xmlhttp,'GET',url,true,callBackRelated,null,null);} function callBackRelated(xmlhttp,domid){eval(xmlhttp.responseText);if(data.length < 1){setDisplay('noticeContainer','none');}else {let notes={};let pdf='';let key='';let type='';let title='';let fields;let values;let arr;let element;let drgExists=false;for (let i=0;i < data.length;i++){if(!data[i]){continue;}fields=data[i].split('\t');if(fields.length < 3){continue;}key=fields[0];type=fields[1];if(type==='ad'){arr=fields[2].split('.');let ext=(arr.pop()).toLowerCase();setInnerHTML('adSpace',(ext==='png'||ext==='jpg'||ext==='jpeg'||ext==='gif')?"":fields[2]);}else if((','+note_types.join(',')+',').indexOf(','+type+',')>-1){if(type in notes){notes[type].push(fields);}else {notes[type]=new Array(fields);}}}let items_cnt=0;for (type in notes){items_cnt+=notes[type].length;}for (type in notes){const parent=document.getElementById('notes_'+type);parent.innerHTML='';title=note_titles[type];pdf=note_pdfs[type];element=document.createElement('li');addClass(element,'title');addClass(element,type);element.innerHTML=(pdf!=='')?title+getHtmlPdfLink(pdf):title;parent.appendChild(element);if(type==='rece'){element=document.createElement('li');addClass(element,'attention');addClass(element,type);element.innerHTML=note_attentions[type];parent.appendChild(element);}let elems_hidden_threshold=3;let li_len=notes[type].length;const details=document.createElement('details');const summary=document.createElement('summary');for (let i=0;i < notes[type].length;i++){fields=notes[type][i];key=fields.shift();type=fields.shift();values=fields;let text=values[0];let source='';if(values.length>1&&values[values.length-1].match(/\.pdf(#page=[0-9]+)?$/i)){pdf='pdf/'+values.pop();if(values.length>1){source=values.pop();}}else {pdf='';}let pdf_html=(pdf!=='')?getHtmlPdfLink(pdf,source):'';element=document.createElement('li');addClass(element,'item');addClass(element,type);element.setAttribute('title','マッチしたキーワード:'+key.replace(/\[.+\]/,''));let html='';let code='';let elem_id='';switch (type){case 'adv':let remarks_html;[html,remarks_html,code]=buildRelatedAdv(text,items_cnt);if(code) elem_id=type+'_item_'+code;html+=pdf_html;html+=remarks_html;break;case 'drg':[html,code]=buildRelatedDrg(text,values);if(code) elem_id=type+'_item_'+code;if(code) drgExists=true;html+=pdf_html;break;case 'rece':[html,code]=buildRelatedRece(text,values,elems_hidden_threshold);if(code) elem_id=type+'_item_'+code;html+=pdf_html;break;case 'compli':[html,code]=buildRelatedCompli(text,values);if(code) elem_id=type+'_item_'+code;break;case 'gigi':[html,code]=buildRelatedGigi(text);if(code) elem_id=type+'_item_'+code;html+=pdf_html;break;default:[html,code]=buildRelatedDefault(text);if(code) elem_id=type+'_item_'+code;html+=pdf_html;break;}if(key.indexOf('[')>-1&&key.slice(-1)===']'){const dpc=g('dpc');const more_keys=key.substring(key.indexOf('[')+1,key.length-1).split(',');const cols_class=(type==='adv')?' three_cols':'';html+="';}else if(key==='-'&&type==='adv'){html+="';}if(type==='icd'){if(i===3){summary.style.cursor='pointer';summary.style.paddingLeft='0.5em';summary.style.color='#48802a';summary.style.textDecoration='underline';summary.innerHTML='クリックして 全'+li_len+'項目 を表示する...';details.appendChild(summary);element.innerHTML=html;if(elem_id){element.id=elem_id;}details.appendChild(element);}else if(li_len>3&&i===li_len-1){parent.appendChild(details);}else if(i>3){element.innerHTML=html;if(elem_id){element.id=elem_id;}details.appendChild(element);}else {element.innerHTML=html;if(elem_id){element.id=elem_id;}parent.appendChild(element);}}else {element.innerHTML=html;if(elem_id){element.id=elem_id;}parent.appendChild(element);}}}setDisplay('noticeContainer','none');if(drgExists){const selectedDrgId=g('drgId');if(selectedDrgId&&parseInt(selectedDrgId,10)>0){const refParent=document.getElementById('drg_item_'+selectedDrgId);if(refParent){const label=refParent.querySelector('label');if(label){scrollToAnchorOnSelectDrg=false;label.click();}}}}}contentsChanged();} function buildRelatedAdv(text,items_cnt){const arr=text.split(':');const code=(arr.length>1)?arr[0]:'';let name=(arr.length>1)?arr[1]:text;let remarks_html='';const match=name.match(/^(.*)\|(.*)$/);if(match){name=match[1];const remarks=match[2];const onclick='this.children[1].style.display=(this.children[1].style.display==="none")?"block":"none";';const div_remarks_options=" class='remarks' onclick='"+onclick+"' title='クリックして適用条件の表示を切り替える' style='cursor: pointer;display: block;transition: height 2s ease 1s;'";const display_default=(items_cnt>2)?'display:none;':'display:block';remarks_html=' ※適用条件
"+remarks+'
';}const html="';return [html,remarks_html,code];} function buildRelatedDrg(text,values){const name=values[0] ?? '';const drgId=values[1] ?? '';const iroha=values[2] ?? '';const code=values[3] ?? '';const html="';return [html,drgId.toString()];} function buildRelatedRece(text,values,elems_hidden_threshold){const arr=text.split(':');const code=arr[0];const name=arr[1];let html='';const elems_subtitle=(values.length-1>1)?1:0;for (let k=1;k < values.length;k++){const s=values[k];let s_indexOfKakko=s.indexOf('[');const label=s.substring(0,s_indexOfKakko);const label_code=label.substring(0,label.indexOf(':'));let label_title=label.substring(label.indexOf(':')+1);const reces=s.substring(s_indexOfKakko+1,s.length-1).split(',');const reces_cnt=reces.length;const annotation='(全'+reces_cnt+'項目)';const expand_entries='▽ クリックして全'+reces_cnt+'項目を表示する...';const shrink_entries='△ クリックして閉じる...('+elems_hidden_threshold+'項目だけ表示)';const onClickToggleJs=`const ch=this.children; let disp='none'; if(ch[ch.length-2].style.display==='none'){disp='list-item';} for (let i= ${elems_subtitle}+${elems_hidden_threshold},len=ch.length-1;i < len;i++){ch[i].style.display=disp;} ch[ch.length-1].children[0].innerHTML=(disp==='none')?'${expand_entries}':'${shrink_entries}';`;const onclick_toggle=(reces_cnt>elems_hidden_threshold)?' onclick="'+onClickToggleJs+'"':'';const mdc6=g('dpc').substring(0,6);const dl_url='/fukuro2026/query.php?type=rece_list&val='+mdc6+'|'+label_code.replace(/^x/,'');const dl_url_html="download";if(k===1){if(elems_subtitle){html="
"+code+' '+name+'
';}else {html+="
"+code+' '+(name.length>17?name.substring(0,16)+'...':name)+""+annotation+dl_url_html+'
';}}html+="';}return [html,code];} function buildRelatedCompli(text,values){const arr=text.split(':');const code=arr[0];const name=arr[1];const icds=values[1].split(',');const icds_cnt=icds.length;const annotation='(全'+icds_cnt+'項目)';let html="
"+code+' '+name+""+annotation+'
';const footer_tooltip_shrinked='▽ クリックして該当する標準病名を表示する...';const footer_tooltip_expanded='△ クリックして標準病名を非表示にする';let onClickToggleJs=`const ch=this.children; const len=ch.length-1; let disp='none'; for (let i=0;i < len;i++){if(ch[i].className==='more_subkey'&&ch[i].style.display==='none'){disp='list-item';}} for (let i=0;i < len;i++){if(ch[i].className==='more_subkey'){ch[i].style.display=disp;}} ch[ch.length-1].children[0].innerHTML=(disp==='none')?'${footer_tooltip_shrinked}':'${footer_tooltip_expanded}';`;const onclick_toggle=' onclick="'+onClickToggleJs+'"';html+="