SPADT61300.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /**
  2. * 파 일 명 : SPADT61300.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. /**
  13. * 초기화
  14. */
  15. function fInit() {
  16. var sParam = model.getAttribute("params");
  17. model.makeValue("/root/send/prcpinfo/drugdd", astfMatrixData(sParam, 1, 0));
  18. model.makeValue("/root/send/prcpinfo/drugno", astfMatrixData(sParam, 1, 1));
  19. model.makeValue("/root/send/prcpinfo/ioflag", astfMatrixData(sParam, 1, 2));
  20. model.makeValue("/root/send/prcpinfo/lblflag", astfMatrixData(sParam, 1, 3));
  21. model.makeValue("/root/send/prcpinfo/liquidflag", astfMatrixData(sParam, 1, 4));
  22. model.makeValue("/root/send/prcpinfo/reprintyn", astfMatrixData(sParam, 1, 5));
  23. model.makeValue("/root/send/prcpinfo/autoinprntyn", astfMatrixData(sParam, 1, 6));
  24. model.makeValue("/root/send/prcpinfo/prntflag", "O");
  25. model.refresh();
  26. submit("TRADT61301");
  27. if(model.getValue("/root/main/lbllist/lbllist["+1+"]/drugkindnm") != ""){
  28. if(model.getValue("/root/send/prcpinfo/liquidflag") == "Y"){
  29. fLiquidLBLPrint();
  30. } else {
  31. fLBLPrint();
  32. }
  33. }
  34. model.refresh();
  35. gTimer = window.setInterval("fStopTimer()",10000);
  36. window.close();
  37. }
  38. /**
  39. *
  40. */
  41. function fStopTimer() {
  42. window.clearinterval(gTimer);
  43. }
  44. function fSleep(numberMillis) {
  45. var now = new Date();
  46. var exitTime = now.getTime() + numberMillis;
  47. while (true) {
  48. now = new Date();
  49. if (now.getTime() > exitTime)
  50. return;
  51. }
  52. }
  53. /**
  54. * 라벨출력
  55. */
  56. function fLBLPrint() {
  57. /*
  58. 라벨 Sorting 로직
  59. //mgt에서 vo로 리턴
  60. 대분류
  61. - 내복약, 외용약, 주사, 항암제, TPN, 마약,
  62. 중분류
  63. - 방법코드
  64. 소분류
  65. - 내복약,외용약(방법코드), 주사,마약,항암제(mix)
  66. web js 출력로직
  67. 1 약종류(내복약/주사약/외용약)
  68. 1.1 방법코드
  69. 1.2 처방수량
  70. */
  71. // Comm 설정
  72. //CommAX.CommPort = "1"; // 출력 Port
  73. //CommAX.Settings = "9600,n,8,1"; // Comm 설정
  74. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  75. PrnKind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/prntkind");
  76. PrnMarginLeft = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/left");
  77. PrnMarginTop = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/top");
  78. var commkind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/commkind")
  79. if ( PrnKind ==7 ) {
  80. CommAX.PrnKind =4;
  81. } else {
  82. CommAX.PrnKind =PrnKind;
  83. }
  84. if(commkind == "02") {
  85. CommAX.PortNm = 1;
  86. } else {
  87. CommAX.PortNm = 2;
  88. }
  89. if(commkind == "01") {
  90. CommAX.PrtNm = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval");
  91. }
  92. // zebra 용지부족일때 오류 메시지 2009.10.14 pymi
  93. /*if( (CommAX.PrnKind == 0 || CommAX.PrnKind == 1) && CommAX.PortNm == 1) {
  94. if(!CommAX.Zebra_chk()) {
  95. return;
  96. }
  97. }*/
  98. // (e)
  99. // alert(PrnKind + "///" + commkind + "///" + model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval"));
  100. var reprint ="";
  101. //if ( CommAX.PortOpen() == true) {
  102. //alert("라벨 프린트 Open");
  103. //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");
  104. //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");
  105. //CommAX.PortClose();
  106. //return;
  107. //페이지번호 조회
  108. var iPageCnt = 0;
  109. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  110. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  111. reprint ="(재)";
  112. }
  113. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  114. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  115. if (mthdcd == "ZZZ" || mthdcd == "A10PQ") { //기타용법이거나 '필요시 복용하십시오' 용법인 경우도 단독라벨출력
  116. sumcls = mthdcd;
  117. }
  118. if( fChkSumcls(iPoint)){
  119. //단독라벨출력
  120. } else {
  121. //일반라벨출력
  122. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  123. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  124. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  125. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  126. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  127. var cnt = 0;
  128. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  129. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  130. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  131. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  132. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  133. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  134. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  135. && !fChkSumcls(j)){
  136. cnt++;
  137. } else {
  138. break;
  139. }
  140. if(cnt == 8){
  141. j++;
  142. break;
  143. }
  144. }
  145. if(j != iPoint) {
  146. iPoint = j-1;
  147. }
  148. }
  149. iPageCnt++;
  150. }
  151. var iTotalPageNum = iPageCnt;
  152. iPageCnt = 0;
  153. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  154. //시작(X, Y)
  155. sSndMsg += astfStartFormat(0, 0, "B");
  156. iPageCnt++;
  157. //////////////////////////////////////////////////
  158. // 라벨 상단내용 //
  159. /////////////////////////////////////////////////
  160. //투약번호
  161. sSndMsg += astfPrintOut(30, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno") + reprint ,"");
  162. //환자명
  163. sSndMsg += astfPrintOut(180, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm").substring(0,5),"");
  164. //바코드(변환)
  165. sSndMsg += astfBarCode_Code39(390, 40, "N", 70, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode"));
  166. //환자번호
  167. sSndMsg += astfPrintOut(30, 80, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid"),"");
  168. //성별나이
  169. sSndMsg += astfPrintOut(240, 85, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sexage"),"");
  170. //처방과약어명
  171. sSndMsg += astfPrintOut(30, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/deptengabbr"),"");
  172. //의사명
  173. sSndMsg += astfPrintOut(120, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/orddrnm"),"");
  174. //처방일자==>수납일자로 변경(20091014 이선경)
  175. //sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  176. sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd")),"");
  177. //페이지수
  178. sSndMsg += astfPrintOut(430, 135, 3, iPageCnt+"/"+iTotalPageNum,"");
  179. //바코드
  180. sSndMsg += astfPrintOut(510, 130, 3, "*"+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode")+"*","");
  181. //선그리기
  182. sSndMsg += astfGraphicBox(5, 180, 815, 0, 4);
  183. if(PrnKind == "2") {
  184. sSndMsg += astfPrintOut(20, 600, 1, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  185. sSndMsg += astfPrintOut(20, 630, 1, " 일단 조제투약된 약은 반납할 수 없습니다.");
  186. } else {
  187. sSndMsg += astfPrintOut(20, 600, 2, "*의약품은 그 특성상 보관및관리가 엄격해야하므로,");
  188. sSndMsg += astfPrintOut(20, 630, 2, " 일단 조제투약된 약은 반납할 수 없습니다.");
  189. }
  190. //////////////////////////////////////////////////
  191. // 라벨 하단내용 //
  192. /////////////////////////////////////////////////
  193. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  194. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  195. if (mthdcd == "ZZZ" || mthdcd == "A10PQ") { //기타용법이거나 '필요시 복용하십시오' 용법인 경우도 단독라벨출력
  196. sumcls = mthdcd;
  197. }
  198. if( fChkSumcls(iPoint)){
  199. //단독라벨출력
  200. fIndependPrint();
  201. } else {
  202. //일반라벨출력
  203. fGnrlPrint();
  204. }
  205. //종료(매수)
  206. sSndMsg += astfEndFormat(0);
  207. CommAX.SendMsg(sSndMsg);
  208. // alert(sSndMsg);
  209. fSleep(500);
  210. sSndMsg = "";
  211. }
  212. //CommAX.PortClose();
  213. model.refresh();
  214. //}
  215. }
  216. /**
  217. *
  218. */
  219. function fIndependPrint() {
  220. //약종류(내복약/주사약/외용약)
  221. sSndMsg += astfPrintOut(30, 230, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  222. //라벨내용
  223. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  224. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  225. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  226. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqtyunit");
  227. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  228. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno"); //처방일수
  229. var mthddayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayno"); //용법일수
  230. var packunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/packunit"); //약품마스터의 수량단위
  231. if (drugkindnm == "[주사약]"){
  232. //용법2
  233. sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  234. } else if (drugkindnm == "[외용약]"){
  235. //sSndMsg += astfPrintOut(210, 230, 7, "1일 "+tims+"회 "+fChkFloat(qty)+"개씩 "+dayno+"일분","");
  236. //용법1
  237. ///sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  238. ///
  239. //용법2
  240. ///sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),""); + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  241. //이선경 2008-08-20 start(용법이 짤리지 않고 출력되도록)
  242. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  243. + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  244. if(val.length > 22) {
  245. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 22),"");
  246. if(val.substring(0, 22).length > 22) {
  247. sSndMsg += astfPrintOut(30, 370, 7, val.substring(22, 50),"");
  248. sSndMsg += astfPrintOut(30, 440, 7, val.substring(50, val.length),"");
  249. } else {
  250. sSndMsg += astfPrintOut(30, 370, 7, val.substring(22, val.length),"");
  251. }
  252. } else {
  253. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 22),"");
  254. }
  255. //이선경 2008-08-20 end(용법이 짤리지 않고 출력되도록)
  256. } else if (drugkindnm == "[내복약]"){
  257. var sumcls = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  258. if( sumcls == "DM" || sumcls == "DS" || sumcls == "DT" || sumcls == "DX"){ //20091110 이선경 수정 : 라벨그룹이 마약(경구), 수제, ptp, 기타약일경우 약품마스터의 수량단위를 출력
  259. var tmpqty = Math.round(qty * 10) / 10;
  260. if(packunit == "T" || packunit == "C") {
  261. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(qty)+"정씩 "+(dayno*mthddayno)+"일분","");
  262. } else {
  263. //sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(tmpqty)+ qtyunit +"씩 "+(dayno*mthddayno)+"일분","");
  264. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(tmpqty)+ packunit +"씩 "+(dayno*mthddayno)+"일분","");
  265. }
  266. } else {
  267. sSndMsg += astfPrintOut(210, 230, 7, mthddayno + "일 "+tims+"회 "+fChkFloat(qty)+"포[정]씩 "+(dayno*mthddayno)+"일분","");
  268. }
  269. //용법1
  270. //sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  271. // + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  272. //용법2
  273. //sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  274. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2") + " "
  275. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") + " " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  276. if(val.length > 25) {
  277. sSndMsg += astfPrintOut(30, 300, 7, val.substring(0, 25),"");
  278. if(val.substring(0, 25).length > 25) {
  279. sSndMsg += astfPrintOut(30, 370, 7, val.substring(25, 53),"");
  280. sSndMsg += astfPrintOut(30, 440, 7, val.substring(53, val.length),"");
  281. } else {
  282. sSndMsg += astfPrintOut(30, 370, 7, val.substring(25, val.length),"");
  283. }
  284. } else {
  285. sSndMsg += astfPrintOut(30, 300, 7, val,"");
  286. }
  287. }
  288. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  289. lblcnts1 = lblcnts1.setReplaceWord("~", "-"); //20090728
  290. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")
  291. +" "+parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty"))
  292. +" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  293. if(lblcnts1.length > 25){
  294. //주의사항
  295. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1.substring(0,25),"");
  296. if(val.substring(0, 25).length > 25) {
  297. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(25,53),"");
  298. sSndMsg += astfPrintOut(30, 570, 5, lblcnts1.substring(53,lblcnts1.length),"");
  299. } else {
  300. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(25,lblcnts1.length),"");
  301. }
  302. //약정보
  303. sSndMsg += astfPrintOut(30, 570, 4, val, "");
  304. } else {
  305. //주의사항
  306. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1,"");
  307. //약정보
  308. sSndMsg += astfPrintOut(30, 510, 4, val, "");
  309. }
  310. /*if(lblcnts1.length > 28){
  311. //주의사항
  312. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(0,24),"");
  313. sSndMsg += astfPrintOut(30, 570, 5, lblcnts1.substring(24,lblcnts1.length),"");
  314. //약정보
  315. sSndMsg += astfPrintOut(30, 630, 4, val, "");
  316. } else {
  317. //주의사항
  318. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1,"");
  319. //약정보
  320. sSndMsg += astfPrintOut(30, 570, 4, val, "");
  321. }*/
  322. //var s= "복용기간: "+((getCurrentDate()).toDate("YYYYMMDD")).getDateFormat("YYYY/MM/DD") +" - "+ (((getCurrentDate()).toDate("YYYYMMDD")).getAddDate( parseInt(dayno),"D")).getDateFormat("YYYY/MM/DD");
  323. //sSndMsg +=astfPrintOut(30, 630, 3, s);
  324. }
  325. /**
  326. *
  327. */
  328. function fGnrlPrint() {
  329. var cnt = 0;
  330. //약종류(내복약/주사약/외용약)
  331. sSndMsg += astfPrintOut(30, 220, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  332. //라벨내용
  333. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  334. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  335. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  336. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  337. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");//처방일수
  338. var mthddayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayno"); //용법일수
  339. //약코드 출력
  340. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  341. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  342. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  343. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  344. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  345. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  346. if (drugkindnm == "[주사약]"){
  347. //용법2
  348. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  349. } else if (drugkindnm == "[외용약]"){
  350. //sSndMsg += astfPrintOut(210, 220, 7, "1일 "+tims+"회 "+qty+"개씩 "+dayno+"일분","");
  351. //용법1
  352. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  353. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  354. //용법2
  355. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  356. } else if (drugkindnm == "[내복약]"){
  357. var lbltims =0;
  358. lbl_tims = mthd2.split(",");
  359. if ( mthdcd == "ZZZ" ){
  360. lbltims = tims;
  361. } else if ( mthd3.indexOf("취침") > -1 ) {
  362. lbltims = lbl_tims.length +1;
  363. } else if(mthd2.indexOf("마다") > -1){
  364. lbltims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  365. } else {
  366. lbltims = lbl_tims.length;
  367. }
  368. tims = lbltims;
  369. if(lbltims == 1) {
  370. if(mthd2.indexOf("마다") == -1) {
  371. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno * mthddayno)+"일분","");
  372. } else {
  373. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+tims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  374. }
  375. } else {
  376. sSndMsg += astfPrintOut(210, 220, 7, mthddayno + "일 "+lbltims+ "회 1포씩 "+(dayno*mthddayno)+"일분","");
  377. }
  378. //용법1
  379. //if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") =="취침전에" ){
  380. // sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  381. // +" " + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  382. //} else {
  383. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2")
  384. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  385. sSndMsg += astfPrintOut(30, 290, 7, val,"");
  386. //}
  387. //sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/abbrnm"),"");
  388. //용법2
  389. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  390. }
  391. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  392. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  393. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  394. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  395. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  396. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  397. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  398. && !fChkSumcls(j)){
  399. //if(model.getValue("/root/main/lbllist/lbllist["+j+"]/fst_prnt") == "Y"){
  400. var prcpqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/totdrugqty")/model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  401. prcpqty = Math.ceil( prcpqty * tims*1000)/1000 ;
  402. if(PrnKind == "2") {
  403. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  404. +" "+prcpqty
  405. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  406. val = val.substr(0,21);
  407. } else {
  408. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  409. +" "+prcpqty
  410. +" "+(model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm")).substring(0,6);
  411. }
  412. sSndMsg += astfPrintOut(30+((cnt%2)*380), 440+((parseInt(cnt/2, 10))*40), 2, val, "");
  413. //}
  414. cnt++;
  415. } else {
  416. break;
  417. }
  418. if(cnt == 8){
  419. j++;
  420. break;
  421. }
  422. }
  423. iPoint = j-1;
  424. //var s ="복용기간: "+((getCurrentDate()).toDate("YYYYMMDD")).getDateFormat("YYYY/MM/DD") +" - "+ (((getCurrentDate()).toDate("YYYYMMDD")).getAddDate( parseInt(dayno),"D")).getDateFormat("YYYY/MM/DD") ;
  425. //sSndMsg +=astfPrintOut(30, 630, 3, s);
  426. }
  427. /**
  428. *
  429. */
  430. function fGetImage() {
  431. var pImage = "";
  432. iImageCnt++;
  433. if(iImageCnt > 99){
  434. pImage = "GRAPH"+iImageCnt;
  435. } else if(iImageCnt > 9){
  436. pImage = "GRAPH0"+iImageCnt;
  437. } else {
  438. pImage = "GRAPH00"+iImageCnt;
  439. }
  440. return pImage
  441. }
  442. /**
  443. *
  444. */
  445. function fDateFormat(sDD) {
  446. return sDD.substr(0,4)+"/"+sDD.substr(4,2)+"/"+sDD.substr(6,2);
  447. }
  448. /**
  449. *
  450. */
  451. function fChkFloat(qty) {
  452. var fQty = parseFloat(qty);
  453. var fRst = "";
  454. if(fQty%1 == 0){
  455. fRst = parseInt(qty);
  456. } else {
  457. fRst = qty;
  458. }
  459. return fRst;
  460. }
  461. /**
  462. *
  463. */
  464. function fChkSumcls(cnt) {
  465. var chk = false;
  466. var sSumcls = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/sumcls");
  467. var sSnglyn = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/atcifsnglyn");
  468. var sDrugindependpackflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/drugindependpackflag");
  469. if(sSumcls == "DI" || sSumcls == "DS"|| sSumcls == "DX"|| sSumcls == "DT" || sSumcls == "DM" || sSumcls == "IH"|| sSumcls == "IO"
  470. || sSumcls == "IS"|| sSumcls == "IX"|| sSumcls == "X" || sSumcls == "ZZZ" || sSumcls == "A10PQ" || sSumcls == "I"){
  471. chk = true;
  472. }
  473. if ( sSumcls == "D" && sSnglyn =="Y" ) {
  474. chk = true;
  475. }
  476. if ( sDrugindependpackflag =="Y"){
  477. chk = true;
  478. }
  479. return chk;
  480. }
  481. /**
  482. * 물약라벨출력
  483. */
  484. function fLiquidLBLPrint() {
  485. // Comm 설정
  486. //CommAX.CommPort = "1"; // 출력 Port
  487. //CommAX.Settings = "9600,n,8,1"; // Comm 설정
  488. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  489. PrnKind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/prntkind");
  490. PrnMarginLeft = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/left");
  491. PrnMarginTop = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/blank/top");
  492. var commkind = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/commkind")
  493. if ( PrnKind ==7 ) {
  494. CommAX.PrnKind =4;
  495. } else {
  496. CommAX.PrnKind =PrnKind;
  497. }
  498. if(commkind == "02") {
  499. CommAX.PortNm = 1;
  500. } else {
  501. CommAX.PortNm = 2;
  502. }
  503. if(commkind == "01") {
  504. CommAX.PrtNm = model.getvalue("/root/init/barcdprntsetup/prntsetupinfo/setupinfo/comm01/setupval");
  505. }
  506. var reprint="";
  507. //if ( CommAX.PortOpen() == true) {
  508. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  509. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  510. reprint ="(재)";
  511. }
  512. //시작(X, Y)
  513. sSndMsg += astfStartFormat(0, 0, "S");
  514. //////////////////////////////////////////////////
  515. // 라벨 상단내용 //
  516. /////////////////////////////////////////////////
  517. //투약번호
  518. //sSndMsg += astfPrintOut(50, 30, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint,"");
  519. //환자명
  520. //sSndMsg += astfPrintOut(50, 85, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  521. //내복약
  522. //sSndMsg += astfPrintOut(250, 30, 3, "내복약","");
  523. //처방일자
  524. //sSndMsg += astfPrintOut(250, 70, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  525. //환자번호
  526. //sSndMsg += astfPrintOut(250, 110, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid"),"");
  527. //선그리기
  528. //8sSndMsg += astfGraphicBox(5, 145, 465, 0, 4);
  529. var sDD = getCurrentDate();
  530. var sTM = getCurrentTime();
  531. //라벨이름(내복약/주사약/마약)
  532. sSndMsg += astfPrintOut(20, 25, 20, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  533. if(PrnKind == "2") {
  534. //출력일자
  535. sSndMsg += astfPrintOut(170, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  536. //처방일자==>수납일자로 변경(20091014 이선경)
  537. //sSndMsg += astfPrintOut(170, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  538. sSndMsg += astfPrintOut(170, 55, 21, "수 납 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd"), "MD"),"");
  539. } else {
  540. //출력일자
  541. sSndMsg += astfPrintOut(220, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  542. //처방일자==>수납일자로 변경(20091014 이선경)
  543. //sSndMsg += astfPrintOut(220, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  544. sSndMsg += astfPrintOut(220, 55, 21, "수 납 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/rcptdd"), "MD"),"");
  545. }
  546. //처방과약어명
  547. sSndMsg += astfPrintOut(20, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/deptengabbr"),"");
  548. //환자이름
  549. sSndMsg += astfPrintOut(120, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  550. //환자번호
  551. sSndMsg += astfPrintOut(240, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid")+" ("+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint+")","");
  552. //선그리기
  553. sSndMsg += astfGraphicBox(5, 120, 465, 0, 4);
  554. //////////////////////////////////////////////////
  555. // 라벨 하단내용 //
  556. /////////////////////////////////////////////////
  557. //라벨내용
  558. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  559. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqtyunit");
  560. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  561. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  562. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  563. var totqty = parseInt(dayqty)*parseInt(dayno);
  564. //1일 X회 Xml씩 X일분
  565. qty = Math.round(qty*10) / 10;
  566. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1");
  567. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2");
  568. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3");
  569. //용법
  570. if ( mthd1 == "" && mthd2 == "" && mthd3 == "" ){
  571. //1일 X회 Xml씩 X일분
  572. sSndMsg += astfPrintOut(40, 126, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  573. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/abbrnm");
  574. if (val.length > 17) {
  575. sSndMsg += astfPrintOut(40, 171, 27, val.substring(0,17) ,"");
  576. sSndMsg += astfPrintOut(40, 210, 27, val.substring(17,val.length) ,"");
  577. } else {
  578. sSndMsg += astfPrintOut(40, 210, 27, val ,"");
  579. }
  580. } else {
  581. //1일 X회 Xml씩 X일분
  582. var val = mthd1 + " " + mthd2 + " " + mthd3;
  583. if (val.length > 17) {
  584. sSndMsg += astfPrintOut(40, 126, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  585. sSndMsg += astfPrintOut(40, 171, 27, val.substring(0,17) ,"");
  586. sSndMsg += astfPrintOut(40, 210, 27, val.substring(17,val.length) ,"");
  587. } else {
  588. sSndMsg += astfPrintOut(40, 165, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  589. sSndMsg += astfPrintOut(40, 210, 27, val ,"");
  590. }
  591. }
  592. //약품코드 + 총용량 + 약품명
  593. var prcpnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  594. if(PrnKind == "2") {
  595. var val = "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+
  596. parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty")) + " " +
  597. prcpnm;
  598. sSndMsg += astfPrintOut(20, 255, 27, val,"");
  599. } else {
  600. if(prcpnm.length > 12) {
  601. prcpnm = prcpnm.substring(0,12);
  602. }
  603. sSndMsg += astfPrintOut(20, 255, 27, "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+
  604. parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty")) + " " +
  605. prcpnm,"");
  606. }
  607. //보관방법
  608. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  609. lblcnts1 = lblcnts1.setReplaceWord("~", "-"); //20090728
  610. if ( lblcnts1 == "" ) {
  611. if(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd") != ""){
  612. sSndMsg += astfPrintOut(40, 300, 27, "< "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd")+" >","");
  613. }
  614. } else {
  615. if(lblcnts1.length > 17){
  616. //주의사항
  617. sSndMsg += astfPrintOut(20, 285, 3, lblcnts1.substring(0,17),"");
  618. sSndMsg += astfPrintOut(20, 315, 3, lblcnts1.substring(17,lblcnts1.length),"");
  619. } else {
  620. //주의사항
  621. sSndMsg += astfPrintOut(40, 300, 27, lblcnts1,"");
  622. }
  623. }
  624. //종료(매수)
  625. sSndMsg += astfEndFormat(0);
  626. CommAX.SendMsg(sSndMsg);
  627. fSleep(500);
  628. sSndMsg = "";
  629. }
  630. //CommAX.PortClose();
  631. model.refresh();
  632. //}
  633. }
  634. function fPrntTime(sDD, sTM) {
  635. if(PrnKind == "2") {
  636. return sDD.substr(4,2)+"/"+sDD.substr(6,2)+" "+sTM.substr(0,2)+":"+sTM.substr(2,2)+":"+sTM.substr(4,2);
  637. } else {
  638. return sDD.substr(4,2)+" / "+sDD.substr(6,2)+" "+sTM.substr(0,2)+":"+sTM.substr(2,2)+":"+sTM.substr(4,2);
  639. }
  640. }