def DoctorPrescription(self): #self.params['IOPReduction'] = 0.12 tracenode = node(0) tracenode = TreatmentTree if self.medicalRecords['MedicationPath'][0] == 0: self.medicalRecords['MedicationPath'][0] = 1 self.operations(TreatmentTree) self.medicalRecords['TreatmentOverallStatus'] = 0 self.medicalRecords['MedicationIntake'] = 0 else: i = 1 #this would shortcut CurrentMedicationType ==10, so when if-else evaluate below, we sure this is not because #the new treatment is if self.medicalRecords['CurrentMedicationType'] == 10 and self.params['FirstProgression'] == 1: #self.medicalRecords['TreatmentBlock'] += 1 self.medicalRecords['ExitCode'] = True self.ResetMedicationPath() while i < 5 and self.medicalRecords['MedicationPath'][i] <> 0 and self.medicalRecords['CurrentMedicationType'] <> 10: #add condition of i in here if self.medicalRecords['MedicationPath'][i] == 1: tracenode = tracenode.left i = i +1 elif self.medicalRecords['MedicationPath'][i] == 2: tracenode = tracenode.right i = i+1 if i < 5 and self.medicalRecords['CurrentMedicationType'] <> 10 : self.medicalRecords['MedicationPath'][i] = self.medicalRecords['TreatmentOverallStatus'] if self.medicalRecords['TreatmentOverallStatus'] == 1: tracenode = tracenode.left self.operations(tracenode) if self.medicalRecords['TreatmentOverallStatus'] == 2: #print('shit') tracenode = tracenode.right self.operations(tracenode) #This is the only way to get out of the treatment block # Here after every medication indication, patients need to self.medicalRecords['TreatmentOverallStatus'] = 0 self.medicalRecords['MedicationIntake'] = 0 #exit the block if i == 5 if i == 5 and self.params['FirstProgression'] == 1: #self.medicalRecords['TreatmentBlock'] += 1 self.medicalRecords['ExitCode'] = True self.ResetMedicationPath()
def DoctorPrescription(self): """Reassign/assign medication to patient when unusual event/no medication yet """ tracenode = node(0) tracenode = TreatmentTree # .medicalRecords['MedicationPath'][0] == 0 means no medication assigned yet if self.medicalRecords['MedicationPath'][0] == 0: #assign first medication and block self.medicalRecords['MedicationPath'][0] = 1 self.operations(TreatmentTree) self.medicalRecords['TreatmentOverallStatus'] = 0 self.medicalRecords['MedicationIntake'] = 0 else: #already on some medication i = 1 #special case (premature exit), if current medication type (before reassigning) #is 10, Exit #because there is no more medication node to take. if self.medicalRecords['CurrentMedicationType'] == 10 and self.params['FirstProgression'] == 1: self.medicalRecords['ExitCode'] = True self.ResetMedicationPath() #now, trace to the current medication block #while not exhaust all medication nodes on the path or not medication type == 10 while i < 5 and self.medicalRecords['MedicationPath'][i] <> 0 and self.medicalRecords['CurrentMedicationType'] <> 10: if self.medicalRecords['MedicationPath'][i] == 1: tracenode = tracenode.left i = i +1 elif self.medicalRecords['MedicationPath'][i] == 2: tracenode = tracenode.right i = i+1 #if current medication type (before reassigning) is not the terminal node #first, trace to the next medication node depending on overall status #then reassign .operations(tracenode) if i < 5 and self.medicalRecords['CurrentMedicationType'] <> 10 : self.medicalRecords['MedicationPath'][i] = self.medicalRecords['TreatmentOverallStatus'] if self.medicalRecords['TreatmentOverallStatus'] == 1: tracenode = tracenode.left self.operations(tracenode) if self.medicalRecords['TreatmentOverallStatus'] == 2: tracenode = tracenode.right self.operations(tracenode) #if current medication type (before reassigning) is the terminal node if i == 5 and self.params['FirstProgression'] == 1: self.medicalRecords['ExitCode'] = True self.ResetMedicationPath() #Reset status variables self.medicalRecords['TreatmentOverallStatus'] = 0 self.medicalRecords['MedicationIntake'] = 0
def __init__(self, input_matrix): if len(input_matrix) != len(input_matrix[0]): print("Please enter a valid n x n sized matrix") else: self.__size = len(input_matrix) print("You have entered a valid ", self.__size, "x", self.__size, "matrix") #create 2d list of nxn nodes self.__node_matrix = [[node() for i in range(self.__size)] for j in range(self.__size)] #user input of nxn matrix values for row in range(self.__size): for column in range(self.__size): #cost = eval(input("Enter a value and press Enter: ")) self.__node_matrix[row][column].setCost( input_matrix[row][column]) temp_matrix = input_matrix self.__printMatrix() #print original matrix self.__Execute() self.__printMatrix()
TreatmentTree = node ([ [511,1381] ,1, [10,109] , [1,0,0,0,0] ], node([ [589,1407] ,2, [22,258] , [0,1,0,0,0] ], node([ [294,1231] ,3, [2,12] ,[0,0,1,0,0] ], node([ [148,559] ,4, [5,17] , [0,0,0,1,0]], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,23,[5,17],[0,0,0,1,1] ])), node([ [148,559] ,21,[5,17] , [0,0,1,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,22,[5,17],[0,0,1,1,1] ]))), node([ [294,1231] , 16 , [2,12] , [0,1,0,1,0] ], node([ [148,559] ,17,[5,17] , [0,1,0,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,20,[5,17],[0,1,0,1,1] ])), node([ [148,559] ,18,[5,17] , [0,1,1,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,19,[5,17],[0,1,1,1,1] ]))) ), node([ [589,1407] , 6 , [22,258] , [1,1,0,0,0] ], node([ [294,1231] , 7 , [2,12] , [1,0,1,0,0] ], node([ [148,559] ,12,[5,17] , [1,0,0,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,15,[5,17],[1,0,0,1,1] ])), node([ [148,559] ,13,[5,17] , [0,1,0,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,14,[5,17],[1,0,1,1,1] ]))), node([ [294,1231] , 8 , [2,12] , [1,1,1,0,0] ], node([ [148,559] ,9,[5,17] , [1,1,0,1,0] ], node([ [763,1480] ,5, 0 , [0,0,0,0,1]]), node([ [763,1480] ,11,[5,17],[1,1,0,1,1] ])), node([ [148,559] ,10,[5,17] , [1,1,1,0,1] ])) ) )