Skip to content

Testing Your Local Environment Setup

meliGuzman edited this page Sep 3, 2024 · 9 revisions

Testing Local Environment Setup

Once you've got dependencies installed and the BFD repository downloaded as noted in Local Environment Setup for BFD Development, you may want to run a test to ensure everything is set up correctly. This guide will run you through loading data using the pipeline into your local BFD database, setting up a local BFD server, and then hitting the server to return data.

Loading Beneficiary

  1. First let's make sure the containerized database is set up completely.

Move to the scripts directory, where we have a number of useful scripts for setting up the pieces of BFD:

Starting from the top level of your bfd-repo:

cd apps/utils/scripts

If you did not create a containerized database in the prior setup, we can do that now. Make sure your container service (docker, podman, etc) is running and run:

   ./create-bfd-db

Once this is complete, the bfd database should be created and running in your container service. Now let's make sure the schema is up-to-date:

   ./run-db-migrator

This will apply the latest schema to your database and it should be ready to ingest data.

  1. To load one test beneficiary, with your container database running, change directories into apps/bfd-pipeline/bfd-pipeline-ccw-rif and run:

    mvn -Dits.db.url="jdbc:postgresql://localhost:5432/fhirdb" -Dits.db.username=bfd -Dits.db.password=InsecureLocalDev -Dit.test=RifLoaderIT#loadSampleA -Dmaven.build.cache.enabled=false clean verify

    This will kick off the integration test loadSampleA. After the job completes, you can verify that it ran properly with:

    docker exec bfd-db psql 'postgresql://bfd:InsecureLocalDev@localhost:5432/fhirdb' -c 'SELECT bene_id FROM ccw.beneficiaries LIMIT 1;'
  2. Now it's time to start the server up. Change to apps/utils/scripts. If this is your first time running this script, you will be prompted to set a couple environment variables: BFD_PATH: this should be set to the top-level BFD repo directory you downloaded locally. Example:

    export BFD_PATH=~/Git/beneficiary-fhir-data

    BFD_EXEC: This should be set to a directory on your machine the script will store some local files to. Create a directory somewhere outside your repo for this and set the env var. Example, after having created a bfd-scripts directory in Documents:

    export BFD_EXEC=~/Documents/bfd-scripts

Once these are set, we can run the server using the server start script (make sure you're in apps/utils/scripts):

./run-bfd-server
  1. We're finally going to make a request. BFD requires that clients authenticate themselves with a certificate. Those certs live in the apps/bfd-server/dev/ssl-stores directory. We can curl the server using a cert with this command:

    curl --silent --insecure --cert $BFD_PATH/apps/bfd-server/dev/ssl-stores/client-unsecured.pem "https://localhost:6500/v2/fhir/ExplanationOfBenefit/?patient=567834&_format=json"
  2. Total success (probably)!. You have a working call. To stop the server, you can ctrl+c in the command tab you were running the server in to stop it.

Clone this wiki locally