SPADT62301.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /**
  2. * 파 일 명 : SPADT62301.js
  3. * 설 명 : (팝업)병동라벨출력 Javascriot
  4. * 설 계 자 : 공두경
  5. * 작 성 자 : 공두경
  6. * 수정이력 : 2007.09.17 / 최초작성 / 공두경
  7. */
  8. var sSndMsg = ""; //라벨출력내용
  9. var iPoint = 1; //라벨출력row
  10. var iCnt = 0; //라벨출력매수
  11. var iImageCnt = 0; //라벨그래픽폰트수
  12. var gTimer = null;
  13. var pg =0;
  14. var totpg =0;
  15. var totcnt =0;
  16. /**
  17. * 초기화
  18. */
  19. function fInit() {
  20. //window.minimize();
  21. var sParam = model.getAttribute("params");
  22. model.makeValue("/root/send/prcpinfo/drugdd", astfMatrixData(sParam, 1, 0));
  23. model.makeValue("/root/send/prcpinfo/drugno", astfMatrixData(sParam, 1, 1));
  24. model.makeValue("/root/send/prcpinfo/ioflag", astfMatrixData(sParam, 1, 2));
  25. model.makeValue("/root/send/prcpinfo/prcpdd", astfMatrixData(sParam, 1, 3));
  26. model.makeValue("/root/send/prcpinfo/orddd", astfMatrixData(sParam, 1, 4));
  27. model.makeValue("/root/send/prcpinfo/cretno", astfMatrixData(sParam, 1, 5));
  28. model.makeValue("/root/send/prcpinfo/prcpgenrflag", astfMatrixData(sParam, 1, 6));
  29. model.makeValue("/root/send/prcpinfo/pid", astfMatrixData(sParam, 1, 7));
  30. model.makeValue("/root/send/prcpinfo/orddeptcd", astfMatrixData(sParam, 1, 8));
  31. model.makeValue("/root/send/prcpinfo/wardcd", astfMatrixData(sParam, 1, 9));
  32. model.makeValue("/root/send/prcpinfo/lblflag", astfMatrixData(sParam, 1, 10));
  33. model.makeValue("/root/send/prcpinfo/prcpflag", astfMatrixData(sParam, 1, 11));
  34. model.makeValue("/root/send/prcpinfo/prntflag", astfMatrixData(sParam, 1, 12));
  35. model.makeValue("/root/send/prcpinfo/liquidflag", astfMatrixData(sParam, 1, 13));
  36. model.makeValue("/root/send/prcpinfo/etcdescflag", astfMatrixData(sParam, 1, 14));
  37. model.makeValue("/root/send/prcpinfo/lblkind", astfMatrixData(sParam, 1, 15));
  38. model.makeValue("/root/send/prcpinfo/outlblyn", astfMatrixData(sParam, 1, 16));
  39. model.makeValue("/root/send/prcpinfo/ptplblyn", astfMatrixData(sParam, 1, 17));
  40. model.makeValue("/root/send/prcpinfo/reprintyn", astfMatrixData(sParam, 1, 18));
  41. model.makeValue("/root/send/prcpinfo/lbltype", astfMatrixData(sParam, 1, 19));
  42. model.makeValue("/root/send/prcpinfo/drugkind", astfMatrixData(sParam, 1, 20));
  43. model.makeValue("/root/send/prcpinfo/autolblyn", astfMatrixData(sParam, 1, 21));
  44. // model.makeValue("/root/send/prcpinfo/lbltype", astfMatrixData(sParam, 1, 16));
  45. model.refresh();
  46. submit("TRADT62301");
  47. if(model.getValue("/root/main/lbllist/lbllist["+1+"]/drugkindnm") != ""){
  48. if(model.getValue("/root/send/prcpinfo/liquidflag") == "Y"|| model.getValue("/root/send/prcpinfo/outlblyn") == "Y"){
  49. fLiquidLBLPrint();
  50. } else if(model.getValue("/root/main/lbllist/lbllist["+1+"]/drugflag") == "E" || model.getValue("/root/main/lbllist/lbllist["+1+"]/drugflag") == "L"
  51. || model.getValue("/root/main/lbllist/lbllist["+1+"]/drugflag") == "G"){
  52. fBigLBLPrint();
  53. } else {
  54. fSmallLBLPrint();
  55. }
  56. }
  57. model.refresh();
  58. gTimer = window.setInterval("fStopTimer()",10000);
  59. window.close();
  60. }
  61. /**
  62. *
  63. */
  64. function fStopTimer() {
  65. window.clearinterval(gTimer);
  66. }
  67. function fSleep(numberMillis) {
  68. var now = new Date();
  69. var exitTime = now.getTime() + numberMillis;
  70. while (true) {
  71. now = new Date();
  72. if (now.getTime() > exitTime)
  73. return;
  74. }
  75. }
  76. /**
  77. * 병동 라벨출력(작은사이즈)
  78. */
  79. function fSmallLBLPrint() {
  80. /*
  81. 라벨 Sorting 로직
  82. //mgt에서 vo로 리턴
  83. 대분류
  84. - 내복약, 외용약, 주사, 항암제, TPN, 마약,
  85. 중분류
  86. - 방법코드
  87. 소분류
  88. - 내복약,외용약(방법코드), 주사,마약,항암제(mix)
  89. web js 출력로직
  90. 가. 퇴원/외래/응급실/외박/외출 : 큰사이즈라벨
  91. 외래기준
  92. 나. 그외 입원처방
  93. 1. 외용약
  94. 단독출력
  95. 2. 내복약
  96. 단독출력
  97. 따로포장
  98. 복용방법
  99. 3. 주사약
  100. 단독출력
  101. mix끼리
  102. 고가,향정,보관벙법이 실온이 아닌경우 자가주사인 경우 단독
  103. 나머지
  104. */
  105. // Comm 설정
  106. CommAX.CommPort = "1"; // 출력 Port
  107. CommAX.Settings = "9600,n,8,1"; // Comm 설정
  108. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  109. // zebra 용지부족일때 오류 메시지 2009.10.14 pymi
  110. /*alert(999);
  111. if(!CommAX.zebra_chk()) {
  112. return;
  113. }
  114. alert(888); */
  115. // (e)
  116. if ( CommAX.PortOpen() == true) {
  117. //alert("라벨 프린트 Open");
  118. //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");
  119. //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");
  120. //CommAX.PortClose();
  121. //return;
  122. var sDD = getCurrentDate();
  123. var sTM = getCurrentTime();
  124. var reprint ="";
  125. for ( var i = 1; i <= getNodesetCount("/root/main/lbllist/lbllist") ; i++){
  126. if ( model.getValue("/root/main/lbllist/lbllist["+i+"]/lblgrup") != "DI" && model.getValue("/root/main/lbllist/lbllist["+i+"]/lblgrup") != "DS" ){
  127. totcnt++;
  128. }
  129. }
  130. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  131. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  132. reprint ="(재)";
  133. }
  134. //시작(X, Y)
  135. sSndMsg += astfStartFormat(0, 0);
  136. //라벨이름(내복약/주사약/마약)
  137. sSndMsg += astfPrintOut(20, 25, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  138. //출력일자
  139. sSndMsg += astfPrintOut(220, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  140. //출력일자
  141. sSndMsg += astfPrintOut(220, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  142. //병실
  143. sSndMsg += astfPrintOut(20, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/roomcd"),"");
  144. //환자이름
  145. sSndMsg += astfPrintOut(120, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  146. //환자번호
  147. sSndMsg += astfPrintOut(240, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid")+" ("+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint+")","");
  148. //선그리기
  149. sSndMsg += astfGraphicBox(5, 120, 465, 0, 4);
  150. var sDrugKindcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  151. var sMixno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpmixno");
  152. if(sDrugKindcd == "[내복약]"){
  153. if(model.getValue("/root/send/prcpinfo/lbltype") == "Y"){
  154. fInUseDrugLBL2();
  155. } else {
  156. fInUseDrugLBL();
  157. }
  158. } else if(sDrugKindcd == "[외용약]"){
  159. //fExUseDrugLBL();
  160. if(model.getValue("/root/send/prcpinfo/lbltype") == "Y"){
  161. fInUseDrugLBL2();
  162. } else {
  163. fInUseDrugLBL();
  164. }
  165. } else if(sDrugKindcd == "[주사약]"){
  166. if(sMixno != "-"){
  167. fMixLBL();
  168. } else {
  169. fInjDrugLBL();
  170. }
  171. }
  172. CommAX.SendMessage(sSndMsg);
  173. fSleep(500);
  174. sSndMsg = "";
  175. }
  176. CommAX.PortClose();
  177. model.refresh();
  178. }
  179. }
  180. /**
  181. * mix 라벨
  182. */
  183. function fMixLBL() {
  184. var sMixno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpmixno");
  185. var cnt = 0;
  186. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  187. sMixno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpmixno");
  188. var qty = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqty");
  189. var dayqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/dayprcpqty");
  190. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqtyunit");
  191. var tims = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  192. var dayno = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  193. if(sMixno1 == sMixno2){
  194. //
  195. sSndMsg += astfPrintOut(20, 140+(cnt*30), 24, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd"),"");
  196. //
  197. sSndMsg += astfPrintOut(140, 140+(cnt*30), 11, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm"),"");
  198. //
  199. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, dayqty+qtyunit,"");
  200. //
  201. sSndMsg += astfPrintOut(390, 140+(cnt*30), 2, tims,"");
  202. //
  203. sSndMsg += astfPrintOut(420, 140+(cnt*30), 2, dayno,"");
  204. cnt++;
  205. } else {
  206. j--;
  207. break;
  208. }
  209. if(cnt == 5){
  210. break;
  211. }
  212. }
  213. iPoint = j;
  214. //종료(매수)
  215. sSndMsg += astfEndFormat(0);
  216. }
  217. /**
  218. * 내복약 라벨
  219. */
  220. function fInUseDrugLBL() {
  221. // var sSumCls1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  222. var sMthdcd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  223. var qty = "";
  224. var dayqty = "";
  225. var qtyunit = "";
  226. var tims = "";
  227. var dayno = "";
  228. var cnt = 0;
  229. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  230. if(cnt != 0 && fChkIndependDrug(j)){
  231. break;
  232. }
  233. // sSumCls2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/sumcls");
  234. sMthdcd2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthdcd");
  235. qty = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqty");
  236. dayqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/dayprcpqty");
  237. qtyunit = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqtyunit");
  238. tims = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  239. dayno = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  240. if((sMthdcd1 == sMthdcd2)){
  241. //
  242. sSndMsg += astfPrintOut(20, 140+(cnt*30), 24, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd"),"");
  243. //
  244. sSndMsg += astfPrintOut(135, 140+(cnt*30), 11, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm"),"");
  245. if( model.getValue("/root/main/lbllist/lbllist["+j+"]/lblgrup") == "DS"){
  246. //
  247. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, dayqty+qtyunit,"");
  248. //
  249. sSndMsg += astfPrintOut(400, 140+(cnt*30), 2, tims,"");
  250. //
  251. sSndMsg += astfPrintOut(430, 140+(cnt*30), 2, dayno,"");
  252. } else {
  253. //
  254. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, dayqty,"");
  255. //
  256. sSndMsg += astfPrintOut(390, 140+(cnt*30), 2, tims,"");
  257. //
  258. sSndMsg += astfPrintOut(420, 140+(cnt*30), 2, dayno,"");
  259. }
  260. cnt++;
  261. } else {
  262. break;
  263. }
  264. if(cnt == fMthdnmLength(iPoint) || fChkIndependDrug(j)){
  265. j++;
  266. break;
  267. }
  268. }
  269. iPoint = j-1;
  270. //보관방법 고가 출력
  271. var sKeepmthd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd");
  272. var sExpnyn = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/expnyn");
  273. var sExpnnm = "";
  274. if(sExpnyn == "Y") sExpnnm = "고가";
  275. //if(sKeepmthd != "" && sExpnnm != ""){
  276. // sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+sExpnnm+">","");
  277. //} else
  278. if(sKeepmthd != ""){
  279. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+">","");
  280. }
  281. if(sExpnnm != ""){
  282. sSndMsg += astfPrintOut(135, 180, 3, "<"+sExpnnm+">","");
  283. }
  284. /*
  285. if(sKeepmthd != "" && sExpnnm != ""){
  286. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+sExpnnm+">","");
  287. } else if(sKeepmthd != ""){
  288. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+">","");
  289. } if(sExpnnm != ""){
  290. sSndMsg += astfPrintOut(20, 180, 3, "<"+sExpnnm+">","");
  291. }*/
  292. //용법의 길이에 따라 찍는 위치를 달리한다(용법찍을 공간을 확보)
  293. var iYPoint = 0;
  294. if( fMthdnmLength(iPoint) == 4){
  295. iYPoint = 280;
  296. } else {
  297. iYPoint = 245;
  298. }
  299. if( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblgrup") == "DS"){
  300. sSndMsg += astfPrintOut(20, iYPoint, 3, "1일 "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims")+"회 "
  301. +qty+qtyunit+" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno")+"일분","");
  302. } else {
  303. sSndMsg += astfPrintOut(20, iYPoint, 3, "1일 "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims")+"회 "
  304. +model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno")+"일분","");
  305. }
  306. //
  307. sSndMsg += fMthdnm(iPoint);
  308. //종료(매수)
  309. sSndMsg += astfEndFormat(0);
  310. }
  311. /**
  312. * 내복약 라벨 - 한장에 모든 용법 약을 ...
  313. */
  314. function fInUseDrugLBL2() {
  315. // var sSumCls1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  316. var sMthdcd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  317. var qty = "";
  318. var dayqty = "";
  319. var qtyunit = "";
  320. var tims = "";
  321. var dayno = "";
  322. var cnt = 0;
  323. var chk = false;
  324. totpg = Math.ceil(totcnt / 6 );
  325. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  326. if(cnt != 0 && model.getValue("/root/main/lbllist/lbllist["+j+"]/lblgrup") == "DI" ) {
  327. break;
  328. }
  329. //if(cnt != 0 && fChkIndependDrug(j)){
  330. // break;
  331. //}
  332. // sSumCls2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/sumcls");
  333. sMthdcd2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthdcd");
  334. qty = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqty");
  335. dayqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/dayprcpqty");
  336. qtyunit = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqtyunit");
  337. tims = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  338. dayno = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  339. //if((sMthdcd1 == sMthdcd2)){
  340. //
  341. if( model.getValue("/root/main/lbllist/lbllist["+j+"]/lblgrup") == "DT"){ //PTP는 * 표시
  342. sSndMsg += astfPrintOut(20, 140+(cnt*30), 24, "*","");
  343. }
  344. sSndMsg += astfPrintOut(30, 140+(cnt*30), 24, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd"),"");
  345. //
  346. var prcpnm = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  347. prcpnm = prcpnm.substring(0,16);
  348. sSndMsg += astfPrintOut(135, 140+(cnt*30), 11, prcpnm,"");
  349. if( model.getValue("/root/main/lbllist/lbllist["+j+"]/lblgrup") == "DS"){
  350. //
  351. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, dayqty+qtyunit,"");
  352. //
  353. sSndMsg += astfPrintOut(400, 140+(cnt*30), 2, tims,"");
  354. //
  355. sSndMsg += astfPrintOut(430, 140+(cnt*30), 2, dayno,"");
  356. } else {
  357. //
  358. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, dayqty,"");
  359. //
  360. sSndMsg += astfPrintOut(390, 140+(cnt*30), 2, tims,"");
  361. //
  362. sSndMsg += astfPrintOut(420, 140+(cnt*30), 2, dayno,"");
  363. }
  364. cnt++;
  365. //} else {
  366. // break;
  367. //}
  368. //if(cnt == fMthdnmLength(iPoint) || fChkIndependDrug(j)){
  369. // j++;
  370. // break;
  371. //}
  372. if(cnt == 6){
  373. pg++;
  374. sSndMsg += astfPrintOut(430,320, 2, pg+ "/" + totpg ,"");
  375. j++;
  376. chk=true;
  377. break;
  378. }
  379. }
  380. if ( chk == false ){
  381. pg++;
  382. if( model.getValue("/root/main/lbllist/lbllist["+(j-1)+"]/lblgrup") != "DI" ) {
  383. sSndMsg += astfPrintOut(430,320, 2, pg+"/" +totpg ,"");
  384. }
  385. }
  386. iPoint = j-1;
  387. //보관방법 고가 출력
  388. var sKeepmthd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd");
  389. var sExpnyn = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/expnyn");
  390. var sExpnnm = "";
  391. if(sExpnyn == "Y") sExpnnm = "고가";
  392. //if(sKeepmthd != "" && sExpnnm != ""){
  393. // sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+sExpnnm+">","");
  394. //} else
  395. if(sKeepmthd != ""){
  396. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+">","");
  397. }
  398. if(sExpnnm != ""){
  399. sSndMsg += astfPrintOut(135, 180, 3, "<"+sExpnnm+">","");
  400. }
  401. /*
  402. if(sKeepmthd != "" && sExpnnm != ""){
  403. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+sExpnnm+">","");
  404. } else if(sKeepmthd != ""){
  405. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+">","");
  406. } if(sExpnnm != ""){
  407. sSndMsg += astfPrintOut(20, 180, 3, "<"+sExpnnm+">","");
  408. }*/
  409. //용법의 길이에 따라 찍는 위치를 달리한다(용법찍을 공간을 확보)
  410. //var iYPoint = 0;
  411. //if( fMthdnmLength(iPoint) == 4){
  412. // iYPoint = 280;
  413. //} else {
  414. // iYPoint = 245;
  415. //}
  416. //if( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblgrup") == "DS"){
  417. // sSndMsg += astfPrintOut(20, iYPoint, 3, "1일 "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims")+"회 "
  418. // +qty+qtyunit+" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno")+"일분","");
  419. //} else {
  420. // sSndMsg += astfPrintOut(20, iYPoint, 3, "1일 "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims")+"회 "
  421. // +model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno")+"일분","");
  422. //}
  423. //
  424. //sSndMsg += fMthdnm(iPoint);
  425. //종료(매수)
  426. sSndMsg += astfEndFormat(0);
  427. }
  428. /**
  429. * 외용약 라벨
  430. */
  431. function fExUseDrugLBL() {
  432. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  433. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  434. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  435. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  436. //
  437. sSndMsg += astfPrintOut(20, 140, 24, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd"),"");
  438. //
  439. sSndMsg += astfPrintOut(135, 140, 11, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm"),"");
  440. //
  441. sSndMsg += astfPrintOut(330, 140, 2, dayqty,"");
  442. //
  443. sSndMsg += astfPrintOut(390, 140, 2, tims,"");
  444. //
  445. sSndMsg += astfPrintOut(420, 140, 2, dayno,"");
  446. sSndMsg += astfPrintOut(20, 280, 3, "1일 "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims")+"회 "
  447. +model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno")+"일분","");
  448. //
  449. sSndMsg += fMthdnm(iPoint);
  450. //종료(매수)
  451. sSndMsg += astfEndFormat(0);
  452. }
  453. /**
  454. * 주사약 라벨
  455. */
  456. function fInjDrugLBL() {
  457. var sSumCls1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls");
  458. var cnt = 0;
  459. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  460. if(cnt != 0 && fChkIndependInj(j)){
  461. //주사가 뭉쳐서 나오다가 단독주사를 만날경우 단독주사는 출력하지 아니함.
  462. break;
  463. }
  464. sSumCls2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/sumcls");
  465. var qty = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqty");
  466. var dayqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/dayprcpqty");
  467. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpqtyunit");
  468. var tims = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims");
  469. var dayno = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  470. //
  471. sSndMsg += astfPrintOut(20, 140+(cnt*30), 24, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd"),"");
  472. //
  473. sSndMsg += astfPrintOut(135, 140+(cnt*30), 11, model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm").substr(0,14),"");
  474. //
  475. sSndMsg += astfPrintOut(330, 140+(cnt*30), 2, fChkFloat(dayqty)+qtyunit,"");
  476. //
  477. sSndMsg += astfPrintOut(390, 140+(cnt*30), 2, tims,"");
  478. //
  479. sSndMsg += astfPrintOut(420, 140+(cnt*30), 2, dayno,"");
  480. cnt++;
  481. if(cnt == 5 || fChkIndependInj(j)){
  482. j++;
  483. break;
  484. }
  485. }
  486. iPoint = j-1;
  487. //보관방법 고가 출력
  488. var sKeepmthd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd");
  489. var sExpnyn = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/expnyn");
  490. var sExpnnm = "";
  491. if(sExpnyn == "Y") sExpnnm = "고가";
  492. //if(sKeepmthd != "" && sExpnnm != ""){
  493. // sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+sExpnnm+">","");
  494. //} else
  495. if(sKeepmthd != ""){
  496. sSndMsg += astfPrintOut(20, 180, 3, "<"+sKeepmthd+">","");
  497. }
  498. if(sExpnnm != ""){
  499. sSndMsg += astfPrintOut(135, 180, 3, "<"+sExpnnm+">","");
  500. }
  501. //종료(매수)
  502. sSndMsg += astfEndFormat(0);
  503. }
  504. /**
  505. * 내복약 단독라벨 검증작업
  506. */
  507. function fChkIndependDrug(cnt) {
  508. var sLBLGrup = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/lblgrup");
  509. var sSnglyn = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/atcifsnglyn");
  510. var sDrugindependpackflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/drugindependpackflag");
  511. var sKeepmthd = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/keepmthd");
  512. var sExpnyn = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/expnyn");
  513. var sRst = false;
  514. if(sLBLGrup == "DS" || sLBLGrup == "DI" || sLBLGrup == "DT" || sLBLGrup == "DX") sRst = true;
  515. if(sSnglyn == "Y") sRst = true;
  516. if(sDrugindependpackflag == "Y") sRst = true;
  517. if(sExpnyn == "Y") sRst = true;
  518. if(sKeepmthd != "") sRst = true;
  519. return sRst;
  520. }
  521. /**
  522. * 주사약 단독라벨 검증작업
  523. */
  524. function fChkIndependInj(cnt) {
  525. var sLBLGrup = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/lblgrup");
  526. var sExp = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/expnyn");
  527. var sKeepmthd = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/keepmthd");
  528. var sSelfprcpflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/selfprcpflag");
  529. var sDrugindependpackflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/drugindependpackflag");
  530. var sRst = false;
  531. if(sLBLGrup == "IH" || sLBLGrup == "IO" || sLBLGrup == "IS" || sLBLGrup == "IX") sRst = true;
  532. if(sExp == "Y" || sKeepmthd != "" || sSelfprcpflag == "Y") sRst = true;
  533. if(sDrugindependpackflag == "Y") sRst = true;
  534. return sRst;
  535. }
  536. /**
  537. * 용법 생성
  538. */
  539. function fMthdnm(iPoint) {
  540. var sMthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1");
  541. var sMthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2");
  542. var sMthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3");
  543. var sMthd4 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  544. var sTemp = "";
  545. var sRst = "";
  546. if(sMthd1 != "") sTemp += sMthd1 + " ";
  547. if(sMthd2 != "") sTemp += sMthd2 + " ";
  548. if(sMthd3 != "") sTemp += sMthd3 + " ";
  549. if(sMthd4 != "") sTemp += sMthd4;
  550. if(sTemp.length > 28){
  551. var sTemp1 = sTemp.substr(0, 26);
  552. var sTemp2 = sTemp.substr(26, sTemp.length);
  553. sRst = astfPrintOut(20, 285, 28, sTemp1,"");
  554. sRst += astfPrintOut(20, 320, 28, sTemp2,"");
  555. } else if(sTemp.length > 24){
  556. sRst = astfPrintOut(20, 320, 29, sTemp,"");
  557. } else if(sTemp.length > 22){
  558. sRst = astfPrintOut(20, 320, 3, sTemp,"");
  559. } else if(sTemp.length > 21){
  560. sRst = astfPrintOut(20, 320, 3, sTemp,"");
  561. } else if(sTemp.length <= 21){
  562. sRst = astfPrintOut(20, 320, 3, sTemp,"");
  563. }
  564. return sRst;
  565. }
  566. /**
  567. * 용법 길이
  568. */
  569. function fMthdnmLength(iPoint) {
  570. var sMthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1");
  571. var sMthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2");
  572. var sMthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3");
  573. var sMthd4 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4");
  574. var sTemp = "";
  575. var sRst = "4"; //병동라벨은 기본 4줄까지 약처방이 출력된다.
  576. if(sMthd1 != "") sTemp += sMthd1 + " ";
  577. if(sMthd2 != "") sTemp += sMthd2 + " ";
  578. if(sMthd3 != "") sTemp += sMthd3 + " ";
  579. if(sMthd4 != "") sTemp += sMthd4;
  580. if(sTemp.length > 28){
  581. sRst = "3"; //복용방법이 길경우 3줄까지 약처방을 출력한다.
  582. }
  583. return sRst;
  584. }
  585. /**
  586. * 응급실/퇴원/외박/외출 라벨출력(큰사이즈)
  587. */
  588. function fBigLBLPrint() {
  589. /*
  590. 라벨 Sorting 로직
  591. //mgt에서 vo로 리턴
  592. 대분류
  593. - 내복약, 외용약, 주사, 항암제, TPN, 마약,
  594. 중분류
  595. - 방법코드
  596. 소분류
  597. - 내복약,외용약(방법코드), 주사,마약,항암제(mix)
  598. web js 출력로직
  599. 1 약종류(내복약/주사약/외용약)
  600. 1.1 방법코드
  601. 1.2 처방수량
  602. */
  603. // Comm 설정
  604. CommAX.CommPort = "1"; // 출력 Port
  605. CommAX.Settings = "9600,n,8,1"; // Comm 설정
  606. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  607. // zebra 용지부족일때 오류 메시지 2009.10.14 pymi
  608. /*if(!CommAX.zebra_chk()) {
  609. return;
  610. }*/
  611. // (e)
  612. var reprint="";
  613. if ( CommAX.PortOpen() == true) {
  614. //alert("라벨 프린트 Open");
  615. //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");
  616. //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");
  617. //CommAX.PortClose();
  618. //return;
  619. //페이지번호 조회(입원쪽은 전부 페이지번호 안넣기로 함 2.14 공두경)
  620. /*var iPageCnt = 0;
  621. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  622. if( fChkSumcls(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sumcls"))){
  623. //단독라벨출력
  624. } else {
  625. //일반라벨출력
  626. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  627. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  628. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  629. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  630. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  631. var cnt = 0;
  632. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  633. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  634. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  635. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  636. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  637. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  638. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  639. && !fChkSumcls(model.getValue("/root/main/lbllist/lbllist["+j+"]/sumcls"))){
  640. cnt++;
  641. } else {
  642. break;
  643. }
  644. if(cnt == 10){
  645. j++;
  646. break;
  647. }
  648. }
  649. iPoint = j-1;
  650. }
  651. iPageCnt++;
  652. }
  653. var iTotalPageNum = iPageCnt;
  654. iPageCnt = 0;
  655. */
  656. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  657. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  658. reprint ="(재)";
  659. }
  660. //시작(X, Y)
  661. sSndMsg += astfStartFormat(0, 0);
  662. //iPageCnt++;
  663. //////////////////////////////////////////////////
  664. // 라벨 상단내용 //
  665. /////////////////////////////////////////////////
  666. //병실
  667. sSndMsg += astfPrintOut(30, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/roomcd"),"");
  668. //환자명
  669. sSndMsg += astfPrintOut(180, 30, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm").substring(0,5),"");
  670. //바코드(변환)
  671. sSndMsg += astfBarCode_Code39(390, 40, "N", 70, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode"));
  672. //환자번호
  673. sSndMsg += astfPrintOut(30, 85, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid") ,"");
  674. //(투약번호)=>20091014 이선경 : 크고 진하게 변경
  675. sSndMsg += astfPrintOut(130, 85, 6, " (" + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno") + ")","");
  676. //성별나이
  677. sSndMsg += astfPrintOut(280, 85, 3, reprint+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/sexage"),"");
  678. //처방과약어명
  679. sSndMsg += astfPrintOut(30, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/deptengabbr"),"");
  680. //의사명
  681. sSndMsg += astfPrintOut(120, 135, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/orddrnm"),"");
  682. //처방일자
  683. sSndMsg += astfPrintOut(270, 135, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  684. //페이지수
  685. //sSndMsg += astfPrintOut(430, 135, 3, iPageCnt+"/"+iTotalPageNum,"");
  686. //바코드
  687. sSndMsg += astfPrintOut(510, 130, 3, "*"+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/barcode")+"*","");
  688. //선그리기
  689. sSndMsg += astfGraphicBox(5, 180, 815, 0, 4);
  690. sSndMsg += astfPrintOut(20, 630, 2, "*의약품은 그 특성상 보관및관리가 엄격해야하므로, 일단 조제투약된 약은 반납할 수 없습니다.");
  691. //////////////////////////////////////////////////
  692. // 라벨 하단내용 //
  693. /////////////////////////////////////////////////
  694. if( fChkSumcls(iPoint)){
  695. //단독라벨출력
  696. fIndependPrint();
  697. } else {
  698. //일반라벨출력
  699. fGnrlPrint();
  700. }
  701. //종료(매수)
  702. sSndMsg += astfEndFormat(0);
  703. CommAX.SendMessage(sSndMsg);
  704. fSleep(500);
  705. sSndMsg = "";
  706. }
  707. CommAX.PortClose();
  708. model.refresh();
  709. }
  710. }
  711. /**
  712. *
  713. */
  714. function fIndependPrint() {
  715. //약종류(내복약/주사약/외용약)
  716. sSndMsg += astfPrintOut(30, 230, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  717. //라벨내용
  718. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  719. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  720. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  721. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  722. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  723. if (drugkindnm == "[주사약]"){
  724. //용법2
  725. sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  726. } else if (drugkindnm == "[외용약]"){
  727. //sSndMsg += astfPrintOut(210, 230, 7, "1일 "+tims+"회 "+fChkFloat(qty)+"개씩 "+dayno+"일분","");
  728. //용법1
  729. sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  730. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  731. //용법2
  732. sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  733. } else if (drugkindnm == "[내복약]"){
  734. sSndMsg += astfPrintOut(210, 230, 7, "1일 "+tims+"회 "+fChkFloat(qty)+"포[정]씩 "+dayno+"일분","");
  735. //용법1
  736. sSndMsg += astfPrintOut(30, 300, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  737. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  738. //용법2
  739. sSndMsg += astfPrintOut(30, 370, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  740. }
  741. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  742. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")
  743. +" "+parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty"))
  744. +" "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  745. if(lblcnts1.length > 28){
  746. //주의사항
  747. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1.substring(0,24),"");
  748. sSndMsg += astfPrintOut(30, 510, 5, lblcnts1.substring(24,lblcnts1.length),"");
  749. //약정보
  750. sSndMsg += astfPrintOut(30, 570, 4, val, "");
  751. } else {
  752. //주의사항
  753. sSndMsg += astfPrintOut(30, 450, 5, lblcnts1,"");
  754. //약정보
  755. sSndMsg += astfPrintOut(30, 510, 4, val, "");
  756. }
  757. }
  758. /**
  759. *
  760. */
  761. function fGnrlPrint() {
  762. var cnt = 0;
  763. var drugcnt = 0;
  764. //약종류(내복약/주사약/외용약)
  765. sSndMsg += astfPrintOut(30, 220, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  766. //라벨내용
  767. var drugkindnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  768. var qty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqty");
  769. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  770. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  771. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  772. //약코드 출력
  773. var drugkind1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm");
  774. var dayno1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  775. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1");
  776. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2");
  777. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3");
  778. var mthdcd = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcd");
  779. if (drugkindnm == "[주사약]"){
  780. //용법2
  781. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  782. } else if (drugkindnm == "[외용약]"){
  783. //sSndMsg += astfPrintOut(210, 220, 7, "1일 "+tims+"회 "+qty+"개씩 "+dayno+"일분","");
  784. //용법1
  785. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  786. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  787. //용법2
  788. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  789. } else if (drugkindnm == "[내복약]"){
  790. var lbltims =0;
  791. lbl_tims = mthd2.split(",");
  792. if ( mthdcd == "ZZZ" ){
  793. lbltims = tims;
  794. } else if ( mthd3.indexOf("취침") > -1 ) {
  795. lbltims = lbl_tims.length +1;
  796. } else if(mthd2.indexOf("마다") > -1){
  797. lbltims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  798. } else {
  799. lbltims = lbl_tims.length;
  800. }
  801. tims = lbltims;
  802. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  803. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  804. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  805. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  806. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  807. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  808. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  809. && !fChkSumcls(j)){
  810. drugcnt++;
  811. } else {
  812. break;
  813. }
  814. }
  815. if ( drugcnt == 1 ){
  816. if(lbltims == 1) {
  817. if(mthd2.indexOf("마다") == -1) {
  818. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+lbltims+ "회"+fChkFloat(qty)+"포[정]씩 "+dayno+"일분","");
  819. prcpqty = prcpqty * lbltims;
  820. } else {
  821. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+tims+ "회"+fChkFloat(qty)+"포[정]씩 "+dayno+"일분","");
  822. prcpqty = prcpqty * tims;
  823. }
  824. } else {
  825. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+lbltims+ "회"+fChkFloat(qty)+"포[정]씩 "+dayno+"일분","");
  826. prcpqty = prcpqty * lbltims;
  827. }
  828. } else {
  829. if(lbltims == 1) {
  830. if(mthd2.indexOf("마다") == -1) {
  831. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+lbltims+ "회 1포씩 "+dayno+"일분","");
  832. } else {
  833. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+tims+ "회 1포씩 "+dayno+"일분","");
  834. }
  835. } else {
  836. sSndMsg += astfPrintOut(210, 220, 7, "1일 "+lbltims+ "회 1포씩 "+dayno+"일분","");
  837. }
  838. }
  839. //용법1
  840. //if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3") =="취침전에" ){
  841. // sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2")
  842. // + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3"),"");
  843. //} else {
  844. sSndMsg += astfPrintOut(30, 290, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd1") + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd2")
  845. + model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthd3"),"");
  846. //}
  847. //용법2
  848. sSndMsg += astfPrintOut(30, 360, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts4"),"");
  849. }
  850. for(var j = iPoint; j <= getNodesetCount("/root/main/lbllist/lbllist") ; j++){
  851. var drugkind2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/drugkindnm");
  852. var dayno2 = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpdayno");
  853. var mthd4 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd1");
  854. var mthd5 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd2");
  855. var mthd6 = model.getValue("/root/main/lbllist/lbllist["+j+"]/mthd3");
  856. if((drugkind1 == drugkind2) && (dayno1 == dayno2) && (mthd1 == mthd4 && mthd2 == mthd5 && mthd3 == mthd6)
  857. && !fChkSumcls(j)){
  858. //if(model.getValue("/root/main/lbllist/lbllist["+j+"]/fst_prnt") == "Y"){
  859. var prcpqty = model.getValue("/root/main/lbllist/lbllist["+j+"]/totdrugqty")/model.getValue("/root/main/lbllist/lbllist["+j+"]/prcptims") ;
  860. prcpqty = Math.ceil( prcpqty * tims*1000)/1000;
  861. var val = model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpcd")
  862. +" "+prcpqty
  863. +" "+model.getValue("/root/main/lbllist/lbllist["+j+"]/prcpnm");
  864. sSndMsg += astfPrintOut(30+((cnt%2)*380), 440+((parseInt(cnt/2, 10))*40), 2, val, "");
  865. //}
  866. cnt++;
  867. } else {
  868. break;
  869. }
  870. if(cnt == 10){
  871. j++;
  872. break;
  873. }
  874. }
  875. iPoint = j-1;
  876. }
  877. /**
  878. *
  879. */
  880. function fDateFormat(sDD, sYMD) {
  881. if(sYMD == "MD"){
  882. return sDD.substr(4,2)+" / "+sDD.substr(6,2);
  883. } else {
  884. return sDD.substr(0,4)+" / "+sDD.substr(4,2)+" / "+sDD.substr(6,2);
  885. }
  886. }
  887. /**
  888. *
  889. */
  890. function fPrntTime(sDD, sTM) {
  891. return sDD.substr(4,2)+" / "+sDD.substr(6,2)+" "+sTM.substr(0,2)+":"+sTM.substr(2,2)+":"+sTM.substr(4,2);
  892. }
  893. /**
  894. *
  895. */
  896. function fChkFloat(qty) {
  897. var fQty = parseFloat(qty);
  898. var fRst = "";
  899. if(fQty%1 == 0){
  900. fRst = parseInt(qty);
  901. } else {
  902. fRst = qty;
  903. }
  904. return fRst;
  905. }
  906. /**
  907. *
  908. */
  909. function fChkSumcls(cnt) {
  910. var chk = false;
  911. var sSumcls = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/sumcls");
  912. var sSnglyn = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/atcifsnglyn");
  913. var sDrugindependpackflag = model.getValue("/root/main/lbllist/lbllist["+cnt+"]/drugindependpackflag");
  914. if(sSumcls == "DI" || sSumcls == "DS"|| sSumcls == "DX"|| sSumcls == "DT" || sSumcls == "DM" || sSumcls == "IH"|| sSumcls == "IO"
  915. || sSumcls == "IS"|| sSumcls == "IX"|| sSumcls == "X" || sSumcls == "I"){
  916. chk = true;
  917. }
  918. if ( sSumcls == "D" && sSnglyn =="Y" ) {
  919. chk = true;
  920. }
  921. if ( sDrugindependpackflag =="Y"){
  922. chk = true;
  923. }
  924. return chk;
  925. }
  926. /**
  927. * 물약라벨출력
  928. */
  929. function fLiquidLBLPrint() {
  930. // Comm 설정
  931. CommAX.CommPort = "1"; // 출력 Port
  932. CommAX.Settings = "9600,n,8,1"; // Comm 설정
  933. //CommAX.Settings = "127.0.0.1"; // Comm 설정
  934. // zebra 용지부족일때 오류 메시지 2009.10.14 pymi
  935. /*if(!CommAX.zebra_chk()) {
  936. return;
  937. }*/
  938. // (e)
  939. var reprint ="";
  940. if ( CommAX.PortOpen() == true) {
  941. for(iPoint = 1; iPoint <= getNodesetCount("/root/main/lbllist/lbllist") ; iPoint++){
  942. if ( model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblprnttims")>0 ){
  943. reprint ="(재)";
  944. }
  945. //시작(X, Y)
  946. sSndMsg += astfStartFormat(0, 0);
  947. //////////////////////////////////////////////////
  948. // 라벨 상단내용 //
  949. /////////////////////////////////////////////////
  950. //병실
  951. //sSndMsg += astfPrintOut(50, 30, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/roomcd"),"");
  952. //환자명
  953. //sSndMsg += astfPrintOut(50, 85, 6, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  954. //내복약
  955. //sSndMsg += astfPrintOut(250, 30, 3, "내복약","");
  956. //처방일자
  957. //sSndMsg += astfPrintOut(250, 70, 3, fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd")),"");
  958. //환자번호(투약번호)
  959. //sSndMsg += astfPrintOut(250, 110, 3, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid")+ " ( "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint+" )","");
  960. //선그리기
  961. //sSndMsg += astfGraphicBox(5, 145, 465, 0, 4);
  962. var sDD = getCurrentDate();
  963. var sTM = getCurrentTime();
  964. //라벨이름(내복약/주사약/마약)
  965. sSndMsg += astfPrintOut(20, 25, 7, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugkindnm"),"");
  966. //출력일자
  967. sSndMsg += astfPrintOut(220, 25, 21, "출 력 : "+fPrntTime(sDD, sTM),"");
  968. //출력일자
  969. sSndMsg += astfPrintOut(220, 55, 21, "처 방 : "+fDateFormat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdd"), "MD"),"");
  970. //병실
  971. sSndMsg += astfPrintOut(20, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/roomcd"),"");
  972. //환자이름
  973. sSndMsg += astfPrintOut(120, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/patnm"),"");
  974. //환자번호
  975. sSndMsg += astfPrintOut(240, 80, 31, model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/pid")+" ("+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/drugno")+reprint+")","");
  976. //선그리기
  977. sSndMsg += astfGraphicBox(5, 120, 465, 0, 4);
  978. //////////////////////////////////////////////////
  979. // 라벨 하단내용 //
  980. /////////////////////////////////////////////////
  981. //라벨내용
  982. var dayqty = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/dayprcpqty");
  983. var qtyunit = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpqtyunit");
  984. var tims = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcptims");
  985. var dayno = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpdayno");
  986. var qty = Math.ceil(dayqty / tims * 1000)/1000 ;
  987. var totqty = parseInt(dayqty)*parseInt(dayno);
  988. var mthd1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts1");
  989. var mthd2 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts2");
  990. var mthd3 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/mthdcnts3");
  991. //용법
  992. if ( mthd1 == "" && mthd2 == "" && mthd3 == "" ){
  993. //1일 X회 Xml씩 X일분
  994. sSndMsg += astfPrintOut(40, 126, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  995. var val = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/abbrnm");
  996. sSndMsg += astfPrintOut(40, 171, 27, val.substring(0,17) ,"");
  997. sSndMsg += astfPrintOut(40, 210, 27, val.substring(17,val.length) ,"");
  998. } else {
  999. //1일 X회 Xml씩 X일분
  1000. sSndMsg += astfPrintOut(40, 165, 27, "1일 "+tims+"회 "+qty+qtyunit+"씩 "+dayno+"일분","");
  1001. sSndMsg += astfPrintOut(40, 210, 27, mthd1 + " " + mthd2 + " " + mthd3 ,"");
  1002. }
  1003. //약품코드 + 총용량
  1004. //sSndMsg += astfPrintOut(40, 255, 27, "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+totqty,"");
  1005. //약품코드 + 총용량 + 약품명
  1006. var prcpnm = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpnm");
  1007. if(prcpnm.length > 12) {
  1008. prcpnm = prcpnm.substring(0,12);
  1009. }
  1010. sSndMsg += astfPrintOut(20, 255, 27, "[ "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/prcpcd")+" ] "+
  1011. parseFloat(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/totdrugqty")) + " " +
  1012. prcpnm,"");
  1013. //보관방법
  1014. var lblcnts1 = model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/lblcnts1");
  1015. if ( lblcnts1 == "" ) {
  1016. if(model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd") != ""){
  1017. sSndMsg += astfPrintOut(40, 300, 27, "< "+model.getValue("/root/main/lbllist/lbllist["+iPoint+"]/keepmthd")+" >","");
  1018. }
  1019. } else {
  1020. if(lblcnts1.length > 28){
  1021. //주의사항
  1022. sSndMsg += astfPrintOut(20, 285, 3, lblcnts1.substring(0,24),"");
  1023. sSndMsg += astfPrintOut(20, 315, 3, lblcnts1.substring(24,lblcnts1.length),"");
  1024. } else {
  1025. //주의사항
  1026. sSndMsg += astfPrintOut(40, 300, 27, lblcnts1,"");
  1027. }
  1028. }
  1029. //종료(매수)
  1030. sSndMsg += astfEndFormat(0);
  1031. CommAX.SendMessage(sSndMsg);
  1032. fSleep(500);
  1033. sSndMsg = "";
  1034. }
  1035. CommAX.PortClose();
  1036. model.refresh();
  1037. }
  1038. }