From 503f16b117a37ed44a11cc33a52be8aa7e9f91c0 Mon Sep 17 00:00:00 2001 From: erikperfalk Date: Tue, 18 Apr 2023 09:17:19 +0200 Subject: [PATCH 1/8] Fixed load_cancelled and added data_loader --- .../loaders/raw/load_lab_results.py | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/psycop_feature_generation/loaders/raw/load_lab_results.py b/src/psycop_feature_generation/loaders/raw/load_lab_results.py index 413121b3..6f6bb959 100644 --- a/src/psycop_feature_generation/loaders/raw/load_lab_results.py +++ b/src/psycop_feature_generation/loaders/raw/load_lab_results.py @@ -123,7 +123,7 @@ def load_cancelled( else: npu_where = f"npukode = '{blood_sample_id}'" - sql = f"SELECT {cols} FROM [fct].{view} {npu_where} AND datotid_sidstesvar IS NOT NULL AND Svar == 'Aflyst' AND (left(Svar,1) == '>' OR left(Svar, 1) == '<')" + sql = f"SELECT {cols} FROM [fct].{view} WHERE {npu_where} AND datotid_sidstesvar IS NOT NULL AND Svar = 'Aflyst'" df = sql_load( sql, @@ -753,3 +753,46 @@ def p_ethanol( n_rows=n_rows, values_to_load=values_to_load, ) + + +@data_loaders.register("cancelled_standard_lab_results") +def cancelled_standard_lab_results( + n_rows: int | None = None, + values_to_load: str = "cancelled", +) -> pd.DataFrame: + """Cancelled lab results for some standard lab results: HbA1c, triglycerides, HDL, LDL, ALAT, ASAT, + lymphocytes, leukocytes, crp, creatinine, egfr, albumine-creatinine-ratio, hæmoglobin, natrium, kalium, + calcium, trombocytter, d-vitamin, tsh, b12""" + return blood_sample( + blood_sample_id=[ + "NPU27300", + "AAB00093", + "NPU04094", + "NPU01567", + "NPU01568", + "AAB00101", + "NPU19651", + "NPU19654", + "NPU02636", + "NPU02593", + "NPU19748", + "NPU18016", + "ASS00355", + "ASS00354", + "DNK35302", + "DNK35131", + "AAB00345", + "AAB00343", + "NPU19661", + "NPU02319", + "NPU03429", + "NPU03230", + "NPU01443", + "NPU03568", + "NPU10267", + "NPU03577", + "NPU01700", + ], + n_rows=n_rows, + values_to_load=values_to_load, + ) From 0acf37aaa411d999736d95bf245cde63040e0188 Mon Sep 17 00:00:00 2001 From: erikperfalk Date: Tue, 18 Apr 2023 09:18:09 +0200 Subject: [PATCH 2/8] added example for load_lab_results --- .../loaders/example/load_lab_results.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/psycop_feature_generation/loaders/example/load_lab_results.py diff --git a/src/psycop_feature_generation/loaders/example/load_lab_results.py b/src/psycop_feature_generation/loaders/example/load_lab_results.py new file mode 100644 index 00000000..3007a601 --- /dev/null +++ b/src/psycop_feature_generation/loaders/example/load_lab_results.py @@ -0,0 +1,6 @@ +"""Example of loading lab results.""" + +import psycop_feature_generation.loaders.raw.load_lab_results as lb + +if __name__ == "__main__": + df = lb.cancelled_standard_lab_results(n_rows=5000) From 2649723039fd8f2bcac16332672a09d0216fff37 Mon Sep 17 00:00:00 2001 From: sarakolding Date: Tue, 18 Apr 2023 15:47:56 +0200 Subject: [PATCH 3/8] remame text column to value --- src/psycop_feature_generation/loaders/raw/load_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psycop_feature_generation/loaders/raw/load_text.py b/src/psycop_feature_generation/loaders/raw/load_text.py index a545b4e2..ab6d19e6 100644 --- a/src/psycop_feature_generation/loaders/raw/load_text.py +++ b/src/psycop_feature_generation/loaders/raw/load_text.py @@ -121,7 +121,7 @@ def load_text_sfis( df = pd.concat(dfs) df = df.rename( - {"datotid_senest_aendret_i_sfien": "timestamp", "fritekst": "text"}, + {"datotid_senest_aendret_i_sfien": "timestamp", "fritekst": "value"}, axis=1, ) return df From cbf5893046081eb9d32ece3e688e721d207f0037 Mon Sep 17 00:00:00 2001 From: erikperfalk Date: Wed, 19 Apr 2023 08:37:28 +0200 Subject: [PATCH 4/8] added # comments after lab_results --- .../loaders/raw/load_lab_results.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/psycop_feature_generation/loaders/raw/load_lab_results.py b/src/psycop_feature_generation/loaders/raw/load_lab_results.py index 6f6bb959..7f4add77 100644 --- a/src/psycop_feature_generation/loaders/raw/load_lab_results.py +++ b/src/psycop_feature_generation/loaders/raw/load_lab_results.py @@ -761,37 +761,37 @@ def cancelled_standard_lab_results( values_to_load: str = "cancelled", ) -> pd.DataFrame: """Cancelled lab results for some standard lab results: HbA1c, triglycerides, HDL, LDL, ALAT, ASAT, - lymphocytes, leukocytes, crp, creatinine, egfr, albumine-creatinine-ratio, hæmoglobin, natrium, kalium, - calcium, trombocytter, d-vitamin, tsh, b12""" + lymphocytes, leukocytes, crp, creatinine, egfr, albumine-creatinine-ratio, haemoglobin, natrium, kalium, + calcium, trombocytes, d-vitamin, tsh, b12-vitamin""" return blood_sample( blood_sample_id=[ - "NPU27300", - "AAB00093", - "NPU04094", - "NPU01567", - "NPU01568", - "AAB00101", - "NPU19651", - "NPU19654", - "NPU02636", - "NPU02593", - "NPU19748", - "NPU18016", - "ASS00355", - "ASS00354", - "DNK35302", - "DNK35131", - "AAB00345", - "AAB00343", - "NPU19661", - "NPU02319", - "NPU03429", - "NPU03230", - "NPU01443", - "NPU03568", - "NPU10267", - "NPU03577", - "NPU01700", + "NPU27300", # hba1c + "AAB00093", # hba1c + "NPU04094", # triglycerides + "NPU01567", # hdl + "NPU01568", # ldl + "AAB00101", # ldl + "NPU19651", # alat + "NPU19654", # asat + "NPU02636", # lymphocytes + "NPU02593", # leukocytes + "NPU19748", # crp + "NPU18016", # creatinine + "ASS00355", # creatinine + "ASS00354", # creatinine + "DNK35302", # egfr + "DNK35131", # egfr + "AAB00345", # egfr + "AAB00343", # egfr + "NPU19661", # albumine_creatinine_ratio + "NPU02319", # haemoglobin + "NPU03429", # natrium + "NPU03230", # kalium + "NPU01443", # calcium + "NPU03568", # trombocytes + "NPU10267", # d-vitamin + "NPU03577", # tsh + "NPU01700", # b12-vitamin ], n_rows=n_rows, values_to_load=values_to_load, From e1ac5df2ec0ab01f59d042b7e0eeba02722a48a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:01:30 +0000 Subject: [PATCH 5/8] deps:(deps-dev): update wandb requirement Updates the requirements on [wandb](https://github.com/wandb/wandb) to permit the latest version. - [Release notes](https://github.com/wandb/wandb/releases) - [Changelog](https://github.com/wandb/wandb/blob/main/CHANGELOG.md) - [Commits](https://github.com/wandb/wandb/compare/v0.12.0...v0.15.0) --- updated-dependencies: - dependency-name: wandb dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f206751d..b4fb4de6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ requires-python = ">=3.9" dependencies = [ "wasabi>=0.9.1,<1.1.2", "scikit-learn>=1.1.2,<1.2.3", - "wandb>=0.12.0,<0.14.3", + "wandb>=0.12.0,<0.15.1", "deepchecks>=0.8.0,<0.12.0", "dill>=0.3.0,<0.3.7", "srsly>=2.4.4,<2.4.6", From 53addb5bd815285d91684c40d452e2bb145f67d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:10:37 +0000 Subject: [PATCH 6/8] deps:(deps-dev): update numpy requirement Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v1.23.3...v1.24.3) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b4fb4de6..2ca12093 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "psutil>=5.9.1, <6.0.0", "pandas>=1.4.0,<2.1.0", "catalogue>=2.0.0, <2.1.0", - "numpy>=1.23.3,<1.24.2", + "numpy>=1.23.3,<1.24.4", "transformers>=4.22.2, <5.0.0", "pyarrow>=9.0.0,<11.1.0", "psycopmlutils>=0.2.4,<0.12.0", From f6adac4c8469730d31bf4fde81ef482c66e96437 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:15:00 +0000 Subject: [PATCH 7/8] deps:(deps-dev): update sqlalchemy requirement Updates the requirements on [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) to permit the latest version. - [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases) - [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/main/CHANGES.rst) - [Commits](https://github.com/sqlalchemy/sqlalchemy/commits) --- updated-dependencies: - dependency-name: sqlalchemy dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2ca12093..4d27a80b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ dependencies = [ "deepchecks>=0.8.0,<0.12.0", "dill>=0.3.0,<0.3.7", "srsly>=2.4.4,<2.4.6", - "SQLAlchemy>=1.4.41, <2.0.10", + "SQLAlchemy>=1.4.41, <2.0.11", "pyodbc>=4.0.34, <4.0.40", "dask>=2022.9.0,<2023.5.0", "pydantic>=1.9.0, <1.11.0", From f216435ff21d532abaf0d53a2e65869abc2d6801 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:19:17 +0000 Subject: [PATCH 8/8] deps:(deps-dev): update docformatter requirement Updates the requirements on [docformatter](https://github.com/PyCQA/docformatter) to permit the latest version. - [Release notes](https://github.com/PyCQA/docformatter/releases) - [Changelog](https://github.com/PyCQA/docformatter/blob/master/CHANGELOG.md) - [Commits](https://github.com/PyCQA/docformatter/compare/v1.5.0...v1.6.3) --- updated-dependencies: - dependency-name: docformatter dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4d27a80b..5c0986f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ dev = [ "pylint", "ruff", "black>=22.8.0,<23.1.1", - "docformatter>=1.5.0, <1.6.1", + "docformatter>=1.5.0, <1.6.4", "pre-commit==3.2.2", "mypy==1.2.0", "pydantic"