Build and Test

Requirement:

  1. PostgreSQL are installed somewhere.

Task 1

  1. Put the SQL files into the code folder.

  2. Import the generated synthetic data into the database:

psql -U your_super_user_name -f dump-synthea-202212120538.sql

This SQL is exported from the PostgreSQL database. The data inside is generated using Synthea 2.7.0 and imported using the ETL tool provided in the reference. The data is generated using the following command (no need to run this):

java -jar .\synthea-with-dependencies.jar -s 12 -p 100 --exporter.csv.export true
  1. Create 2 users: user1 and readonly:
psql -U your_super_user_name -d synthea -f create_user.sql
  1. Create a query using table joins and where clause:
psql -U your_super_user_name -d synthea -f create_query.sql

Inside the SQL files there are explanations and optimizations of the query.

Task 2

  1. Install relevant dependencies
pip install -r requirements.txt
  1. Setup environment variables for PostgreSQL, for example:
export synthea_user=test synthea_password=test synthea_host=localhost synthea_port=5432 synthea_database=synthea
  1. Run main.py and get test results
python main.py
  1. To run unit tests:
python -m unittest tests.test_main

Task 3

The github repository is here: https://github.com/wanghewen/synthea_query