prescription-detail.js 7.5 KB

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