Skip to content

Commit

Permalink
renamed to GetDrugExposureIDs (#63)
Browse files Browse the repository at this point in the history
* renamed to GetDrugExposureIDs

* Updated changelog for new changes

* Updated docstring for Drug Exposures

---------

Co-authored-by: TheCedarPrince <jacobszelko@gmail.com>
  • Loading branch information
Jay-sanjay and TheCedarPrince authored Nov 11, 2023
1 parent abd9f5c commit 5a0a09a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GetMostRecentConditions
GetMostRecentVisit
GetVisitCondition
GetDatabaseYearRange
GetDrugExposure
GetDrugExposureIDs
GetDrugConceptIDs
GetDrugAmounts
GetVisitProcedure
Expand Down
20 changes: 10 additions & 10 deletions src/getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
)
Expand Down Expand Up @@ -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
12 changes: 6 additions & 6 deletions test/sqlite/getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -382,15 +382,15 @@ 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)
genders = From(OMOPCDMCohortCreator.person)
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


Expand All @@ -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


Expand Down Expand Up @@ -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
"""

0 comments on commit 5a0a09a

Please sign in to comment.