I have a legacy system I'm working on and there is a particular relationship I'm having trouble with.
The issue is that I need to relate Patient to HL7EPICareMeds... the relationship above isn't working, of course.
From the table perspective, here is what I have
Patient:
PatientId : int, PK
ClinicPatientId : varchar --- not unique
HL7EPICareMeds:
Id: : int, PK
ClinicPatientId : varchar
MedName: varchar
AdminTime : datetime
Should I reuse the Patient table as an association table between ClinicPatientIDs and PatientId?
[ActiveRecord]
public class Patient : RecordBase<Patient>
{
[PrimaryKey("PatientId", Generator=PrimaryKeyType.Native)]
public int? Id
{
get { return _id; }
set
{
_id = value;
}
}
[HasAndBelongsToMany(Inverse = true, Lazy = true)]
public IList<HL7EPICareMeds> Meds
{
get { return _meds; }
set { _meds = value; }
}
}
[ActiveRecord]
public class HL7EPICareMeds : RecordBase<HL7EPICareMeds>
{
[PrimaryKey(Generator = PrimaryKeyType.Native)]
public long Id
{
get { return _Id; }
set
{
_Id = value;
}
}
[Property("AdminTime")]
public DateTime? AdministrationTime
{
get { return _AdministrationTime; }
set { _AdministrationTime = value; }
}
[Property(NotNull = true,Update=false,Insert=false),
ValidateLength(0, 20)]
public string ClinicPatientId
{
get { return _ClinicPatientId; }
set
{
_ClinicPatientId = value;
}
}
[Property(NotNull = true),
ValidateLength(0, 255)]
public string MedName
{
get { return _MedName; }
set
{
_MedName = value;
}
}
[HasAndBelongsToMany()]
public Patient Patient
{
get { return _patient; }
set { _patient = value; }
}
}