define([
	'Global',
    'moment'
],
	function(Global, moment) {
		var singleInstance,
			Patient = Backbone.Model.extend({
			defaults: {
                age: "",
                dateOfBirth: "",
				displayName: "",
				gender: "",
				inpatient: false,
                ssn: "",
				wardLocation: "",
				firstName:"",
				lastName:""
			},
			isValid: function() {
				var displayName = this.get('displayName');

				return typeof displayName !== 'undefined' && displayName
			},
            parse: function (response) {
                response = response || {};

                response.dateOfBirthDisplay = response.dateOfBirth ? moment(response.dateOfBirth).format("L") : "";
                response.genderChar = response.gender ? response.gender.substr(0, 1) : "";

                return response;
            }
		});

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

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

		return Patient;
	}
);