Skip to content

Instantly share code, notes, and snippets.

@Vaccano
Created July 6, 2011 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vaccano/1068068 to your computer and use it in GitHub Desktop.
Save Vaccano/1068068 to your computer and use it in GitHub Desktop.
Patient.cs
namespace PatientEntities
{
public partial class Patient
{
#region Primitive Properties
public virtual long PatientId
{
get;
set;
}
public virtual string Mrn
{
get;
set;
}
public virtual string ClientPatientIdentity
{
get;
set;
}
public virtual string FinNumber
{
get;
set;
}
public virtual long GenderId
{
get;
set;
}
public virtual string PreferredName
{
get;
set;
}
public virtual string Race
{
get;
set;
}
public virtual Nullable<long> AddressId
{
get { return _addressId; }
set
{
try
{
_settingFK = true;
if (_addressId != value)
{
if (Address != null && Address.AddressId != value)
{
Address = null;
}
_addressId = value;
}
}
finally
{
_settingFK = false;
}
}
}
private Nullable<long> _addressId;
public virtual string CountryCode
{
get;
set;
}
public virtual string HomePhone
{
get;
set;
}
public virtual string BusinessPhone
{
get;
set;
}
public virtual string Language
{
get;
set;
}
public virtual string MaritalStatus
{
get;
set;
}
public virtual string Religion
{
get;
set;
}
public virtual long InformationSourceId
{
get;
set;
}
public virtual string LastName
{
get;
set;
}
public virtual string FirstName
{
get;
set;
}
public virtual string MiddleName
{
get;
set;
}
public virtual string NamePrefix
{
get;
set;
}
public virtual string NameSuffix
{
get;
set;
}
public virtual string NameTypeCode
{
get;
set;
}
#endregion
#region Navigation Properties
public virtual Address Address
{
get { return _address; }
set
{
if (!ReferenceEquals(_address, value))
{
var previousValue = _address;
_address = value;
FixupAddress(previousValue);
}
}
}
private Address _address;
#endregion
#region Association Fixup
private bool _settingFK = false;
private void FixupAddress(Address previousValue)
{
if (previousValue != null && previousValue.Patients.Contains(this))
{
previousValue.Patients.Remove(this);
}
if (Address != null)
{
if (!Address.Patients.Contains(this))
{
Address.Patients.Add(this);
}
if (AddressId != Address.AddressId)
{
AddressId = Address.AddressId;
}
}
else if (!_settingFK)
{
AddressId = null;
}
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment