diff --git a/backend/.DS_Store b/backend/.DS_Store index a22452b60a..520517a478 100644 Binary files a/backend/.DS_Store and b/backend/.DS_Store differ diff --git a/Content Extractor/3_LangchainLoader b/backend/M1: RAG-Content Extractor/3_LangchainLoader similarity index 100% rename from Content Extractor/3_LangchainLoader rename to backend/M1: RAG-Content Extractor/3_LangchainLoader diff --git a/backend/content_extractor/.gitignore b/backend/M2: Tesseract-Content Extractor/.gitignore similarity index 100% rename from backend/content_extractor/.gitignore rename to backend/M2: Tesseract-Content Extractor/.gitignore diff --git a/backend/content_extractor/__pycache__/__autograph_generated_file2efcijjs.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_file2efcijjs.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_file2efcijjs.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_file2efcijjs.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_fileagoi3pfn.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileagoi3pfn.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_fileagoi3pfn.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileagoi3pfn.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_fileh3rc0qzn.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileh3rc0qzn.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_fileh3rc0qzn.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileh3rc0qzn.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_files1hmmvgh.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_files1hmmvgh.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_files1hmmvgh.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_files1hmmvgh.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_filetp7m4pav.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_filetp7m4pav.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_filetp7m4pav.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_filetp7m4pav.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_filetxjgb_rx.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_filetxjgb_rx.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_filetxjgb_rx.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_filetxjgb_rx.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_fileu1oxb_17.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileu1oxb_17.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_fileu1oxb_17.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileu1oxb_17.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/__autograph_generated_fileua2uwj9e.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileua2uwj9e.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/__autograph_generated_fileua2uwj9e.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/__autograph_generated_fileua2uwj9e.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/ocr.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/ocr.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/ocr.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/ocr.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/postprocessing.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/postprocessing.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/postprocessing.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/postprocessing.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/preprocessing.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/preprocessing.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/preprocessing.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/preprocessing.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/subprocess.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/subprocess.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/subprocess.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/subprocess.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/utils.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/utils_evaluate.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils_evaluate.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils_evaluate.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils_evaluate.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/utils_evaluate.cpython-311.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils_evaluate.cpython-311.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils_evaluate.cpython-311.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils_evaluate.cpython-311.pyc diff --git a/backend/content_extractor/__pycache__/utils_ocr.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils_ocr.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils_ocr.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils_ocr.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/utils_postprocessing.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils_postprocessing.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils_postprocessing.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils_postprocessing.cpython-310.pyc diff --git a/backend/content_extractor/__pycache__/utils_preprocessing.cpython-310.pyc b/backend/M2: Tesseract-Content Extractor/__pycache__/utils_preprocessing.cpython-310.pyc similarity index 100% rename from backend/content_extractor/__pycache__/utils_preprocessing.cpython-310.pyc rename to backend/M2: Tesseract-Content Extractor/__pycache__/utils_preprocessing.cpython-310.pyc diff --git a/backend/content_extractor/content_extractor.Rproj b/backend/M2: Tesseract-Content Extractor/content_extractor.Rproj similarity index 100% rename from backend/content_extractor/content_extractor.Rproj rename to backend/M2: Tesseract-Content Extractor/content_extractor.Rproj diff --git a/backend/content_extractor/data/CE_gold_queries_EX2.txt b/backend/M2: Tesseract-Content Extractor/data/CE_gold_queries_EX2.txt similarity index 100% rename from backend/content_extractor/data/CE_gold_queries_EX2.txt rename to backend/M2: Tesseract-Content Extractor/data/CE_gold_queries_EX2.txt diff --git a/backend/content_extractor/data/example2.png b/backend/M2: Tesseract-Content Extractor/data/example2.png similarity index 100% rename from backend/content_extractor/data/example2.png rename to backend/M2: Tesseract-Content Extractor/data/example2.png diff --git a/backend/content_extractor/data/images/example1.pdf b/backend/M2: Tesseract-Content Extractor/data/images/example1.pdf similarity index 100% rename from backend/content_extractor/data/images/example1.pdf rename to backend/M2: Tesseract-Content Extractor/data/images/example1.pdf diff --git a/backend/content_extractor/data/images/example3.jpg b/backend/M2: Tesseract-Content Extractor/data/images/example3.jpg similarity index 100% rename from backend/content_extractor/data/images/example3.jpg rename to backend/M2: Tesseract-Content Extractor/data/images/example3.jpg diff --git a/backend/content_extractor/data/images/example4.jpg b/backend/M2: Tesseract-Content Extractor/data/images/example4.jpg similarity index 100% rename from backend/content_extractor/data/images/example4.jpg rename to backend/M2: Tesseract-Content Extractor/data/images/example4.jpg diff --git a/backend/content_extractor/data/images/os.getenv(_ANYSCALE_API_KEY_) - Google Suche.html b/backend/M2: Tesseract-Content Extractor/data/images/os.getenv(_ANYSCALE_API_KEY_) - Google Suche.html similarity index 100% rename from backend/content_extractor/data/images/os.getenv(_ANYSCALE_API_KEY_) - Google Suche.html rename to backend/M2: Tesseract-Content Extractor/data/images/os.getenv(_ANYSCALE_API_KEY_) - Google Suche.html diff --git a/backend/content_extractor/data_analysis.R b/backend/M2: Tesseract-Content Extractor/data_analysis.R similarity index 100% rename from backend/content_extractor/data_analysis.R rename to backend/M2: Tesseract-Content Extractor/data_analysis.R diff --git a/backend/content_extractor/evaluate.py b/backend/M2: Tesseract-Content Extractor/evaluate.py similarity index 100% rename from backend/content_extractor/evaluate.py rename to backend/M2: Tesseract-Content Extractor/evaluate.py diff --git a/backend/content_extractor/extraction.py b/backend/M2: Tesseract-Content Extractor/extraction.py similarity index 100% rename from backend/content_extractor/extraction.py rename to backend/M2: Tesseract-Content Extractor/extraction.py diff --git a/backend/content_extractor/logs/evaluate.out b/backend/M2: Tesseract-Content Extractor/logs/evaluate.out similarity index 100% rename from backend/content_extractor/logs/evaluate.out rename to backend/M2: Tesseract-Content Extractor/logs/evaluate.out diff --git a/backend/content_extractor/logs/ocr.out b/backend/M2: Tesseract-Content Extractor/logs/ocr.out similarity index 100% rename from backend/content_extractor/logs/ocr.out rename to backend/M2: Tesseract-Content Extractor/logs/ocr.out diff --git a/backend/content_extractor/logs/ocr_070724.out b/backend/M2: Tesseract-Content Extractor/logs/ocr_070724.out similarity index 100% rename from backend/content_extractor/logs/ocr_070724.out rename to backend/M2: Tesseract-Content Extractor/logs/ocr_070724.out diff --git a/backend/content_extractor/logs/postprocessing.out b/backend/M2: Tesseract-Content Extractor/logs/postprocessing.out similarity index 100% rename from backend/content_extractor/logs/postprocessing.out rename to backend/M2: Tesseract-Content Extractor/logs/postprocessing.out diff --git a/backend/content_extractor/logs/postprocessing_070724.out b/backend/M2: Tesseract-Content Extractor/logs/postprocessing_070724.out similarity index 100% rename from backend/content_extractor/logs/postprocessing_070724.out rename to backend/M2: Tesseract-Content Extractor/logs/postprocessing_070724.out diff --git a/backend/content_extractor/logs/preprocessing.out b/backend/M2: Tesseract-Content Extractor/logs/preprocessing.out similarity index 100% rename from backend/content_extractor/logs/preprocessing.out rename to backend/M2: Tesseract-Content Extractor/logs/preprocessing.out diff --git a/backend/content_extractor/logs/preprocessing_070724.out b/backend/M2: Tesseract-Content Extractor/logs/preprocessing_070724.out similarity index 100% rename from backend/content_extractor/logs/preprocessing_070724.out rename to backend/M2: Tesseract-Content Extractor/logs/preprocessing_070724.out diff --git a/backend/content_extractor/logs/testing.out b/backend/M2: Tesseract-Content Extractor/logs/testing.out similarity index 100% rename from backend/content_extractor/logs/testing.out rename to backend/M2: Tesseract-Content Extractor/logs/testing.out diff --git a/backend/content_extractor/logs/testing_070724.out b/backend/M2: Tesseract-Content Extractor/logs/testing_070724.out similarity index 100% rename from backend/content_extractor/logs/testing_070724.out rename to backend/M2: Tesseract-Content Extractor/logs/testing_070724.out diff --git a/backend/content_extractor/ocr.py b/backend/M2: Tesseract-Content Extractor/ocr.py similarity index 100% rename from backend/content_extractor/ocr.py rename to backend/M2: Tesseract-Content Extractor/ocr.py diff --git a/backend/content_extractor/postprocessing.py b/backend/M2: Tesseract-Content Extractor/postprocessing.py similarity index 100% rename from backend/content_extractor/postprocessing.py rename to backend/M2: Tesseract-Content Extractor/postprocessing.py diff --git a/backend/content_extractor/preprocessing.py b/backend/M2: Tesseract-Content Extractor/preprocessing.py similarity index 100% rename from backend/content_extractor/preprocessing.py rename to backend/M2: Tesseract-Content Extractor/preprocessing.py diff --git a/backend/content_extractor/requirements/evaluate_venv_requirements.txt b/backend/M2: Tesseract-Content Extractor/requirements/evaluate_venv_requirements.txt similarity index 100% rename from backend/content_extractor/requirements/evaluate_venv_requirements.txt rename to backend/M2: Tesseract-Content Extractor/requirements/evaluate_venv_requirements.txt diff --git a/backend/content_extractor/requirements/extraction_venv_requirements.txt b/backend/M2: Tesseract-Content Extractor/requirements/extraction_venv_requirements.txt similarity index 100% rename from backend/content_extractor/requirements/extraction_venv_requirements.txt rename to backend/M2: Tesseract-Content Extractor/requirements/extraction_venv_requirements.txt diff --git a/backend/content_extractor/requirements/ocr_venv_requirements.txt b/backend/M2: Tesseract-Content Extractor/requirements/ocr_venv_requirements.txt similarity index 100% rename from backend/content_extractor/requirements/ocr_venv_requirements.txt rename to backend/M2: Tesseract-Content Extractor/requirements/ocr_venv_requirements.txt diff --git a/backend/content_extractor/requirements/postprocessing_venv_requirements.txt b/backend/M2: Tesseract-Content Extractor/requirements/postprocessing_venv_requirements.txt similarity index 100% rename from backend/content_extractor/requirements/postprocessing_venv_requirements.txt rename to backend/M2: Tesseract-Content Extractor/requirements/postprocessing_venv_requirements.txt diff --git a/backend/content_extractor/requirements/preprocessing_venv_requirements.txt b/backend/M2: Tesseract-Content Extractor/requirements/preprocessing_venv_requirements.txt similarity index 100% rename from backend/content_extractor/requirements/preprocessing_venv_requirements.txt rename to backend/M2: Tesseract-Content Extractor/requirements/preprocessing_venv_requirements.txt diff --git a/backend/content_extractor/results/csv/evaluated.csv b/backend/M2: Tesseract-Content Extractor/results/csv/evaluated.csv similarity index 100% rename from backend/content_extractor/results/csv/evaluated.csv rename to backend/M2: Tesseract-Content Extractor/results/csv/evaluated.csv diff --git a/backend/content_extractor/results/csv/evaluation.csv b/backend/M2: Tesseract-Content Extractor/results/csv/evaluation.csv similarity index 100% rename from backend/content_extractor/results/csv/evaluation.csv rename to backend/M2: Tesseract-Content Extractor/results/csv/evaluation.csv diff --git a/backend/content_extractor/results/images/preprocessed/preprocessing_log.txt b/backend/M2: Tesseract-Content Extractor/results/images/preprocessed/preprocessing_log.txt similarity index 100% rename from backend/content_extractor/results/images/preprocessed/preprocessing_log.txt rename to backend/M2: Tesseract-Content Extractor/results/images/preprocessed/preprocessing_log.txt diff --git a/backend/content_extractor/results/images/preprocessed/preprocessing_log_070724.txt b/backend/M2: Tesseract-Content Extractor/results/images/preprocessed/preprocessing_log_070724.txt similarity index 100% rename from backend/content_extractor/results/images/preprocessed/preprocessing_log_070724.txt rename to backend/M2: Tesseract-Content Extractor/results/images/preprocessed/preprocessing_log_070724.txt diff --git a/backend/content_extractor/results/txt/extracted/ocr_results_log.txt b/backend/M2: Tesseract-Content Extractor/results/txt/extracted/ocr_results_log.txt similarity index 100% rename from backend/content_extractor/results/txt/extracted/ocr_results_log.txt rename to backend/M2: Tesseract-Content Extractor/results/txt/extracted/ocr_results_log.txt diff --git a/backend/content_extractor/results/txt/extracted/ocr_results_log_070724.txt b/backend/M2: Tesseract-Content Extractor/results/txt/extracted/ocr_results_log_070724.txt similarity index 100% rename from backend/content_extractor/results/txt/extracted/ocr_results_log_070724.txt rename to backend/M2: Tesseract-Content Extractor/results/txt/extracted/ocr_results_log_070724.txt diff --git a/backend/content_extractor/test.py b/backend/M2: Tesseract-Content Extractor/test.py similarity index 100% rename from backend/content_extractor/test.py rename to backend/M2: Tesseract-Content Extractor/test.py diff --git a/backend/content_extractor/testing.sh b/backend/M2: Tesseract-Content Extractor/testing.sh similarity index 100% rename from backend/content_extractor/testing.sh rename to backend/M2: Tesseract-Content Extractor/testing.sh diff --git a/backend/content_extractor/utils_evaluate.py b/backend/M2: Tesseract-Content Extractor/utils_evaluate.py similarity index 100% rename from backend/content_extractor/utils_evaluate.py rename to backend/M2: Tesseract-Content Extractor/utils_evaluate.py diff --git a/backend/content_extractor/utils_ocr.py b/backend/M2: Tesseract-Content Extractor/utils_ocr.py similarity index 100% rename from backend/content_extractor/utils_ocr.py rename to backend/M2: Tesseract-Content Extractor/utils_ocr.py diff --git a/backend/content_extractor/utils_postprocessing.py b/backend/M2: Tesseract-Content Extractor/utils_postprocessing.py similarity index 100% rename from backend/content_extractor/utils_postprocessing.py rename to backend/M2: Tesseract-Content Extractor/utils_postprocessing.py diff --git a/backend/content_extractor/utils_preprocessing.py b/backend/M2: Tesseract-Content Extractor/utils_preprocessing.py similarity index 100% rename from backend/content_extractor/utils_preprocessing.py rename to backend/M2: Tesseract-Content Extractor/utils_preprocessing.py diff --git a/backend/content_extractor/data/json/example3_goldstandard.json b/backend/content_extractor/data/json/example3_goldstandard.json deleted file mode 100644 index 1cecde862f..0000000000 --- a/backend/content_extractor/data/json/example3_goldstandard.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "Date": "02.12.202X", - "patient_information": { - "patient_id": 555, - "patient_name": "Yash M. Patel", - "patient_sex": "Male", - "patient_age": 21 - }, - "test_results": [ - { - "test_name": "Hemoglobin (Hb)", - "result_value": 12.5, - "unit_of_measurement": "g/dL", - "reference_range": "13.0 - 17.0" - }, - { - "test_name": "RBC count", - "result_value": 5.2, - "unit_of_measurement": "mill/cumm", - "reference_range": "4.5 - 5.5" - }, - { - "test_name": "Packed Cell Volume (PCV)", - "result_value": 57.5, - "unit_of_measurement": "%", - "reference_range": "40 - 50" - }, - { - "test_name": "Mean Corpuscular Volume (MCV)", - "result_value": 87.75, - "unit_of_measurement": "fL", - "reference_range": "83 - 101" - }, - { - "test_name": "MCH", - "result_value": 27.2, - "unit_of_measurement": "pg", - "reference_range": "27 - 32" - }, - { - "test_name": "MCHC", - "result_value": 32.8, - "unit_of_measurement": "g/dL", - "reference_range": "32.5 - 34.5" - }, - { - "test_name": "RDW", - "result_value": 13.6, - "unit_of_measurement": "%", - "reference_range": "11.6 - 14.0" - }, - { - "test_name": "WBC Count", - "result_value": 9000, - "unit_of_measurement": "cumm", - "reference_range": "4000 - 11000" - }, - { - "test_name": "Neutrophils", - "result_value": 60, - "unit_of_measurement": "%", - "reference_range": "50 - 62" - }, - { - "test_name": "Lymphocytes", - "result_value": 31, - "unit_of_measurement": "%", - "reference_range": "20 - 40" - }, - { - "test_name": "Eosinophils", - "result_value": 1, - "unit_of_measurement": "%", - "reference_range": "00 - 06" - }, - { - "test_name": "Monocytes", - "result_value": 7, - "unit_of_measurement": "%", - "reference_range": "00 - 10" - }, - { - "test_name": "Basophils", - "result_value": 1, - "unit_of_measurement": "%", - "reference_range": "00 - 02" - } - ] -} \ No newline at end of file diff --git a/backend/content_extractor/data/json/example4_goldstandard.json b/backend/content_extractor/data/json/example4_goldstandard.json deleted file mode 100644 index 1cecde862f..0000000000 --- a/backend/content_extractor/data/json/example4_goldstandard.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "Date": "02.12.202X", - "patient_information": { - "patient_id": 555, - "patient_name": "Yash M. Patel", - "patient_sex": "Male", - "patient_age": 21 - }, - "test_results": [ - { - "test_name": "Hemoglobin (Hb)", - "result_value": 12.5, - "unit_of_measurement": "g/dL", - "reference_range": "13.0 - 17.0" - }, - { - "test_name": "RBC count", - "result_value": 5.2, - "unit_of_measurement": "mill/cumm", - "reference_range": "4.5 - 5.5" - }, - { - "test_name": "Packed Cell Volume (PCV)", - "result_value": 57.5, - "unit_of_measurement": "%", - "reference_range": "40 - 50" - }, - { - "test_name": "Mean Corpuscular Volume (MCV)", - "result_value": 87.75, - "unit_of_measurement": "fL", - "reference_range": "83 - 101" - }, - { - "test_name": "MCH", - "result_value": 27.2, - "unit_of_measurement": "pg", - "reference_range": "27 - 32" - }, - { - "test_name": "MCHC", - "result_value": 32.8, - "unit_of_measurement": "g/dL", - "reference_range": "32.5 - 34.5" - }, - { - "test_name": "RDW", - "result_value": 13.6, - "unit_of_measurement": "%", - "reference_range": "11.6 - 14.0" - }, - { - "test_name": "WBC Count", - "result_value": 9000, - "unit_of_measurement": "cumm", - "reference_range": "4000 - 11000" - }, - { - "test_name": "Neutrophils", - "result_value": 60, - "unit_of_measurement": "%", - "reference_range": "50 - 62" - }, - { - "test_name": "Lymphocytes", - "result_value": 31, - "unit_of_measurement": "%", - "reference_range": "20 - 40" - }, - { - "test_name": "Eosinophils", - "result_value": 1, - "unit_of_measurement": "%", - "reference_range": "00 - 06" - }, - { - "test_name": "Monocytes", - "result_value": 7, - "unit_of_measurement": "%", - "reference_range": "00 - 10" - }, - { - "test_name": "Basophils", - "result_value": 1, - "unit_of_measurement": "%", - "reference_range": "00 - 02" - } - ] -} \ No newline at end of file diff --git a/backend/content_extractor/results/images/preprocessed/example4_config0.tiff b/backend/content_extractor/results/images/preprocessed/example4_config0.tiff deleted file mode 100644 index b5aa2e7be8..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config0.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config1.tiff b/backend/content_extractor/results/images/preprocessed/example4_config1.tiff deleted file mode 100644 index a75235b92d..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config1.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config10.tiff b/backend/content_extractor/results/images/preprocessed/example4_config10.tiff deleted file mode 100644 index 6f54861d4b..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config10.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config11.tiff b/backend/content_extractor/results/images/preprocessed/example4_config11.tiff deleted file mode 100644 index 8925023d7f..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config11.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config12.tiff b/backend/content_extractor/results/images/preprocessed/example4_config12.tiff deleted file mode 100644 index f6dd762724..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config12.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config13.tiff b/backend/content_extractor/results/images/preprocessed/example4_config13.tiff deleted file mode 100644 index 8b6d4c3c5d..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config13.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config2.tiff b/backend/content_extractor/results/images/preprocessed/example4_config2.tiff deleted file mode 100644 index 8c5224eca0..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config2.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config3.tiff b/backend/content_extractor/results/images/preprocessed/example4_config3.tiff deleted file mode 100644 index e9f9416943..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config3.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config4.tiff b/backend/content_extractor/results/images/preprocessed/example4_config4.tiff deleted file mode 100644 index 0544b379dd..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config4.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config5.tiff b/backend/content_extractor/results/images/preprocessed/example4_config5.tiff deleted file mode 100644 index 96d94a2697..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config5.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config6.tiff b/backend/content_extractor/results/images/preprocessed/example4_config6.tiff deleted file mode 100644 index 722c008511..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config6.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config7.tiff b/backend/content_extractor/results/images/preprocessed/example4_config7.tiff deleted file mode 100644 index e9f9416943..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config7.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config8.tiff b/backend/content_extractor/results/images/preprocessed/example4_config8.tiff deleted file mode 100644 index 3be76b7a80..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config8.tiff and /dev/null differ diff --git a/backend/content_extractor/results/images/preprocessed/example4_config9.tiff b/backend/content_extractor/results/images/preprocessed/example4_config9.tiff deleted file mode 100644 index 139d1ccfd0..0000000000 Binary files a/backend/content_extractor/results/images/preprocessed/example4_config9.tiff and /dev/null differ diff --git a/backend/content_extractor/results/txt/extracted/example4_config206_PaddleOCR_Gemma7B.json b/backend/content_extractor/results/txt/extracted/example4_config206_PaddleOCR_Gemma7B.json deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/desktop_app/__init__.py b/desktop_app/__init__.py index e69de29bb2..208620ce0d 100644 --- a/desktop_app/__init__.py +++ b/desktop_app/__init__.py @@ -0,0 +1 @@ +default_app_config = 'users.apps.UsersConfig' diff --git a/desktop_app/db.sqlite3 b/desktop_app/db.sqlite3 index 0584f366a2..1db8ff8d92 100644 Binary files a/desktop_app/db.sqlite3 and b/desktop_app/db.sqlite3 differ diff --git a/desktop_app/desktop_app/__pycache__/settings.cpython-310.pyc b/desktop_app/desktop_app/__pycache__/settings.cpython-310.pyc index c1b50954a2..062f00179e 100644 Binary files a/desktop_app/desktop_app/__pycache__/settings.cpython-310.pyc and b/desktop_app/desktop_app/__pycache__/settings.cpython-310.pyc differ diff --git a/desktop_app/desktop_app/__pycache__/wsgi.cpython-310.pyc b/desktop_app/desktop_app/__pycache__/wsgi.cpython-310.pyc index edce24ab19..83ae0425d0 100644 Binary files a/desktop_app/desktop_app/__pycache__/wsgi.cpython-310.pyc and b/desktop_app/desktop_app/__pycache__/wsgi.cpython-310.pyc differ diff --git a/desktop_app/desktop_app/settings.py b/desktop_app/desktop_app/settings.py index 93df91c5b2..ff9760d0b0 100644 --- a/desktop_app/desktop_app/settings.py +++ b/desktop_app/desktop_app/settings.py @@ -84,7 +84,6 @@ } } - # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators @@ -130,3 +129,5 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +LOGIN_REDIRECT_URL = 'home' +LOGIN_URL = 'login' \ No newline at end of file diff --git a/desktop_app/ui/__pycache__/admin.cpython-310.pyc b/desktop_app/ui/__pycache__/admin.cpython-310.pyc index 419fca1ba8..711e415c26 100644 Binary files a/desktop_app/ui/__pycache__/admin.cpython-310.pyc and b/desktop_app/ui/__pycache__/admin.cpython-310.pyc differ diff --git a/desktop_app/ui/__pycache__/apps.cpython-310.pyc b/desktop_app/ui/__pycache__/apps.cpython-310.pyc index 461bcd3743..1a4481b7ab 100644 Binary files a/desktop_app/ui/__pycache__/apps.cpython-310.pyc and b/desktop_app/ui/__pycache__/apps.cpython-310.pyc differ diff --git a/desktop_app/ui/__pycache__/forms.cpython-310.pyc b/desktop_app/ui/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000000..1c4430235b Binary files /dev/null and b/desktop_app/ui/__pycache__/forms.cpython-310.pyc differ diff --git a/desktop_app/ui/__pycache__/models.cpython-310.pyc b/desktop_app/ui/__pycache__/models.cpython-310.pyc index 111de07791..18994fd642 100644 Binary files a/desktop_app/ui/__pycache__/models.cpython-310.pyc and b/desktop_app/ui/__pycache__/models.cpython-310.pyc differ diff --git a/desktop_app/ui/__pycache__/urls.cpython-310.pyc b/desktop_app/ui/__pycache__/urls.cpython-310.pyc index 0a51e8c943..4abcdf8af5 100644 Binary files a/desktop_app/ui/__pycache__/urls.cpython-310.pyc and b/desktop_app/ui/__pycache__/urls.cpython-310.pyc differ diff --git a/desktop_app/ui/__pycache__/views.cpython-310.pyc b/desktop_app/ui/__pycache__/views.cpython-310.pyc index df114c3019..cf8a1d4ead 100644 Binary files a/desktop_app/ui/__pycache__/views.cpython-310.pyc and b/desktop_app/ui/__pycache__/views.cpython-310.pyc differ diff --git a/desktop_app/ui/admin.py b/desktop_app/ui/admin.py index ea5d68b7c4..ebeab847d6 100644 --- a/desktop_app/ui/admin.py +++ b/desktop_app/ui/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin +from .models import Profile -# Register your models here. +admin.site.register(Profile) \ No newline at end of file diff --git a/desktop_app/ui/apps.py b/desktop_app/ui/apps.py index ffe083ec1b..f5e22da1b4 100644 --- a/desktop_app/ui/apps.py +++ b/desktop_app/ui/apps.py @@ -4,3 +4,9 @@ class UiConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'ui' +class UsersConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'users' + + def ready(self): + import users.signals \ No newline at end of file diff --git a/desktop_app/ui/forms.py b/desktop_app/ui/forms.py new file mode 100644 index 0000000000..576604acd3 --- /dev/null +++ b/desktop_app/ui/forms.py @@ -0,0 +1,15 @@ +from django import forms +from .models import Profile +from django.contrib.auth.models import User + +class UserForm(forms.ModelForm): + password = forms.CharField(widget=forms.PasswordInput) + + class Meta: + model = User + fields = ['username', 'password'] + +class ProfileForm(forms.ModelForm): + class Meta: + model = Profile + fields = ['full_name', 'blood_report'] diff --git a/desktop_app/ui/migrations/0004_profile_delete_user.py b/desktop_app/ui/migrations/0004_profile_delete_user.py new file mode 100644 index 0000000000..cea8c23037 --- /dev/null +++ b/desktop_app/ui/migrations/0004_profile_delete_user.py @@ -0,0 +1,28 @@ +# Generated by Django 5.1 on 2024-08-15 09:56 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('ui', '0003_remove_user_email'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('full_name', models.CharField(max_length=100)), + ('blood_report', models.BooleanField(default=False)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.DeleteModel( + name='User', + ), + ] diff --git a/desktop_app/ui/migrations/__pycache__/0001_initial.cpython-310.pyc b/desktop_app/ui/migrations/__pycache__/0001_initial.cpython-310.pyc index e557118261..0ee7b26607 100644 Binary files a/desktop_app/ui/migrations/__pycache__/0001_initial.cpython-310.pyc and b/desktop_app/ui/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/desktop_app/ui/migrations/__pycache__/0002_remove_user_id_alter_user_user_id_alter_user_table.cpython-310.pyc b/desktop_app/ui/migrations/__pycache__/0002_remove_user_id_alter_user_user_id_alter_user_table.cpython-310.pyc index 7ed075d675..93a7062111 100644 Binary files a/desktop_app/ui/migrations/__pycache__/0002_remove_user_id_alter_user_user_id_alter_user_table.cpython-310.pyc and b/desktop_app/ui/migrations/__pycache__/0002_remove_user_id_alter_user_user_id_alter_user_table.cpython-310.pyc differ diff --git a/desktop_app/ui/migrations/__pycache__/0003_remove_user_email.cpython-310.pyc b/desktop_app/ui/migrations/__pycache__/0003_remove_user_email.cpython-310.pyc index 3d97a58ee0..6bbb989d73 100644 Binary files a/desktop_app/ui/migrations/__pycache__/0003_remove_user_email.cpython-310.pyc and b/desktop_app/ui/migrations/__pycache__/0003_remove_user_email.cpython-310.pyc differ diff --git a/desktop_app/ui/migrations/__pycache__/0004_profile_delete_user.cpython-310.pyc b/desktop_app/ui/migrations/__pycache__/0004_profile_delete_user.cpython-310.pyc new file mode 100644 index 0000000000..2b276e6ba6 Binary files /dev/null and b/desktop_app/ui/migrations/__pycache__/0004_profile_delete_user.cpython-310.pyc differ diff --git a/desktop_app/ui/migrations/__pycache__/__init__.cpython-310.pyc b/desktop_app/ui/migrations/__pycache__/__init__.cpython-310.pyc index 54121f0684..c071c409ce 100644 Binary files a/desktop_app/ui/migrations/__pycache__/__init__.cpython-310.pyc and b/desktop_app/ui/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/desktop_app/ui/models.py b/desktop_app/ui/models.py index fd029ce9db..a5881496af 100644 --- a/desktop_app/ui/models.py +++ b/desktop_app/ui/models.py @@ -1,16 +1,10 @@ from django.db import models +from django.contrib.auth.models import User +from django.db.models.signals import post_save +from django.dispatch import receiver -class User(models.Model): - user_id = models.AutoField(primary_key=True) - first_name = models.CharField(max_length=100) - last_name = models.CharField(max_length=100) - gender = models.CharField(max_length=10) - birth_date = models.IntegerField() - # email = models.EmailField(unique=True) - phone_number = models.CharField(max_length=15) - - class Meta: - db_table = 'USER' - - def __str__(self): - return self.first_name + ' ' + self.last_name +#1. Create a Profile Model +class Profile(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + full_name = models.CharField(max_length=100) + blood_report = models.BooleanField(default=False) # True = Blood Report diff --git a/desktop_app/ui/signals.py b/desktop_app/ui/signals.py new file mode 100644 index 0000000000..7e52e449ee --- /dev/null +++ b/desktop_app/ui/signals.py @@ -0,0 +1,13 @@ +from django.db.models.signals import post_save +from django.dispatch import receiver +from django.contrib.auth.models import User +from .models import Profile + +@receiver(post_save, sender=User) +def create_user_profile(sender, instance, created, **kwargs): + if created: + Profile.objects.create(user=instance) + +@receiver(post_save, sender=User) +def save_user_profile(sender, instance, **kwargs): + instance.profile.save() diff --git a/desktop_app/ui/static/ui/css/general.css b/desktop_app/ui/static/ui/css/general.css new file mode 100644 index 0000000000..faa12ff220 --- /dev/null +++ b/desktop_app/ui/static/ui/css/general.css @@ -0,0 +1,145 @@ +/* || GENERAL STYLES */ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} + +.container { + background-color: white; + padding: 200px; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + text-align: center; +} + +h1 { + margin-bottom: 20px; +} + +h2 { + margin-bottom: 20px; +} + +form { + display: flex; + flex-direction: column; + align-items: center; +} + +label { + margin-bottom: 10px; +} + +input[type="file"] { + margin-bottom: 20px; +} + +.button-container { + display: flex; + justify-content: center; /* Centers the buttons horizontally */ + gap: 10px; /* Adds space between buttons */ +} +/* Home Button */ +.home-button { + display: inline-block; + padding: 10px 20px; + color: white; + text-align: center; + text-decoration: none; + border-radius: 25px; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + transition: background-color 0.3s ease, box-shadow 0.3s ease; + font-family: 'Comic Sans MS', cursive, sans-serif; + background-color: #FF9800; /* Orange */ +} + +.home-button:hover { + background-color: #FFC107; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); +} + +/* Green Button */ +.green-button { + display: inline-block; + padding: 10px 20px; + color: white; + text-align: center; + text-decoration: none; + border-radius: 25px; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + transition: background-color 0.3s ease, box-shadow 0.3s ease; + font-family: 'Comic Sans MS', cursive, sans-serif; + background-color: #4CAF50; /* Green */ +} + +.green-button:hover { + background-color: #45A049; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); +} + +/* Red Button */ +.red-button { + display: inline-block; + padding: 10px 20px; + color: white; + text-align: center; + text-decoration: none; + border-radius: 25px; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + transition: background-color 0.3s ease, box-shadow 0.3s ease; + font-family: 'Comic Sans MS', cursive, sans-serif; + background-color: #F44336; /* Red */ +} + +.red-button:hover { + background-color: #E53935; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); +} + +/* White Button */ +.white-button { + display: inline-block; + padding: 10px 20px; /* Smaller padding for smaller size */ + color: black; + text-align: center; + text-decoration: none; + border-radius: 25px; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + transition: background-color 0.3s ease, box-shadow 0.3s ease; + font-family: 'Comic Sans MS', cursive, sans-serif; + background-color: #FFFFFF; /* White */ + border: 2px solid #000000; /* Adding a border for visibility */ +} + +.white-button:hover { + background-color: #F0F0F0; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); +} + +.upload-box { + background-color: #f9f9f9; + border: 1px solid #ccc; + padding: 20px; + border-radius: 10px; + max-width: 500px; + margin: 0 auto; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +.upload-box h5 { + margin-bottom: 20px; +} + +.upload-box form { + margin-bottom: 20px; +} \ No newline at end of file diff --git a/desktop_app/ui/static/ui/css/home.css b/desktop_app/ui/static/ui/css/home.css index b9ce00c6fe..1a7f6a152e 100644 --- a/desktop_app/ui/static/ui/css/home.css +++ b/desktop_app/ui/static/ui/css/home.css @@ -8,7 +8,6 @@ body { } .background-image { - background-image: url('background.jpg'); background-size: cover; /* Ensures the background image covers the entire element */ background-position: center; background-repeat: no-repeat; /* Prevents the background image from repeating */ diff --git a/desktop_app/ui/static/ui/css/page2_1.css b/desktop_app/ui/static/ui/css/page2_1.css deleted file mode 100644 index 3d4a5edfaa..0000000000 --- a/desktop_app/ui/static/ui/css/page2_1.css +++ /dev/null @@ -1,54 +0,0 @@ -body { - font-family: Arial, sans-serif; - background-color: #f4f4f4; - margin: 0; - padding: 0; - display: flex; - justify-content: center; - align-items: center; - height: 100vh; -} - -.container { - background-color: white; - padding: 200px; - border-radius: 5px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); - text-align: center; -} - -h1 { - margin-bottom: 20px; -} - -form { - display: flex; - flex-direction: column; - align-items: center; -} - -label { - margin-bottom: 10px; -} - -input[type="file"] { - margin-bottom: 20px; -} - -button { - background-color: #4CAF50; - color: white; - border: none; - padding: 10px 20px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 16px; - margin: 4px 2px; - cursor: pointer; - border-radius: 4px; -} - -button:hover { - background-color: #45a049; -} \ No newline at end of file diff --git a/desktop_app/ui/static/ui/images/background.jpg b/desktop_app/ui/static/ui/images/background.jpg index ef6f318df8..28464913a0 100644 Binary files a/desktop_app/ui/static/ui/images/background.jpg and b/desktop_app/ui/static/ui/images/background.jpg differ diff --git a/desktop_app/ui/static/ui/css/background.jpg b/desktop_app/ui/static/ui/images/background_PP.jpg similarity index 100% rename from desktop_app/ui/static/ui/css/background.jpg rename to desktop_app/ui/static/ui/images/background_PP.jpg diff --git a/desktop_app/ui/templates/ui/home.html b/desktop_app/ui/templates/ui/home.html index 44ff8999e0..75fab68f4e 100644 --- a/desktop_app/ui/templates/ui/home.html +++ b/desktop_app/ui/templates/ui/home.html @@ -9,9 +9,11 @@ -
+
+ Your data +
-

