diag_push.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. (function ($) {
  2. var urls = {
  3. //His推送接口
  4. 'get_push':'http://192.168.2.236/api/icss/emr/pushEMR',
  5. 'get_info':'http://192.168.2.236/api/icss/emr/getIntroduceByEMR'
  6. };
  7. $.support.cors = true;
  8. var config = {
  9. width:'560px', //推送内容显示的宽度
  10. num:'11', //每行显示的最大个数
  11. mode:'horizontal', //布局模式水平horizontal,垂直vertical,
  12. models:[5,6,7] //需要显示的推送模块,主诉-诊断1-7
  13. };
  14. var urlSearch = parseUrl();
  15. handleConfig();
  16. getPushData();
  17. function parseUrl() {
  18. var r = window.location.search.substr(1).split("&"),
  19. obj = {};
  20. $.each(r, function (i, v) {
  21. if (v) {
  22. var arr = v.split("=");
  23. obj[arr[0]] = arr[1]?decodeURI(arr[1]):'';
  24. }
  25. });
  26. return obj;
  27. };
  28. function handleConfig(){
  29. $("tr td:last-child").css({width:config.width});
  30. $('.'+config.mode).show();
  31. }
  32. function getPushData(){
  33. var url = urls.get_push;
  34. var myParam = {
  35. symptom: urlSearch.symptomJson||"",
  36. past: urlSearch.pastJson||"",
  37. other: urlSearch.otherJson||"",
  38. vital: urlSearch.vitalsJson||"",
  39. lis: JSON.parse(urlSearch.labsJson||null),
  40. pacs: urlSearch.pacsJson||"",
  41. diag: urlSearch.disJson||"",
  42. featureType: config.models.join(","),
  43. hosCode:'A001',
  44. age:urlSearch.age,
  45. sex:urlSearch.sexType
  46. };
  47. $.ajax({
  48. url: url,
  49. type:'post',
  50. dataType: "json",
  51. cache:false,
  52. contentType:"application/json",
  53. data:JSON.stringify(myParam),
  54. success:function(response){
  55. var data = response.data;
  56. if(response.code=='0'){
  57. fillPushData(data);
  58. }
  59. },
  60. error:function(error){
  61. console.log("error:"+error);
  62. },
  63. complete:function(){
  64. console.log("complete")
  65. }
  66. });
  67. }
  68. function getTreatInfo(type,name){
  69. var url = urls.get_info;
  70. var myParam = {
  71. icdCode:urlSearch.icd,
  72. type:type,
  73. name:name,
  74. detailName:'白蛋白(Alb)',
  75. hosCode:'A001',
  76. age:urlSearch.age,
  77. sex:urlSearch.sexType
  78. };
  79. $.ajax({
  80. url: url,
  81. type:'post',
  82. dataType: "json",
  83. cache:false,
  84. contentType:"application/json",
  85. data:JSON.stringify(myParam),
  86. success:function(response){
  87. var data = response.data;
  88. if(response.code=='0'){
  89. fillInfomation(data);
  90. }
  91. },
  92. error:function(error){
  93. console.log("error:"+error);
  94. },
  95. complete:function(){
  96. console.log("complete")
  97. }
  98. });
  99. }
  100. //填入提示信息
  101. function fillInfomation(data){
  102. var dom='';
  103. for(var i=0;i<data.length;i++){
  104. dom+='<div class="info-item clearfix"><span class="title">'+data[i].title+':</span><p class="content">'+data[i].text+'</p></div>';
  105. }
  106. $(".box0 .item-content").html(dom);
  107. }
  108. //填入推送信息
  109. function fillPushData(data){
  110. if(!data||JSON.stringify(data)=='{}'){
  111. console.warn("获取推送数据为空!");
  112. return ;
  113. }
  114. var key='',modeClass='.'+config.mode;
  115. mapItem(modeClass+" .box5", data['lisList'],5); //化验
  116. mapItem(modeClass+" .box6", data['pacsList'],6); //辅捡
  117. data['dis']['可能诊断'].length>0&&mapItem(modeClass+" .box7", data['dis']['可能诊断'],7); //初步诊断
  118. data['dis']['确诊'].length>0&&mapItem(modeClass+" .box8", data['dis']['确诊'],7); //疑似诊断
  119. data['dis']['警惕'].length>0&&mapItem(modeClass+" .box9", data['dis']['警惕'],7); //警惕
  120. $("a.info").click(function(e){
  121. getTreatInfo($(e.target).attr('type'),$(e.target).attr('name'))
  122. });
  123. //$(modeClass+" .box .item-content").html(str); //治疗建议
  124. }
  125. //遍历数据
  126. function mapItem(dom,item,type){
  127. var itemDom = '';
  128. for(var i=0;i<item.length;i++){
  129. if(i>config.num-1){
  130. itemDom += '<span style="white-space:nowrap"><a href="##" class="hide">'+item[i]+'</a><a class="info hide" target="_blank name="'+item[i]+'" type='+type+'>i</a></span>';
  131. }else{
  132. itemDom += '<span style="white-space:nowrap"><a href="##">'+item[i]+'</a><a class="info" target="_blank" name='+item[i]+' type="'+type+'">i</a></span>';
  133. }
  134. }
  135. $(dom+" .item-content").html(itemDom||"无");
  136. $(dom).show();
  137. var hide = $(dom).find(".hide")[0];
  138. if(hide){
  139. $("<a class='more'>...</a>").insertBefore(hide);
  140. $(".more").click(function(e){
  141. $(e.target).siblings(".hide").removeClass("hide");
  142. $(e.target).hide();
  143. });
  144. }
  145. }
  146. })(jQuery);