From 5a0a09a27391d667f6040b3ef7bd0a279f37816e Mon Sep 17 00:00:00 2001 From: Jay-sanjay <134289328+Jay-sanjay@users.noreply.github.com> Date: Sun, 12 Nov 2023 04:31:11 +0530 Subject: [PATCH] renamed to GetDrugExposureIDs (#63) * renamed to GetDrugExposureIDs * Updated changelog for new changes * Updated docstring for Drug Exposures --------- Co-authored-by: TheCedarPrince --- CHANGELOG.md | 6 ++++++ docs/src/api.md | 2 +- src/getters.jl | 20 ++++++++++---------- test/sqlite/getters.jl | 12 ++++++------ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d2b2d5..7e44f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +- Misc + + * Changed GetDrugExposures to GetDrugExposureIDs + ## [0.3.0] - August 25th, 2023 New minor release to introduce some new functionalities and novel extensions of the API diff --git a/docs/src/api.md b/docs/src/api.md index d41959d..72546f8 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -24,7 +24,7 @@ GetMostRecentConditions GetMostRecentVisit GetVisitCondition GetDatabaseYearRange -GetDrugExposure +GetDrugExposureIDs GetDrugConceptIDs GetDrugAmounts GetVisitProcedure diff --git a/src/getters.jl b/src/getters.jl index ee4397f..09fe759 100644 --- a/src/getters.jl +++ b/src/getters.jl @@ -1238,7 +1238,7 @@ function GetVisitDate( end """ -GetDrugExposures(ids, conn; tab = drug_exposure) +GetDrugExposureIDs(ids, conn; tab = drug_exposure) Given a list of person IDs, find their drug exposure. @@ -1256,26 +1256,26 @@ Given a list of person IDs, find their drug exposure. - `df::DataFrame` - a two column `DataFrame` comprised of columns: `:person_id` and `:drug_exposure_id` """ -function GetDrugExposures( +function GetDrugExposureIDs( ids, conn; tab=drug_exposure ) - df = DBInterface.execute(conn, GetDrugExposures(ids; tab=tab)) |> DataFrame + df = DBInterface.execute(conn, GetDrugExposureIDs(ids; tab=tab)) |> DataFrame return df end """ -function GetDrugExposures(df:DataFrame, conn; tab = drug_exposure) +function GetDrugExposureIDs(df:DataFrame, conn; tab = drug_exposure) Given a `DataFrame` with a `:person_id` column, return the `DataFrame` with an associated `:drug_exposure_id`for each `person_id` in the `DataFrame` -Multiple dispatch that accepts all other arguments like in `GetDrugExposures(ids, conn; tab = drug_exposure)` +Multiple dispatch that accepts all other arguments like in `GetDrugExposureIDs(ids, conn; tab = drug_exposure)` """ -function GetDrugExposures( +function GetDrugExposureIDs( df::DataFrame, conn; tab=drug_exposure @@ -1284,11 +1284,11 @@ function GetDrugExposures( df_ids= df[:,"person_id"] - return outerjoin(GetDrugExposures(df_ids, conn; tab=tab), df, on = :person_id) + return outerjoin(GetDrugExposureIDs(df_ids, conn; tab=tab), df, on = :person_id) end """ -GetDrugExposures(ids; tab = drug_exposure) +GetDrugExposureIDs(ids; tab = drug_exposure) Return SQL statement that gets the `drug_exposure_id` for a given list of `person_id`'s @@ -1305,7 +1305,7 @@ Return SQL statement that gets the `drug_exposure_id` for a given list of `perso - `df::DataFrame` - a two column `DataFrame` comprised of columns: `:person_id` and `:drug_exposure_id` """ -function GetDrugExposures( +function GetDrugExposureIDs( ids; tab=drug_exposure ) @@ -1564,4 +1564,4 @@ function GetVisitProcedure( end -export GetDatabasePersonIDs, GetPatientState, GetPatientGender, GetPatientRace, GetPatientAgeGroup, GetPatientVisits, GetMostRecentConditions, GetMostRecentVisit, GetVisitCondition, GetPatientEthnicity, GetDatabaseYearRange, GetVisitPlaceOfService, GetVisitConcept, GetVisitDate, GetDrugExposures, GetDrugConceptIDs, GetDrugAmounts, GetVisitProcedure +export GetDatabasePersonIDs, GetPatientState, GetPatientGender, GetPatientRace, GetPatientAgeGroup, GetPatientVisits, GetMostRecentConditions, GetMostRecentVisit, GetVisitCondition, GetPatientEthnicity, GetDatabaseYearRange, GetVisitPlaceOfService, GetVisitConcept, GetVisitDate, GetDrugExposureIDs, GetDrugConceptIDs, GetDrugAmounts, GetVisitProcedure diff --git a/test/sqlite/getters.jl b/test/sqlite/getters.jl index 1d96a69..8f759ea 100644 --- a/test/sqlite/getters.jl +++ b/test/sqlite/getters.jl @@ -194,7 +194,7 @@ end end -@testset "GetDrugExposures Tests" begin +@testset "GetDrugExposureIDs Tests" begin test_ids = From(OMOPCDMCohortCreator.person) |> Select(Get.person_id) |> Limit(10) |> q -> render(q, dialect = OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame @@ -203,7 +203,7 @@ end Drug_exposure_ids = test_query |> LeftJoin(drug_exposures, on = test_query.person_id.== drug_exposures.person_id) |> Select(test_query.person_id, drug_exposures.drug_exposure_id) |> q -> render(q, dialect=OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame Drug_exposure_ids = sort( Drug_exposure_ids, :person_id) - df = GetDrugExposures(test_ids, sqlite_conn) + df = GetDrugExposureIDs(test_ids, sqlite_conn) @test Drug_exposure_ids == sort(df, :person_id) end @@ -382,7 +382,7 @@ end end -@testset "GetDrugExposures multiple dispatch Tests" begin +@testset "GetDrugExposureIDs multiple dispatch Tests" begin test_ids = From(OMOPCDMCohortCreator.drug_exposure) |> Select(Get.person_id) |> Limit(1) |> q -> render(q, dialect = OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame test_query = From(OMOPCDMCohortCreator.drug_exposure) |> Select(Get.drug_exposure_id, Get.person_id) |> Where(Get.person_id .== 573.0) @@ -390,7 +390,7 @@ end Drug_exposure_genders = test_query |> LeftJoin(genders, on = test_query.person_id.== genders.person_id) |> Select(genders.person_id, test_query.drug_exposure_id, genders.gender_concept_id) |> q -> render(q, dialect=OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame - @test Drug_exposure_genders == GetDrugExposures(GetPatientGender(test_ids, sqlite_conn), sqlite_conn) + @test Drug_exposure_genders == GetDrugExposureIDs(GetPatientGender(test_ids, sqlite_conn), sqlite_conn) end @@ -399,7 +399,7 @@ end drug_exposure_ids = From(OMOPCDMCohortCreator.drug_exposure) |> Select(Get.drug_exposure_id, Get.person_id) |> Where(Get.person_id .== 573.0) |> q -> render(q, dialect = OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame - @test GetDrugConceptIDs(drug_exposure_ids, sqlite_conn) == GetDrugConceptIDs(GetDrugExposures(test_ids, sqlite_conn), sqlite_conn) + @test GetDrugConceptIDs(drug_exposure_ids, sqlite_conn) == GetDrugConceptIDs(GetDrugExposureIDs(test_ids, sqlite_conn), sqlite_conn) end @@ -429,7 +429,7 @@ This test is blocked as there is no amount_value in eunomia, Looking at the http drug_conceptIDs_exposures = GetDrugConceptIDs(From(OMOPCDMCohortCreator.drug_exposure) |> Select( Get.drug_exposure_id, Get.person_id)|> Where(Get.person_id .== 573.0) |> q -> render(q, dialect = OMOPCDMCohortCreator.dialect) |> q -> DBInterface.execute(sqlite_conn, q) |> DataFrame,sqlite_conn) - @test GetDrugAmounts(drug_conceptIDs_exposures, sqlite_conn) == GetDrugAmounts(GetDrugConceptIDs(GetDrugExposures(test_ids,sqlite_conn),sqlite_conn), sqlite_conn) + @test GetDrugAmounts(drug_conceptIDs_exposures, sqlite_conn) == GetDrugAmounts(GetDrugConceptIDs(GetDrugExposureIDs(test_ids,sqlite_conn),sqlite_conn), sqlite_conn) end """