Welcome to PregPal

+

Welcome to HealthTalk

diff --git a/desktop_app/ui/templates/ui/login.html b/desktop_app/ui/templates/ui/login.html new file mode 100644 index 0000000000..1dff9c3c96 --- /dev/null +++ b/desktop_app/ui/templates/ui/login.html @@ -0,0 +1,22 @@ +{% load static %} + + + + + + Login + + + +
+

Login to HealthTalk

+
+ {% csrf_token %} + {{ form.as_p }} +
+ + Register +
+
+
+ diff --git a/desktop_app/ui/templates/ui/page2_1.html b/desktop_app/ui/templates/ui/page2_1.html index 52aa1fc88e..9a68ab365e 100644 --- a/desktop_app/ui/templates/ui/page2_1.html +++ b/desktop_app/ui/templates/ui/page2_1.html @@ -6,37 +6,24 @@ Upload Reports - +
- Back to Home -

Upload Reports

-
- {% csrf_token %} - - - -
- - {% if output %} -

Output:

-
{{ output|pprint }}
-
+

Upload Your Blood Report

+
+
At this time, our application only accepts blood reports. Please do not upload other report types.
+ {% csrf_token %} - - + + + - {% endif %} - - {% if error %} -

{{ error }}

- {% endif %} - - {% if sql_query %} -

