prescription_detail.js 4.1 KB

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