(function($){
    var urls = {
        url:{
            'host':"/icss-web",
            'start_drug': '/rule_controller/start_drug_title',
            'get_diagnose_extend':'/kl/diagnose/get_diagnose_extend',
            'get_by_itemidAndType': '/kl/introduce/get_by_itemidAndType'
        }
    };
    getCaseInfo();
    function getCaseInfo(){
        var host = urls.url.host;
        var url = host + urls.url.get_diagnose_extend;
        var txtUrl = host + urls.url.get_by_itemidAndType;
        var diseaseId = parseUrl().diseaseId;
        var moreUrl = "/static/pages/information.html?type=7&diseaseId=" + diseaseId;
        $("#more").attr("href",moreUrl);
        //获取诊断依据
        $.get(url,{diseaseId:diseaseId},function(data){
            if(data.status=="OK"){
                var dom = jointData(data.data);
                $(".information").html('<p class="line"></p>'+dom);
            }
        });
        //获取摘要
        $.get(txtUrl,{type:7,itemId:diseaseId},function(data){
            if(data.status=="OK"){
                $("h1").text(data.data.shortName);
                fillContext(data.data);
            }
        });
    }
    function parseUrl(){
        var r = window.location.search.substr(1).split("&"),
            obj = {};
        $.each(r, function (i, v) {
            if (v) {
                var arr = v.split("=");
                obj[arr[0]] = encodeURI(arr[1]);
            }
        });
        return obj;
    }
    function jointData(data) {
        var str = "",extend="",prefix,name,suffix;
        for(var i=0;i<data.length;i++){
            str += "<p>"+(i+1)+".";
            extend = data[i].diagnoseExtendWrapperList;
            for(var j=0;j<extend.length;j++){
                suffix = extend[j].suffix||'';
                name = extend[j].name||'';
                prefix = extend[j].prefix||'';
                str +=  prefix +  name + suffix;
            }
            str += "</p>";
        }
        return str;
    }
    function fillContext(data){
        var content = data.introduceDetailList[0];
        if(content){
            $(".context .content").html(content.description);
        }
    }
})(jQuery);