var request = getRequest(),
    code = request.code,
    patient = request.patient,
    fv_id = request.fv_id; //记录从随访跳转过来的数据
  
var info; //保存处方信息

$(function(){
    if(fv_id){
        $("#fvBtn").show();
    }
    var params = {
        code: code,
        patient: patient
    }
    jwPrescriptionAPI.getJwPrescriptionInfo({data: params}).then(function(res){
        if(res.status == 200){
            info = res.data;
            var html = template('tmp', res.data);
            $("#main").empty().append(html);
        }else{

        }
    });

    $("#backBtn").on('click', function(){
        history.go(-1);
    });
    
    $("#fvBtn").on('click', function(){
        //保存处方的药品信息
        var drugs = info.prescriptionInfo;
        window.sessionStorage.setItem("chooseDrugs", JSON.stringify(drugs));
        //触发填充药品信息
        top.fillChooseDrugs();
        //关闭当前的layer弹框
        setTimeout(function(){
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);
        }, 300);
    })
});