For a medical application I want to combine several lists into one list. The items in each list represent actions to be taken for a specific disease.
For instance the list Malaria would look like that:
- 'Give Malaria medication'
- 'Give antibiotics'
- 'Tell patient to come back tomorrow'
- 'Give a warm lemon tea'
A second list for Bacterial sore throat would be this:
- 'Give antibiotics'
- 'Give paracetamol'
- 'Give a warm lemon tea'
- 'Warm the patient'
The actions in each list are hierarchical. That means that the more important tasks are mentioned first.
The lists themselves have a hierarchy as well, so Malaria is higher than Bacterial sore throat.
I need to combine those lists into a global one, that has the items sorted in a way that both hierarchies are preserved. This would be the case that a patient has both Malaria AND Bacterial sore throat and receives treatment according to the importance of each action.
For this case I would want this list:
- 'Give Malaria medication' (from Malaria list because it is higher than sore throat)
- 'Give antibiotics' (covers an action from both lists)
- 'Tell patient to come back tomorrow' (from Malaria list)
- 'Give Paracetamol' (more important than warm tea as seen in
sore throat) - 'Give a warm lemon tea' (covers an action from both lists)
- 'Warm the patient'
Currently this sorting is done by hand, but it becomes too complex with 50+ diseases.
I have looked into networkx trying to do a topological sort but I guess this is not the right approach.
It becomes more complex when sorting is not possible and the actions are in reverse order.
For instance in Diarrhoea there are
- make the patient drink
- give treatment
while in Severe Diarrhoea these are in reverse order
- give treatment
- make the patient drink
In this case I want the solution to double an item in the global list to
- give treatment
- make the patient drink
- give treatment
Is there a way to solve at least one of those steps?