-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new "cumulus-etl export" command for bulk exporting
This new command is quite simple. It just takes a URL and an output folder. The usual auth and export args (like --since) are accepted. You can also filter exported resources by task with --task. But even if you don't use --since or --task, you can provide an export URL that has _since, _type, _typeFilter, whatever you want. In addition: - "--task=help" will now print a list of task names and exit. - The traditional way to kick off a bulk export when doing an ETL job (by providing a URL as the input path) now also lets you specify custom parameters like _since or _typeFilter directly in the URL. - Handle non-compliant servers that give us transactionTime values that aren't formatted correctly (as bulk-data-server does).
- Loading branch information
Showing
20 changed files
with
438 additions
and
134 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Cumulus public entry point""" | ||
"""Turns FHIR data into de-identified & aggregated records""" | ||
|
||
__version__ = "1.1.1" | ||
__version__ = "1.2.0" |
This file contains 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 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 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 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 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 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,3 @@ | ||
"""Bulk export""" | ||
|
||
from .cli import run_export |
This file contains 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,49 @@ | ||
"""Do a standalone bulk export from an EHR""" | ||
|
||
import argparse | ||
|
||
from cumulus_etl import cli_utils, fhir, loaders, store | ||
from cumulus_etl.etl.tasks import task_factory | ||
|
||
|
||
def define_export_parser(parser: argparse.ArgumentParser) -> None: | ||
parser.usage = "cumulus-etl export [OPTION]... FHIR_URL DIR" | ||
|
||
parser.add_argument("url_input", metavar="https://fhir.example.com/Group/ABC") | ||
parser.add_argument("export_to", metavar="/path/to/output") | ||
cli_utils.add_bulk_export(parser, as_subgroup=False) | ||
|
||
cli_utils.add_auth(parser, use_fhir_url=False) | ||
cli_utils.add_task_selection(parser) | ||
|
||
|
||
async def export_main(args: argparse.Namespace) -> None: | ||
"""Exports data from an EHR to a folder.""" | ||
# record filesystem options before creating Roots | ||
store.set_user_fs_options(vars(args)) | ||
|
||
selected_tasks = task_factory.get_selected_tasks(args.task, args.task_filter) | ||
required_resources = {t.resource for t in selected_tasks} | ||
using_default_tasks = not args.task and not args.task_filter | ||
|
||
fhir_root = store.Root(args.url_input) | ||
client = fhir.create_fhir_client_for_cli(args, fhir_root, required_resources) | ||
|
||
async with client: | ||
loader = loaders.FhirNdjsonLoader( | ||
fhir_root, | ||
client=client, | ||
export_to=args.export_to, | ||
since=args.since, | ||
until=args.until, | ||
) | ||
await loader.load_from_bulk_export( | ||
sorted(required_resources), prefer_url_resources=using_default_tasks | ||
) | ||
|
||
|
||
async def run_export(parser: argparse.ArgumentParser, argv: list[str]) -> None: | ||
"""Parses an export CLI""" | ||
define_export_parser(parser) | ||
args = parser.parse_args(argv) | ||
await export_main(args) |
This file contains 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.