/contention-classification/va-gov-claim-classifier
maps contention text and diagnostic codes from 526 submission to contention classification codes as defined in the Benefits Reference Data API.
This service can be run standalone using Poetry for dependency management or using Docker.
Mac Users: you can use pyenv to handle multiple python versions
brew install pyenv
pyenv install 3.12.3 #Installs latest version of python 3.12.3
pyenv global 3.12.3 # or don't do this if you want a different version available globally for your system
Mac Users: If python path hasn't been setup, you can put the following in your ~/.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi" #Initalize pyenv in current shell session
This project uses Poetry to manage dependencies.
Follow the directions on the Poetry website for installation:
curl -sSL https://install.python-poetry.org | python3 -
Use Poetry to install all dependencies:
poetry install
poetry run pre-commit install
To run the pre-commit hooks manually:
poetry run pre-commit run --all-files
Using Poetry, run the FastAPI server:
poetry run uvicorn python_src.api:app --port 8120 --reload
Using Poetry, run the test suite:
poetry run pytest
For test coverage report:
poetry run pytest --cov=src --cov-report=term-missing
This application can also be run with Docker using the following commands.
docker compose down
docker compose build --no-cache
docker compose up -d
With the application running using either Docker or Python, tests requests can be sent using the following curl commands.
To test the health of the application or to check if the application is running at the contention-classification/health
endpoint:
curl -X 'GET' 'http://localhost:8120/health'
To test the classification provided at the contention-classification/va-gov-claim-classifier
endpoint:
curl -X 'POST' 'http://localhost:8120/va-gov-claim-classifier' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
"claim_id": 44,
"form526_submission_id": 55,
"contentions": [
{
"contention_text": "PTSD (post-traumatic stress disorder)",
"contention_type": "NEW"
},
{
"contention_text": "acl tear, right",
"contention_type": "NEW"
},
{
"contention_text": "",
"contention_type": "INCREASE",
"diagnostic_code": 5012
}
]
}'
To test the classification provided by the experimental endpoint at contention-classification/expanded-contention-classification
:
curl -X 'POST' 'http://localhost:8120/expanded-contention-classification' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{
"claim_id": 44,
"form526_submission_id": 55,
"contentions": [
{
"contention_text": "PTSD (post-traumatic stress disorder)",
"contention_type": "NEW"
},
{
"contention_text": "acl tear, right",
"contention_type": "NEW"
},
{
"contention_text": "",
"contention_type": "INCREASE",
"diagnostic_code": 5012
}
]
}'
An alternative to the above curl
commands is to use a local testing application like Bruno or Postman. Different JSON request bodies can be set up for testing each of the above endpoints and tests can be saved using Collections within these tools.
API Documentation is automatically created by FastAPI. This can be viewed by visiting localhost:8120/docs
while the application is running.
For exporting the open API spec:
poetry run python src/python_src/pull_api_documentation.py