SMMMD03600.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. /*
  2. - ▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩
  3. MDCS ( SMMMD03600_MDCS.xrw - JScript )
  4. - ▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩▩
  5. */
  6. /**
  7. * @desc : SMMMD03600_MDCS.xrw Calculator 버튼 클릭시 iviewer 페이지 결정
  8. * @
  9. * @param :
  10. * @return :
  11. * @author : 정연우
  12. */
  13. function fCalcBtnClick(){
  14. var trgObj = document.controls(event.target);
  15. if( trgObj.elementName == "xforms:button" ) {
  16. var buttonObj = trgObj;
  17. var buttonID = buttonObj.attribute("id");
  18. if (buttonID == "button1") {
  19. iviewer1.src = "SMMMD03700_혈중농도.xrw";
  20. } else if (buttonID == "button2") {
  21. iviewer1.src = "SMMMD04000_용량변경.xrw";
  22. } else if (buttonID == "button3") {
  23. iviewer1.src = "SMMMD04200_청소율.xrw";
  24. } else if (buttonID == "button6") {
  25. iviewer1.src = "SMMMD03800_투여량.xrw";
  26. } else if (buttonID == "button7") {
  27. alert("차후 화면추가 예정입니다.");
  28. } else if (buttonID == "button8") {
  29. iviewer1.src = "SMMMD04300_IBW.xrw";
  30. } else if (buttonID == "button9") {
  31. iviewer1.src = "SMMMD04100_Capacity.xrw";
  32. //iviewer1.src = "SMMMD04100_유지용량.xrw";
  33. } else if (buttonID == "button10") {
  34. //alert("구현중");
  35. } else if (buttonID == "button11") {
  36. iviewer1.src = "SMMMD03900_투여간격.xrw";
  37. } else if (buttonID == "button13") {
  38. iviewer1.src = "SMMMD04400_BMI.xrw";
  39. } else if (buttonID == "button16") {
  40. iviewer1.src = "SMMMD04500_Fluid volume.xrw";
  41. } else if (buttonID == "button17") {
  42. alert("차후 화면추가 예정입니다.");
  43. } else if (buttonID == "button5") {
  44. alert("차후 화면추가 예정입니다.");
  45. } else if (buttonID == "button15") {
  46. alert("차후 화면추가 예정입니다.");
  47. } else if (buttonID == "button20") {
  48. alert("차후 화면추가 예정입니다.");
  49. } else if (buttonID == "button4") {
  50. alert("차후 화면추가 예정입니다.");
  51. } else {
  52. alert("구현중");
  53. }
  54. }
  55. }
  56. // 엔터 입력시 포커스 이동
  57. function fMoveFocus(vCtrlID){
  58. if( event.keyCode == 13 ) {
  59. if( vCtrlID != "" ) model.setFocus(vCtrlID);
  60. }
  61. }
  62. // 소수점 자리수 자르기
  63. function getCutNumber(num, place) {
  64. return Math.floor( num * Math.pow(10,parseInt(place,10)) ) / Math.pow(10,parseInt(place,10));
  65. }
  66. /**
  67. * @desc : SMMMD03700_혈중농도.xrw 탭별 UI(Caption, input)결정
  68. * @
  69. * @param :
  70. * @return :
  71. * @author : 정연우
  72. */
  73. function fSetBolusUI(btnStr){
  74. if(btnStr == "ivbolus"){
  75. caption1.visible = true;
  76. caption2.visible = true;
  77. caption3.visible = false;
  78. caption4.visible = true;
  79. caption5.visible = true;
  80. caption6.visible = false;
  81. caption7.visible = true;
  82. caption8.visible = false;
  83. caption9.visible = true;
  84. caption11.visible = true;
  85. caption12.visible = true;
  86. caption14.visible = false;
  87. caption15.visible = false;
  88. caption16.visible = false;
  89. input1.visible = true;
  90. input2.visible = true;
  91. input3.visible = false;
  92. input4.visible = true;
  93. input5.visible = true;
  94. input6.visible = false;
  95. input7.visible = true;
  96. input8.visible = false;
  97. input9.visible = true;
  98. input10.visible = true;
  99. input11.visible = true;
  100. input13.visible = false;
  101. input14.visible = false;
  102. } else if(btnStr == "infusioninter"){
  103. caption1.visible = false;
  104. caption2.visible = true;
  105. caption3.visible = false;
  106. caption4.visible = true;
  107. caption5.visible = true;
  108. caption6.visible = false;
  109. caption7.visible = true;
  110. caption8.visible = true;
  111. caption9.visible = true;
  112. caption11.visible = true;
  113. caption12.visible = true;
  114. caption14.visible = false;
  115. caption15.visible = false;
  116. caption16.visible = true;
  117. input1.visible = true;
  118. input2.visible = true;
  119. input3.visible = false;
  120. input4.visible = true;
  121. input5.visible = true;
  122. input6.visible = false;
  123. input7.visible = true;
  124. input8.visible = true;
  125. input9.visible = true;
  126. input10.visible = true;
  127. input11.visible = true;
  128. input13.visible = false;
  129. input14.visible = false;
  130. } else if(btnStr == "infusioncont"){
  131. caption1.visible = false;
  132. caption2.visible = false;
  133. caption3.visible = false;
  134. caption4.visible = true;
  135. caption5.visible = false;
  136. caption6.visible = false;
  137. caption7.visible = true;
  138. caption8.visible = false;
  139. caption9.visible = true;
  140. caption11.visible = false;
  141. caption12.visible = false;
  142. caption14.visible = true;
  143. caption15.visible = false;
  144. caption16.visible = true;
  145. input1.visible = true;
  146. input2.visible = false;
  147. input3.visible = false;
  148. input4.visible = true;
  149. input5.visible = false;
  150. input6.visible = false;
  151. input7.visible = true;
  152. input8.visible = false;
  153. input9.visible = true;
  154. input10.visible = false;
  155. input11.visible = false;
  156. input13.visible = true;
  157. input14.visible = true;
  158. } else {
  159. caption1.visible = true;
  160. caption2.visible = true;
  161. caption3.visible = true;
  162. caption4.visible = true;
  163. caption5.visible = true;
  164. caption6.visible = true;
  165. caption7.visible = true;
  166. caption8.visible = false;
  167. caption9.visible = true;
  168. caption11.visible = false;
  169. caption12.visible = true;
  170. caption14.visible = true;
  171. caption15.visible = true;
  172. caption16.visible = false;
  173. input1.visible = true;
  174. input2.visible = true;
  175. input3.visible = true;
  176. input4.visible = true;
  177. input5.visible = true;
  178. input6.visible = true;
  179. input7.visible = true;
  180. input8.visible = false;
  181. input9.visible = true;
  182. input10.visible = true;
  183. input11.visible = true;
  184. input13.visible = false;
  185. input14.visible = false;
  186. }
  187. }
  188. // 혈중농도 - 혈중농도 계산
  189. function fCalcBloodBolus(selectedTab) {
  190. // 계산에 필요한 항목
  191. var admin_val = model.getValue("/root/main/cond/adminval"); // 투여량
  192. var admin_times = model.getValue("/root/main/cond/admintimes"); // 투여횟수
  193. var use_rate = model.getValue("/root/main/cond/userate"); // 생체이용률
  194. var range_capacity = model.getValue("/root/main/cond/rangecapacity"); // 분포용적
  195. var admin_interval = model.getValue("/root/main/cond/admininterval"); // 투여간격
  196. var suction_rate = model.getValue("/root/main/cond/suctionrate"); // 흡수율
  197. var half_life = model.getValue("/root/main/cond/halflife"); // 반감기
  198. var infusion_time1 = model.getValue("/root/main/cond/infusiontime1"); // Infusion 시간1
  199. var infusion_time2 = model.getValue("/root/main/cond/infusiontime2"); // Infusion 시간2
  200. var after_time = model.getValue("/root/main/cond/aftertime"); // 투여후 경과시간
  201. // Divide By Zero 관련 처리
  202. if(admin_val == "0") { messageBox("투여량은 '0'값을 입력", "E001"); model.setFocus("input1"); return; }
  203. else if(range_capacity == "0") { messageBox("분포용적은 '0'값을 입력", "E001"); model.setFocus("input4"); return; }
  204. else if(half_life == "0") { messageBox("반감기는 '0'값을 입력", "E001"); model.setFocus("input7"); return; }
  205. else if(admin_interval == "0") { messageBox("투여간격은 '0'값을 입력", "E001"); model.setFocus("input5"); return; }
  206. // 계산에 필요한 데이터 유무 검증
  207. if(admin_val == "" || range_capacity == "" || half_life == "" || after_time == "" ) { // 투여량, 분포용적, 반감기, 투여경과시간은 공통
  208. messageBox("모든 입력란은 ", "I003"); return;
  209. }
  210. // 탭별 계산에 필요한 데이터 유무검증 및 계산
  211. var ke = 0.693 / half_life; // 소실률(ke)
  212. ke = getCutNumber(ke, 4);
  213. var peak; var trough; var ivbolus; var statusbolus;
  214. if(selectedTab == "tab_ivbolus") {
  215. if(admin_times == "" || admin_interval == "") {
  216. messageBox("모든 입력란은 ", "I003"); return;
  217. }
  218. // IV bolus 계산
  219. peak = getBolusPeak(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate);
  220. trough = getBolusTrough(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate, suction_rate);
  221. ivbolus = getIvbolus(selectedTab, ke, admin_val, range_capacity, admin_interval, admin_times, after_time, infusion_time1, infusion_time2, use_rate, suction_rate);
  222. }else if(selectedTab == "tab_infusioninter") {
  223. if(admin_times == "" || admin_interval == "" || infusion_time1 == "") {
  224. messageBox("모든 입력란은 ", "I003"); return;
  225. }
  226. // IV infusion(inter) 계산
  227. peak = getBolusPeak(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate);
  228. trough = getBolusTrough(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate, suction_rate);
  229. ivbolus = getIvbolus(selectedTab, ke, admin_val, range_capacity, admin_interval, admin_times, after_time, infusion_time1, infusion_time2, use_rate, suction_rate);
  230. }else if(selectedTab == "tab_infusioncont") {
  231. if(infusion_time2 == "") {
  232. messageBox("모든 입력란은 ", "I003"); return;
  233. }
  234. // IV infusion(cont) 계산
  235. statusbolus = getStatusbolus(selectedTab, ke, admin_val, range_capacity);
  236. ivbolus = getIvbolus(selectedTab, ke, admin_val, range_capacity, admin_interval, admin_times, after_time, infusion_time1, infusion_time2, use_rate, suction_rate);
  237. }else{
  238. if(admin_times == "" || admin_interval == "" || use_rate == "" || suction_rate == "") {
  239. messageBox("모든 입력란은 ", "I003"); return;
  240. }
  241. // Oral bolus 계산
  242. peak = getBolusPeak(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate); // Average 계산
  243. trough = getBolusTrough(selectedTab, ke, admin_val, range_capacity, admin_interval, infusion_time1, use_rate, suction_rate);
  244. ivbolus = getIvbolus(selectedTab, ke, admin_val, range_capacity, admin_interval, admin_times, after_time, infusion_time1, infusion_time2, use_rate, suction_rate);
  245. }
  246. // 계산된 값 셋팅
  247. model.setValue("/root/send/savedata/peak", peak); // Peak 계산값 셋팅(Oral bolus에서는 Average)
  248. model.setValue("/root/send/savedata/trough", trough); // Trough 계산값 셋팅
  249. model.setValue("/root/send/savedata/ivbolus", ivbolus); // 특정시간 경과후 농도 계산값 셋팅
  250. model.setValue("/root/send/savedata/statusbolus", statusbolus); // 항정상태에서의 농도 계산값 셋팅
  251. model.refresh();
  252. }
  253. // 혈중농도 - Peak 계산(Oral bolus에서는 Average)
  254. function getBolusPeak(selectedTab, ke, adminVal, rangeCapacity, adminInterval, infusionTime1, useRate){
  255. var thisPeak = 0;
  256. var temp1 = getCutNumber(Math.exp(-ke * adminInterval), 4);
  257. var temp2;
  258. // Divide By Zero 관련 처리
  259. if(temp1 == 1) { temp2 = 0; }
  260. else { temp2 = 1 / (1 - temp1); }
  261. if(selectedTab == "tab_ivbolus"){
  262. thisPeak = (adminVal / rangeCapacity) * temp2;
  263. }else if(selectedTab == "tab_infusioninter"){
  264. thisPeak = (adminVal / (ke * rangeCapacity)) * (1 - Math.exp(-ke * infusionTime1)) * temp2;
  265. }else if(selectedTab == "tab_oralbolus"){
  266. thisPeak = (useRate * adminVal) / (ke * rangeCapacity * adminInterval); //Average
  267. }
  268. return getCutNumber(thisPeak, 4);
  269. }
  270. // 혈중농도 - Trough 계산
  271. function getBolusTrough(selectedTab, ke, adminVal, rangeCapacity, adminInterval, infusionTime1, useRate, suctionRate){
  272. var thisTrough = 0;
  273. var temp1; var temp2; var temp3; var temp4;
  274. temp1 = getCutNumber(Math.exp(-ke * adminInterval), 4);
  275. // Divide By Zero 관련 처리
  276. if(temp1 == 1) { temp2 = 0; }
  277. else{ temp2 = 1 / (1 - temp1); }
  278. temp1 = Math.exp(-ke * infusionTime1);
  279. //alert("temp1:"+temp1);
  280. if(temp1 == 1) { temp3 = 0; }
  281. else{ temp3 = 1 - temp1; }
  282. temp1 = Math.exp(-suctionRate * adminInterval);
  283. if(temp1 == 1) { temp4 = 0; }
  284. else{ temp4 = 1 / (1 - temp1); }
  285. if(selectedTab == "tab_ivbolus"){
  286. thisTrough = (adminVal / rangeCapacity) * temp2 * Math.exp(-ke * adminInterval);
  287. }else if(selectedTab == "tab_infusioninter"){
  288. thisTrough = (adminVal / (ke * rangeCapacity)) * temp3 * temp2 * Math.exp(-ke * adminInterval);
  289. }else if(selectedTab == "tab_oralbolus"){
  290. thisTrough = ((useRate * adminVal) / rangeCapacity) * (suctionRate / (suctionRate - ke)) * (temp2 - temp4);
  291. }
  292. return getCutNumber(thisTrough, 4);
  293. }
  294. // 혈중농도 - 시간경과후 농도 계산
  295. function getIvbolus(selectedTab, ke, adminVal, rangeCapacity, adminInterval, adminTimes, afterTime, infusionTime1, infusionTime2, useRate, suctionRate){
  296. var thisIvbolus = 0;
  297. var temp1 = getCutNumber(Math.exp(-ke * adminInterval), 4);
  298. var temp2;
  299. var temp3 = getCutNumber(Math.exp(-suctionRate * adminInterval), 4);
  300. var temp4;
  301. // Divide By Zero 관련 처리
  302. if(temp1 == 1) { temp2 = 0; }
  303. else { temp2 = (1 - Math.exp(-ke * adminInterval * adminTimes)) / (1 - temp1); }
  304. if(temp3 == 1) { temp4 = 0; }
  305. else { temp4 = (1 - Math.exp(-suctionRate * adminInterval * adminTimes)) / (1 - temp3); }
  306. if(selectedTab == "tab_ivbolus"){
  307. thisIvbolus = (adminVal / rangeCapacity) * temp2 * Math.exp(-ke * afterTime);
  308. }else if(selectedTab == "tab_infusioninter"){
  309. thisIvbolus = (adminVal / (ke * rangeCapacity)) * (1 - Math.exp(-ke * infusionTime1)) * temp2 * Math.exp(-ke * adminInterval);
  310. }else if(selectedTab == "tab_infusioncont"){
  311. thisIvbolus = (adminVal / (ke * rangeCapacity)) * (1 - Math.exp(-ke * afterTime));
  312. }else if(selectedTab == "tab_oralbolus"){
  313. thisIvbolus = ((useRate * adminVal) / rangeCapacity) * (suctionRate / (suctionRate - ke)) * ((Math.exp(-ke * afterTime) * temp2) - (Math.exp(-suctionRate * afterTime) * temp4));
  314. }
  315. return getCutNumber(thisIvbolus, 4);
  316. }
  317. // 혈중농도 - 항정상태에서의 농도 계산
  318. function getStatusbolus(selectedTab, ke, adminVal, rangeCapacity){
  319. var thisStatusbolus = 0;
  320. thisStatusbolus = adminVal / (ke * rangeCapacity);
  321. return getCutNumber(thisStatusbolus, 4);
  322. }
  323. /**
  324. * @desc : SMMMD03800_투여량.xrw 탭별 UI(Caption, input)결정
  325. * @
  326. * @param :
  327. * @return :
  328. * @author : 정연우
  329. */
  330. function fSetAdminUI(btnStr){
  331. if(btnStr == "ivbolus"){
  332. caption1.visible = true;
  333. caption2.visible = true;
  334. caption3.visible = false;
  335. caption4.visible = true;
  336. caption5.visible = true;
  337. caption6.visible = false;
  338. caption7.visible = false;
  339. caption8.visible = true;
  340. caption9.visible = true;
  341. caption10.visible = true;
  342. caption11.visible = true;
  343. caption12.visible = false;
  344. caption13.visible = true;
  345. input1.visible = true;
  346. input2.visible = true;
  347. input3.visible = false;
  348. input4.visible = true;
  349. input5.visible = true;
  350. input6.visible = false;
  351. input7.visible = false;
  352. input8.visible = true;
  353. input9.visible = true;
  354. input10.visible = true;
  355. input11.visible = true;
  356. input12.visible = true;
  357. } else if(btnStr == "infusioninter"){
  358. caption1.visible = true;
  359. caption2.visible = true;
  360. caption3.visible = false;
  361. caption4.visible = true;
  362. caption5.visible = true;
  363. caption6.visible = false;
  364. caption7.visible = true;
  365. caption8.visible = true;
  366. caption9.visible = true;
  367. caption10.visible = true;
  368. caption11.visible = true;
  369. caption12.visible = false;
  370. caption13.visible = true;
  371. input1.visible = true;
  372. input2.visible = true;
  373. input3.visible = false;
  374. input4.visible = true;
  375. input5.visible = true;
  376. input6.visible = false;
  377. input7.visible = true;
  378. input8.visible = true;
  379. input9.visible = true;
  380. input10.visible = true;
  381. input11.visible = true;
  382. input12.visible = true;
  383. } else if(btnStr == "infusioncont"){
  384. caption1.visible = true;
  385. caption2.visible = false;
  386. caption3.visible = false;
  387. caption4.visible = true;
  388. caption5.visible = false;
  389. caption6.visible = false;
  390. caption7.visible = true;
  391. caption8.visible = true;
  392. caption9.visible = true;
  393. caption10.visible = true;
  394. caption11.visible = true;
  395. caption12.visible = false;
  396. caption13.visible = true;
  397. input1.visible = true;
  398. input2.visible = false;
  399. input3.visible = false;
  400. input4.visible = true;
  401. input5.visible = false;
  402. input6.visible = false;
  403. input7.visible = true;
  404. input8.visible = true;
  405. input9.visible = true;
  406. input10.visible = true;
  407. input11.visible = true;
  408. input12.visible = true;
  409. } else {
  410. caption1.visible = true;
  411. caption2.visible = true;
  412. caption3.visible = true;
  413. caption4.visible = true;
  414. caption5.visible = true;
  415. caption6.visible = true;
  416. caption7.visible = false;
  417. caption8.visible = true;
  418. caption9.visible = true;
  419. caption10.visible = false;
  420. caption11.visible = true;
  421. caption12.visible = true;
  422. caption13.visible = true;
  423. input1.visible = true;
  424. input2.visible = true;
  425. input3.visible = true;
  426. input4.visible = true;
  427. input5.visible = true;
  428. input6.visible = true;
  429. input7.visible = false;
  430. input8.visible = true;
  431. input9.visible = true;
  432. input10.visible = true;
  433. input11.visible = true;
  434. input12.visible = true;
  435. }
  436. }
  437. // 투여량 계산
  438. function fCalcAdminVal(selectedTab) {
  439. // 계산에 필요한 항목
  440. var range_capacity = model.getValue("/root/main/cond/rangecapacity"); // 분포용적
  441. var admin_times = model.getValue("/root/main/cond/admintimes"); // 투여횟수
  442. var use_rate = model.getValue("/root/main/cond/userate"); // 생체이용률
  443. var half_life = model.getValue("/root/main/cond/halflife"); // 반감기
  444. var admin_interval = model.getValue("/root/main/cond/admininterval"); // 투여간격
  445. var suction_rate = model.getValue("/root/main/cond/suctionrate"); // 흡수율
  446. var infusion_time = model.getValue("/root/main/cond/infusiontime"); // Infusion 시간
  447. //var special_time = model.getValue("/root/main/cond/specialtime");
  448. var after_time = model.getValue("/root/main/cond/specialtime"); // 특정시간
  449. var blood_bolus = model.getValue("/root/main/cond/bloodbolus"); // 혈중농도
  450. var peak_level = model.getValue("/root/main/cond/peaklevel"); // Peak level
  451. var tro_level = model.getValue("/root/main/cond/trolevel"); // Trough level
  452. // Divide By Zero 관련 처리
  453. if(range_capacity == "0") { messageBox("분포용적은 '0'값을 입력", "E001"); model.setFocus("input1"); return; }
  454. else if(use_rate == "0") { messageBox("생체이용률은 '0'값을 입력", "E001"); model.setFocus("input3"); return; }
  455. else if(half_life == "0") { messageBox("반감기는 '0'값을 입력", "E001"); model.setFocus("input4"); return; }
  456. else if(suction_rate == "0") { messageBox("흡수율은 '0'값을 입력", "E001"); model.setFocus("input6"); return; }
  457. // 계산에 필요한 데이터 유무 검증
  458. if(range_capacity == "" || half_life == "" || after_time == "" ) { // 투여량, 분포용적, 반감기, 투여경과시간은 공통
  459. messageBox("모든 입력란은 ", "I003"); return;
  460. }
  461. // 탭별 계산에 필요한 데이터 유무검증 및 계산
  462. var ke = 0.693 / half_life; // 소실률(ke)
  463. var calc_val_rslt; // 투여량 계산결과
  464. if(selectedTab == "tab_ivbolus") {
  465. if(admin_times == "" || admin_interval == "") {
  466. messageBox("모든 입력란은 ", "I003"); return;
  467. }
  468. calc_val_rslt = getCalcRslt(selectedTab, ke, range_capacity, admin_interval, admin_times, after_time, infusion_time, use_rate, suction_rate, blood_bolus, peak_level, tro_level);
  469. }else if(selectedTab == "tab_infusioninter") {
  470. calc_val_rslt = getCalcRslt(selectedTab, ke, range_capacity, admin_interval, admin_times, after_time, infusion_time, use_rate, suction_rate, blood_bolus, peak_level, tro_level);
  471. }else if(selectedTab == "tab_infusioncont") {
  472. calc_val_rslt = getCalcRslt(selectedTab, ke, range_capacity, admin_interval, admin_times, after_time, infusion_time, use_rate, suction_rate, blood_bolus, peak_level, tro_level);
  473. }else{
  474. calc_val_rslt = getCalcRslt(selectedTab, ke, range_capacity, admin_interval, admin_times, after_time, infusion_time, use_rate, suction_rate, blood_bolus, peak_level, tro_level);
  475. }
  476. // 계산된 값 셋팅
  477. model.setValue("/root/send/savedata/adminresult", calc_val_rslt);
  478. model.refresh();
  479. }
  480. // 투여량 - 투여량 계산결과
  481. function getCalcRslt(selectedTab, ke, rangeCapacity, adminInterval, adminTimes, afterTime, infusionTime, useRate, suctionRate, cTarget, cPeak, cTrough){
  482. var thisRslt = 0;
  483. var temp1 = getCutNumber(Math.exp(-ke * adminInterval * adminTimes), 4);
  484. var temp2;
  485. var temp3;
  486. var temp4;
  487. var temp5;
  488. // Divide By Zero 관련 처리
  489. if(temp1 == 1) { temp2 = 0; }
  490. else { temp2 = (1 - Math.exp(-ke * adminInterval)) / (1 - temp1); }
  491. temp1 = Math.exp(-ke * infusionTime);
  492. if(temp1 == 1) { temp3 = 0; }
  493. else { temp3 = (cTarget * ke * rangeCapacity) / (1 - temp1); }
  494. temp1 = Math.exp(-ke * afterTime);
  495. if(temp1 == 1) { temp5 = 0; // temp4가 '0'이면 divide by zero에 걸림
  496. } else {
  497. temp4 = 1 / (1 - temp1);
  498. temp5 = (cTarget * ke * rangeCapacity) / temp4
  499. }
  500. if(selectedTab == "tab_ivbolus"){
  501. thisRslt = ((cTarget * rangeCapacity) / (Math.exp(-ke * afterTime))) * temp2; //n회 투여후 특정시간 특정농도에 도달하기 위한 투여량
  502. //thisRslt = (cPeak * rangeCapacity) * ((1 - Math.exp(-ke * adminInterval)); // 항정상태에서 희망 peak level에 도달하기 위한 투여량
  503. //thisRslt = ((cTrough * rangeCapacity) / Math.exp(-ke * adminInterval)) * ((1 - Math.exp(-ke * adminInterval)); // 항정상태에서 희망 trough level에 도달하기 위한 투여량
  504. }else if(selectedTab == "tab_infusioninter"){
  505. thisRslt = temp3 * temp2 * temp4; //n회 투여후 특정시간 특정농도에 도달하기 위한 시간당 투여량
  506. //thisRslt = ((cPeak * ke * rangeCapacity) * ((1 - Math.exp(-ke * adminInterval)); // 항정상태에서 희망 peak level에 도달하기 위한 시간당 투여량
  507. //thisRslt = ((cTrough * ke * rangeCapacity) * ((1 - Math.exp(-ke * adminInterval)) * (1 / (1 - Math.exp(-ke * afterTime))); // 항정상태에서 희망 trough level에 도달하기 위한 시간당 투여량
  508. }else if(selectedTab == "tab_infusioncont"){
  509. thisRslt = temp5; // 특정시간 특정농도에 도달하기 위한 시간당 투여량
  510. //thisRslt = cPeak * ke * rangeCapacity; // 항정상태에서 희망 농도에 도달하기 위한 시간당 투여량
  511. }else if(selectedTab == "tab_oralbolus"){
  512. var temp1 = getCutNumber(Math.exp(-ke * afterTime), 4);
  513. var temp2 = getCutNumber(Math.exp(-ke * adminInterval * adminTimes), 4);
  514. var temp3 = getCutNumber(Math.exp(-ke * adminInterval), 4);
  515. var temp4 = getCutNumber(Math.exp(-suctionRate * afterTime), 4);
  516. var temp5 = getCutNumber(Math.exp(-suctionRate * adminInterval * adminTimes), 4);
  517. var temp6 = getCutNumber(Math.exp(-suctionRate * adminInterval), 4);
  518. var temp7;
  519. var temp8;
  520. var temp9;
  521. // Divide By Zero 관련 처리
  522. if(temp2 == 1 && temp3 == 1) { temp7 = 0; }
  523. else { temp7 = (1 - temp2) / (1 - temp3); }
  524. if(temp5 == 1 && temp6 == 1) { temp8 = 0; }
  525. else { temp8 = (1 - temp5) / (1 - temp6); }
  526. var temp = (temp1 * temp7) - (temp4 * temp8);
  527. // Divide By Zero 관련 처리
  528. temp = getCutNumber(temp, 4);
  529. if(temp == 0){ temp9 = 0; }
  530. else { temp9 = temp9 = getCutNumber((1 / temp),4); }
  531. thisRslt = getCutNumber(((cTarget * rangeCapacity) / useRate),4) * getCutNumber(((suctionRate - ke) / suctionRate),4) * temp9; //n회 투여후 특정시간 특정농도에 도달하기 위한 투여량
  532. //temp = (1 / (1 - Math.exp(-ke * adminInterval))) - (1 / (1 - Math.exp(-suctionRate * adminInterval)));
  533. //temp = getCutNumber(temp, 4);
  534. //thisRslt = ((cTrough * rangeCapacity) / useRate) * ((suctionRate - ke) / suctionRate) * (1 / temp); // 항정상태에서 희망 trough level에 도달하기 위한 투여량
  535. //thisRslt = (cPeak * ke * rangeCapacity * adminInterval) / useRate; // 항정상태에서 희망 average level에 도달하기 위한 투여량
  536. }
  537. return getCutNumber(thisRslt, 4);
  538. }
  539. // 투여간격 계산
  540. function fCalcAdminItv() {
  541. // 계산에 필요한 항목
  542. var peak_level = model.getValue("/root/main/cond/peaklevel"); // Peak level
  543. var tro_level = model.getValue("/root/main/cond/trolevel"); // Trough level
  544. var half_life = model.getValue("/root/main/cond/halflife"); // 반감기
  545. // Divide By Zero 관련 처리
  546. if(peak_level == "0") { messageBox("peak level은 '0'값을 입력", "E001"); model.setFocus("input1"); return; }
  547. else if(tro_level == "0") { messageBox("trough level은 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  548. else if(half_life == "0") { messageBox("반감기는 '0'값을 입력", "E001"); model.setFocus("input3"); return; }
  549. // 계산에 필요한 데이터 유무 검증
  550. if(peak_level == "" || tro_level == "" || half_life == "" ) { // Peak level, Trough level, 반감기
  551. messageBox("모든 입력란은 ", "I003"); return;
  552. }
  553. // 탭별 계산에 필요한 데이터 유무검증 및 계산
  554. var ke = 0.693 / half_life; // 소실률(ke)
  555. var calc_itv_rslt; // 투여간격 계산결과
  556. calc_itv_rslt = getCalcItvRslt(ke, peak_level, tro_level);
  557. // 계산된 값 셋팅
  558. model.setValue("/root/send/savedata/intervalresult", calc_itv_rslt);
  559. model.refresh();
  560. }
  561. // 투여간격 계산 결과
  562. function getCalcItvRslt(ke, cPeak, cTrough){
  563. var thisRslt = 0;
  564. var temp = cPeak / cTrough;
  565. temp = getCutNumber(temp, 4);
  566. ke = getCutNumber(ke, 4);
  567. thisRslt = Math.log(temp) / ke; // Natural log cf) base 10 log -> log10(double a)
  568. return getCutNumber(thisRslt, 4);
  569. }
  570. // 용량변경
  571. function fCalcAdmin(){
  572. // 계산에 필요한 항목
  573. var base_val = model.getValue("/root/main/cond/baseval"); // 기존투여량
  574. var calc_concent = model.getValue("/root/main/cond/calcconcentration"); // 측정혈중농도
  575. var expect_concent = model.getValue("/root/main/cond/expectconcentration"); // 희망혈중농도
  576. // Divide By Zero 관련 처리
  577. if(calc_concent == "0") { messageBox("측정혈중농도는 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  578. // 계산에 필요한 데이터 유무 검증
  579. if(base_val == "" || calc_concent == "" || expect_concent == "" ) { // 기존투여량, 측정혈중농도, 희망혈중농도
  580. messageBox("모든 입력란은 ", "I003"); return;
  581. }
  582. var calc_admin_rslt;
  583. calc_value_rslt = getCalcAdmin(base_val, calc_concent, expect_concent);
  584. // 계산된 값 셋팅
  585. model.setValue("/root/send/savedata/valresult", calc_value_rslt);
  586. model.refresh();
  587. }
  588. // 용량변경 계산 결과
  589. function getCalcAdmin(baseVal, calcConcent, expectConcent){
  590. var thisRslt = 0;
  591. thisRslt = (expectConcent * baseVal) / calcConcent
  592. return getCutNumber(thisRslt, 4);
  593. }
  594. // 유지용량 계산
  595. function fCalcMaintenance() {
  596. // 계산에 필요한 항목
  597. var loading_dose = model.getValue("/root/main/cond/loadingdose"); // Loading dose
  598. var half_life = model.getValue("/root/main/cond/halflife"); // 반감기
  599. var admin_interval = model.getValue("/root/main/cond/admininterval"); // 유지용량 투여간격
  600. // Divide By Zero 관련 처리
  601. if(half_life == "0") { messageBox("반감기는 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  602. // 계산에 필요한 데이터 유무 검증
  603. if(loading_dose == "" || half_life == "" || admin_interval == "" ) { // Loading dose, 반감기, 유지용량 투여간격
  604. messageBox("모든 입력란은 ", "I003"); return;
  605. }
  606. var ke = 0.693 / half_life; // 소실률(ke)
  607. ke = getCutNumber(ke, 4);
  608. var calc_itv_rslt; // 유지용량 투여간격
  609. calc_value_rslt = getCalcValRslt(ke, loading_dose, admin_interval);
  610. // 계산된 값 셋팅
  611. model.setValue("/root/send/savedata/valresult", calc_value_rslt);
  612. model.refresh();
  613. }
  614. // 유지용량 계산 결과
  615. function getCalcValRslt(ke, loadingDose, adminInterval){
  616. var thisRslt = 0;
  617. thisRslt = loadingDose * (1 - Math.exp(-ke * adminInterval));
  618. return getCutNumber(thisRslt, 4);
  619. }
  620. // 청소율 계산
  621. function fCalcCleanRate() {
  622. // 계산에 필요한 항목
  623. var weight = model.getValue("/root/main/cond/weight"); // 체중
  624. var height = model.getValue("/root/main/cond/height"); // 키
  625. var scr = model.getValue("/root/main/cond/scr"); // scr
  626. var sex = model.getValue("/root/main/cond/sex"); // 성별
  627. var age = model.getValue("/root/main/cond/patage"); // 나이
  628. if(age == 0) {
  629. messageBox("환자정보가 없어 계산","E001");
  630. return;
  631. }
  632. // Divide By Zero 관련 처리
  633. if(weight == "0") { messageBox("몸누게는 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  634. else if(height == "0") { messageBox("키는 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  635. else if(scr == "0") { messageBox("Scr은 '0'값을 입력", "E001"); model.setFocus("input2"); return; }
  636. // 계산에 필요한 데이터 유무 검증
  637. if(weight == "" || height == "" || scr == "" || sex == "") { // 체중, 키, scr, 성별
  638. messageBox("모든 입력란은 ", "I003"); return;
  639. }
  640. var adult_cl; var adult_gfr; var child_cl; var child_gfr;
  641. adult_cl = getAdultCl(weight, height, scr, sex, age);
  642. adult_gfr = getAdultGfr(weight, height, scr, sex, age);
  643. child_cl = getChildCl(weight, height, scr, sex, age);
  644. child_gfr = getChildGfr(weight, height, scr, sex, age);
  645. // 계산된 값 셋팅
  646. model.setValue("/root/send/savedata/adulcl", adult_cl);
  647. model.setValue("/root/send/savedata/adulgfr", adult_gfr);
  648. model.setValue("/root/send/savedata/childcl", child_cl);
  649. model.setValue("/root/send/savedata/childgfr", child_gfr);
  650. model.refresh();
  651. }
  652. // 청소율 - Adult Cl
  653. function getAdultCl(weight, height, scr, sex, age){
  654. var thisRslt = 0;
  655. if(sex == "M"){ // 남자
  656. thisRslt = ((140 - age) * weight) / (72 * scr);
  657. } else { // 여자
  658. thisRslt = ((140 - age) * weight) / (72 * scr) * 0.85;
  659. }
  660. return getCutNumber(thisRslt, 4);
  661. }
  662. // 청소율 - Adult GFR
  663. function getAdultGfr(weight, height, scr, sex, age){
  664. var thisRslt = 0;
  665. if(sex == "M"){ // 남자
  666. thisRslt = 186 / ((Math.pow(scr, 1.154) * Math.pow(age, 0.203)));
  667. } else { // 여자
  668. thisRslt = (186 * 0.742) / ((Math.pow(scr, 1.154) * Math.pow(age, 0.203)));
  669. }
  670. return getCutNumber(thisRslt, 4);
  671. }
  672. // 청소율 - Child Cl
  673. function getChildCl(height, scr){
  674. var thisRslt = 0;
  675. thisRslt = (0.55 * height) / scr;
  676. return getCutNumber(thisRslt, 4);
  677. }
  678. // 청소율 - Child GFR
  679. function getChildGfr(weight, height, scr, sex, age){
  680. var thisRslt = 0;
  681. thisRslt = (0.43 * height) / scr;
  682. return getCutNumber(thisRslt, 4);
  683. }
  684. // IBW 계산
  685. function fCalcIBW() {
  686. // 계산에 필요한 항목
  687. var weight = model.getValue("/root/main/cond/weight"); // 체중
  688. var height = model.getValue("/root/main/cond/height"); // 키
  689. var sex = model.getValue("/root/main/cond/sex"); // 성별
  690. var age = model.getValue("/root/main/cond/patage"); // 나이
  691. // Divide By Zero 관련 처리
  692. // 계산에 필요한 데이터 유무 검증
  693. if(weight == "" || height == "" || sex == "") { // 체중, 키, 성별
  694. messageBox("모든 입력란은 ", "I003"); return;
  695. }
  696. var devine; var robinson; var miller; var lemmens;
  697. devine = getCalcIBW(weight, height, sex, 50, 2.3, 45.5, 2.3); // Devine equation
  698. robinson = getCalcIBW(weight, height, sex, 52, 1.9, 49, 1.7); // Robinson equation
  699. miller = getCalcIBW(weight, height, sex, 56.2, 1.41, 53.1, 1.36); // Miller equation
  700. lemmens = getLemmens(weight, height); // Lemmens equation
  701. // 계산된 값 셋팅
  702. model.setValue("/root/send/savedata/adulcl", devine);
  703. model.setValue("/root/send/savedata/adulgfr", robinson);
  704. model.setValue("/root/send/savedata/childcl", miller);
  705. model.setValue("/root/send/savedata/childgfr", lemmens);
  706. model.refresh();
  707. }
  708. // IBW - Devine equation, Robinson equation, Miller equation
  709. function getCalcIBW(weight, height, sex, var1, var2, var3, var4){
  710. var thisRslt = 0;
  711. var temp = 0;
  712. if(height > 152.4){
  713. temp = (height - 152.4) / 2.54;
  714. temp = getCutNumber(temp, 4);
  715. }
  716. if(sex == "M"){ // 남자
  717. thisRslt = var1 + (var2 * temp);
  718. } else { // 여자
  719. thisRslt = var3 + (var4 * temp);
  720. }
  721. return getCutNumber(thisRslt, 4);
  722. }
  723. // IBW - Lemmens
  724. function getLemmens(weight, height){
  725. var thisRslt = 0;
  726. thisRslt = 22 * Math.pow(height, 2)
  727. return getCutNumber(thisRslt, 4);
  728. }
  729. // BMI 계산
  730. function fCalcBMI() {
  731. // 계산에 필요한 항목
  732. var weight = model.getValue("/root/main/cond/weight"); // 체중
  733. var height = model.getValue("/root/main/cond/height"); // 키
  734. // Divide By Zero 관련 처리
  735. if(height == "0") { messageBox("키는 '0'값을 입력", "E001"); model.setFocus("input5"); return; }
  736. // 계산에 필요한 데이터 유무 검증
  737. if(weight == "" || height == "") { // 체중, 키
  738. messageBox("모든 입력란은 ", "I003"); return;
  739. }
  740. var cal_bmi;
  741. bmi_result = getCalcBMI(weight, height);
  742. // 계산된 값 셋팅
  743. model.setValue("/root/send/savedata/bmiresult", bmi_result);
  744. model.refresh();
  745. }
  746. // BMI 계산결과
  747. function getCalcBMI(weight, height){
  748. var thisRslt = 0;
  749. thisRslt = weight / Math.pow(height, 2)
  750. return getCutNumber(thisRslt, 4);
  751. }
  752. // Fluid volume 계산
  753. function fCalcFluidVol(selectedTab) {
  754. /*
  755. // 계산에 필요한 항목
  756. var weight = model.getValue("/root/main/cond/weight"); // 체중
  757. var surface = model.getValue("/root/main/cond/surface"); // 체표면적
  758. var kcal = model.getValue("/root/main/cond/kcal"); // 칼로리
  759. // Divide By Zero 관련 처리
  760. // 계산에 필요한 데이터 유무 검증
  761. //if(weight == "" || surface == "" || kcal == "" ) { // 체중, 체표면적, 칼로리
  762. // messageBox("모든 입력란은 ", "I003"); return;
  763. //}
  764. var calc_day_water; // 1일수분유지량
  765. var calc_na; // Na
  766. var calc_k; // k
  767. var calc_glucose; // glucose
  768. // if(admin_times == "" || admin_interval == "") {
  769. // messageBox("모든 입력란은 ", "I003"); return;
  770. // }
  771. calc_day_water = getCalcWater(selectedTab, weight, surface, kcal);
  772. // 계산된 값 셋팅
  773. model.setValue("/root/send/savedata/daywater", calc_day_water);
  774. model.refresh();
  775. */
  776. alert("해당 계산식 점검중입니다.");
  777. }
  778. // BMI 계산결과
  779. function getCalcWater(selectedTab, weight, surface, kca){
  780. var thisRslt = 0;
  781. //thisRslt = weight / Math.pow(height, 2)
  782. return getCutNumber(thisRslt, 4);
  783. }