-
Notifications
You must be signed in to change notification settings - Fork 17
Add monthly daly reporting to individual history tracker #1847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marghe-molaro
wants to merge
9
commits into
master
Choose a base branch
from
molaro/add-dalys-to-individual-history-tracker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
55adae7
Add monthly daly reporting to individual history tracker
marghe-molaro 2bcab12
Fix typo in dispatcher name
marghe-molaro c712997
Finalise test
marghe-molaro 6ae6bfd
Style fix
marghe-molaro a3e43bf
Remove debug messaging
marghe-molaro cf79a8e
Simplify dictionary conversion
marghe-molaro dffe729
Investigate cause of discrepancy between HSI log and iht
marghe-molaro 9e094db
Fix lack of event tag usage
marghe-molaro a16a4c4
Style fix
marghe-molaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||
| get_gbd_causes_not_represented_in_disease_modules, | ||||||
| ) | ||||||
| from tlo.methods.demography import age_at_date | ||||||
| from tlo.notify import notifier | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
| logger.setLevel(logging.INFO) | ||||||
|
|
@@ -614,6 +615,20 @@ def apply(self, population): | |||||
| # Multiply 1/12 as these weights are for one month only | ||||||
| disease_specific_daly_values_this_month = disease_specific_daly_values_this_month * (1 / 12) | ||||||
|
|
||||||
| if notifier.has_listeners("healthburden.monthly_daly_report"): | ||||||
| # Do not dispatch individuals or causes that have zero dalys reported this month | ||||||
| monthly_dalys = disease_specific_daly_values_this_month | ||||||
| monthly_dalys_nonzero = ( | ||||||
| monthly_dalys.loc[(monthly_dalys != 0).any(axis=1), (monthly_dalys != 0).any(axis=0)]) | ||||||
|
|
||||||
| # Only retain non-zero info | ||||||
| data = { | ||||||
| idx: {col: val for col, val in row.items() if val > 0} | ||||||
| for idx, row in monthly_dalys_nonzero.iterrows() | ||||||
| } | ||||||
|
|
||||||
| notifier.dispatch("healthburden.monthly_daly_report", data=data) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use dash instead of underscores here, to match other listeners.
Suggested change
|
||||||
|
|
||||||
| # 4) Summarise the results for this month wrt sex/age/wealth | ||||||
| # - merge in age/wealth/sex information | ||||||
| disease_specific_daly_values_this_month = disease_specific_daly_values_this_month.merge( | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why you pack it into a dictionary here (two nested for-loops), and then unpack again (two more nested for-loops) when it goes to the function in the notifier? Could the
pd.Dataframebe passed here, and then packed-into the eav format once?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that's a good point; my naive guess was that the cost of reformatting non-zero entries into a dictionary is less than dispatching the entire dataframe which may contain a lot of zero entries*, but this may be incorrect. @tamuri happy for you to advise.
*This also a naive guess, based on the assumption that most individuals only have one or two conditions reported every months (meaning that all other columns would be zero for them), and that a single condition would typically affect <<20% (?) of the population.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tim is right - you don't need any filtering here. You're passing a reference, not a copy of the dataframe. You do need to ensure there is no editing of the dataframe in the receiver because it is used after the notification.
It's also how notifications are usually setup. You don't know how receivers need the information so send everything and then the receiver can do its own filtering (or not, as needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An additional benefit is that you can remove the
has_listenerscheck