SPADT61302.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. /**
  2. * 파 일 명 : SPADT61302.js
  3. * 설 명 : (팝업)원내라벨출력 Javascriot
  4. * 설 계 자 : 공두경
  5. * 작 성 자 : 공두경
  6. * 수정이력 : 2007.09.20 / 최초작성 / 공두경
  7. */
  8. var sSndMsg = ""; //라벨출력내용
  9. var iPoint = 0; //라벨출력row
  10. var iCnt = 0; //라벨출력매수
  11. var iImageCnt = 0; //라벨그래픽폰트수
  12. var ordflag = "";
  13. var iTotalPageNum = 0;
  14. var iPageCnt = 0;
  15. var mPoint = 0;
  16. var nextPage = false;
  17. var vCnt = 0;
  18. /**
  19. * 초기화
  20. */
  21. function fInit() {
  22. var sParam = model.getAttribute("params");
  23. model.makeValue("/root/send/prcpinfo/drugdd", astfMatrixData(sParam, 1, 0));
  24. model.makeValue("/root/send/prcpinfo/drugno", astfMatrixData(sParam, 1, 1));
  25. model.makeValue("/root/send/prcpinfo/ioflag", astfMatrixData(sParam, 1, 2));
  26. model.makeValue("/root/send/prcpinfo/lblflag", astfMatrixData(sParam, 1, 3));
  27. model.makeValue("/root/send/prcpinfo/liquidflag", astfMatrixData(sParam, 1, 4));
  28. model.makeValue("/root/send/prcpinfo/reprintyn", astfMatrixData(sParam, 1, 5));
  29. model.makeValue("/root/send/prcpinfo/autoinprntyn", astfMatrixData(sParam, 1, 6));
  30. model.makeValue("/root/send/prcpinfo/lbl5", astfMatrixData(sParam, 1, 7)); // 2010.03.18 pymi
  31. model.makeValue("/root/send/prcpinfo/atclblyn", astfMatrixData(sParam, 1, 8)); // 2010-12-13 이선경
  32. model.makeValue("/root/send/prcpinfo/prntflag", "O");
  33. //model.makeValue("/root/send/prcpinfo/dlblflag", ""); // 2010.03.18 pymi
  34. // 2010.03. 18 pymi
  35. /*var sLblflag = model.getValue("/root/send/prcpinfo/lblflag").split("|");
  36. for(var i = 0 ; i < sLblflag.length ; i++) {
  37. if("D" == sLblflag[i] ) {
  38. model.setValue("/root/send/prcpinfo/dlblflag", "Y");
  39. break;
  40. }
  41. }
  42. model.refresh();*/
  43. // (e)
  44. submit("TRADT61301");
  45. if(model.getValue("/root/main/lbllist/lbllist["+1+"]/drugkindnm") != ""){
  46. if(model.getValue("/root/send/prcpinfo/liquidflag") == "Y"){
  47. fLiquidLBLPrint();
  48. } else {
  49. fLBLPrint();
  50. }
  51. }
  52. model.refresh();
  53. gTimer = window.setInterval("fStopTimer()",10000);
  54. window.close();
  55. }
  56. /**
  57. *
  58. */
  59. function fStopTimer() {
  60. window.clearinterval(gTimer);
  61. }
  62. function fSleep(numberMillis) {
  63. var now = new Date();
  64. var exitTime = now.getTime() + numberMillis;
  65. while (true) {
  66. now = new Date();
  67. if (now.getTime() > exitTime)
  68. return;
  69. }
  70. }
  71. /**
  72. * 라벨출력
  73. */
  74. function fLBLPrint() {
  75. /*
  76. 라벨 Sorting 로직
  77. //mgt에서 vo로 리턴
  78. 대분류
  79. - 내복약, 외용약, 주사, 항암제, TPN, 마약,
  80. 중분류
  81. - 방법코드
  82. 소분류
  83. - 내복약,외용약(방법코드), 주사,마약,항암제(mix)
  84. web js 출력로직
  85. 1 약종류(내복약/주사약/외용약)
  86. 1.1 방법코드
  87. 1.2 처방수량
  88. */
  89. // Comm 설정
  90. //CommAX.CommPort = "1"; // 출력 Port
  91. //CommAX.Settings = "9600,n,8,1"; // Comm 설정
  92. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  93. PrnKind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/prntkind");
  94. PrnMarginLeft = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/left");
  95. PrnMarginTop = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/top");
  96. var commkind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/commkind")
  97. if ( PrnKind ==7 ) {
  98. CommAX.PrnKind =4;
  99. } else {
  100. CommAX.PrnKind =PrnKind;
  101. }
  102. if(commkind == "02") {
  103. CommAX.PortNm = 1;
  104. } else {
  105. CommAX.PortNm = 2;
  106. }
  107. if(commkind == "01") {
  108. CommAX.PrtNm = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval");
  109. }
  110. // zebra 용지부족일때 오류 메시지 2009.10.14 pymi
  111. /*if( (CommAX.PrnKind == 0 || CommAX.PrnKind == 1) && CommAX.PortNm == 1) {
  112. if(!CommAX.Zebra_chk()) {
  113. return;
  114. }
  115. }*/
  116. // (e)
  117. // alert(PrnKind + "///" + commkind + "///" + model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval"));
  118. var reprint ="";
  119. //if ( CommAX.PortOpen() == true) {
  120. //alert("라벨 프린트 Open");
  121. //CommAX.SendMessage("^XA^SEE:UHANGUL.DAT^FS^CWQ,E:AAAAA.FNT^FS^CI26^FO100,50^AQN,40,40^FD이훈재ABCDEFGHI1234^FS^FO100,100^AQN,40,40^FD(주)한글인쇄테스트ABCDEFGHI1234^FS^FO100,150^AQN,40,40^FD A B C D E F G H I^FS^CI0^FO100,200^A0,50,50^FDPRINTING TEST^FS^FO100,250^BY2^B3N,N,100,Y,N,N^FD1232423423^FS^XZ");
  122. //CommAX.SendMessage("^XA^LH0,0^PRB^CF0,89^FO10,05^FDSH07^FS^CF0,70^FO260,05^FD10/10^FS^CF0,89^FO50,80^FD- 234567^FS^CFA20,20^FO10,150^FD1234567890^FS~DGGRAPH001,00504,021,0078000000E00000800000F01E000C00201FFC0000003C0000007007FFC00000F01E000C00201FFC000000006000003003000000C0701C00180060180C03000FFFF00FFE3003000000C0701C00180060180C0300061000061C300300000300783C003001E0101800C0007E000018300300C00300783C003001E0101800C000C30000303001FFE006006C6C006003600018006001818000603000180006006C6C006003600018006000C30000C03000180004006C6C00C0066000300020007E0001803000180004006C6C00C006600030002000180003003000181E0C0066CC0180186000600030001800060030FFFFFF0C0066CC018018600060003000181E1800207000000C00638C0300306000C00030FFFFFF0000000000000C00638C0300306000C000307000000000000000000400638C060060600180002000000000FFF00038000400638C0600606001800020007E00006060007E000600610C0C007FFC0180006000C30000006000C3000600610C0C007FFC018000600181800000400181800300600C18000060018000C001818000FFE00181800300600C18000060018000C001818000600001818000C0F03E300001F80180030000C30000600000C30000C0F03E300001F801800300007E00006060007E00000000000000000000000000003800003FF0003800000000000000000000000000^FO140,150^XGGRAPH001,1,1^FS~DGGRAPH002,00216,009,0000700000000001C00000380000000000E00000180000000000600000180000000000600FFF1807FFE0000060060E180300C03FFC60001C180000C0181C60003018000080001C600060180FFFC000186000D018070000001860018C180300000C18600307180300C006106606031801FFE006207F18001800000006006000001801860006036000001800C300061C6000001000C300FFE06000E00000C30070006000300000C31E000060003000FFFFFF000060003000700000000060003018000000000060001FFC000000000060000000000000000040^FO320,150^XGGRAPH002,1,1^FS^CFA20,20^FO10,180^FD2007-04-25^FS~DGGRAPH003,00240,010,002001E00000E0000080002001E000007007FFC0006006380000300300000060063800303003000001E00C1830183003000001E00C181818300300C003600800181BF001FFE0036008001FF830001800066018001818300018000660180018183000180018601BF0181BF000181E18601BF01FF830FFFFFF30601C1810103070000030601C180000200000006060180C0000000000006060180C0007000038007FFC0C0C000FC0007E007FFC0C0C00186000C30000600E1800303001818000600E1800303001818001F803E000303001818001F803E000186000C30000000000000FC0007E0000000000000700003800^FO140,180^XGGRAPH003,1,1^FS^CFE10,10^FO10,210^FDStomach 2/10^FS^CFA20,20^FO10,240^FDBiopsh^FS^PQ1^XZ");
  123. //CommAX.PortClose();
  124. //return;
  125. //페이지번호 조회
  126. //var iPageCnt = 0;
  127. var prcpnum = "";
  128. var prcpCnt = 8;
  129. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  130. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  131. reprint ="(재)";
  132. }
  133. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  134. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  135. if (mthdcd == "ZZZ" || mthdcd == "A10PQ") { //기타용법이거나 '필요시 복용하십시오' 용법인 경우도 단독라벨출력
  136. sumcls = mthdcd;
  137. }
  138. if( fChkSumcls(iPoint)){
  139. //단독라벨출력
  140. } else {
  141. //일반라벨출력
  142. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  143. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  144. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  145. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  146. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  147. var cnt = 0;
  148. var lblCnt = 0;
  149. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  150. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  151. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  152. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  153. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  154. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  155. var lblcnts2 = model.getValue("/root/main/lbllist/lbllist["+ j +"]/lblcnts2");
  156. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  157. && !fChkSumcls(j)){
  158. if(lblcnts2.length > 0) { lblCnt ++; }
  159. cnt++;
  160. // 용법 바뀌지 않는 마지막 처방 갯수 2010.02.10 pymi
  161. if( j == getNodesetCount("/root/main/lbllist/lbllist")) {
  162. //라벨갯수
  163. if( lblCnt >= 3 ) {
  164. iPageCnt += parseInt(lblCnt/3);
  165. lblCnt = parseInt(lblCnt%3);
  166. }
  167. // 기준 갯수
  168. if(lblCnt == 0) prcpCnt = 8;
  169. if(lblCnt == 1) prcpCnt = 6;
  170. if(lblCnt == 2) prcpCnt = 2;
  171. // 처방갯수 - 기준갯수
  172. var reCnt = cnt - prcpCnt;
  173. if( reCnt > 0 ) {
  174. iPageCnt ++;
  175. iPageCnt += parseInt(reCnt/8);
  176. }
  177. }
  178. // (e)
  179. } else {
  180. //라벨갯수 2010.02.10 pymi
  181. if( lblCnt >= 3 ) {
  182. iPageCnt += parseInt(lblCnt/3);
  183. lblCnt = parseInt(lblCnt%3);
  184. }
  185. // 기준 갯수
  186. if(lblCnt == 0) prcpCnt = 8;
  187. if(lblCnt == 1) prcpCnt = 6;
  188. if(lblCnt == 2) prcpCnt = 2;
  189. // 처방갯수 - 기준갯수
  190. var reCnt = cnt - prcpCnt;
  191. if( reCnt > 0 ) {
  192. iPageCnt ++;
  193. iPageCnt += parseInt(reCnt/8);
  194. }
  195. break;
  196. }
  197. /*if(cnt == 8){
  198. j++;
  199. break;
  200. }*/
  201. }
  202. if(j != iPoint) {
  203. iPoint = j-1;
  204. }
  205. }
  206. iPageCnt++;
  207. }
  208. //var iTotalPageNum = iPageCnt;
  209. iTotalPageNum = iPageCnt; // 2010.02.10 pymi
  210. //alert(iTotalPageNum);
  211. iPageCnt = 0;
  212. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  213. //시작(X, Y)
  214. sSndMsg += astfStartFormat(0, 0, "B");
  215. iPageCnt++;
  216. //alert(iPageCnt);
  217. //////////////////////////////////////////////////
  218. // 라벨 상단내용 //
  219. /////////////////////////////////////////////////
  220. //투약번호
  221. sSndMsg += astfPrintOut(30, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno") + reprint ,"");
  222. //환자명
  223. sSndMsg += astfPrintOut(180, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm").substring(0,5),"");
  224. //바코드(변환)
  225. sSndMsg += astfBarCode_Code39(390, 40, "N", 70, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode"));
  226. //환자번호
  227. sSndMsg += astfPrintOut(30, 80, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid"),"");
  228. //성별나이
  229. sSndMsg += astfPrintOut(240, 85, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sexage"),"");
  230. //처방과약어명
  231. sSndMsg += astfPrintOut(30, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/deptengabbr"),"");
  232. //의사명
  233. sSndMsg += astfPrintOut(120, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/orddrnm"),"");
  234. //처방일자==>수납일자로 변경(20091014 이선경)
  235. //sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  236. sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd")),"");
  237. //페이지수
  238. sSndMsg += astfPrintOut(430, 135, 3, iPageCnt+"/"+iTotalPageNum,"");
  239. //바코드
  240. sSndMsg += astfPrintOut(510, 130, 3, "*"+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode")+"*","");
  241. //선그리기
  242. sSndMsg += astfGraphicBox(5, 180, 815, 0, 4);
  243. if(PrnKind == "2") {
  244. sSndMsg += astfPrintOut(20, 600, 1, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  245. sSndMsg += astfPrintOut(20, 630, 1, " 일단 조제투약된 약은 반납할 수 없습니다.");
  246. } else {
  247. sSndMsg += astfPrintOut(20, 600, 2, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  248. sSndMsg += astfPrintOut(20, 630, 2, " 일단 조제투약된 약은 반납할 수 없습니다.");
  249. }
  250. //////////////////////////////////////////////////
  251. // 라벨 하단내용 //
  252. /////////////////////////////////////////////////
  253. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  254. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  255. if (mthdcd == "ZZZ" || mthdcd == "A10PQ") { //기타용법이거나 '필요시 복용하십시오' 용법인 경우도 단독라벨출력
  256. sumcls = mthdcd;
  257. }
  258. if( fChkSumcls(iPoint)){
  259. //단독라벨출력
  260. fIndependPrint();
  261. } else {
  262. //일반라벨출력
  263. fGnrlPrint();
  264. }
  265. //종료(매수)
  266. sSndMsg += astfEndFormat(0);
  267. CommAX.SendMsg(sSndMsg);
  268. // alert(sSndMsg);
  269. fSleep(500);
  270. sSndMsg = "";
  271. // 2010.02.17 pymi
  272. if(nextPage) {
  273. fGnrlPrintnm(vCnt, ordflag);
  274. nextPage = false;
  275. vCnt = 0;
  276. ordflag = "";
  277. }
  278. // (e)
  279. if(iPoint == getNodesetCount("/root/main/lbllist/lbllist")) {
  280. iTotalPageNum = 0;
  281. iPageCnt = 0;
  282. }
  283. }
  284. //CommAX.PortClose();
  285. model.refresh();
  286. //}
  287. }
  288. /**
  289. *
  290. */
  291. function fIndependPrint() {
  292. //약종류(내복약/주사약/외용약)
  293. sSndMsg += astfPrintOut(30, 230, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  294. //라벨내용
  295. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  296. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  297. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  298. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqtyunit");
  299. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  300. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno"); //처방일수
  301. var mthddayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayno"); //용법일수
  302. var packunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/packunit"); //약품마스터의 수량단위
  303. if (drugkindnm == "[주사약]"){
  304. //용법2
  305. sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  306. } else if (drugkindnm == "[외용약]"){
  307. //sSndMsg += astfPrintOut(210, 230, 7, "1일 "+tims+"회 "+fChkFloat(qty)+"개씩 "+dayno+"일분","");
  308. //용법1
  309. ///sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  310. ///
  311. //용법2
  312. ///sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),""); + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  313. //이선경 2008-08-20 start(용법이 짤리지 않고 출력되도록)
  314. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  315. + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  316. if(val.length > 22) {
  317. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 22),"");
  318. if(val.substring(0, 22).length > 22) {
  319. sSndMsg += astfPrintOut(30, 370, 7, val.substring(22, 50),"");
  320. sSndMsg += astfPrintOut(30, 440, 7, val.substring(50, val.length),"");
  321. } else {
  322. sSndMsg += astfPrintOut(30, 370, 7, val.substring(22, val.length),"");
  323. }
  324. } else {
  325. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 22),"");
  326. }
  327. //이선경 2008-08-20 end(용법이 짤리지 않고 출력되도록)
  328. } else if (drugkindnm == "[내복약]"){
  329. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  330. if( sumcls == "DM" || sumcls == "DS" || sumcls == "DT" || sumcls == "DX"){ //20091110 이선경 수정 : 라벨그룹이 마약(경구), 수제, ptp, 기타약일경우 약품마스터의 수량단위를 출력
  331. var tmpqty = Math.round(qty * 10) / 10;
  332. if(packunit == "T" || packunit == "C") {
  333. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(qty)+"정씩 "+(dayno*mthddayno)+"일분","");
  334. } else {
  335. //sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(tmpqty)+ qtyunit +"씩 "+(dayno*mthddayno)+"일분","");
  336. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(tmpqty)+ packunit +"씩 "+(dayno*mthddayno)+"일분","");
  337. }
  338. } else {
  339. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(qty)+"포[정]씩 "+(dayno*mthddayno)+"일분","");
  340. }
  341. //용법1
  342. //sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  343. // + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  344. //용법2
  345. //sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  346. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2") + " "
  347. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  348. if(val.length > 25) {
  349. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 25),"");
  350. if(val.substring(0, 25).length > 25) {
  351. sSndMsg += astfPrintOut(30, 370, 7, val.substring(25, 53),"");
  352. sSndMsg += astfPrintOut(30, 440, 7, val.substring(53, val.length),"");
  353. } else {
  354. sSndMsg += astfPrintOut(30, 370, 7, val.substring(25, val.length),"");
  355. }
  356. } else {
  357. sSndMsg += astfPrintOut(30, 300, 7, val,"");
  358. }
  359. }
  360. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  361. lblcnts1 = lblcnts1.setReplaceWord("~", "-"); //20090728
  362. // 2010.03.18 pymi
  363. if(!fChkSumcls(iPoint) && model.getValue("/root/send/prcpinfo/lbl5") == "Y") {
  364. var val = "";
  365. } else {
  366. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")
  367. +" "+parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty"))
  368. +" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  369. }
  370. /*var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")
  371. +" "+parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty"))
  372. +" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");*/
  373. if(lblcnts1.length > 25){
  374. //주의사항
  375. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1.substring(0,25),"");
  376. if(val.substring(0, 25).length > 25) {
  377. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(25,53),"");
  378. sSndMsg += astfPrintOut(30, 570, 5, lblcnts1.substring(53,lblcnts1.length),"");
  379. } else {
  380. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(25,lblcnts1.length),"");
  381. }
  382. //약정보
  383. sSndMsg += astfPrintOut(30, 570, 4, val, "");
  384. } else {
  385. //주의사항
  386. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1,"");
  387. //약정보
  388. sSndMsg += astfPrintOut(30, 510, 4, val, "");
  389. }
  390. /*if(lblcnts1.length > 28){
  391. //주의사항
  392. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(0,24),"");
  393. sSndMsg += astfPrintOut(30, 570, 5, lblcnts1.substring(24,lblcnts1.length),"");
  394. //약정보
  395. sSndMsg += astfPrintOut(30, 630, 4, val, "");
  396. } else {
  397. //주의사항
  398. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1,"");
  399. //약정보
  400. sSndMsg += astfPrintOut(30, 570, 4, val, "");
  401. }*/
  402. //var s= "복용기간: "+((getCurrentDate()).toDate("YYYYMMDD")).getDateFormat("YYYY/MM/DD") +" - "+ (((getCurrentDate()).toDate("YYYYMMDD")).getAddDate( parseInt(dayno),"D")).getDateFormat("YYYY/MM/DD");
  403. //sSndMsg +=astfPrintOut(30, 630, 3, s);
  404. }
  405. /**
  406. *
  407. */
  408. function fGnrlPrint() {
  409. var cnt = 0;
  410. var ordCnt = 0; // 2010.02.10 pymi
  411. //약종류(내복약/주사약/외용약)
  412. sSndMsg += astfPrintOut(30, 220, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  413. //라벨내용
  414. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  415. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  416. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  417. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  418. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");//처방일수
  419. var mthddayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayno"); //용법일수
  420. //약코드 출력
  421. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  422. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  423. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  424. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  425. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  426. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  427. if(drugkindnm != "[내복약]") {
  428. if (drugkindnm == "[주사약]"){
  429. //용법2
  430. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  431. } else if (drugkindnm == "[외용약]"){
  432. //sSndMsg += astfPrintOut(210, 220, 7, "1일 "+tims+"회 "+qty+"개씩 "+dayno+"일분","");
  433. //용법1
  434. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  435. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  436. //용법2
  437. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  438. }
  439. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  440. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  441. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  442. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  443. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  444. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  445. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  446. && !fChkSumcls(j)){
  447. //if(model.getValue("/root/main/lbllist/lbllist["+j+"]/fst_prnt") == "Y"){
  448. var prcpqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/totdrugqty")/model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  449. prcpqty = Math.ceil( prcpqty * tims*1000)/1000 ;
  450. if(PrnKind == "2") {
  451. // 2010.03.18 pymi
  452. if(!fChkSumcls(j) && model.getValue("/root/send/prcpinfo/lbl5") == "Y") {
  453. var val = "";
  454. } else {
  455. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  456. +" "+prcpqty
  457. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  458. val = val.substr(0,21);
  459. }
  460. /*var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  461. +" "+prcpqty
  462. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  463. val = val.substr(0,21);*/
  464. } else {
  465. // 2010.03.18 pymi
  466. if(!fChkSumcls(j) && model.getValue("/root/send/prcpinfo/lbl5") == "Y") {
  467. var val = "";
  468. } else {
  469. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  470. +" "+prcpqty
  471. +" "+(model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm")).substring(0,6);
  472. }
  473. /*var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  474. +" "+prcpqty
  475. +" "+(model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm")).substring(0,6);*/
  476. }
  477. sSndMsg += astfPrintOut(30+((cnt%2)*380), 440+((parseInt(cnt/2, 10))*40), 2, val, "");
  478. //}
  479. cnt++;
  480. } else {
  481. break;
  482. }
  483. if(cnt == 8){
  484. j++;
  485. break;
  486. }
  487. }
  488. iPoint = j-1;
  489. } else if (drugkindnm == "[내복약]"){
  490. var lbltims =0;
  491. lbl_tims = mthd2.split(",");
  492. if ( mthdcd == "ZZZ" ){
  493. lbltims = tims;
  494. } else if ( mthd3.indexOf("취침") > -1 ) {
  495. lbltims = lbl_tims.length +1;
  496. } else if(mthd2.indexOf("마다") > -1){
  497. lbltims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  498. } else {
  499. lbltims = lbl_tims.length;
  500. }
  501. tims = lbltims;
  502. if(lbltims == 1) {
  503. if(mthd2.indexOf("마다") == -1) {
  504. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno * mthddayno)+"일분","");
  505. } else {
  506. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+tims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  507. }
  508. } else {
  509. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  510. }
  511. //용법1
  512. //if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") =="취침전에" ){
  513. // sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  514. // +" " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  515. //} else {
  516. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2")
  517. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  518. sSndMsg += astfPrintOut(30, 290, 7, val,"");
  519. //}
  520. //sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/abbrnm"),"");
  521. //용법2
  522. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  523. // 포장 라벨내용찍기 2010.02.10 pymi
  524. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  525. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  526. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  527. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  528. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  529. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  530. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  531. && !fChkSumcls(j)){
  532. // 2010.02.10 pymi
  533. var lblcnts2 = model.getValue("/root/main/lbllist/lbllist["+ j +"]/lblcnts2");
  534. ordflag += j + "/"; // 포장라벨 처방코드 순서
  535. if(lblcnts2.length > 0) {
  536. sSndMsg += astfPrintOut(30, 440 +(50 * ordCnt), 5, lblcnts2, "");
  537. ordCnt++; // 포장라벨 갯수
  538. }
  539. // (e)
  540. } else {
  541. // 용법이 바뀌는 시점 2010.02.10 pymi
  542. // 처방출력
  543. fGnrlPrintnm(ordCnt, ordflag);
  544. ordflag = "";
  545. // (e)
  546. break;
  547. }
  548. //if(cnt == 8){
  549. if(ordCnt == 3){ //2010.02.10 pymi
  550. j++;
  551. if(j <= getNodesetCount("/root/main/lbllist/lbllist")) {
  552. var drugkind3 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  553. var dayno3 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  554. var mthd7 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  555. var mthd8 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  556. var mthd9 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  557. if((drugkind1 == drugkind3) && (dayno1 == dayno3) && (mthd1 == mthd7 && mthd2 == mthd8 && mthd3 == mthd9)
  558. && !fChkSumcls(j)){
  559. // 페이지 넘겨서도 용법 바뀌지 않으면 계속 진행
  560. } else {
  561. // 페이지 넘길때 용법이 바뀌면 처방 출력
  562. nextPage = true;
  563. vCnt = ordCnt;
  564. //fGnrlPrintnm(ordCnt, bordflag);
  565. }
  566. }
  567. break;
  568. }
  569. }
  570. iPoint = j-1;
  571. //var s ="복용기간: "+((getCurrentDate()).toDate("YYYYMMDD")).getDateFormat("YYYY/MM/DD") +" - "+ (((getCurrentDate()).toDate("YYYYMMDD")).getAddDate( parseInt(dayno),"D")).getDateFormat("YYYY/MM/DD") ;
  572. //sSndMsg +=astfPrintOut(30, 630, 3, s);
  573. // 용법 바뀌지 않는 마지막 처방 출력 2010.02.10 pymi
  574. if(iPoint == getNodesetCount("/root/main/lbllist/lbllist") ) {
  575. if(ordCnt == 3) {
  576. nextPage = true;
  577. vCnt = ordCnt;
  578. }
  579. else {
  580. fGnrlPrintnm(ordCnt, ordflag);
  581. ordflag = "";
  582. }
  583. }
  584. // (e)
  585. } // end of if(내복)
  586. }
  587. /*
  588. * 2010.02.10 pymi 처방출력
  589. */
  590. function fGnrlPrintnm(linecnt, ordflag) {
  591. var cnt = 0;
  592. var xValue = 440;
  593. var valCnt = 8;
  594. var lblup = false;
  595. var sordflag = "";
  596. sordflag = ordflag.split("/");
  597. if(linecnt == 1) { xValue = 490; valCnt = 6; }
  598. if(linecnt == 2) { xValue = 540; valCnt = 2; }
  599. if(linecnt == 3) { xValue = 440; valCnt = 8; lblup = true;}
  600. for(mPoint = parseInt(sordflag[0]); mPoint <= parseInt(sordflag[sordflag.length - 2]); mPoint++) {
  601. if(lblup) {
  602. //시작(X, Y)
  603. xValue = 440;
  604. valCnt = 8;
  605. cnt = 0;
  606. //
  607. /*PrnKind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/prntkind");
  608. PrnMarginLeft = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/left");
  609. PrnMarginTop = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/top");
  610. var commkind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/commkind")
  611. if ( PrnKind ==7 ) {
  612. CommAX.PrnKind =4;
  613. } else {
  614. CommAX.PrnKind =PrnKind;
  615. }
  616. if(commkind == "02") {
  617. CommAX.PortNm = 1;
  618. } else {
  619. CommAX.PortNm = 2;
  620. }
  621. if(commkind == "01") {
  622. CommAX.PrtNm = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval");
  623. }*/
  624. //
  625. var reprint ="";
  626. if ( model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/lblprnttims")>0 ){
  627. reprint ="(재)";
  628. }
  629. sSndMsg += astfStartFormat(0, 0, "B");
  630. iPageCnt++;
  631. //alert(iPageCnt);
  632. //////////////////////////////////////////////////
  633. // 라벨 상단내용 //
  634. /////////////////////////////////////////////////
  635. //투약번호
  636. sSndMsg += astfPrintOut(30, 30, 6, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/drugno") + reprint ,"");
  637. //환자명
  638. sSndMsg += astfPrintOut(180, 30, 6, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/patnm").substring(0,5),"");
  639. //바코드(변환)
  640. sSndMsg += astfBarCode_Code39(390, 40, "N", 70, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/barcode"));
  641. //환자번호
  642. sSndMsg += astfPrintOut(30, 80, 3, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/pid"),"");
  643. //성별나이
  644. sSndMsg += astfPrintOut(240, 85, 3, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/sexage"),"");
  645. //처방과약어명
  646. sSndMsg += astfPrintOut(30, 135, 3, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/deptengabbr"),"");
  647. //의사명
  648. sSndMsg += astfPrintOut(120, 135, 3, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/orddrnm"),"");
  649. //처방일자==>수납일자로 변경(20091014 이선경)
  650. //sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  651. sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/rcptdd")),"");
  652. //페이지수
  653. sSndMsg += astfPrintOut(430, 135, 3, iPageCnt+"/"+iTotalPageNum,"");
  654. //바코드
  655. sSndMsg += astfPrintOut(510, 130, 3, "*"+model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/barcode")+"*","");
  656. //선그리기
  657. sSndMsg += astfGraphicBox(5, 180, 815, 0, 4);
  658. if(PrnKind == "2") {
  659. sSndMsg += astfPrintOut(20, 600, 1, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  660. sSndMsg += astfPrintOut(20, 630, 1, " 일단 조제투약된 약은 반납할 수 없습니다.");
  661. } else {
  662. sSndMsg += astfPrintOut(20, 600, 2, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  663. sSndMsg += astfPrintOut(20, 630, 2, " 일단 조제투약된 약은 반납할 수 없습니다.");
  664. }
  665. lblup = false;
  666. }
  667. sSndMsg += astfPrintOut(30, 220, 7, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/drugkindnm"),"");
  668. //라벨내용
  669. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/drugkindnm");
  670. var qty = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/prcpqty");
  671. var dayqty = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/dayprcpqty");
  672. var tims = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/prcptims");
  673. var dayno = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/prcpdayno");//처방일수
  674. var mthddayno = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/dayno"); //용법일수
  675. //약코드 출력
  676. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/drugkindnm");
  677. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/prcpdayno");
  678. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd1");
  679. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd2");
  680. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd3");
  681. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthdcd");
  682. //용법출력
  683. var lbltims =0;
  684. lbl_tims = mthd2.split(",");
  685. if ( mthdcd == "ZZZ" ){
  686. lbltims = tims;
  687. } else if ( mthd3.indexOf("취침") > -1 ) {
  688. lbltims = lbl_tims.length +1;
  689. } else if(mthd2.indexOf("마다") > -1){
  690. lbltims = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/prcptims");
  691. } else {
  692. lbltims = lbl_tims.length;
  693. }
  694. tims = lbltims;
  695. if(lbltims == 1) {
  696. if(mthd2.indexOf("마다") == -1) {
  697. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno * mthddayno)+"일분","");
  698. } else {
  699. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+tims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  700. }
  701. } else {
  702. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  703. }
  704. //용법1
  705. var val = model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd1") + model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd2")
  706. + model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthd3");
  707. sSndMsg += astfPrintOut(30, 290, 7, val,"");
  708. //용법2
  709. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+mPoint+"]/mthdcnts4"),"");
  710. for(var j = mPoint; j <= parseInt(sordflag[sordflag.length - 2]) ; j++){
  711. //var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  712. //var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  713. //var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  714. //var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  715. //var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  716. //if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  717. // && !fChkSumcls(j)){
  718. //if(model.getValue("/root/main/lbllist/lbllist["+j+"]/fst_prnt") == "Y"){
  719. var prcpqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/totdrugqty")/model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  720. prcpqty = Math.ceil( prcpqty * tims*1000)/1000 ;
  721. if(PrnKind == "2") {
  722. // 2010.03.18 pymi
  723. if(!fChkSumcls(j) && model.getValue("/root/send/prcpinfo/lbl5") == "Y") {
  724. var val = "";
  725. } else {
  726. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  727. +" "+prcpqty
  728. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  729. val = val.substr(0,21);
  730. }
  731. /*var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  732. +" "+prcpqty
  733. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  734. val = val.substr(0,21);*/
  735. } else {
  736. // 2010.03.18 pymi
  737. if(!fChkSumcls(j) && model.getValue("/root/send/prcpinfo/lbl5") == "Y") {
  738. var val = "";
  739. } else {
  740. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  741. +" "+prcpqty
  742. +" "+(model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm")).substring(0,6);
  743. }
  744. /*var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  745. +" "+prcpqty
  746. +" "+(model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm")).substring(0,6);*/
  747. }
  748. sSndMsg += astfPrintOut(30+((cnt%2)*380), xValue+((parseInt(cnt/2, 10))*40), 2, val, "");
  749. //}
  750. cnt++;
  751. //} else {
  752. // break;
  753. //}
  754. //if(cnt == 8){
  755. if(cnt == valCnt){
  756. j++;
  757. lblup = true;
  758. break;
  759. }
  760. }
  761. mPoint = j-1;
  762. //var s ="복용기간: "+(rcptdd.toDate("YYYYMMDD")).getDateFormat("YYYY/MM/DD") +" - "+ ((rcptdd.toDate("YYYYMMDD")).getAddDate( parseInt(dayno),"D")).getDateFormat("YYYY/MM/DD") ;
  763. //sSndMsg +=astfPrintOut(30, 630, 3, s);
  764. //종료(매수)
  765. sSndMsg += astfEndFormat(0);
  766. CommAX.SendMsg(sSndMsg);
  767. fSleep(500);
  768. sSndMsg = "";
  769. }
  770. }
  771. /**
  772. *
  773. */
  774. function fGetImage() {
  775. var pImage = "";
  776. iImageCnt++;
  777. if(iImageCnt > 99){
  778. pImage = "GRAPH"+iImageCnt;
  779. } else if(iImageCnt > 9){
  780. pImage = "GRAPH0"+iImageCnt;
  781. } else {
  782. pImage = "GRAPH00"+iImageCnt;
  783. }
  784. return pImage
  785. }
  786. /**
  787. *
  788. */
  789. function fDateFormat(sDD) {
  790. return sDD.substr(0,4)+"/"+sDD.substr(4,2)+"/"+sDD.substr(6,2);
  791. }
  792. /**
  793. *
  794. */
  795. function fChkFloat(qty) {
  796. var fQty = parseFloat(qty);
  797. var fRst = "";
  798. if(fQty%1 == 0){
  799. fRst = parseInt(qty);
  800. } else {
  801. fRst = qty;
  802. }
  803. return fRst;
  804. }
  805. /**
  806. *
  807. */
  808. function fChkSumcls(cnt) {
  809. var chk = false;
  810. var sSumcls = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/sumcls");
  811. var sSnglyn = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/atcifsnglyn");
  812. var sDrugindependpackflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/drugindependpackflag");
  813. if(sSumcls == "DI" || sSumcls == "DS"|| sSumcls == "DX"|| sSumcls == "DT" || sSumcls == "DM" || sSumcls == "IH"|| sSumcls == "IO"
  814. || sSumcls == "IS"|| sSumcls == "IX"|| sSumcls == "X" || sSumcls == "ZZZ" || sSumcls == "A10PQ" || sSumcls == "I"){
  815. chk = true;
  816. }
  817. if ( sSumcls == "D" && sSnglyn =="Y" ) {
  818. chk = true;
  819. }
  820. if ( sDrugindependpackflag =="Y"){
  821. chk = true;
  822. }
  823. return chk;
  824. }
  825. /**
  826. * 물약라벨출력
  827. */
  828. function fLiquidLBLPrint() {
  829. // Comm 설정
  830. //CommAX.CommPort = "1"; // 출력 Port
  831. //CommAX.Settings = "9600,n,8,1"; // Comm 설정
  832. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  833. PrnKind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/prntkind");
  834. PrnMarginLeft = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/left");
  835. PrnMarginTop = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/top");
  836. var commkind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/commkind")
  837. if ( PrnKind ==7 ) {
  838. CommAX.PrnKind =4;
  839. } else {
  840. CommAX.PrnKind =PrnKind;
  841. }
  842. if(commkind == "02") {
  843. CommAX.PortNm = 1;
  844. } else {
  845. CommAX.PortNm = 2;
  846. }
  847. if(commkind == "01") {
  848. CommAX.PrtNm = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval");
  849. }
  850. var reprint="";
  851. //if ( CommAX.PortOpen() == true) {
  852. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  853. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  854. reprint ="(재)";
  855. }
  856. //시작(X, Y)
  857. sSndMsg += astfStartFormat(0, 0, "S");
  858. //////////////////////////////////////////////////
  859. // 라벨 상단내용 //
  860. /////////////////////////////////////////////////
  861. //투약번호
  862. //sSndMsg += astfPrintOut(50, 30, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint,"");
  863. //환자명
  864. //sSndMsg += astfPrintOut(50, 85, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  865. //내복약
  866. //sSndMsg += astfPrintOut(250, 30, 3, "내복약","");
  867. //처방일자
  868. //sSndMsg += astfPrintOut(250, 70, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  869. //환자번호
  870. //sSndMsg += astfPrintOut(250, 110, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid"),"");
  871. //선그리기
  872. //8sSndMsg += astfGraphicBox(5, 145, 465, 0, 4);
  873. var sDD = getCurrentDate();
  874. var sTM = getCurrentTime();
  875. //라벨이름(내복약/주사약/마약)
  876. sSndMsg += astfPrintOut(20, 25, 20, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  877. if(PrnKind == "2") {
  878. //출력일자
  879. sSndMsg += astfPrintOut(170, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  880. //처방일자==>수납일자로 변경(20091014 이선경)
  881. //sSndMsg += astfPrintOut(170, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  882. sSndMsg += astfPrintOut(170, 55, 21, "수 납 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd"), "MD"),"");
  883. } else {
  884. //출력일자
  885. sSndMsg += astfPrintOut(220, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  886. //처방일자==>수납일자로 변경(20091014 이선경)
  887. //sSndMsg += astfPrintOut(220, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  888. sSndMsg += astfPrintOut(220, 55, 21, "수 납 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd"), "MD"),"");
  889. }
  890. //처방과약어명
  891. sSndMsg += astfPrintOut(20, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/deptengabbr"),"");
  892. //환자이름
  893. sSndMsg += astfPrintOut(120, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  894. //환자번호
  895. sSndMsg += astfPrintOut(240, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid")+" ("+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint+")","");
  896. //선그리기
  897. sSndMsg += astfGraphicBox(5, 120, 465, 0, 4);
  898. //////////////////////////////////////////////////
  899. // 라벨 하단내용 //
  900. /////////////////////////////////////////////////
  901. //라벨내용
  902. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  903. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqtyunit");
  904. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  905. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  906. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  907. var totqty = parseInt(dayqty)*parseInt(dayno);
  908. //1일 X회 Xml씩 X일분
  909. qty = Math.round(qty*10) / 10;
  910. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1");
  911. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2");
  912. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3");
  913. //용법
  914. if ( mthd1 == "" && mthd2 == "" && mthd3 == "" ){
  915. //1일 X회 Xml씩 X일분
  916. sSndMsg += astfPrintOut(40, 126, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  917. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/abbrnm");
  918. if (val.length > 17) {
  919. sSndMsg += astfPrintOut(40, 171, 27, val.substring(0,17) ,"");
  920. sSndMsg += astfPrintOut(40, 210, 27, val.substring(17,val.length) ,"");
  921. } else {
  922. sSndMsg += astfPrintOut(40, 210, 27, val ,"");
  923. }
  924. } else {
  925. //1일 X회 Xml씩 X일분
  926. var val = mthd1 + " " + mthd2 + " " + mthd3;
  927. if (val.length > 17) {
  928. sSndMsg += astfPrintOut(40, 126, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  929. sSndMsg += astfPrintOut(40, 171, 27, val.substring(0,17) ,"");
  930. sSndMsg += astfPrintOut(40, 210, 27, val.substring(17,val.length) ,"");
  931. } else {
  932. sSndMsg += astfPrintOut(40, 165, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  933. sSndMsg += astfPrintOut(40, 210, 27, val ,"");
  934. }
  935. }
  936. //약품코드 + 총용량 + 약품명
  937. var prcpnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  938. if(PrnKind == "2") {
  939. var val = "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+
  940. parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty")) + " " +
  941. prcpnm;
  942. sSndMsg += astfPrintOut(20, 255, 27, val,"");
  943. } else {
  944. if(prcpnm.length > 12) {
  945. prcpnm = prcpnm.substring(0,12);
  946. }
  947. sSndMsg += astfPrintOut(20, 255, 27, "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+
  948. parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty")) + " " +
  949. prcpnm,"");
  950. }
  951. //보관방법
  952. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  953. lblcnts1 = lblcnts1.setReplaceWord("~", "-"); //20090728
  954. if ( lblcnts1 == "" ) {
  955. if(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd") != ""){
  956. sSndMsg += astfPrintOut(40, 300, 27, "< "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd")+" >","");
  957. }
  958. } else {
  959. if(lblcnts1.length > 17){
  960. //주의사항
  961. sSndMsg += astfPrintOut(20, 285, 3, lblcnts1.substring(0,17),"");
  962. sSndMsg += astfPrintOut(20, 315, 3, lblcnts1.substring(17,lblcnts1.length),"");
  963. } else {
  964. //주의사항
  965. sSndMsg += astfPrintOut(40, 300, 27, lblcnts1,"");
  966. }
  967. }
  968. //종료(매수)
  969. sSndMsg += astfEndFormat(0);
  970. CommAX.SendMsg(sSndMsg);
  971. fSleep(500);
  972. sSndMsg = "";
  973. }
  974. //CommAX.PortClose();
  975. model.refresh();
  976. //}
  977. }
  978. function fPrntTime(sDD, sTM) {
  979. if(PrnKind == "2") {
  980. return sDD.substr(4,2)+"/"+sDD.substr(6,2)+" "+sTM.substr(0,2)+":"+sTM.substr(2,2)+":"+sTM.substr(4,2);
  981. } else {
  982. return sDD.substr(4,2)+" / "+sDD.substr(6,2)+" "+sTM.substr(0,2)+":"+sTM.substr(2,2)+":"+sTM.substr(4,2);
  983. }
  984. }