Skip to content

Instantly share code, notes, and snippets.

@mat-mcloughlin
Last active December 18, 2016 08:36
Show Gist options
  • Save mat-mcloughlin/bdbeba60fc20ce2e08310b12ce12d355 to your computer and use it in GitHub Desktop.
Save mat-mcloughlin/bdbeba60fc20ce2e08310b12ce12d355 to your computer and use it in GitHub Desktop.
public class Encounter
{
string patientName;
DateTime birthDate;
int ageInYears;
DateTime timeOfAdmission;
WardHistory wardHistory;
bool currentlyAdmitted;
public void AdmitPatient(string patientName, DateTime birthDate, int ageInYears, DateTime timeOfAdmission, int wardNumber)
{
if (currentlyAdmitted)
{
throw new DomainException("Patient is already admitted");
}
Raise(new PatientAdmitted(patientName, birthDate, ageInYears, timeOfAdmission, wardNumber));
}
public void MarkPatientAsTreated()
{
if (!currentlyAdmitted)
{
throw new DomainException("Cannot treat a patient that is not admitted");
}
Raise(new PatientMarkedAsTreated());
}
public void TransferPatient(int toWardNumber)
{
if (!currentlyAdmitted)
{
throw new DomainException("Cannot transfer a patient that is not admitted");
}
if (wardHistory.Current.WardNumber == toWardNumber)
{
throw new DomainException("Cannot transfer a patient to the ward they are currently on");
}
Raise(new PatientTransfered(toWardNumber));
}
public void DischargePatient()
{
if (!currentlyAdmitted)
{
throw new DomainException("Cannot discharge a patient that is not admitted");
}
Raise( new PatientDischarged());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment