prescription_detail.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. var request = GetRequest();
  6. var code = request.code, //从链接中获得处方code
  7. preCode = request.preCode;
  8. var prescriptionCode = ""; //续方的code
  9. var patient,
  10. patientName,
  11. cannotPrescription;
  12. $(function(){
  13. cannotPrescription = window.localStorage.getItem("cannotPrescription");
  14. getDetail();
  15. bindEvents();
  16. })
  17. function getDetail(){
  18. d.show();
  19. var url = "/patient/prescriptionInfo/getPrescription",
  20. params = {code: code, preCode: preCode};
  21. sendPost(url, params, 'json', 'GET', queryFailed, function(res){
  22. if(res.status == 200){
  23. d.close();
  24. prescriptionCode = res.data.prescriptionCode;
  25. patient = res.data.patient;
  26. patientName = res.data.patientName;
  27. //判断是否可以续方
  28. var reuse = getXFStatus(res.data.prescriptionDt, res.data.createTime); //可续方
  29. //reviewedState: 0 为审核中 1.已经处理完成/未申请
  30. if(reuse){
  31. if(cannotPrescription){
  32. $("#btn-div").hide();
  33. }else{
  34. if(res.data.reviewedState == 1){
  35. $("#btn-div").find("a").text("申请续方");
  36. $("#btn-div").find("a").attr("data-status", 1);
  37. }else{
  38. $("#btn-div").find("a").text("续方申请中");
  39. $("#btn-div").find("a").attr("data-status", 0);
  40. }
  41. $("#btn-div").show();
  42. }
  43. $("#reuseStatus").text('可续方');
  44. }else{
  45. $("#btn-div").hide();
  46. $("#reuseStatus").text('不可续方');
  47. }
  48. //填充基本信息和临床诊断信息
  49. $("#dateTime").text(res.data.createTime);
  50. $("#docName").text(res.data.doctorName);
  51. $("#deptName").text(res.data.hospitalName);
  52. var diseaseName = "";
  53. for(i=0; i<res.data.prescriptionDt.length; i++){
  54. var ds = res.data.prescriptionDt[i];
  55. diseaseName += ds.healthProblemName+ ' ';
  56. }
  57. $("#deseaseDetail").text(diseaseName);
  58. //药品列表
  59. var rpList = res.data.prescriptionInfo;
  60. var html = template('rp_tmp', {list: rpList});
  61. $("#rpList").empty().append(html);
  62. }else{
  63. queryFailed(res);
  64. }
  65. });
  66. }
  67. //判断是否可以续方
  68. function getXFStatus(arr, date){
  69. var isXFDesease = true,
  70. statusName = '',
  71. canXF = false;
  72. if(arr){
  73. for(i=0; i<arr.length; i++){
  74. var item = arr[i];
  75. //HP0093 - 高血压 , HP0047 - 糖尿病
  76. if((item.healthProblem != 'HP0093') && (item.healthProblem != 'HP0047')){
  77. isXFDesease = false;
  78. break;
  79. }
  80. }
  81. if(isXFDesease){
  82. //判断时间是否是在6个月内的
  83. // var d = new Date(date),
  84. // now = new Date();
  85. // now.setMonth(now.getMonth() - 2);
  86. // if(d > now){ //6个月内的时间
  87. statusName = '续方';
  88. canXF = true;
  89. // }
  90. }
  91. }
  92. return canXF;
  93. }
  94. function bindEvents(){
  95. $(".c-btn").on('click', function(){
  96. var status = $(this).attr("data-status");
  97. //状态为可申请时,跳转去新增续方咨询页面,其他状态跳转去续方记录页面
  98. //0 为审核中 1.已经处理完成/未申请
  99. var userInfo = JSON.parse(window.localStorage.getItem(agentName1));
  100. if(status == 1){
  101. //跳转去新增续方咨询页面
  102. window.location.href = "../../yszx/html/add-prescription-consult.html?patient="+userInfo.uid+"&name="+userInfo.name+"&jw_code="+code;
  103. }else{
  104. //跳转去续方记录页面
  105. window.location.href = "re-prescription_info.html?code="+prescriptionCode+"&toUser="+userInfo.uid;
  106. }
  107. });
  108. }
  109. function queryFailed(res){
  110. d.close();
  111. if(res && res.msg) {
  112. dialog({
  113. contentType: 'tipsbox',
  114. skin: 'bk-popup',
  115. content: res.msg
  116. }).show();
  117. } else {
  118. dialog({
  119. contentType: 'tipsbox',
  120. skin: 'bk-popup',
  121. content: '加载失败'
  122. }).show();
  123. }
  124. }