prescription-detail.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. $(function(){
  2. //获取团队信息
  3. var request = getRequest(),
  4. teamCode = request.id,
  5. isLeader = isTeamLeader(),
  6. prescriptionCode = request.code;
  7. var $main = $('#main');
  8. var jwHospital = '',
  9. jwDoctorCode = '';
  10. // 认证专用
  11. var strOriginalData;
  12. template.helper('idcardWidthStar',function(idcard) {
  13. if(idcard) {
  14. if(idcard.length == 18) {
  15. return idcard.substring(0,8) +'********'+idcard.substring(16,18)
  16. } else {
  17. idcard.substring(0,5) +'********'+idcard.substring(16,18)
  18. }
  19. }
  20. return "";
  21. })
  22. template.helper('getStatusName',function(status) {
  23. return getStatusName(status)
  24. })
  25. template.helper('getReviewResultName',function(status) {
  26. return getReviewResultName(status)
  27. })
  28. prescriptionDetailApis.getContinuedPrescriptionAsDoctor({
  29. data: {
  30. code: prescriptionCode, // 续方CODE
  31. type: isLeader?1:2 // 是否为团队长,1:是,2:否
  32. }
  33. }).then(function(res) {
  34. if(res.status == 200) {
  35. var data = res.data;
  36. var prescription = data.prescription;
  37. var diagnosis = data.diagnosis;
  38. strOriginalData = data;
  39. jwHospital = prescription.jwHospital;
  40. jwDoctorCode = prescription.jwDoctorCode;
  41. var diagnosisNames = _.pluck(diagnosis,'name').join('、')
  42. if(isLeader) {
  43. getDataPromises().then(function(responses) {
  44. var deptRes = responses[0],
  45. feeRes = responses[1],
  46. authRes = responses[2],
  47. reasonRes = responses[3];
  48. $main.html(template('detailTmpl',$.extend({}, data , {
  49. diagnosisNames: diagnosisNames,
  50. depts: deptRes.data,
  51. feeRes: feeRes.data,
  52. isAuthentication: authRes.data.type == 4,
  53. isLeader: isLeader,
  54. reasonTypes: reasonRes.data
  55. })))
  56. bindEvents()
  57. }).catch(function(e) {
  58. showErrorMsg('初始化失败')
  59. })
  60. } else {
  61. $main.html(template('detailTmpl',$.extend({}, data , {
  62. diagnosisNames: diagnosisNames,
  63. isLeader: isLeader
  64. })))
  65. bindEvents()
  66. }
  67. } else {
  68. showErrorMsg(res.msg)
  69. }
  70. })
  71. function bindEvents() {
  72. $('#auditResultSel').on('change',function() {
  73. var value = $(this).val();
  74. if(value == 1) {
  75. $('#disagreeAudit').hide();
  76. $('#agreeAudit').show();
  77. } else if(value == 2) {
  78. $('#agreeAudit').hide();
  79. $('#disagreeAudit').show();
  80. } else {
  81. $('#agreeAudit').hide();
  82. $('#disagreeAudit').hide();
  83. }
  84. })
  85. $('#reviewBtn').on('click',function() {
  86. var result = $('#auditResultSel').val();
  87. var data = {
  88. code: prescriptionCode, // 续方CODE
  89. reason: '', // 不同意原因
  90. reasonCode: '', // 不同意原因CODE
  91. state: '', // 1同意,2不同意
  92. dept: '', // 科室
  93. registerFee: '', // 诊金
  94. rateTypeCode: '' // 诊金类型
  95. }
  96. if(result == 1) { // 审核通过
  97. if(!checkAgreeInputs()) {
  98. return ;
  99. }
  100. $('#reviewBtn').attr('disabled','disabled')
  101. var params ={
  102. strRealNameSoftCertCalledPasswd: $('#reviewPassword').val(),
  103. strOriginalData:JSON.stringify(getStrOriginalData()),
  104. prescriptionCode:prescriptionCode
  105. }
  106. prescriptionDetailApis.requestRealNameSoftCertAndSign({
  107. data: params
  108. }).then(function(res) {
  109. if(res.status==200 && res.data){
  110. var feesel = $('#feeSel').val().split(' ');
  111. prescriptionDetailApis.reviewPrescription({
  112. data: {
  113. code: prescriptionCode, // 续方CODE
  114. state: 1, // 1同意,2不同意
  115. dept: $('#deptSel').val(), // 科室
  116. registerFee: feesel[1], // 诊金
  117. rateTypeCode: feesel[0] // 诊金类型
  118. }
  119. }).then(function(res) {
  120. if(res.status == 200 && res.data){
  121. showSuccessMsg(res.msg || '操作成功')
  122. setTimeout(function() {
  123. location.reload(true)
  124. }, 2000)
  125. } else {
  126. $('#reviewBtn').removeAttr('disabled')
  127. }
  128. })
  129. } else {
  130. showErrorMsg(res.msg)
  131. $('#reviewBtn').removeAttr('disabled')
  132. }
  133. }).catch(function(e) {
  134. showErrorMsg(e)
  135. })
  136. } else { // 审核不通过
  137. if(!checkDisAgreeInputs()) {
  138. return ;
  139. }
  140. var reasonType = $('#adjustReason li.active').text();
  141. var reason = $('#disagreeReason').val();
  142. prescriptionDetailApis.reviewPrescription({
  143. data: {
  144. code: prescriptionCode, // 续方CODE
  145. state: 2, // 1同意,2不同意
  146. reason: reasonType, // 不同意原因
  147. reasonCode: reason, // 不同意原因CODE
  148. }
  149. }).then(function(res) {
  150. if(res.status == 200 && res.data){
  151. showSuccessMsg(res.msg || '操作成功')
  152. setTimeout(function() {
  153. location.reload(true)
  154. }, 2000)
  155. } else {
  156. $('#reviewBtn').removeAttr('disabled')
  157. }
  158. }).catch(function(e) {
  159. showErrorMsg(e)
  160. })
  161. }
  162. })
  163. $('#editBtn').on('click',function() {
  164. location.href = 'prescription-adjustment.html'
  165. })
  166. $('#backBtn').on('click',function() {
  167. history.go(-1);
  168. })
  169. $('#adjustReason').on('click','li',function() {
  170. $(this).siblings().removeClass('active');
  171. $(this).addClass('active')
  172. })
  173. calcWorldWithTextarea()
  174. }
  175. function getStrOriginalData() {
  176. var imporMsg = {
  177. prescription: {}
  178. };
  179. imporMsg.prescription.jwCode = strOriginalData.prescription.jwCode;
  180. imporMsg.prescription.patientName = strOriginalData.prescription.patientName;
  181. imporMsg.prescription.doctorName = strOriginalData.prescription.doctorName;
  182. imporMsg.prescription.diagnosis = strOriginalData.diagnosis;
  183. var arr = _.map(strOriginalData.prescriptionInfo,function(item){
  184. return _.pick(item, 'drugCode','drugName','jwSubCode','physicAmount','physicAmountUnit','physicAmountUnitName');
  185. })
  186. imporMsg.prescription.prescriptionInfo = arr;
  187. return imporMsg;
  188. }
  189. function checkAgreeInputs() {
  190. var fee = $('#feeSel').val();
  191. var dept = $('#deptSel').val();
  192. var pwd = $('#reviewPassword').val();
  193. if(!fee) {
  194. showErrorMsg("请选择诊查费用")
  195. return false;
  196. } else if(!dept) {
  197. showErrorMsg("请选择开方科室")
  198. return false;
  199. } else if(!pwd) {
  200. showErrorMsg("请输入审方密码")
  201. return false;
  202. }
  203. return true;
  204. }
  205. function checkDisAgreeInputs() {
  206. var reasonType = $('#adjustReason li.active').text();
  207. var reason = $('#disagreeReason').val();
  208. if(!reasonType) {
  209. showErrorMsg("请选择不通过原因")
  210. return false;
  211. } else if(!reason) {
  212. showErrorMsg("请输入不通过原因")
  213. return false;
  214. }
  215. return true;
  216. }
  217. function getDataPromises() {
  218. return Promise.all([
  219. prescriptionDetailApis.getDeptList({
  220. data: {
  221. jwHospital: jwHospital,
  222. jwDoctorCode: jwDoctorCode
  223. }
  224. }),
  225. prescriptionDetailApis.getRegisterRee({
  226. data: {
  227. jwHospital: jwHospital,
  228. jwDoctorCode: jwDoctorCode
  229. }
  230. }),
  231. prescriptionDetailApis.isAuthentication({}),
  232. prescriptionDetailApis.getReasonByType({
  233. data: {
  234. type: '0'
  235. }
  236. })
  237. ])
  238. }
  239. })