SPADT61300.xjs 31 KB

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