• resserone13

    @JonB I figured. I was just messing with you back hahaha. And I will to do the research. I usually learn 10 things that I wasn’t looking for before I find the one thing I was looking for and then I end up using those 10 things later...

    What I was thinking if I had a patient class and a nurse class. I would like for every time a patient is created it to be added to a nurse. Or I would like a doctors to be added to a patient depending on the illness of the patient. So each patient will have an attribute called illness and I would like the doctor class to know that illness and assign the appropriate doctor. Or If I have The start and end times of when rooms were cleaned from my room class how can I access those from the housekeeper class to use the same times for the housekeeper class. I am sure I can use in Heritance in someway but I didn’t want random things inheriting from each other.

    
    master_patient_list = []
    current_patient_list = []
    iso_patient_list = []
    
    iso_type_dict = {'covid': 'droplets', 'cdiff': 'contact', 'tuberculosis': 'airborne', 'influenza': 'droplets', 'reverse isolation': 'patient saftey'}
    
    def count_patients(list):
            return len(list)
    
    class Patient (object):
            
            def __init__(self, name='', age=None, gender= None, room_number=None, assigned_doctor=None, assigned_nurse=None, illness=None, iso_status=None, patient_record_nunber='AD000',patient_medications=[]):
                    self.name = name
                    self.age = age 
                    self.gender = gender
                    self.room_number = room_number
                    self.assigned_doctor = assigned_doctor
                    self.assigned_nurse = assigned_nurse
                    self.illness = illness
                    self.iso_status = iso_type_dict
                    self.patient_record_number = next(self.patient_id_gen())
                    self.patient_medications = list(patient_medications)
                    self.add_patient()
                                                
            def add_patient(self):
                    master_patient_list.append(self)
                    current_patient_list.append(self)
                    
                    
            def remove_patient():
                    pass
                                        
            def move_patient(self, new_room):
                    self.room_number = new_room         
                    
            def add_med(self, med):
                    if med not in self.patient_medications:
                            self.patient_medications.append(med)
                            
            def remove_med(self, med):
                    if med in self.patient_medications:
                            self.patient_medications.remove(med)    
                            
    #generates patine records numbers
            def patient_id_gen(self):
                    ''' generates patient id one at a time as patient object is created '''
                    
                    prefix = 'AD'
                    for i in range(1000,9999):
                            yield f"{prefix}{i}"
            
            def get_patient_id(self):
                    return self.patient_record_number
                                                        
            def __str__(self):
                    return f'Room: {self.room_number} \nName: {self.name} \nPhysician: {self.assigned_doctor} \nNurse: {self.assigned_nurse} \nIllness: {self.illness} \nIso status: {self.iso_status} \nPRN: {self.patient_record_number} \nMedication: {self.patient_medications}'    
                    
            def __repr__(self):
                    pass
    
    #patient info           
    patient1 = Patient()
    patient1.name = 'Sally'
    patient1.age = 35
    patient1.room_number = 430
    patient1.assigned_doctor = 'Dr. Seuss'
    patient1.assigned_nurse = 'Jessica'
    patient1.illness = 'Broken Leg'
    patient1.iso_status = 'NONE'
    patient1.add_med('norco')
    
    class Nurse ():
            
            def __init__(self, patient):
                    self.patient = Patient.self.name
                    patient_list = [self.patient]
                    patient_count = len(patient_list)
                    
            def __str__():
                    return f'{name} \n{room_number} \n{assigned_doctor}'        
    
    class Physician (Employee):
            pass
    
    
    

    posted in Pythonista read more
  • resserone13

    @JonB ok. I’ll keep researching. Thanks

    posted in Pythonista read more
  • resserone13

    Is there a way I can have an attribute from one class received the value of an attribute from another class?

    posted in Pythonista read more
  • resserone13

    @ccc your right. When I made the body of the function I was imagining 3 dials with the numbers 0 through 9 and as they rotate when first dial hit 9 the next dial would click over to 1 and the first dial change to 0. Like an odometer. I figured it out but I see now all I need is <999 += 1.

    I was watching a video and thinking of what you recommended and came up with this

    
    def patient_id_gen():
            ''' generates patient id one at a time as patient object is created '''
            
            prefix = 'AD'
            for i in range(1000,9999):
                    yield f"{prefix}{i}"
    
    

    posted in Pythonista read more
  • resserone13

    @JonB nice. My patient class Has a str method Which prints out most of the patient details.. I’m gonna add a rep and it will be simple print out. Thanks. Adding a repr was the next path I was going to go down. I just thought I would ask her cause I didn’t want to have to research everything just to get it to print out. Thanks again

    posted in Pythonista read more
  • resserone13

    @ccc thanks that worked for the Id. It now shows the object. Any ideas on how to show the objects in my list. Also the generator is generating the same number for both patients?

    posted in Pythonista read more
  • resserone13

    How can I print the object and not the memory location to my list. I also added a patient Id generator to generator a patient records number for each patient that is created. It’s also shows as a memory location. Any advice on this or any of my code is welcome. Like do I need to have a default value of none for all my class variables in init?

    
    master_patient_list = []
    current_patient_list = []
    iso_patient_list = []
    
    iso_type_dict = {'covid': 'droplets', 'cdiff': 'contact', 'tuberculosis': 'airborne', 'influenza': 'droplets', 'reverse isolation': 'patient saftey'}
    
    def count_patients(list):
            return len(list)
    
    class Patient (object):
            
            def __init__(self, name='', age=None, room_number=None, assigned_doctor=None, assigned_nurse=None, illness=None, iso_status=None, patient_record_nunber=None,patient_medications=[]):
                    self.name = name
                    self.age = age 
                    self.room_number = room_number
                    self.assigned_doctor = assigned_doctor
                    self.assigned_nurse = assigned_nurse
                    self.illness = illness
                    self.iso_status = iso_type_dict
                    self.patient_record_number = self.patient_id_gen()
                    self.patient_medications = list(patient_medications)
                    self.add_patient()
                                                
            def add_patient(self):
                    master_patient_list.append(self)
                    current_patient_list.append(self)
                    
            def remove_patient():
                    pass
                                        
            def move_patient(self, new_room):
                    self.room_number = new_room         
                    
            def add_med(self, med):
                    if med not in self.patient_medications:
                            self.patient_medications.append(med)
                            
            def remove_med(self, med):
                    if med in self.patient_medications:
                            self.patient_medications.remove(med)    
                            
    #generates patine records numbers
            def patient_id_gen(self):
                    ''' generates patient id one at a time as patient object is created '''
                
                    first_digit = 0
                    second_digit = 0
                    third_digit = 0
                    
                    for i in range(201):
                            final_num = f'AD{third_digit}{second_digit}{first_digit}'
                            #print(final_num)
            
                            if first_digit < 10:
                                    first_digit += 1
                                    if first_digit == 10:
                                            first_digit = 0
                                            second_digit += 1
                                            if second_digit == 10:
                                                    second_digit = 0
                                                    third_digit += 1
            
                                    
                                    yield final_num
            
        
                                                        
            def __str__(self):
                    return f'Room: {self.room_number} \nName: {self.name} \nPhysician: {self.assigned_doctor} \nNurse: {self.assigned_nurse} \nIllness: {self.illness} \nIso status: {self.iso_status} \nPRN: {self.patient_record_number} \nMedication: {self.patient_medications}'    
                    
    
    #patient info               
    patient1 = Patient()
    patient1.name = 'Sally'
    patient1.age = 35
    patient1.room_number = 430
    patient1.assigned_doctor = 'Dr. Seuss'
    patient1.assigned_nurse = 'Jessica'
    patient1.illness = 'Broken Leg'
    patient1.iso_status = 'NONE'
    #patient1.patient_reord_number = 'AD123456789'
    patient1.add_med('norco')
    
    patient2 = Patient()
    patient2.name = 'Labrone'
    patient2.age = 40
    patient2.room_number = 46208
    patient2.assigned_doctor = 'Dr. Patel'
    patient2.assigned_nurse = 'Melissa'
    patient2.illness = 'Broken Heart'
    patient2.iso_status = '5150'
    patient2.patient_record_number
    patient2.add_med('norco')
    
    
    #test code
    print(patient1)
    print()
    print(patient2)
    print()
    print(f'Master list: \n{master_patient_list}')
    print()
    print(f'Current list: \n{current_patient_list}')
    
    
    
    
    

    Here’s the output...

    Room: 430
    Name: Sally
    Physician: Dr. Seuss
    Nurse: Jessica
    Illness: Broken Leg
    Iso status: NONE
    PRN: <generator object Patient.patient_id_gen at 0x11528b468>
    Medication: ['norco']

    Room: 46208
    Name: Labrone
    Physician: Dr. Patel
    Nurse: Melissa
    Illness: Broken Heart
    Iso status: 5150
    PRN: <generator object Patient.patient_id_gen at 0x115237bf8>
    Medication: ['norco']

    Master list:
    [<main.Patient object at 0x1154d8438>, <main.Patient object at 0x1154d86a0>]

    Current list:
    [<main.Patient object at 0x1154d8438>, <main.Patient object at 0x1154d86a0>]

    posted in Pythonista read more
  • resserone13

    @mikael thanks for the feedback. I always appreciate it. I see now how checking the list the way I am isn’t going to work. The master list will have every patient who’s ever been at the hospital and the current list will only have current patients. That along with how I was storing them by name. With all this in mind I will try to figure something else out and let you know how it goes. Thanks

    posted in Pythonista read more
  • resserone13

    I’ve been haven’t trouble adding the patient to a list when the object is created.

    
    master_patient_list = []
    current_patient_list = []
    iso_patient_list = []
    
    def count_patients(list):
            return len(list)
    
    class Patient (object):
            
            def __init__(self, name=None, age=None, room_number=None, assigned_doctor=None, assigned_nurse=None, illness=None, iso_status=None, patient_record_nunber=None,patient_medications=[]):
                    self.name = name
                    self.age = age 
                    self.room_number = room_number
                    self.assigned_doctor = assigned_doctor
                    self.assigned_nurse = assigned_nurse
                    self.illness = illness
                    self.iso_status = iso_status
                    self.patient_reord_number = patient_record_nunber
                    self.patient_medications = list(patient_medications)
                    self.add_patient()
                                                
            def add_patient(self):
                    if self.name not in master_patient_list and current_patient_list:
                            master_patient_list.append(self.name)
                            current_patient_list.append(self.name)
                    
            def remove_patient():
                    pass
                                        
            def move_patient(self, new_room):
                    self.room_number = new_room         
                    
            def add_med(self, med):
                    if med not in self.patient_medications:
                            self.patient_medications.append(med)
                            
            def remove_med(self, med):
                    if med in self.patient_medications:
                            self.patient_medications.remove(med)        
                            
                                                        
            def __str__(self):
                    return f'Room: {self.room_number} \nName: {self.name} \nPhysician: {self.assigned_doctor} \nNurse: {self.assigned_nurse} \nIllness: {self.illness} \nIso status: {self.iso_status} \nPRN: {self.patient_reord_number} \nMedication: {self.patient_medications}' 
                    
    
    #patient info               
    patient1 = Patient()
    patient1.name = 'Sally'
    patient1.age = 35
    patient1.room_number = 430
    patient1.assigned_doctor = 'Dr. Seuss'
    patient1.assigned_nurse = 'Jessica'
    patient1.illness = 'Broken Leg'
    patient1.iso_status = 'NONE'
    patient1.patient_reord_number = 'AD123456789'
    patient1.add_med('norco')
    
    #test code
    print(patient1)
    
    print(f'Master list: {master_patient_list}')
    print(f'Current list: {current_patient_list}')
    
    count_patients(current_patient_list)
    
    
    
    

    posted in Pythonista read more
  • resserone13

    @mikael for the way I’m using them I would like there to be one list of patients. Not a list associated with each patient. I guess that means I should create the list outside of the class. Making them global. I will check back on the other thread with the cleaning log and see what I can figure out. Thank you for the information.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!