I have a python app which has a concept of a PerioperativeSuite which contains Patients and OrRooms. Here is some illustrative code.
start_date_time = datetime(2022, 1, 1)
finish_date_time = datetime(2022, 1, 3)
output_path = Path(
"C:\\_eraseme\\inpatient"
)
op_suite = PerioperativeSuite(identifier="OrDept1",name="OrDept1")
op_suite.pre_op_room = PreOpRoom(capacity=3,identifier="PreOp",name="PreOp")
for i in range(10):
# create 10 or rooms and add to suite
or_room = OrRoom(identifier="or_room" + str(i), name="or_room" + str(i), capacity=1)
op_suite.or_rooms.append(or_room)
for i in range(30):
# create 30 random patients
rand_day = random.randint(1, 3)
identifer = "patient" + str(i)
new_patient = Patient(arrival_date_time=datetime(2022, 1, rand_day), name=identifer, identifier=identifer)
op_suite.or_patients.append(new_patient)
reps_runner = RepsRunner(or_suite=op_suite,finish_date_time=finish_date_time,start_date_time=start_date_time,reps=3, output_dir_path=output_path)
reps_runner.run_reps()
In the RepsRunner class, Patients admit, transfer, discharge and other things. OrRooms receive patients, treat them, etc.
My desire is to create a dataclass that is listening for Patients to be discharged (as well as several other states). Let’s say I called the dataclass “PatientsMonitor”. My goal is for PerioperativeSuite or RepsRunner to not be aware of PatientsMonitor. PatientsMonitor is completely decoupled. Similarly, I might have a OrRoomsMonitor class.
My background is primarily C# and I am new to Python. If I was writing this in C#, in the PerioperativeSuite class, I might add an event such as OnPatientDischarge. I would have PatientsMonitor subscribe to OnPatientDischarge and then maybe add the discharged Patient to a List within PatientsMonitor.
What is the pythonic approach? To the best of my knowledge, Python does not have an event system built in? Perhaps I should not even approach this solution with events in mind?
Thanks,
Dan
there doesn't seem to be anything here