-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
146 lines (90 loc) · 3.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
"""
Main file:
Author: Max
Date: 30/05/2022
Description: reads patient details data in JSON format and calculates BMI for each patient.
"""
import pandas as pd
import os
from utils import read_json_data as ds
from calculate_bmi import calculate_patient_bmi as bmi
dir_name = os.path.dirname(__file__)
# logging.basicConfig(filename='warning.log', filemode='w', format='%(name)s - %(levelname)s - %(message)s')
# logging.warning('This will get logged to a file')
print("This is the beginning of patients BMI task:")
print('-------------------------------------------')
def read_json_file(input_path: str, json_file_name: str) -> pd.DataFrame:
data_source_obj = ds.JSONReadData(input_path, json_file_name)
data_source_obj.display_file_location()
data_source_obj.read_json_data()
data_source_obj.display_summary()
return data_source_obj.get_data()
def print_patient_data(patient_df):
print("Printing patients dataframe:")
print(patient_df)
def main():
# can go into a config file
list_of_bmi_ranges = [18.4, (18.5, 24.9), (25, 29.9), (30, 34.9), (35, 39.9), 40]
input_path = dir_name + '/calculate_bmi/data'
json_file_name = "patient_details.json"
patient_details_df = read_json_file(input_path, json_file_name)
print(patient_details_df)
bmi_obj = bmi.CalculatePatientBMI(patient_details_df, list_of_bmi_ranges)
bmi_obj.calculate_bmi()
print(bmi_obj.get_patient_details())
bmi_obj.calculate_bmi_metrics()
print(bmi_obj.get_patient_details())
total_bmi_category = bmi_obj.count_category_by_bmi_range((25, 29.9))
print(total_bmi_category)
total_bmi_category = bmi_obj.count_category_by_bmi_category('Overweight')
print(total_bmi_category)
if __name__ == '__main__':
main()
# """
# This is my main script
#
# Author: Max Kadoche
#
# """
#
# import pandas as pd
#
# import logging
#
# from calculate_bmi import read_json_data as ds
#
#
# def read_json_file(input_path: str, json_file_name: str) -> pd.DataFrame:
#
# patients_data = ds.JSONReadData(input_path, json_file_name)
# # ds.display_file_location(patients_data.path, patients_data.file_name)
# patients_data.read_json_data()
# patients_data.display_summary()
# return patients_data.get_data()
#
#
# def main():
#
# # can go into a config file
# list_of_bmi_ranges = [18.4, (18.5, 24.9), (25, 29.9), (30, 34.9), (35, 39.9), 40]
# input_path = "/home/maxk/PycharmProjects/tesco/data"
# json_file_name = "patient_details.json"
# patient_df = read_json_file(input_path, json_file_name)
#
#
#
# if __name__ == '__main__':
# main()
#
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
# def print_hi(name):
# # Use a breakpoint in the code line below to debug your script.
# print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
#
#
# # Press the green button in the gutter to run the script.
# if __name__ == '__main__':
# print_hi('PyCharm')
# See PyCharm help at https://www.jetbrains.com/help/pycharm/