//**************************************************************
//
// CS 240C   :Spring 2003 Ohio University Travis Dillon
// Project 2 :Emergency Room Triage
// file      :patient.cc
// started   :04-21-03
//
//**************************************************************

#include "patient.h"

Patient::Patient()
{  //c-tor , makes me the patient
   Date temp(6,17,1982);
   birth = temp;
   name = ("Travis Dillon");
   level = 1;
   carrier = ("Ohio University");
   arrival = Time();
}

Patient::Patient(const Time& time, const string& in_name,
                 const string& in_carrier)
{  //copy c-tor
   //gives random birth day
   Date temp((rand()%31 + 1), (rand()%12 + 1), (rand()%114 + 1890));
   birth = temp;
   arrival = time;  //sets time to time patient arrived
   name = in_name;  //random name sent in_name
   carrier = in_carrier;  //random carrier in_carrier
   level = ((rand() % 10) + 1);  //random level
}

ostream& operator <<(ostream& os, const Patient& rop)
{
   Time temp(rop.arrival);
   os.setf(ios::left);  //output neatly to os
   os << endl << setw(6) << rop.level << setw(22) << rop.name
      << rop.birth << "  " << setw(22) << rop.carrier << temp;
   
}

bool operator <(const Patient& p1, const Patient& p2)
{  //operator needed for priority queue
   if(p1.level < p2.level) return true;  //lower emergency levels go first
   if(p1.arrival < p2.arrival) return true;  //if same level check times
   return false;
}

Time Patient::get_arrival() const
{
   return arrival;
}

int Patient::get_level()const
{
   return level;
}