-
Notifications
You must be signed in to change notification settings - Fork 16
Automate hospital admission patch #2043
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
aysim319
wants to merge
29
commits into
main
Choose a base branch
from
automate-hospital-admission-patch
base: main
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 8 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
23e1055
implement
aysim319 39c433e
implement
aysim319 cbc7894
implimentation done
aysim319 5b9e69a
fixed typo and conditional
aysim319 1bb84d8
feat: adding patching with backfill
aysim319 3d5701c
lint
aysim319 230086a
suggested changes
aysim319 7bd15be
suggested changes
aysim319 b71dd82
making backfill to monthly in progess
aysim319 eed2a63
adjusting logic to match new naming format and chunking
aysim319 65a06d8
added logging and more clean up
aysim319 6995c8a
added conditional for merging
aysim319 1666e0c
lint
aysim319 73a9063
Merge branch 'main' into automate-hospital-admission-patch
aysim319 98d631a
remove unrelated file
aysim319 74bebe3
update libary for ci
aysim319 8be796e
fix test
aysim319 75a9e4a
lint
aysim319 f1c11e5
fixing logic
aysim319 cf4e4bc
lint
aysim319 0498ed4
making test more robust in progress
aysim319 f95a146
cleaning up and fixing tests
aysim319 1d98c03
fix test and suggestions
aysim319 a6cb942
add package
aysim319 b1ee511
added time to issue date to accomdate for filetime
aysim319 d5b414a
reverting in process
aysim319 584a9b7
in progress
aysim319 7ad0896
fixed test
aysim319 6a5d423
lint
aysim319 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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" | ||
This module is used for patching data in the delphi_claims_hosp package. | ||
|
||
To use this module, you need to specify the range of issue dates in params.json, like so: | ||
|
||
{ | ||
"common": { | ||
"custom_flag" : true, | ||
... | ||
}, | ||
"validation": { | ||
... | ||
}, | ||
"patch": { | ||
"patch_dir": "/covidcast-indicators/hopspital-admissions/patch", | ||
"start_issue": "2024-04-20", | ||
"end_issue": "2024-04-21" | ||
} | ||
} | ||
|
||
It will generate data for that range of issue dates, and store them in batch issue format: | ||
[name-of-patch]/issue_[issue-date]/doctor-visits/actual_data_file.csv | ||
""" | ||
aysim319 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
from datetime import datetime, timedelta | ||
from os import makedirs | ||
|
||
from delphi_utils import get_structured_logger, read_params | ||
|
||
from .run import run_module | ||
|
||
|
||
def patch(): | ||
""" | ||
Run the hospital-admissions indicator for a range of issue dates. | ||
|
||
The range of issue dates is specified in params.json using the following keys: | ||
- "patch": Only used for patching data | ||
- "start_date": str, YYYY-MM-DD format, first issue date | ||
- "end_date": str, YYYY-MM-DD format, last issue date | ||
- "patch_dir": str, directory to write all issues output | ||
""" | ||
params = read_params() | ||
logger = get_structured_logger("delphi_claims_hosp.patch", filename=params["common"]["log_filename"]) | ||
|
||
start_issue = datetime.strptime(params["patch"]["start_issue"], "%Y-%m-%d") | ||
end_issue = datetime.strptime(params["patch"]["end_issue"], "%Y-%m-%d") | ||
|
||
logger.info( | ||
"Starting patching", | ||
patch_directory=params["patch"]["patch_dir"], | ||
start_issue=start_issue.strftime("%Y-%m-%d"), | ||
end_issue=end_issue.strftime("%Y-%m-%d"), | ||
) | ||
|
||
makedirs(params["patch"]["patch_dir"], exist_ok=True) | ||
|
||
current_issue = start_issue | ||
|
||
while current_issue <= end_issue: | ||
logger.info("Running issue", issue_date=current_issue.strftime("%Y-%m-%d")) | ||
|
||
params["patch"]["current_issue"] = current_issue.strftime("%Y-%m-%d") | ||
|
||
current_issue_yyyymmdd = current_issue.strftime("%Y%m%d") | ||
current_issue_dir = f"""{params["patch"]["patch_dir"]}/issue_{current_issue_yyyymmdd}/hospital-admissions""" | ||
makedirs(f"{current_issue_dir}", exist_ok=True) | ||
params["common"]["export_dir"] = f"""{current_issue_dir}""" | ||
|
||
run_module(params, logger) | ||
current_issue += timedelta(days=1) | ||
|
||
|
||
if __name__ == "__main__": | ||
patch() |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.