Data-Structures-and-Algorithms / Triage / PriorityQueue / Patient.cpp
Patient.cpp
Raw
/*  File Name: Patient.cpp
	Author: Essam Fahmy
	Date: 2023-11-01

	Patient class implementation
*/

#include "Patient.h"


using namespace std;

Patient::Patient(string name) : name_(move(name)), priorityScore_(0) {}

void Patient::add_ailment(const Ailment& ailment)
{
	ailments_.push_back(ailment);

	priorityScore_ = 0;
	for (auto* node = ailments_.begin(); node != nullptr; node = node->next)
	{
		const Ailment& ailment = node->data;
		priorityScore_ += (ailment.get_severity() * ailment.get_time_sensitivity()) + (ailment.get_contagiousness());
	}
}

LinkedList<Ailment>& Patient::get_ailments()
{
	return ailments_;
}

string Patient::get_name() const
{
	return name_;
}

int Patient::get_score() const
{
	return priorityScore_;
}

bool Patient::operator==(const Patient& other) const
{
	return name_ == other.name_;
}

Patient::Patient(const Patient& other) : name_(other.name_), priorityScore_(other.priorityScore_), ailments_(other.ailments_) {}