define([
    'Global',
    'PatientContext',
    'Patient',
    'Text!../html/templates/patient-simple-details.html'
],
    function (Global, PatientContext, Patient, template) {
        'use strict';
        var singleInstance,
            PatientSimpleDetailsView = Backbone.View.extend({
                attributes:{
                    "id": "patient-simple-details",
	                "class": "patient-simple-details"
                },
                initialize: function () {
                    this.template = _.template(template);
                },
                render: function(model) {
                    var $container = getSubHeaderRight();

                    PatientSimpleDetailsView.remove();

                    if (model) {
	                    $container
		                    .addClass('patient-simple-details')
		                    .append(this.$el.html(this.template(model.toJSON())));
                    }
                    $container.trigger("create");
                    return this;
                }
            });

        PatientSimpleDetailsView.instance = function() {
            if (typeof singleInstance === "undefined") {
                singleInstance = new PatientSimpleDetailsView();
            }
            return singleInstance;
        };

        PatientSimpleDetailsView.clearInstance = function() {
            singleInstance = undefined;
        };

        PatientSimpleDetailsView.remove = function(){
            if(singleInstance){
                singleInstance.remove();

	            getSubHeaderRight().removeClass('patient-simple-details');
            }
        };

        return PatientSimpleDetailsView;
    }
);
