prescription-detail.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 reason = $('#disagreeReason').val();
  143. var reasonType = _.map($('#adjustReason li.active'),function(el) {
  144. return $(el).attr('data-code')
  145. }).join(',');
  146. prescriptionDetailApis.reviewPrescription({
  147. data: {
  148. code: prescriptionCode, // 续方CODE
  149. state: 2, // 1同意,2不同意
  150. reason: reason, // 不同意原因
  151. reasonCode: reasonType // 不同意原因CODE
  152. }
  153. }).then(function(res) {
  154. if(res.status == 200 && res.data){
  155. showSuccessMsg(res.msg || '操作成功')
  156. setTimeout(function() {
  157. location.reload(true)
  158. }, 2000)
  159. } else {
  160. $('#reviewBtn').removeAttr('disabled')
  161. }
  162. }).catch(function(e) {
  163. showErrorMsg(e)
  164. })
  165. } else {
  166. showErrorMsg("请选择审核结果")
  167. }
  168. })
  169. $('#editBtn').on('click',function() {
  170. location.href = 'prescription-adjustment.html'
  171. })
  172. $('#backBtn').on('click',function() {
  173. if(from == 'tab') {
  174. top.toPrePrescriptionTab && top.toPrePrescriptionTab()
  175. } else {
  176. history.go(-1);
  177. }
  178. })
  179. $('#adjustReason').on('click','li',function() {
  180. if($(this).hasClass('active')) {
  181. $(this).removeClass('active')
  182. } else {
  183. $(this).addClass('active')
  184. }
  185. setDisagreeReason()
  186. })
  187. calcWorldWithTextarea()
  188. }
  189. function setDisagreeReason() {
  190. var reasons = _.map($('#adjustReason li.active'),function(el) {
  191. return $.trim($(el).text())
  192. });
  193. if(reasons && reasons.length) {
  194. $('#disagreeReason').val(reasons.join(','))
  195. $('#disagreeReason').focus()
  196. }
  197. }
  198. function getStrOriginalData() {
  199. var imporMsg = {
  200. prescription: {}
  201. };
  202. imporMsg.prescription.jwCode = strOriginalData.prescription.jwCode;
  203. imporMsg.prescription.patientName = strOriginalData.prescription.patientName;
  204. imporMsg.prescription.doctorName = strOriginalData.prescription.doctorName;
  205. imporMsg.prescription.diagnosis = strOriginalData.diagnosis;
  206. var arr = _.map(strOriginalData.prescriptionInfo,function(item){
  207. return _.pick(item, 'drugCode','drugName','jwSubCode','physicAmount','physicAmountUnit','physicAmountUnitName');
  208. })
  209. imporMsg.prescription.prescriptionInfo = arr;
  210. return imporMsg;
  211. }
  212. function checkAgreeInputs() {
  213. var fee = $('#feeSel').val();
  214. var dept = $('#deptSel').val();
  215. var pwd = $('#reviewPassword').val();
  216. if(!fee) {
  217. showErrorMsg("请选择诊查费用")
  218. return false;
  219. } else if(!dept) {
  220. showErrorMsg("请选择开方科室")
  221. return false;
  222. } else if(!pwd) {
  223. showErrorMsg("请输入审方密码")
  224. return false;
  225. }
  226. return true;
  227. }
  228. function checkDisAgreeInputs() {
  229. var reason = $('#disagreeReason').val();
  230. if(!reason) {
  231. showErrorMsg("请输入不通过原因")
  232. return false;
  233. }
  234. return true;
  235. }
  236. function getDataPromises() {
  237. return Promise.all([
  238. prescriptionDetailApis.getDeptList({
  239. data: {
  240. jwHospital: jwHospital,
  241. jwDoctorCode: jwDoctorCode
  242. }
  243. }),
  244. prescriptionDetailApis.getRegisterRee({
  245. data: {
  246. jwHospital: jwHospital,
  247. jwDoctorCode: jwDoctorCode
  248. }
  249. }),
  250. prescriptionDetailApis.isAuthentication({}),
  251. prescriptionDetailApis.getReasonByType({
  252. data: {
  253. type: '0'
  254. }
  255. })
  256. ])
  257. }
  258. })