SQL Query:

-
{{ sql_query }}
- {% endif %} +
+
+
diff --git a/desktop_app/ui/templates/ui/page2_2.html b/desktop_app/ui/templates/ui/page2_2.html index 30e8408fa2..cb9a9415d7 100644 --- a/desktop_app/ui/templates/ui/page2_2.html +++ b/desktop_app/ui/templates/ui/page2_2.html @@ -5,14 +5,61 @@ - Successful Upload - + Check In: Is this information correct? +
- Back to Home -

Successful Upload

-
- + {% if output %} +

Quick Check: Does the following table match your report?

- \ No newline at end of file + + + {{ output|safe }} +
+ +
+ {% csrf_token %} + +
+ + + + +
+
+ {% endif %} +
+ + diff --git a/desktop_app/ui/templates/ui/register.html b/desktop_app/ui/templates/ui/register.html new file mode 100644 index 0000000000..a205ac9e42 --- /dev/null +++ b/desktop_app/ui/templates/ui/register.html @@ -0,0 +1,32 @@ + +{% load static %} + + + + + Login + + + +
+

Complete Your Profile

+
+ {% csrf_token %} +
+ + {{user_form.username }} +
+
+
+ + {{ user_form.password }} +
+ {{ profile_form.as_p }} +
+ + Login +
+
+
+ + diff --git a/desktop_app/ui/urls.py b/desktop_app/ui/urls.py index e754e17c9a..5c86b7b1af 100644 --- a/desktop_app/ui/urls.py +++ b/desktop_app/ui/urls.py @@ -1,8 +1,12 @@ from django.urls import path from . import views +from .views import login_view, home_view, update_table + urlpatterns = [ - path('', views.home, name='home'), + path('register/', views.register, name='register'), + path('', views.login_view, name='login'), + path('home/', views.home_view, name='home'), path('page1/', views.page1_view, name='page1'), path('page2_1/', views.page2_1view, name='page2_1'), path('page2/process', views.process_reports, name='process_reports'), @@ -12,5 +16,7 @@ path('page3_3/', views.page3_3, name='page3_3'), # path('chatbot/', views.chatbot_view, name='chatbot'), path('convert_to_sql/', views.convert_to_sql, name='convert_to_sql'), + path('update_table/', views.update_table, name='update_table'), ] + diff --git a/desktop_app/ui/views.py b/desktop_app/ui/views.py index 23ec4a239d..4bf53663e3 100644 --- a/desktop_app/ui/views.py +++ b/desktop_app/ui/views.py @@ -6,7 +6,7 @@ from langchain_community.utilities.sql_database import SQLDatabase import sqlalchemy from .DB_query.helper import generate_query, generate_response, SUBCHAIN_PROMPT, FULLCHAIN_PROMPT -from .DB_query.AnyScaleLLM import AnyScaleLLM +#from .DB_query.AnyScaleLLM import AnyScaleLLM import logging from django.shortcuts import render, redirect from django.core.files.storage import FileSystemStorage @@ -16,8 +16,13 @@ from pathlib import Path from django.http import HttpResponseRedirect from django.urls import reverse +from json2html import * import tempfile import subprocess +from django.contrib.auth.decorators import login_required +from .forms import ProfileForm +from django.contrib.auth.views import LoginView + from octoai.client import OctoAI from octoai.text_gen import ChatMessage @@ -52,6 +57,75 @@ # NSFWText, threshold=0.8, validation_method="sentence", on_fail="exception" # ) +from django.shortcuts import render, redirect +from django.contrib.auth import authenticate, login +from django.contrib.auth.forms import AuthenticationForm + +def home_view(request): + return render(request, 'ui/home.html') + +from django.shortcuts import render, redirect +from django.contrib.auth import authenticate, login +from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth.models import User +from .forms import UserForm, ProfileForm + +def login_view(request): + if request.method == 'POST': + form = AuthenticationForm(request, data=request.POST) #AuthenticationForm: This form automatically checks the username and password fields. + if form.is_valid(): + username = form.cleaned_data.get('username') + password = form.cleaned_data.get('password') + # Check if the user exists in the database + user = authenticate(username=username, password=password) #authenticate(): This function verifies the credentials against the SQLite database. + if user is not None: + login(request, user) #login(): If authentication is successful, this function logs in the user and sets up the session. + return redirect('home') # Redirect to the home page after login + else: + # If the user doesn't exist or wrong credentials + form.add_error(None, "Invalid username or password.") + else: + form = AuthenticationForm() + return render(request, 'ui/login.html', {'form': form}) + +from django.shortcuts import render, redirect +from .forms import UserForm, ProfileForm +from .models import Profile +from django.db import IntegrityError + +def register(request): + if request.method == 'POST': + user_form = UserForm(request.POST) + profile_form = ProfileForm(request.POST) + + if user_form.is_valid() and profile_form.is_valid(): + try: + user = user_form.save(commit=False) + user.set_password(user.password) + user.save() + + # Check if the user already has a profile + if not Profile.objects.filter(user=user).exists(): + profile = profile_form.save(commit=False) + profile.user = user + profile.save() + else: + # Handle the case where the user already has a profile + print("Profile already exists for this user.") + + return redirect('login') # Redirect to login page after successful registration + except IntegrityError: + # Handle the exception if there's a unique constraint violation + user_form.add_error(None, "A profile for this user already exists.") + else: + print("User Form Errors:", user_form.errors) + print("Profile Form Errors:", profile_form.errors) + else: + user_form = UserForm() + profile_form = ProfileForm() + + return render(request, 'ui/register.html', {'user_form': user_form, 'profile_form': profile_form}) + #Test database connection def test_db_connection(db_uri): @@ -69,8 +143,6 @@ def test_db_connection(db_uri): logger.error(f"Database connection failed: {e}") return False -def home(request): - return render(request, 'ui/home.html') def page1_view(request): try: @@ -131,7 +203,7 @@ def process_reports(request): # ['python', '/home/leonnico/Documents/UP/Personal-Medical-Assistant/backend/content_extractor/extraction.py', # '-f', temp_file.name], ['python', '/Users/hanamcmahon-cole/Documents/Medical_assistant/Personal-Medical-Assistant/backend/content_extractor/extraction.py', - '-f', temp_file.name], + '-f', temp_file.name], capture_output=True, text=True, check=True @@ -144,14 +216,34 @@ def process_reports(request): try: json_output = json.loads(result.stdout) + html_output = json2html.convert(json = json_output) os.unlink(temp_file.name) # Delete the temporary file - return render(request, 'ui/page2_1.html', {'output': json.dumps(json_output, indent=4)}) + #todo: also transfer json output for sql update + return render(request, 'ui/page2_2.html', {'output': html_output}) + #return render(request, 'ui/page2_1.html', {'output': json.dumps(json_output, indent=4)}) except json.JSONDecodeError: print("Script did not return valid JSON. Please try again.") return render(request, 'ui/page2_1.html', {'error': "Invalid JSON output"}) return HttpResponseRedirect(reverse('upload_success')) +from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt +import json + +@csrf_exempt # Allows POST requests without CSRF token for this example; handle with caution +def update_table(request): + if request.method == 'POST': + updated_data = json.loads(request.body) + # Process the updated data (e.g., save to the database) + # Example: Save updated data to your model or perform some logic + print(updated_data) + + # Respond back to the client + return JsonResponse({'status': 'success', 'data': updated_data}) + + return JsonResponse({'status': 'error', 'message': 'Invalid request'}, status=400) + def convert_to_sql(request): json_data = request.POST.get('json_data') if json_data: @@ -350,6 +442,18 @@ def page3_view(request): def page3_3(request): return render(request, 'ui/page3_3.html') + + +''' +def profile_setup(request): + if request.method == 'POST': + form = ProfileForm(request.POST, request.FILES, instance=request.user.profile) + if form.is_valid(): + form.save() + return redirect('home') + else: + form = ProfileForm(instance=request.user.profile) + return render(request, 'profile_setup.html', {'form': form})''' # def page3_view(request): # if request.method == "POST": # try: