class HealthCentre(): def __init__( self, name, suburb, service_type, description, ): self._name = name self._suburb = suburb self._service_type = service_type self._description = description self._doctors = [] self._rating = Rating() def get_name(self): return self._name def get_suburb(self): return self._suburb def get_service_type(self): return self._service_type def get_description(self): return self._description def get_doctors(self): return self._doctors # draft 1 def get_average_rating(self): return self._rating.get_average() def record_rating(self, customer, score): self._rating.makeRating(customer, score) def isRated(self, customer): if self._rating.get_previous_rating(customer): return True return False def __str__(self): return 'name:' + self._name + '-suburb:' + self._suburb + '-service_type:' + self._service_type def add_doctor(self, doctor): #print(doctor) if doctor not in self._doctors: self._doctors.append(doctor)
class HealthProvider(HASUser): def __init__(self, username, password, name, profile): HASUser.__init__(self, username, password, 'health_provider', name) self._profile = profile self._healthCentre = [] self._rating = Rating() def make_appointment(self, patient, time, message): new_appointment = Appointment(patient, self, time, message) self._appointments.append(new_appointment) self._appointments.sort(key=lambda x: x.time, reverse=False) # sort appointments return new_appointment def get_avaliable_time_slot(self, date): avaliable_slots = [] for hour in range(0, 24): for minute in [00, 30]: slot = datetime.strptime( date + ' ' + str(hour) + ':' + str(minute), '%Y-%m-%d %H:%M') if slot.strftime("%Y-%m-%d %H:%M") not in [ x.time.strftime("%Y-%m-%d %H:%M") for x in self.get_appointment() ]: avaliable_slots.append(slot.strftime("%H:%M")) return avaliable_slots def get_health_centre(self): pass #todo def get_profile(self): return self._profile def get_average_rating(self): return self._rating.get_average() def record_rating(self, customer, score): self._rating.makeRating(customer, score) def isRated(self, customer): if self._rating.get_previous_rating(customer): return True return False def __str__(self): return HASUser.__str__(self) + ' ' + str(self._healthCentre)