change-chufang2.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. var self,
  2. methodDire,//用药字典
  3. medicineFreqData,//用药频率数据
  4. prescriptionCode,//续方code
  5. diagnosis=[],//疾病
  6. isChangeDiagnosis = 0,//判断是否改变疾病类型
  7. usefulMsg,
  8. usageDropDown;
  9. mui.plusReady(function() {
  10. self = plus.webview.currentWebview();
  11. usefulMsg = self.jsonStr;
  12. prescriptionCode = usefulMsg.prescriptionCode;//保存续方code
  13. var medi_html = template('medi_tmp',{data:$.map(usefulMsg.prescriptionInfo,function(o,index){
  14. o.jsonVal = JSON.stringify(o);
  15. return o })
  16. })
  17. $("#mainContain").html(medi_html);
  18. startDose();
  19. //展示诊断类型
  20. var diaArr=[]
  21. $.map(usefulMsg.diagnosis,function(item,index){
  22. diaArr.push(item.name)
  23. })
  24. $('#j-sick-choose').html(diaArr.join(','))
  25. function startDose(){
  26. //获取用药频率
  27. sendPost("doctor/prescriptionInfo/getRateList",{}, function(){
  28. mui.toast("获取用药频率数据失败");
  29. }, function(res){
  30. if(res.status == 200){
  31. medicineFreqData = res.data;
  32. addMedicineFreq($('.j-selFreq'),false)
  33. }
  34. },'get')
  35. //获取药品用法
  36. sendPost("doctor/prescriptionInfo/getUsageDict",{}, function(){
  37. mui.toast("获取药品用法数据失败");
  38. }, function(res){
  39. if(res.status == 200){
  40. methodDire = res.data;
  41. addUsage($(".j-method"), false);
  42. }
  43. },'get')
  44. //调整原因
  45. sendPost("doctor/prescriptionInfo/getReasonByType",{type:1}, function(){
  46. mui.toast("请求失败");
  47. }, function(res){
  48. if(res.status = 200){
  49. var str=""
  50. $.map(res.data,function(o,i){
  51. str += '<li data-code="'+o.code+'">'+o.value+'</li>'
  52. })
  53. $('.nopass-list').html(str)
  54. }
  55. },'get')
  56. bindEvents();
  57. addMedicineDate($('.j-selDate'),false)
  58. //添加药品
  59. window.addEventListener("addMedicine", function(){
  60. var content = JSON.parse(plus.storage.getItem("chooseMedicineList"));
  61. var arr=[];
  62. //判断是否重复
  63. var again=false;
  64. for(var i=0;i<$('.j-medi-name').length;i++){
  65. if($('.j-medi-name').eq(i).attr('data-id') == content.drugCode){
  66. again = true;
  67. }
  68. }
  69. if(again){
  70. mui.toast('重复添加药品')
  71. }else{
  72. arr.push(content);
  73. var medi_html = template('medi_tmp',{data:$.map(arr,function(o,index){
  74. o.jsonVal = JSON.stringify(o);
  75. return o })
  76. })
  77. $("#mainContain").append(medi_html);
  78. addMedicineFreq($('.j-selFreq:last'),true)
  79. addMedicineDate($('.j-selDate:last'),true)
  80. addUsage($(".j-method:last"), true);
  81. }
  82. plus.storage.removeItem("chooseMedicineList")
  83. })
  84. //修改诊断
  85. window.addEventListener("reviseDiagnosis", function(){
  86. var content = JSON.parse(plus.storage.getItem("reviseDiagnosis"));
  87. diagnosis = content;
  88. isChangeDiagnosis = 1;
  89. var diaArr=[]
  90. $.map(content,function(item,index){
  91. diaArr.push(item.name)
  92. })
  93. $('#j-sick-choose').html(diaArr.join(','))
  94. plus.storage.removeItem("reviseDiagnosis")
  95. })
  96. //采用模板
  97. window.addEventListener("chooseTemplate", function(){
  98. var content = JSON.parse(plus.storage.getItem("chooseTemplate"));
  99. content.prescriptionInfo = _.uniq(content.prescriptionInfo)//去重
  100. plus.nativeUI.showWaiting();
  101. //整理药品的数据
  102. var countNum = 1;
  103. var newData=[];
  104. var noDrugInfo = [];
  105. $.map(content.prescriptionInfo,function(o,index){
  106. toMediMsg(o.drugCode,function(msg){
  107. if(msg){ // 存在模板中药品不存在的情况,如果药品不存在则不显示该药品信息
  108. o.subjectClass = msg.subjectClass;
  109. o.storageConditions = msg.storageConditions;
  110. o.physicAmount = '';
  111. o.physicAmountUnit = msg.packUnit;
  112. o.physicAmountUnitName = msg.packUnitName;
  113. o.jsonVal = JSON.stringify(o);
  114. newData.push(o);
  115. }else{
  116. noDrugInfo.push(o);
  117. }
  118. })
  119. })
  120. setTimeout(function(){
  121. var medi_html = template('medi_tmp',{data:newData})
  122. $("#mainContain").empty().append(medi_html);
  123. addMedicineFreq($('.j-selFreq'),false)
  124. addMedicineDate($('.j-selDate'),false)
  125. addUsage($('.j-method'), false)
  126. plus.storage.removeItem("chooseTemplate");
  127. //弹框提示用户有些药品已经不存在
  128. if(noDrugInfo.length > 0){
  129. var content = "<div class='scroll-drug-div'>以下药品无法查到使用指导,请手动选择填写:<br/>";
  130. for(i=0; i<noDrugInfo.length; i++){
  131. var item = noDrugInfo[i];
  132. if(i == noDrugInfo.length-1){
  133. content += "<span class='mr15 c-bold'>"+item.drugName+"</span>"+item.drugFormat;
  134. }else{
  135. content += "<span class='mr15 c-bold'>"+item.drugName+"</span>"+item.drugFormat+"</br>";
  136. }
  137. }
  138. content += "</div>"
  139. dialog({
  140. content: content,
  141. okValue: "我知道了",
  142. ok: function(){}
  143. }).showModal();
  144. }
  145. plus.nativeUI.closeWaiting();
  146. }, 300)
  147. })
  148. }
  149. })
  150. function bindEvents(){
  151. var $text_count = $("#text_count");
  152. //文本框
  153. $("textarea").on('keyup', function(){
  154. var count = $(this).val().length;
  155. $text_count.text(count);
  156. })
  157. $("textarea").on('change', function(){
  158. var count = $(this).val().length;
  159. $text_count.text(count);
  160. })
  161. //调整原因
  162. $('.nopass-list').on('click','li',function(){
  163. var $this = $(this)
  164. if($this.hasClass('active')){
  165. $this.removeClass('active')
  166. }else{
  167. $this.addClass('active')
  168. }
  169. fillWord()
  170. })
  171. function fillWord(){
  172. var str=''
  173. $.map($('.nopass-list li.active'),function(o,i){
  174. str += $('.nopass-list li.active').eq(i).text()+',';
  175. })
  176. $('textarea').val(str.substr(0,str.length-1))
  177. $text_count.text(str.length-1);
  178. }
  179. //增减
  180. $("#mainContain").on('click','.add-icon',function(){
  181. var $this = $(this)
  182. var $val = $this.siblings('.j-medi-single').val().trim()
  183. $this.siblings('.j-medi-single').val($val*1+0.25)
  184. countMediSum($(this).closest('.cc-ul'))
  185. })
  186. $("#mainContain").on('click','.desc-icon',function(){
  187. var $this = $(this)
  188. var $val = $this.siblings('.j-medi-single').val().trim()
  189. var num = $val*1-0.25
  190. if(num>=0){
  191. $this.siblings('.j-medi-single').val($val*1-0.25)
  192. }else{
  193. $this.siblings('.j-medi-single').val(0)
  194. }
  195. countMediSum($(this).closest('.cc-ul'))
  196. })
  197. //用法选择
  198. // $("#mainContain").on('click','.j-method',function(){
  199. // var $this = $(this)
  200. // var num = $this.closest('.cc-ul').index()
  201. // add_selected_fun(methodDire,$('.j-method').eq(num),'name','code')
  202. //
  203. // })
  204. //删除
  205. $("#medicineType").on('click','.j-delete',function(){
  206. var $this = $(this).closest('.cc-ul');
  207. $this.remove();
  208. })
  209. //添加药品
  210. $('.cc-add-drug').click(function(){
  211. mui.openWindow({
  212. id: "yaopinsousuo",
  213. url: "yaopinsousuo.html",
  214. extras: {
  215. }
  216. })
  217. })
  218. //选择模板
  219. $('.cc-link').click(function(){
  220. mui.openWindow({
  221. id: "chufangmuban",
  222. url: "chufangmuban.html",
  223. extras: {
  224. }
  225. })
  226. })
  227. //修改疾病类型
  228. $('#j-sick-choose').click(function(){
  229. mui.openWindow({
  230. id: "linchuangzhenduan",
  231. url: "linchuangzhenduan.html",
  232. extras: {
  233. diagnosis:isChangeDiagnosis?diagnosis:usefulMsg.diagnosis
  234. }
  235. })
  236. })
  237. //提交
  238. $('#confirm').click(function(){
  239. var $sum = $(".j-sumMedicine");
  240. if($sum.length > 0){
  241. for(var i=0;i<$sum.length;i++){
  242. if(! $sum.eq(i).attr('data-num')){
  243. mui.toast('请完善药品信息')
  244. return
  245. }
  246. }
  247. }else{
  248. mui.toast('请添加药品')
  249. return
  250. }
  251. plus.nativeUI.showWaiting();
  252. var msgArr = [],
  253. $ul = $('.cc-ul');
  254. for(var i=0;i<$ul.length;i++){
  255. var data = {};
  256. var saveData = JSON.parse($ul.eq(i).attr('data-info'));
  257. data.prescriptionCode = prescriptionCode;
  258. data.drugCode = saveData.drugCode;
  259. data.drugName = $ul.eq(i).find('.j-medi-name').val().replace(/\(/,'(').replace(/\)/,')');
  260. data.drugRate = $ul.eq(i).find('.j-selFreq').attr('data-code');
  261. data.drugRateName = $ul.eq(i).find('.j-selFreq').attr('data-name');
  262. data.drugFormat=saveData.drugFormat.replace(/\(/,'(').replace(/\)/,')');
  263. data.subjectClass = $ul.eq(i).find('.j-medi-name').attr('data-class');
  264. data.isRefrigerate = $ul.eq(i).find('.j-medi-name').attr('data-storage')==2?1:0;
  265. data.physicAmount = "";
  266. data.physicAmountUnit = saveData.physicAmountUnit;
  267. data.physicAmountUnitName = saveData.physicAmountUnitName;
  268. data.physicDose = $ul.eq(i).find('.j-medi-single').val().trim();
  269. data.physicDoseUnit = $ul.eq(i).find('.j-medi-unit').attr('data-unit');
  270. data.physicDoseUnitName = $ul.eq(i).find('.j-medi-unit').text();
  271. data.drugNumUnit = $ul.eq(i).find('.j-sumMedicine').attr('data-unit');//取当次用量单位
  272. data.drugNumUnitName = $ul.eq(i).find('.j-sumMedicine').attr('data-name');
  273. data.drugUsage= $ul.eq(i).find('.j-method').attr('data-id');
  274. data.usageName= $ul.eq(i).find('.j-method').attr('data-name');
  275. data.num= $ul.eq(i).find(".j-sumMedicine").attr('data-num');//取总量
  276. data.dayCount=$ul.eq(i).find('.j-selDate').attr('data-id');
  277. msgArr.push(data);
  278. }
  279. //调整CODE
  280. var reasonCode=[];
  281. $.map($('.nopass-list li.active'),function(o,i){
  282. reasonCode.push($('.nopass-list li.active').eq(i).attr('data-code'))
  283. })
  284. var params= {
  285. code:prescriptionCode,
  286. infos:JSON.stringify(msgArr),
  287. reason:$('textarea').val().trim()?$('textarea').val().trim():'-',
  288. reasonCode:reasonCode.join(','),
  289. diagnosis:isChangeDiagnosis?JSON.stringify(diagnosis):''
  290. }
  291. sendPost("doctor/prescriptionInfo/updatePresInfo",params, function(){
  292. plus.nativeUI.closeWaiting();
  293. mui.toast("保存失败");
  294. }, function(res){
  295. if(res.status == 200){
  296. mui.toast("保存成功");
  297. refreshHz();
  298. setTimeout(function(){
  299. mui.back()
  300. },1000)
  301. }else{
  302. plus.nativeUI.closeWaiting();
  303. mui.toast("保存失败");
  304. }
  305. })
  306. })
  307. //填写药品
  308. $("#mainContain").on("blur",".j-medi-name",function(){
  309. countMediSum($(this).closest('.cc-ul'))
  310. })
  311. //填写次剂量
  312. $("#mainContain").on("blur",".j-medi-single",function(){
  313. countMediSum($(this).closest('.cc-ul'))
  314. })
  315. $("#mainContain").on("change",".j-medi-single",function(){
  316. var $val = $(this).val().trim()
  317. var reg = /^[0-9]+(.[0-9]{1,5})?$/;
  318. if($val && reg.test($val)){
  319. }else{
  320. $(this).val('')
  321. }
  322. })
  323. //刷新页面
  324. function refreshHz(){
  325. var page3 = plus.webview.getWebviewById("xufangxiangqing");
  326. if(page3){
  327. mui.fire(page3, "refreshXufang");
  328. }
  329. var page4 = plus.webview.getWebviewById("juminxufangxiangqing");
  330. if(page4){
  331. mui.fire(page4, "refreshXufang");
  332. }
  333. var page = plus.webview.getWebviewById("xufangguanli");
  334. if(page){
  335. mui.fire(page, "refreshXufang");
  336. }
  337. var page1 = plus.webview.getWebviewById("juminxufangjilu");
  338. if(page1){
  339. mui.fire(page1, "refreshXufang");
  340. }
  341. }
  342. }
  343. //获取频率换算
  344. function toFreqRate(code,fun){
  345. var data={
  346. code:code
  347. }
  348. sendPost("doctor/prescriptionInfo/drugToRate",data, function(){
  349. plus.nativeUI.closeWaiting();
  350. mui.toast("获取用药频率数据失败");
  351. }, function(res){
  352. if(res.status == 200){
  353. fun&&fun.call(this,res.data.rate)
  354. }
  355. },'get')
  356. }
  357. //获取药品信息
  358. function toMediMsg(code,fun){
  359. var data={
  360. code:code
  361. }
  362. sendPost("doctor/prescriptionInfo/getPhysicInfo",data, function(){
  363. mui.toast("获取药品信息失败");
  364. }, function(res){
  365. if(res.status == 200){
  366. fun&&fun.call(this,res.data[0])
  367. }
  368. },'get')
  369. }
  370. //用药频率
  371. function addMedicineFreq($id,newADD){
  372. for(i=0; i<$id.length; i++){
  373. var html = '<option disabled selected></option>';
  374. //取频率code
  375. if(newADD){
  376. var obj = JSON.parse($('.cc-ul:last').attr('data-info'));
  377. }else{
  378. var obj = JSON.parse($('.cc-ul').eq(i).attr('data-info'));
  379. }
  380. var code = obj.drugRate
  381. for(j=0;j<medicineFreqData.length;j++){
  382. if(medicineFreqData[j].code == code){
  383. html += '<option selected value="'+medicineFreqData[j].code+'">'+medicineFreqData[j].name+'</option>';
  384. }else{
  385. html += '<option value="'+medicineFreqData[j].code+'">'+medicineFreqData[j].name+'</option>';
  386. }
  387. }
  388. $id.eq(i).html(html);
  389. $id.eq(i).mobiscroll().select({
  390. theme: 'ios',
  391. lang: 'zh',
  392. display: 'bottom',
  393. placeholder:'请选择用药频次',
  394. rows:7,
  395. onSelect: function ( valueText, inst) {
  396. var selectedData = {};
  397. $.map(medicineFreqData,function(item,index){
  398. if(item.name == valueText){
  399. selectedData = item;
  400. return;
  401. }
  402. })
  403. $(this).closest('.j-selFreq').attr('data-code',selectedData.code);
  404. $(this).closest('.j-selFreq').attr('data-name',selectedData.name);
  405. countMediSum($(this).closest('.cc-ul'))
  406. }
  407. })
  408. }
  409. }
  410. //用药天数
  411. function addMedicineDate($id,newADD){
  412. for(i=0; i<$id.length; i++){
  413. var html = '<option disabled selected></option>'
  414. //取天数
  415. if(newADD){
  416. var obj = JSON.parse($('.cc-ul:last').attr('data-info'));
  417. }else{
  418. var obj = JSON.parse($('.cc-ul').eq(i).attr('data-info'));
  419. }
  420. var num = obj.dayCount;
  421. for(j=1;j<31;j++){
  422. if(num == j){
  423. html += '<option selected value="'+j+'">'+j+'</option>';
  424. }else{
  425. html += '<option value="'+j+'">'+j+'</option>';
  426. }
  427. }
  428. $id.eq(i).html(html);
  429. $id.eq(i).mobiscroll().select({
  430. theme: 'ios',
  431. lang: 'zh',
  432. display: 'bottom',
  433. placeholder:'请选择用药天数',
  434. rows:7,
  435. onSelect: function ( valueText, inst) {
  436. $(this).closest('.j-selDate').attr('data-id',valueText);
  437. countMediSum($(this).closest('.cc-ul'))
  438. }
  439. })
  440. }
  441. }
  442. //用药方式
  443. function addUsage($id,newADD){
  444. for(i=0; i<$id.length; i++){
  445. var html = '<option disabled selected></option>'
  446. //取天数
  447. if(newADD){
  448. var obj = JSON.parse($('.cc-ul:last').attr('data-info'));
  449. }else{
  450. var obj = JSON.parse($('.cc-ul').eq(i).attr('data-info'));
  451. }
  452. var code = obj.drugUsage;
  453. for(j=0;j<methodDire.length;j++){
  454. if(code == methodDire[j].code){
  455. html += '<option selected value="'+methodDire[j].code+'">'+methodDire[j].name+'</option>';
  456. }else{
  457. html += '<option value="'+methodDire[j].code+'">'+methodDire[j].name+'</option>';
  458. }
  459. }
  460. $id.eq(i).html(html);
  461. $id.eq(i).mobiscroll().select({
  462. theme: 'ios',
  463. lang: 'zh',
  464. display: 'bottom',
  465. placeholder:'请选择药品用法',
  466. rows:7,
  467. onSelect: function ( valueText, inst) {
  468. var selectedData = {};
  469. $.map(methodDire,function(item,index){
  470. if(item.name == valueText){
  471. selectedData = item;
  472. return;
  473. }
  474. })
  475. $(this).closest('.j-method').attr('data-id',selectedData.code);
  476. $(this).closest('.j-method').attr('data-name',selectedData.name);
  477. // countMediSum($(this).closest('.cc-ul'))
  478. }
  479. })
  480. }
  481. }
  482. //计算药品总量
  483. function countMediSum($ul){
  484. $ul.find(".j-sumMedicine").html("")//清空
  485. $ul.find(".j-sumMedicine").attr('data-num','')//清空
  486. var $name = $ul.find(".j-medi-name").val().trim(),
  487. $single = $ul.find(".j-medi-single").val().trim(),
  488. $freq = $ul.find(".j-selFreq").attr('data-code'),
  489. $date = $ul.find(".j-selDate").attr('data-id'),
  490. $info = JSON.parse($ul.attr('data-info')),
  491. dispPackUntuckFlag = $info.dispPackUntuckFlag, //门诊包装可拆标志 0不可拆,1可拆
  492. dispQuantityUntuckFlag = $info.dispQuantityUntuckFlag, //门诊数量可拆标志 0不可拆,1可拆
  493. drugNumUnit = $info.drugNumUnit,
  494. physicDoseUnit = $info.physicDoseUnit;
  495. if($name && $single && $freq && $date){
  496. toFreqRate($freq,function(rate){
  497. var num = $single*rate*$date
  498. num = Math.round(num*100)/100
  499. var sum="";
  500. if($info.pakeSpec){
  501. //新增药品
  502. // sum = Math.ceil(num/$info.minDose)
  503. // showResultSum(sum);
  504. if(!dispPackUntuckFlag && !dispQuantityUntuckFlag){
  505. sum = Math.ceil((Math.ceil($single / $info.minDose) * rate * $date)/$info.pakeSpec)
  506. $ul.find(".j-sumMedicine").html(sum + $info.packUnitName); //显示的是包装单位
  507. $ul.find(".j-sumMedicine").attr('data-num', sum * $info.pakeSpec);
  508. $ul.find(".j-sumMedicine").attr('data-name', $info.drugNumUnitName);
  509. $ul.find(".j-sumMedicine").attr('data-unit', $info.drugNumUnit);
  510. }else{
  511. if(dispQuantityUntuckFlag){
  512. //ceil(剂量数量*频次*天数/最小剂量)
  513. sum = Math.ceil(num / $info.minDose);
  514. if(dispPackUntuckFlag){
  515. $ul.find(".j-sumMedicine").html(sum + $info.drugNumUnitName);
  516. $ul.find(".j-sumMedicine").attr('data-num',sum);
  517. $ul.find(".j-sumMedicine").attr('data-name',$info.drugNumUnitName);
  518. $ul.find(".j-sumMedicine").attr('data-unit',$info.drugNumUnit);
  519. }else{
  520. //不可拆包
  521. sum = Math.ceil(sum / $info.pakeSpec);
  522. $ul.find(".j-sumMedicine").html(sum + $info.packUnitName); //显示的是包装单位
  523. $ul.find(".j-sumMedicine").attr('data-num', sum * $info.pakeSpec);
  524. $ul.find(".j-sumMedicine").attr('data-name', $info.drugNumUnitName);
  525. $ul.find(".j-sumMedicine").attr('data-unit', $info.drugNumUnit);
  526. }
  527. }else if(dispPackUntuckFlag){
  528. //可拆包: 单元数量(ceil(次剂量/最小单位))*频次*天数
  529. sum = Math.ceil($single / $info.minDose) * rate * $date;
  530. $ul.find(".j-sumMedicine").html(sum + $info.drugNumUnitName);
  531. $ul.find(".j-sumMedicine").attr('data-num', sum);
  532. $ul.find(".j-sumMedicine").attr('data-name', $info.drugNumUnitName);
  533. $ul.find(".j-sumMedicine").attr('data-unit', $info.drugNumUnit);
  534. }
  535. }
  536. }else{
  537. //请求药品信息
  538. var drugCode = $info.drugCode;
  539. toMediMsg(drugCode,function(msg){
  540. $ul.find(".j-medi-name").attr('data-storage',msg.storageConditions);//冷藏
  541. $ul.find(".j-medi-name").attr('data-class',msg.subjectClass);
  542. if(!msg.dispPackUntuckFlag && !msg.dispQuantityUntuckFlag){
  543. sum = Math.ceil((Math.ceil($single / msg.minDose) * rate * $date)/msg.packSpec)
  544. $ul.find(".j-sumMedicine").html(sum + msg.packUnitName);
  545. $ul.find(".j-sumMedicine").attr('data-num', sum * msg.packSpec);
  546. $ul.find(".j-sumMedicine").attr('data-name', msg.quantityUnitName);
  547. $ul.find(".j-sumMedicine").attr('data-unit', msg.quantityUnit);
  548. }else{
  549. if(msg.dispQuantityUntuckFlag){
  550. //ceil(剂量数量*频次*天数/最小剂量)
  551. sum = Math.ceil(num / msg.minDose);
  552. if(msg.dispPackUntuckFlag){
  553. $ul.find(".j-sumMedicine").html(sum + msg.quantityUnitName);
  554. $ul.find(".j-sumMedicine").attr('data-num',sum);
  555. $ul.find(".j-sumMedicine").attr('data-name',msg.quantityUnitName);
  556. $ul.find(".j-sumMedicine").attr('data-unit',msg.quantityUnit);
  557. }else{
  558. //不可拆包
  559. sum = Math.ceil(sum / msg.packSpec);
  560. $ul.find(".j-sumMedicine").html(sum + msg.packUnitName);
  561. $ul.find(".j-sumMedicine").attr('data-num', sum * msg.packSpec);
  562. $ul.find(".j-sumMedicine").attr('data-name', msg.quantityUnitName);
  563. $ul.find(".j-sumMedicine").attr('data-unit', msg.quantityUnit);
  564. }
  565. }else if(msg.dispPackUntuckFlag){
  566. //可拆包: 单元数量(ceil(次剂量/最小单位))*频次*天数
  567. sum = Math.ceil($single / msg.minDose) * rate * $date;
  568. $ul.find(".j-sumMedicine").html(sum + msg.quantityUnitName);
  569. $ul.find(".j-sumMedicine").attr('data-num',sum);
  570. $ul.find(".j-sumMedicine").attr('data-name',msg.quantityUnitName);
  571. $ul.find(".j-sumMedicine").attr('data-unit',msg.quantityUnit);
  572. }
  573. }
  574. })
  575. }
  576. })
  577. }
  578. function showResultSum(sum, info){
  579. $ul.find(".j-sumMedicine").html(sum + info.packUnitName);
  580. $ul.find(".j-sumMedicine").attr('data-num', sum);
  581. $ul.find(".j-sumMedicine").attr('data-name', info.packUnitName);
  582. $ul.find(".j-sumMedicine").attr('data-unit', info.packUnit);
  583. }
  584. }