Skip to main content

Download files from the Cencora secure file transfer site

Project description

Purpose

This Python package can be used to download files from the Cencora (formerly Amerisource) secure file transfer site for ingest into clinical data systems.

Downloads are performed from the web-based secure site located at https://secure.amerisourcebergen.com/. FTP is not supported. (There are many easier ways to automate FTP-based downloads.)

Requirements

  • Python 3.10 or newer

Installation

Use pip to install the medberg package.

pip install medberg

Usage

Import the SecureSite class from the medberg module.

from medberg import SecureSite

Initialize a connection to the secure site by providing a username and password.

con = SecureSite(username='yourname', password='yourpassword')

A list of files is automatically downloaded at connection time. Filenames are stored as a list in the files variable.

print(con.files)
# ['039A_012345678_0101.TXT', '077AXM0123456780101.TXT', ...]

Any individual file can be downloaded using the get_file method.

con.get_file('039A_012345678_0101.TXT', save_dir='C:\\Users\\yourname\\Downloads\\')

The file is saved in the path specified by save_dir. If this is left blank, it will default to the current working directory. The local filepath will be returned as a pathlib Path.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

This software is licensed under the MIT License.

Disclaimer

This package and its authors are not afiliated, associated, authorized, or endorsed by Cencora, Inc. All names and brands are properties of their respective owners.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

medberg-0.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

medberg-0.0.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page