123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427 |
- var self,
- pro_id,
- followupClass,
- patientCode,
- fv_id;
- mui.plusReady(function() {
- self = plus.webview.currentWebview();
- fv_id = self.followup_id;//编号
- pro_id = self.project_id;//项目顺序 6
- patientCode = self.patientCode;
- followupClass = self.followupClass;//高糖类型
- //获取用药信息
- plus.nativeUI.showWaiting();
- sendGet("/doctor/followup/getFollowupProjectData", {id: fv_id,followupProject: pro_id},function(){
- plus.nativeUI.closeWaiting()
- mui.toast("请求失败")
- },function(res){
- plus.nativeUI.closeWaiting()
- if(res.status == 200){
- if(res.data){
- regular = res.data.DRUG_COMPLIANCE_CODE
- var typeObj = {1:'规律服药', 2:'间断服药', 3:'不服药'};
- $('#compliance_code').val(typeObj[regular])
- $('#compliance_code').attr('data-id',regular)
- nextSendQuery(false)
- }else{
- nextSendQuery(true)
- }
- }else{
- mui.toast("获取数据失败")
- }
- })
-
- function nextSendQuery(boolen){
- sendPost("doctor/followup/drugs/getFollowupDrugs",{id:fv_id}, function(){
- plus.nativeUI.closeWaiting()
- mui.toast("请求失败")
- }, function(res){
- if(res.status == 200){
- var data = res.data.DRUG_LIST,
- hasInsulin=[],
- noInsulin=[];
- if(data.length>0){
- for(var i=0;i<data.length;i++){
- if(data[i].drugsGroup == 'insulin'){//胰岛素药品
- hasInsulin.push(data[i])
- }else{
- noInsulin.push(data[i])
- }
- }
- mediTemplate(hasInsulin,1,true);
- mediTemplate(noInsulin,0,true);
- monitorNum()
- startDose();
- plus.nativeUI.closeWaiting();
- }else{
- if(boolen){//保存无药品,不再请求接口
- var params={
- type:1,
- isRenewal:2,
- recipeNo:0,
- diagnosisCode:followupClass=='1,2'?3:followupClass,
- patientCode:patientCode
- }
- sendPost("doctor/prescriptionInfo/getPrescriptionInfos",params, function(){
- plus.nativeUI.closeWaiting()
- mui.toast("请求失败")
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- if( res.data.length>0 && res.data[0].prescriptionInfo.length>0){
- var content = res.data[0].prescriptionInfo;
- var hasArr=[],
- allArr=content,
- noArr=[];
- $.map(allArr,function(o,i){
- o.drugsName = o.drugName;
- o.drugsCode = o.drugCode;
- o.frequency = o.drugRate;
- o.dose = o.physicDose;
- o.unit = o.physicDoseUnit;
- var subjectClass = o.subjectClass;
- var name = o.drugsName;
- if(subjectClass.substr(0,2)=='010' && name.indexOf('胰岛素')>0){
- hasArr.push(o)
- }else{
- noArr.push(o)
- }
- })
- mediTemplate(noArr,0,true);
- mediTemplate(hasArr,1,true);
- addMedicineUnit($('.j-selUnit'),false);
- addMedicineFreq($('.j-selFreq'),false);
- monitorNum()
- startDose();
- }else{
- mediTemplate([],true);
- startDose();
- }
- }else{
- mui.toast("获取数据失败")
- }
- },'get')
- }else{
- mediTemplate([],true);
- startDose();
- }
- }
- }else{
- mui.toast("获取数据失败")
- }
- },'get')
- }
-
- function mediTemplate(arr,num,state){
- var medi_html = template('medi_tmp',{data:$.map(arr,function(o,index){
- o.jsonVal = JSON.stringify(o);
- return o })
- })
- if(num>=0){
- if(state){
- $(".j-showList").eq(num).html(medi_html);
- }else{
- $(".j-showList").eq(num).append(medi_html);
- }
- }else{
- if(state){
- $(".j-showList").html(medi_html);
- }else{
- $(".j-showList").append(medi_html);
- }
- }
- }
-
- function startDose(){
- $('#mainContain').show()
- //填充服药依从性的下拉内容
- var type_keys = ['1','2','3'],
- type_vals = ['规律服药','间断服药','不服药'];
- $('#compliance_code').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- customWheels: true,
- wheels: [
- [{
- keys: type_keys,
- values: type_vals
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- $(this).val(dd[0].values);
- $(this).attr('data-id',dd[0].keys);
- }
- });
- bindEvents();
- addMedicineUnit($('.j-selUnit'),false);
- addMedicineFreq($('.j-selFreq'),false);
- //添加药品
- window.addEventListener("addMedicine", function(){
- var content = JSON.parse(plus.storage.getItem("chooseMedicineList"));
- var type = plus.storage.getItem("medicineType")*1
- var arr=[];
- arr.push(content)
- $.map(arr,function(o,i){
- o.drugsName = o.drugName;
- o.drugsCode = o.drugCode;
- return o
- })
- mediTemplate(arr,type,false);
- addMedicineUnit($(".j-showList").eq(type).find('.j-selUnit:last'),true)
- addMedicineFreq($(".j-showList").eq(type).find('.j-selFreq:last'),true)
- monitorNum()
- plus.storage.removeItem("chooseMedicineList")
- plus.storage.removeItem("medicineType")
- })
- //模板添加药品
- window.addEventListener("addMediMsg", function(){
- var content = JSON.parse(plus.storage.getItem("medicineData"));
- var hasArr=[],
- allArr=content,
- noArr=[];
- $.map(allArr,function(o,i){
- o.drugsName = o.drugName;
- o.drugsCode = o.drugCode;
- o.frequency = o.drugRate;
- o.dose = o.physicDose;
- o.unit = o.physicDoseUnit;
- var subjectClass = o.subjectClass;
- var name = o.drugsName;
- if(subjectClass.substr(0,2)=='010' && name.indexOf('胰岛素')>0){
- hasArr.push(o)
- }else{
- noArr.push(o)
- }
- })
- mediTemplate(noArr,0,true);
- mediTemplate(hasArr,1,true);
- monitorNum()
- addMedicineUnit($('.j-selUnit'),false);
- addMedicineFreq($('.j-selFreq'),false);
- plus.storage.removeItem("medicineData")
- })
- }
- })
- function bindEvents(){
- //删除
- $("#mainContain").on('click','.j-delete',function(){
- var $this = $(this).closest('.cc-ul');
- $this.remove();
- monitorNum()
- })
- //添加药品
- $('.cc-add-drug').click(function(){
- mui.openWindow({
- id: "add_drug",
- url: "add_drug.html",
- extras: {
- classes:$(this).attr('data-id')
- }
- })
- })
- //清空药品
- $('.j-clean').click(function(){
- $(this).closest('.dr-section').find('.j-showList').empty()
- monitorNum()
- })
- //提交
- $('#confirm').click(function(e){
- e.stopPropagation();
- if(checkOk()){
- plus.nativeUI.showWaiting();
- var msgArr = [],
- $list = $('.j-showList').eq(1).find('.cc-ul'),//有胰岛素
- $nolist = $('.j-showList').eq(0).find('.cc-ul');//无胰岛素
- for(var i=0;i<$list.length;i++){
- var data = {};
- data.drugsCode = $list.eq(i).find('.j-medi-name').attr('data-id');
- data.drugsName = $list.eq(i).find('.j-medi-name').val();
- data.drugsGroup = 'insulin';
- data.frequency = $list.eq(i).find('.j-selFreq').attr('data-code');
- data.unit = $list.eq(i).find('.j-selUnit').attr('data-code');
- data.dose = $list.eq(i).find('.j-medi-single').val().trim();
- msgArr.push(data);
- }
- for(var i=0;i<$nolist.length;i++){
- var data = {};
- data.drugsCode = $nolist.eq(i).find('.j-medi-name').attr('data-id');
- data.drugsName = $nolist.eq(i).find('.j-medi-name').val();
- data.drugsGroup = 'normal';
- data.frequency = $nolist.eq(i).find('.j-selFreq').attr('data-code');
- data.unit = $nolist.eq(i).find('.j-selUnit').attr('data-code');
- data.dose = $nolist.eq(i).find('.j-medi-single').val().trim();
- msgArr.push(data);
- }
- sendPost("doctor/followup/drugs/saveFollowupDrugs",{drugsData:JSON.stringify(msgArr),id:fv_id}, function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- if(res.status == 200){
- var params = {};
- params.id = fv_id;
- params.followupProject = pro_id;
- var data = {'DRUG_COMPLIANCE_CODE':$("#compliance_code").attr("data-id")};
- params.followupProjectData = JSON.stringify(data);
- sendPost('doctor/followup/saveFollowupProjectData',params,function(){
- plus.nativeUI.closeWaiting();
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- mui.toast("保存成功");
- var preWebview = plus.webview.getWebviewById('fvDetail'),
- curWebview = plus.webview.currentWebview();
- mui.fire(preWebview,"refresh");
- setTimeout(function(){
- curWebview.close();
- },1000)
- }else{
- mui.toast("保存失败");
- }
- })
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast("保存失败");
- }
- })
- }
- })
-
- // $("#mainContain").on("change",".j-medi-single",function(){
- // var $val = $(this).val().trim()
- // var reg = /^[0-9]+(.[0-9]{1,5})?$/;
- // if($val && reg.test($val)){
- //
- // }else{
- // $(this).val('')
- // }
- // })
- //居民用药记录
- $('.dr-getmsg').click(function(){
- mui.openWindow({
- id: "history_medication",
- url: "history_medication.html",
- extras: {
- patientCode:patientCode,
- followupClass:followupClass
- }
- })
- })
- }
-
- //用药频率
- function addMedicineFreq($id,newADD){
- for(i=0; i<$id.length; i++){
- var html = '<option disabled selected></option>';
- //取频率code
- if(newADD){
- var obj = JSON.parse($id.closest('.j-showList').find('.cc-ul:last').attr('data-info'));
- }else{
- var obj = JSON.parse($id.closest('.j-showList').find('.cc-ul').eq(i).attr('data-info'));
- }
- var code = obj.frequency
- for(var key in recipe_frequency_dict){
- if(key == code){
- html += '<option selected value="'+key+'">'+recipe_frequency_dict[key]+'</option>';
- }else{
- html += '<option value="'+key+'">'+recipe_frequency_dict[key]+'</option>';
- }
- }
- $id.eq(i).html(html);
- $id.eq(i).mobiscroll().select({
- theme: 'ios',
- lang: 'zh',
- display: 'bottom',
- placeholder:'请选择用药频次',
- rows:7,
- onSelect: function ( valueText, inst) {
- $(this).closest('.j-selFreq').attr('data-code',inst._tempValue);
- $(this).closest('.j-selFreq').attr('data-name',valueText);
- }
- })
- }
- }
- //用药单位
- function addMedicineUnit($id,newADD){
- for(i=0; i<$id.length; i++){
- var html = '<option disabled selected></option>';
- //取频率code
- if(newADD){
- var obj = JSON.parse($id.closest('.j-showList').find('.cc-ul:last').attr('data-info'));
- }else{
- var obj = JSON.parse($id.closest('.j-showList').find('.cc-ul').eq(i).attr('data-info'));
- }
- var code = obj.unit
- for(var key in measure_unit_dict){
- if(key == code){
- html += '<option selected value="'+key+'">'+measure_unit_dict[key]+'</option>';
- }else{
- html += '<option value="'+key+'">'+measure_unit_dict[key]+'</option>';
- }
- }
- $id.eq(i).html(html);
- $id.eq(i).mobiscroll().select({
- theme: 'ios',
- lang: 'zh',
- display: 'bottom',
- placeholder:'请选择单位',
- rows:7,
- onSelect: function ( valueText, inst) {
- $(this).closest('.j-selUnit').attr('data-code',inst._tempValue);
- $(this).closest('.j-selUnit').attr('data-name',valueText);
- }
- })
- }
- }
- //监测药品数量
- function monitorNum(){
- if($('.dr-section').eq(0).find('.j-showList .cc-ul').length >=6){
- $('.dr-section').eq(0).find('.dr-add').hide();
- }else{
- $('.dr-section').eq(0).find('.dr-add').show();
- }
- if($('.dr-section').eq(1).find('.j-showList .cc-ul').length >=3){
- $('.dr-section').eq(1).find('.dr-add').hide();
- }else{
- $('.dr-section').eq(1).find('.dr-add').show();
- }
- }
- //检查完整
- function checkOk(){
- var num = $('.cc-ul').length
- var selected = $('#compliance_code').attr('data-id')
- if(selected!=""){
- if(num>0){
- for(var i=0;i<num;i++){
- var $this = $('.cc-ul').eq(i);
- if($this.find('.j-medi-single').val() && $this.find('.j-selUnit').attr('data-code') && $this.find('.j-selFreq').attr('data-code')){
- if(i==(num-1)){
- //检测重复
- var arr=[]
- for(var j=0;j<num;j++){
- arr.push($('.cc-ul').eq(j).find('.j-medi-name').attr('data-id'));
- }
- var newArr = _.uniq(arr)
- if(newArr.length == arr.length){
- return true
- }else{
- mui.toast('药品出现重复')
- return false
- }
- }
- }else{
- mui.toast('请完善药品信息')
- return false
- }
- }
- }else{
- // mui.toast('请添加药品')
- return true
- }
- }else{
- mui.toast('请选择服药依从性')
- return false
- }
- }
|