SPMMR09003.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. Map = function(){
  2. this.map = new Object();
  3. };
  4. Map.prototype = {
  5. put : function(key, value){
  6. this.map[key] = value;
  7. },
  8. get : function(key){
  9. return this.map[key];
  10. },
  11. containsKey : function(key){
  12. return key in this.map;
  13. },
  14. containsValue : function(value){
  15. for(var prop in this.map){
  16. if(this.map[prop] == value) return true;
  17. }
  18. return false;
  19. },
  20. isEmpty : function(key){
  21. return (this.size() == 0);
  22. },
  23. clear : function(){
  24. for(var prop in this.map){
  25. delete this.map[prop];
  26. }
  27. },
  28. remove : function(key){
  29. delete this.map[key];
  30. },
  31. keys : function(){
  32. var keys = new Array();
  33. for(var prop in this.map){
  34. keys.push(prop);
  35. }
  36. return keys;
  37. },
  38. values : function(){
  39. var values = new Array();
  40. for(var prop in this.map){
  41. values.push(this.map[prop]);
  42. }
  43. return values;
  44. },
  45. size : function(){
  46. var count = 0;
  47. for (var prop in this.map) {
  48. count++;
  49. }
  50. return count;
  51. }
  52. };
  53. var gGroupMap = new Map();
  54. function fInit(){
  55. if(isPopup()){
  56. var node = getGlobalVariable("paminfo");
  57. model.removeNodeset("/root/main/paminfo");
  58. setCSVToNode("/root/main", node, "paminfo");
  59. if("O" == model.getValue("/root/main/paminfo/ioflag") || "S" == model.getValue("/root/main/paminfo/ioflag")) {
  60. model.setValue("/root/send/ioflag", "O");
  61. model.setValue("/root/send/orddd", model.getValue("/root/main/paminfo/orddd"));
  62. } else {
  63. model.setValue("/root/send/ioflag", "I");
  64. model.setValue("/root/send/orddd", model.getValue("/root/main/paminfo/indd"));
  65. }
  66. model.setValue("/root/send/instcd", model.getValue("/root/main/paminfo/instcd"));
  67. model.setValue("/root/send/pid", model.getValue("/root/main/paminfo/pid"));
  68. model.setValue("/root/send/cretno", model.getValue("/root/main/paminfo/cretno"));
  69. model.setValue("/root/send/orddeptcd", model.getValue("/root/main/paminfo/orddeptcd"));
  70. model.setValue("/root/send/pagecls", "bfprcp"); // 전처방일자 조회 옵션 화면구분(addprcp:, bfprcp:)
  71. model.setValue("/root/send/bfprcpdd", fGetBfPrcpDd("bf"));
  72. var sDegnitemlevlcd = opener.javascript.getParameter("SPMMR09003_degnitemlevlcd");
  73. var sDegnitemcd = opener.javascript.getParameter("SPMMR09003_degnitemcd");
  74. model.setValue("/root/init/opener/degnitemlevlcd", sDegnitemlevlcd);
  75. model.setValue("/root/init/opener/degnitemcd", sDegnitemcd);
  76. model.setValue("/root/init/opener/content", opener.model.getValue("/root/main/recinfo/recitem[degnitemlevlcd = "+ sDegnitemlevlcd +"and degnitemcd = "+ sDegnitemcd +"]/reccnts"));
  77. btn_search.dispatch("DOMActivate");
  78. }
  79. }
  80. function fGetBfPrcpDd(sFlag) {
  81. var sRtn = "";
  82. var sBfPrcpDd = model.getValue("/root/send/bfprcpdd");
  83. if(sBfPrcpDd == "") {
  84. sBfPrcpDd = model.getValue("/root/send/orddd");
  85. }
  86. model.setValue("/root/send/bfprcpdd", sBfPrcpDd);
  87. model.setValue("/root/send/srchcls", sFlag); // 전처방일자 조회 옵션 조회구분 (bf:이전처방일, aft:이후처방일, init:최초상태)
  88. submit("TRMMR09004");
  89. sRtn = model.getValue("/root/main/temp/bfprcpdd");
  90. if(sRtn == "") {
  91. messageBox ( "처방적용일이 없습니다.", "I" );
  92. sRtn = sBfPrcpDd;
  93. }
  94. return sRtn;
  95. }
  96. function fGetTestinfo(){
  97. submit("TRMMR09005");
  98. model.setValue("/root/temp/itemflag", "true");
  99. gGroupMap.clear();
  100. /*
  101. for(var i=0; i < grd_testlist.cols; i++){
  102. grd_testlist.mergeCells = "bycol";
  103. if(i == 1){
  104. grd_testlist.mergeCol(i) = true;
  105. }else{
  106. grd_testlist.mergeCol(i) = false;
  107. }
  108. }
  109. */
  110. grd_testlist.resizeCells();
  111. grd_testlist.rebuild();
  112. model.refresh();
  113. }
  114. function fSetGridFlag(){
  115. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  116. var sFlag = "false"
  117. if(nTotalCount > 0){
  118. if(model.getValue("/root/temp/itemflag") == "true"){
  119. sFlag = "true";
  120. }
  121. for(var i = 1; i <= nTotalCount; i ++) {
  122. model.setValue("/root/main/testlist/testinfo[" + i + "]/itemflag", sFlag);
  123. }
  124. }
  125. }
  126. function fMakeForm(){
  127. if(isPopup()){
  128. var sDegnitemlevlcd = model.getValue("/root/init/opener/degnitemlevlcd");
  129. var sDegnitemcd = model.getValue("/root/init/opener/degnitemcd");
  130. var sContent = model.getValue("/root/init/opener/content") + "\n";
  131. if(getNodesetCount("/root/main/testlist/testinfo") > 0){
  132. //var dutplcecd = getUserInfo("dutplcecd");
  133. var sOrddptcd = model.getValue("/root/main/paminfo/orddeptcd"); //해당환자 진료과로 결과값 가지고옴
  134. switch(sOrddptcd){
  135. case "2010700000" : sContent += fMakeForm_INM(); //신장내과
  136. break;
  137. default :
  138. sContent += fMakeForm_Default();
  139. break;
  140. }
  141. opener.model.setValue("/root/main/recinfo/recitem[degnitemlevlcd = "+ sDegnitemlevlcd +"and degnitemcd = "+ sDegnitemcd +"]/reccnts", sContent);
  142. opener.model.refresh();
  143. }
  144. }
  145. window.close();
  146. }
  147. function fMakeGroupString(pItemSort, pItemGroup){
  148. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  149. var sItemSort = "";
  150. var sItemnm = "";
  151. var sItemval = "";
  152. var sItemgroup = "";
  153. var sContent_name = model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemnm")+"/";
  154. var sContent_value = model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemval")+"/";
  155. for(var i=1; i<= nTotalCount; i++){
  156. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  157. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  158. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  159. sItemgroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  160. if(fCopyCheckedItem(sItemSort, sItemval)){
  161. if(!isNull(pItemGroup)){
  162. if(pItemSort != sItemSort){
  163. if(pItemGroup == sItemgroup ){
  164. sContent_name += sItemnm + "/";
  165. sContent_value += sItemval + "/";
  166. gGroupMap.put(pItemGroup, pItemGroup);
  167. }
  168. }
  169. }
  170. }
  171. }
  172. return sContent_name.substring(0,eval(sContent_name.length -1)) + " : " + sContent_value.substring(0,eval(sContent_value.length -1));
  173. }
  174. function fCopyCheckedItem(pItemSort, pItemval){
  175. return model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemflag") == "true" && !isNull(pItemval);
  176. }
  177. function fMakeForm_Default(){
  178. var sTestVal = "";
  179. var sContent = "";
  180. var sItemSort = "";
  181. var sItemnm = "";
  182. var sItemval = "";
  183. var sItemGroup = "";
  184. var sItemExeDd = "";
  185. var sPreExeDd = "";
  186. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  187. if(nTotalCount > 0){
  188. for(var i=1; i <= nTotalCount; i++){
  189. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  190. sItemExeDd = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemexedd");
  191. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  192. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  193. sItemGroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  194. if(fCopyCheckedItem(sItemSort, sItemval)){
  195. if(sPreExeDd != sItemExeDd) {
  196. sPreExeDd = sItemExeDd;
  197. sContent += "\n검사접수일자 : " + sItemExeDd.substring(0,4) + ". " + sItemExeDd.substring(4,6) + ". " + sItemExeDd.substring(6,8)+ "\n\n";
  198. }
  199. if(isNull(sItemGroup)){
  200. sTestVal += sItemnm +" : "+ sItemval + "\n";
  201. }else{
  202. if(isNull(gGroupMap.get(sItemGroup))){
  203. sContent += fMakeGroupString(sItemSort, sItemGroup) + "\n";
  204. }
  205. }
  206. }
  207. }
  208. }
  209. return sContent;
  210. }
  211. function fMakeForm_INM(){
  212. /* *******************************************************
  213. * 노드셋에서 1~13 번째 까지는 폼형식이 정해져 있기때문에
  214. * 쿼리에서도 유의 해야 함 (ORDER BY 에 유의 ) 기준자료 : 5654
  215. *
  216. * 아래 순서로 데이터가 존재해야 한다
  217. * itemsort itemnm
  218. * 1 Hemoglobin
  219. * 2 WBC
  220. * 3 LC1026
  221. * 4 LC1028
  222. * 5 LCR191
  223. * 6 LH1007
  224. * 7 Hematocrit
  225. * 8 Platelet
  226. * 9 LC1027
  227. * 10 LCR190
  228. * 11 LCR192
  229. * 12 LH1026
  230. * 13 LH102601
  231. *
  232. * Hemoglobin WBC LC1026 LC1028 LCR191 LH1007
  233. * --------------< --------+--------+---------+---------
  234. * Hematocrit Platelet LC1027 LCR190 LCR192 LH1026 (LH102601)
  235. *
  236. * *******************************************************/
  237. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  238. var sTop = "";
  239. var sBottom = "";
  240. var sLine = "------<\t\t ";
  241. var sTestVal = "";
  242. var sTestDate = "검사접수일자 : ";
  243. var sItemSort = "";
  244. var sItemnm = "";
  245. var sItemval = "";
  246. var sItemGroup = "";
  247. var sContent = "";
  248. var bNullflag = false;
  249. if(nTotalCount > 0){
  250. // itemsort를 참조하여 form을 생성한다.
  251. sTestDate += model.getValue("/root/send/orddd").substring(0,4) + ". " + model.getValue("/root/send/orddd").substring(4,6) + ". " + model.getValue("/root/send/orddd").substring(6,8);
  252. for(var i=1; i <= nTotalCount; i++){
  253. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  254. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  255. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  256. sItemGroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  257. if(sItemSort >= 1 && sItemSort <= 13){
  258. if(sItemSort <= 6){ // top itemsort : 1~ 6
  259. sTop += sItemval;
  260. if(sItemSort != 6){
  261. if(sItemval.length < 5){
  262. sTop += "\t\t";
  263. }else{
  264. sTop += "\t";
  265. }
  266. }
  267. }else{ // bottom itemsort : 7 ~ 12
  268. if(sItemSort != 13){
  269. sBottom += sItemval;
  270. if(sItemval.length < 5){
  271. sBottom += "\t\t";
  272. }else{
  273. sBottom += "\t";
  274. }
  275. }else{
  276. if(!isNull(sItemval)){
  277. sBottom += "("+sItemval+")";
  278. }else{
  279. sBottom += "(\t)";
  280. }
  281. }
  282. }
  283. bNullflag = true;
  284. }else{
  285. if(fCopyCheckedItem(sItemSort, sItemval)){
  286. if(isNull(sItemGroup)){
  287. sTestVal += sItemnm +" : "+ sItemval + "\n";
  288. }else{
  289. if(isNull(gGroupMap.get(sItemGroup))){
  290. sTestVal += fMakeGroupString(sItemSort, sItemGroup) + "\n";
  291. }
  292. }
  293. }
  294. }
  295. }
  296. // Line
  297. for(var i=1; i<=4; i++){
  298. if(i != 4){
  299. sLine += "--------+-";
  300. }else{
  301. sLine += "----------";
  302. }
  303. }
  304. // ItemSort 1~12 데이터 존재 여부에 따라 출력 형식이 달라짐
  305. if(bNullflag){
  306. sContent = sTestDate + "\n\n" + sTop + "\n" + sLine + "\n" + sBottom + "\n\n" + sTestVal;
  307. }else{
  308. sContent = sTestDate + "\n\n" + sTestVal;
  309. }
  310. }
  311. return sContent;
  312. }