-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ade3d25
commit fceefd2
Showing
6 changed files
with
136 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "/Users/SimonChapman/.pyenv/versions/rcpchgrowth-cli/bin/python" | ||
} |
Empty file.
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,84 @@ | ||
import click | ||
from datetime import datetime | ||
from rcpchgrowth import date_calculations | ||
from rcpchgrowth import centile_bands | ||
from rcpchgrowth.centile_bands import centile_band_for_centile | ||
from rcpchgrowth.global_functions import centile, measurement_from_sds, sds_for_measurement | ||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
@click.command() | ||
@click.argument('birth_date') | ||
@click.argument('observation_date') | ||
@click.argument('gestation_weeks') | ||
@click.argument('gestation_days') | ||
@click.option('--adjustment', '-a') | ||
def age_calculation(birth_date: datetime, observation_date: datetime, gestation_weeks=40, gestation_days=0, adjustment=False): | ||
decimal_age=0 | ||
calendar_age="" | ||
if adjustment: | ||
decimal_age=date_calculations.corrected_decimal_age( | ||
birth_date=birth_date, | ||
observation_date=observation_date, | ||
gestation_weeks=gestation_weeks, | ||
gestation_days=gestation_days) | ||
calendar_age=date_calculations.chronological_calendar_age( | ||
birth_date=birth_date, | ||
observation_date=observation_date) | ||
else: | ||
decimal_age=date_calculations.chronological_decimal_age( | ||
birth_date=birth_date, | ||
observation_date=observation_date | ||
) | ||
calendar_age=date_calculations.chronological_calendar_age( | ||
birth_date=birth_date, | ||
observation_date=observation_date) | ||
click.echo(f"{decimal_age} y, \n {calendar_age}") | ||
|
||
@click.command() | ||
@click.argument('reference') | ||
@click.argument('decimal_age') | ||
@click.argument('measurement_method') | ||
@click.argument('observation_value') | ||
@click.argument('sex') | ||
def sds(reference: str, decimal_age: float, measurement_method: str, observation_value: float, sex: str): | ||
result = sds_for_measurement( | ||
reference=reference, | ||
age=decimal_age, | ||
measurement_method=measurement_method, | ||
observation_value=observation_value, | ||
sex=sex | ||
) | ||
cent = centile(result) | ||
click.echo(f"SDS: {result}\n Centile: {cent}\n ") | ||
|
||
@click.command() | ||
@click.argument('reference') | ||
@click.argument('decimal_age') | ||
@click.argument('sex') | ||
@click.argument('measurement_method') | ||
@click.argument('sds') | ||
def measurement(reference: str, decimal_age: float, sex:str, measurement_method: str, sds: float): | ||
result = measurement_from_sds( | ||
reference, | ||
requested_sds=sds, | ||
measurement_method=measurement_method, | ||
sex=sex, | ||
age=decimal_age | ||
) | ||
suffix="cm" | ||
if measurement_method=="weight": | ||
suffix="kg" | ||
elif measurement_method=="bmi": | ||
suffix="kg/m2" | ||
click.echo(f"SDS {sds}\n {measurement_method}: {result} {suffix}") | ||
|
||
|
||
cli.add_command(age_calculation) | ||
cli.add_command(sds) | ||
cli.add_command(measurement) | ||
|
||
if __name__ == 'main': | ||
cli() |
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 @@ | ||
rcpchgrowth-cli |
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,15 @@ | ||
attrs==20.3.0 | ||
click==7.1.2 | ||
iniconfig==1.1.1 | ||
marshmallow==3.11.1 | ||
numpy==1.20.2 | ||
packaging==20.9 | ||
pluggy==0.13.1 | ||
py==1.10.0 | ||
pyparsing==2.4.7 | ||
pytest==6.2.3 | ||
python-dateutil==2.8.1 | ||
rcpchgrowth==2.1.11 | ||
scipy==1.6.2 | ||
six==1.15.0 | ||
toml==0.10.2 |
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,33 @@ | ||
from setuptools import setup, find_packages | ||
|
||
with open('requirements.txt') as f: | ||
requirements = f.readlines() | ||
|
||
long_description = 'Calculate SDS and centiles using \ | ||
UK-WHO, Down and Turner reference data. \ | ||
This is official RCPCH software.' | ||
|
||
setup( | ||
name ='rcpchgrowth-python-cli', | ||
version ='1.0.0', | ||
author ='Simon Chapman', | ||
author_email ='[email protected]', | ||
url ='https://github.com/rcpch/rcpchgrowth-python-cli', | ||
description ='Command Line Interface for RCPCHGrowth.', | ||
long_description = long_description, | ||
long_description_content_type ="text/markdown", | ||
packages = find_packages(), | ||
entry_points ={ | ||
'console_scripts': [ | ||
'rcpchgrowth-cli = cli:main' | ||
] | ||
}, | ||
classifiers =( | ||
"Programming Language :: Python :: 3", | ||
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)', | ||
"Operating System :: OS Independent", | ||
), | ||
keywords ='RCPCHGrowth UK-WHO Down Turner', | ||
install_requires = requirements, | ||
zip_safe = False | ||
) |