SPADT61301.js 28 KB

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