SPMMR09001.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. model.setValue("/root/send/instcd", model.getValue("/root/main/paminfo/instcd"));
  60. model.setValue("/root/send/pid", model.getValue("/root/main/paminfo/pid"));
  61. model.setValue("/root/send/orddeptcd", model.getValue("/root/main/paminfo/orddeptcd"));
  62. var sDegnitemlevlcd = opener.javascript.getParameter("SPMMR09001_degnitemlevlcd");
  63. var sDegnitemcd = opener.javascript.getParameter("SPMMR09001_degnitemcd");
  64. model.setValue("/root/init/opener/degnitemlevlcd", sDegnitemlevlcd);
  65. model.setValue("/root/init/opener/degnitemcd", sDegnitemcd);
  66. model.setValue("/root/init/opener/content", opener.model.getValue("/root/main/recinfo/recitem[degnitemlevlcd = "+ sDegnitemlevlcd +"and degnitemcd = "+ sDegnitemcd +"]/reccnts"));
  67. fGetOrdddinfo();
  68. btn_search.dispatch("DOMActivate");
  69. }
  70. }
  71. function fGetOrdddinfo(){
  72. submit("TRMMR09002");
  73. model.setValue("/root/send/orddd", model.getValue("/root/main/ordddlist/ordddinfo[1]/value"));
  74. }
  75. function fGetTestinfo(){
  76. submit("TRMMR09001");
  77. model.setValue("/root/temp/itemflag", "true");
  78. model.refresh();
  79. gGroupMap.clear();
  80. for(var i=0; i < grd_testlist.cols; i++){
  81. grd_testlist.mergeCells = "bycol";
  82. if(i == 1){
  83. grd_testlist.mergeCol(i) = true;
  84. }else{
  85. grd_testlist.mergeCol(i) = false;
  86. }
  87. }
  88. grd_testlist.rebuild();
  89. }
  90. function fSetGridFlag(){
  91. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  92. var sFlag = "false"
  93. if(nTotalCount > 0){
  94. if(model.getValue("/root/temp/itemflag") == "true"){
  95. sFlag = "true";
  96. }
  97. for(var i = 1; i <= nTotalCount; i ++) {
  98. model.setValue("/root/main/testlist/testinfo[" + i + "]/itemflag", sFlag);
  99. }
  100. }
  101. }
  102. function fMakeForm(){
  103. if(isPopup()){
  104. var sDegnitemlevlcd = model.getValue("/root/init/opener/degnitemlevlcd");
  105. var sDegnitemcd = model.getValue("/root/init/opener/degnitemcd");
  106. var sContent = model.getValue("/root/init/opener/content") + "\n";
  107. if(getNodesetCount("/root/main/testlist/testinfo") > 0){
  108. //var dutplcecd = getUserInfo("dutplcecd");
  109. var sOrddptcd = model.getValue("/root/main/paminfo/orddeptcd"); //해당환자 진료과로 결과값 가지고옴
  110. switch(sOrddptcd){
  111. case "2010700000" : sContent += fMakeForm_INM(); //신장내과
  112. break;
  113. default :
  114. sContent += fMakeForm_Default();
  115. break;
  116. }
  117. opener.model.setValue("/root/main/recinfo/recitem[degnitemlevlcd = "+ sDegnitemlevlcd +"and degnitemcd = "+ sDegnitemcd +"]/reccnts", sContent);
  118. opener.model.refresh();
  119. }
  120. }
  121. window.close();
  122. }
  123. function fMakeGroupString(pItemSort, pItemGroup){
  124. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  125. var sItemSort = "";
  126. var sItemnm = "";
  127. var sItemval = "";
  128. var sItemgroup = "";
  129. var sContent_name = model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemnm")+"/";
  130. var sContent_value = model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemval")+"/";
  131. for(var i=1; i<= nTotalCount; i++){
  132. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  133. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  134. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  135. sItemgroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  136. if(fCopyCheckedItem(sItemSort, sItemval)){
  137. if(!isNull(pItemGroup)){
  138. if(pItemSort != sItemSort){
  139. if(pItemGroup == sItemgroup ){
  140. sContent_name += sItemnm + "/";
  141. sContent_value += sItemval + "/";
  142. gGroupMap.put(pItemGroup, pItemGroup);
  143. }
  144. }
  145. }
  146. }
  147. }
  148. return sContent_name.substring(0,eval(sContent_name.length -1)) + " : " + sContent_value.substring(0,eval(sContent_value.length -1));
  149. }
  150. function fCopyCheckedItem(pItemSort, pItemval){
  151. return model.getValue("/root/main/testlist/testinfo[itemsort = "+pItemSort+"]/itemflag") == "true" && !isNull(pItemval);
  152. }
  153. function fMakeForm_Default(){
  154. var sContent = "";
  155. var sItemSort = "";
  156. var sItemnm = "";
  157. var sItemval = "";
  158. var sItemGroup = "";
  159. var sItemExeDd = "";
  160. var sPreExeDd = "";
  161. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  162. if(nTotalCount > 0){
  163. for(var i=1; i <= nTotalCount; i++){
  164. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  165. sItemExeDd = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemexedd");
  166. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  167. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  168. sItemGroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  169. if(fCopyCheckedItem(sItemSort, sItemval)){
  170. if(sPreExeDd != sItemExeDd) {
  171. sPreExeDd = sItemExeDd;
  172. sContent += "\n검사접수일자 : " + sItemExeDd.substring(0,4) + ". " + sItemExeDd.substring(4,6) + ". " + sItemExeDd.substring(6,8)+ "\n\n";
  173. }
  174. if(isNull(sItemGroup)){
  175. sContent += sItemnm +" : "+ sItemval + "\n";
  176. }else{
  177. if(isNull(gGroupMap.get(sItemGroup))){
  178. sContent += fMakeGroupString(sItemSort, sItemGroup) + "\n";
  179. }
  180. }
  181. }
  182. }
  183. }
  184. return sContent;
  185. }
  186. function fMakeForm_INM(){
  187. /* *******************************************************
  188. * 노드셋에서 1~13 번째 까지는 폼형식이 정해져 있기때문에
  189. * 쿼리에서도 유의 해야 함 (ORDER BY 에 유의 ) 기준자료 : 5654
  190. *
  191. * 아래 순서로 데이터가 존재해야 한다
  192. * itemsort itemnm
  193. * 1 Hemoglobin
  194. * 2 WBC
  195. * 3 LC1026
  196. * 4 LC1028
  197. * 5 LCR191
  198. * 6 LH1007
  199. * 7 Hematocrit
  200. * 8 Platelet
  201. * 9 LC1027
  202. * 10 LCR190
  203. * 11 LCR192
  204. * 12 LH1026
  205. * 13 LH102601
  206. *
  207. * Hemoglobin WBC LC1026 LC1028 LCR191 LH1007
  208. * --------------< --------+--------+---------+---------
  209. * Hematocrit Platelet LC1027 LCR190 LCR192 LH1026 (LH102601)
  210. *
  211. * *******************************************************/
  212. var nTotalCount = getNodesetCount("/root/main/testlist/testinfo");
  213. var sTop = "";
  214. var sBottom = "";
  215. var sLine = "------<\t\t ";
  216. var sTestVal = "";
  217. var sTestDate = "검사접수일자 : ";
  218. var sItemSort = "";
  219. var sItemnm = "";
  220. var sItemval = "";
  221. var sItemGroup = "";
  222. var sContent = "";
  223. var bNullflag = false;
  224. if(nTotalCount > 0){
  225. // itemsort를 참조하여 form을 생성한다.
  226. 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);
  227. for(var i=1; i <= nTotalCount; i++){
  228. sItemSort = model.getValue("/root/main/testlist/testinfo["+i+"]/itemsort");
  229. sItemnm = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemnm");
  230. sItemval = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemval");
  231. sItemGroup = model.getValue("/root/main/testlist/testinfo[itemsort = "+sItemSort+"]/itemgroup");
  232. if(sItemSort >= 1 && sItemSort <= 13){
  233. if(sItemSort <= 6){ // top itemsort : 1~ 6
  234. sTop += sItemval;
  235. if(sItemSort != 6){
  236. if(sItemval.length < 5){
  237. sTop += "\t\t";
  238. }else{
  239. sTop += "\t";
  240. }
  241. }
  242. }else{ // bottom itemsort : 7 ~ 12
  243. if(sItemSort != 13){
  244. sBottom += sItemval;
  245. if(sItemval.length < 5){
  246. sBottom += "\t\t";
  247. }else{
  248. sBottom += "\t";
  249. }
  250. }else{
  251. if(!isNull(sItemval)){
  252. sBottom += "("+sItemval+")";
  253. }else{
  254. sBottom += "(\t)";
  255. }
  256. }
  257. }
  258. bNullflag = true;
  259. }else{
  260. if(fCopyCheckedItem(sItemSort, sItemval)){
  261. if(isNull(sItemGroup)){
  262. sTestVal += sItemnm +" : "+ sItemval + "\n";
  263. }else{
  264. if(isNull(gGroupMap.get(sItemGroup))){
  265. sTestVal += fMakeGroupString(sItemSort, sItemGroup) + "\n";
  266. }
  267. }
  268. }
  269. }
  270. }
  271. // Line
  272. for(var i=1; i<=4; i++){
  273. if(i != 4){
  274. sLine += "--------+-";
  275. }else{
  276. sLine += "----------";
  277. }
  278. }
  279. // ItemSort 1~12 데이터 존재 여부에 따라 출력 형식이 달라짐
  280. if(bNullflag){
  281. sContent = sTestDate + "\n\n" + sTop + "\n" + sLine + "\n" + sBottom + "\n\n" + sTestVal;
  282. }else{
  283. sContent = sTestDate + "\n\n" + sTestVal;
  284. }
  285. }
  286. return sContent;
  287. }