-
Notifications
You must be signed in to change notification settings - Fork 16
Doctor_visits patching code #1977
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9867c2e
add patching code
minhkhul 640b29c
add documentation
minhkhul 3b7be0a
linter
minhkhul d52af76
linter
minhkhul 1be6836
linter
minhkhul 518c7fa
linter
minhkhul 061719c
linter
minhkhul 7d95000
linter
minhkhul 03fac7d
linter
minhkhul 3bd458b
linter
minhkhul 67408e4
fix dir name
minhkhul b7f5ecb
Update get_latest_claims_name.py
minhkhul 1078eab
remove patch var, use only issue"
minhkhul 5c35211
issue -> issue_date for clarity
minhkhul f68009a
fix logger
minhkhul f12abce
unit test
minhkhul ca77d64
fix unit test
minhkhul 9a4c125
lint
minhkhul 88e14d2
Update doctor_visits/delphi_doctor_visits/patch.py
minhkhul c1d7c00
add download and get_latest_claims_name tests
minhkhul 09b0081
Update test_get_latest_claims_name.py test file name
minhkhul 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,48 @@ | ||
""" | ||
This module is used for patching data in the delphi_doctor_visits package. | ||
|
||
To use this module, you need to specify the range of issue dates in params.json. | ||
minhkhul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
It will generate data for that range of issue dates, and store them in batch issue format: | ||
[name-of-patch]/issue_[issue-date]/nssp/actual_data_file.csv | ||
""" | ||
|
||
from datetime import datetime, timedelta | ||
from os import makedirs | ||
|
||
from delphi_utils import get_structured_logger, read_params | ||
|
||
from .run import run_module | ||
|
||
if __name__ == "__main__": | ||
# Run the doctor visits indicator for a range of issue dates, specified in params.json using 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(__name__, filename=params["common"]["log_filename"]) | ||
aysim319 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
start_issue = datetime.strptime(params["patch"]["start_issue"], "%Y-%m-%d") | ||
end_issue = datetime.strptime(params["patch"]["end_issue"], "%Y-%m-%d") | ||
|
||
logger.info(f"""Start patching {params["patch"]["patch_dir"]}""") | ||
logger.info(f"""Start issue: {start_issue.strftime("%Y-%m-%d")}""") | ||
logger.info(f"""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(f"""Running issue {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}/nssp""" | ||
makedirs(f"{current_issue_dir}", exist_ok=True) | ||
params["common"]["export_dir"] = f"""{current_issue_dir}""" | ||
|
||
run_module(params) | ||
current_issue += timedelta(days=1) |
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.
As a general thought: can we introduce using typing for the function parameters? I checked that typing was introduced as a part of the standard library at 3.5 so should be able to use it for this repo. As a newcomer it would be helpful to know the type.
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.
@aysim319 can you turn this request into an issue?