prescription-detail.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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 if(result == 2){ // 审核不通过
  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. } else {
  162. showErrorMsg("请选择审核结果")
  163. }
  164. })
  165. $('#editBtn').on('click',function() {
  166. location.href = 'prescription-adjustment.html'
  167. })
  168. $('#backBtn').on('click',function() {
  169. history.go(-1);
  170. })
  171. $('#adjustReason').on('click','li',function() {
  172. $(this).siblings().removeClass('active');
  173. $(this).addClass('active')
  174. })
  175. calcWorldWithTextarea()
  176. }
  177. function getStrOriginalData() {
  178. var imporMsg = {
  179. prescription: {}
  180. };
  181. imporMsg.prescription.jwCode = strOriginalData.prescription.jwCode;
  182. imporMsg.prescription.patientName = strOriginalData.prescription.patientName;
  183. imporMsg.prescription.doctorName = strOriginalData.prescription.doctorName;
  184. imporMsg.prescription.diagnosis = strOriginalData.diagnosis;
  185. var arr = _.map(strOriginalData.prescriptionInfo,function(item){
  186. return _.pick(item, 'drugCode','drugName','jwSubCode','physicAmount','physicAmountUnit','physicAmountUnitName');
  187. })
  188. imporMsg.prescription.prescriptionInfo = arr;
  189. return imporMsg;
  190. }
  191. function checkAgreeInputs() {
  192. var fee = $('#feeSel').val();
  193. var dept = $('#deptSel').val();
  194. var pwd = $('#reviewPassword').val();
  195. if(!fee) {
  196. showErrorMsg("请选择诊查费用")
  197. return false;
  198. } else if(!dept) {
  199. showErrorMsg("请选择开方科室")
  200. return false;
  201. } else if(!pwd) {
  202. showErrorMsg("请输入审方密码")
  203. return false;
  204. }
  205. return true;
  206. }
  207. function checkDisAgreeInputs() {
  208. var reasonType = $('#adjustReason li.active').text();
  209. var reason = $('#disagreeReason').val();
  210. if(!reasonType) {
  211. showErrorMsg("请选择不通过原因")
  212. return false;
  213. } else if(!reason) {
  214. showErrorMsg("请输入不通过原因")
  215. return false;
  216. }
  217. return true;
  218. }
  219. function getDataPromises() {
  220. return Promise.all([
  221. prescriptionDetailApis.getDeptList({
  222. data: {
  223. jwHospital: jwHospital,
  224. jwDoctorCode: jwDoctorCode
  225. }
  226. }),
  227. prescriptionDetailApis.getRegisterRee({
  228. data: {
  229. jwHospital: jwHospital,
  230. jwDoctorCode: jwDoctorCode
  231. }
  232. }),
  233. prescriptionDetailApis.isAuthentication({}),
  234. prescriptionDetailApis.getReasonByType({
  235. data: {
  236. type: '0'
  237. }
  238. })
  239. ])
  240. }
  241. })