This program captures various health data points, rates them based on specified ranges, and prints the data fields and their classifications to an output file.
- Author: Will Maxcy
- Created: 6/30/2022
- Last Updated: 7/1/2022
- Python 3.x
- PyPDF2 library
- Place the input PDF files in the
Input
directory. - Run the program to capture and classify the health data points.
- The output will be saved to the output file.
-
Import the required libraries:
- PyPDF2
- os
- sys
- re
-
Set the global variables:
path
: Path to the input files directory.dirs
: Directories in the input files directory.files
: Files in the input files directory.
-
Define comparison functions:
compare(reference, low, high)
: Compares a reference number to low and high values and returns a classification code.lessthan(reference, low)
: Compares a reference number to a low value and returns a classification code.greaterthan(reference, low)
: Compares a reference number to a low value and returns a classification code.compare3(reference, low, high)
: Compares a reference number to low and high values and returns a classification code.match(reference, comp)
: Checks if a reference value matches a comparable variable and returns a classification code.percentage(reference)
: Placeholder function.
-
Define the printer function:
printer(name, rating)
: Prints the name and classification of a data field.
-
Define the page0 function:
page0(text)
: Scans the first page and captures the required variables using regular expressions. Then, it applies the comparison functions to rate the variables and uses the printer function to print the results.
-
Define the page1 function:
page1(text)
: Scans the second page and captures the required variables using regular expressions. Then, it applies the comparison functions to rate the variables and uses the printer function to print the results.
-
Define the page2 function:
page2(text)
: Scans the third page and captures the required variables using regular expressions. Then, it applies the comparison functions to rate the variables and uses the printer function to print the results.
-
Initialize the
output
variable to store the program's output. -
Call the page0, page1, and page2 functions for each input file.
-
The program will print the captured data fields and their classifications to the
output
variable. -
Save the
output
to an output file.
This project is licensed under the MIT License.