Modify a process¶
For your specific project it might be necessary to modify an existing Process, e.g. a disease process.
While there are multiple ways of adapting processes, we want to highlight some good practices.
Copy and modify a process¶
To get readable and flexible adaptations of your processes, it is useful to define your adapted process as a subclass of the original process.
1from miscore import Individual
2from miscore.processes import EC_screening
3
4
5# Define the modified, subclassed EC_screening process which overwrites some of the attributes
6class EC_screening_modified(EC_screening):
This has the advantage that all functions except the ones that you overwrite are inherited from the process you are adapting.
For example, if you wanted to include an additional event_tag in your modified EC_screening process,
you could simply overwrite the inherited event_tags instead of copying the entire EC_screening process.
Similarly, you can overwrite the function schedule_first_invitation:
1from miscore import Individual
2from miscore.processes import EC_screening
3
4
5# Define the modified, subclassed EC_screening process which overwrites some of the attributes
6class EC_screening_modified(EC_screening):
7 event_tags = EC_screening.event_tags + ["additional_event_tag"]
8
9 def schedule_first_invitation(self, individual: Individual):
10 """This is where you can write your new function"""
11 return