Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ done
# determine the number of processing units available
CORES="$(nproc --all)"
# if CORES > 1 compile in parallel where possible
([[ -n "$CORES" ]] && cmake --build . -j"$CORES") || cmake --build .
([[ (-n "$CORES") && ("$CORES" -gt "2") ]] && cmake --build . -j"$(( CORES - 2 ))") || cmake --build .
)
)
# run tests, if they built properly
Expand Down
37 changes: 26 additions & 11 deletions src/event/Linking.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
////////////////////////////////////////////////////////////////////////////////
// File: Linking.cpp //
// Project: HEPCESimulationv2 //
// Project: event //
// Created: 2023-08-14 //
// Author: Matthew Carroll //
// ----- //
// Last Modified: 2025-03-10 //
// Modified By: Dimitri Baptiste //
// Last Modified: Mon Mar 10 2025 //
// Modified By: Matthew Carroll //
// ----- //
// Copyright (c) 2023-2025 Syndemics Lab at Boston Medical Center //
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -41,8 +41,23 @@ class Linking::LinkingIMPL {
(*((linkmap_t *)storage))[tup] = Utils::stod_positive(data[4]);
return 0;
}
std::string LinkSQL(std::string const column) const {
return "SELECT age_years, gender, drug_behavior, pregnancy, " + column +

std::string
LinkSQL(std::string const column,
std::shared_ptr<datamanagement::DataManagerBase> dm) const {
std::string data;
dm->GetFromConfig("simulation.events", data);
std::vector<std::string> event_list =
Utils::split2vecT<std::string>(data, ',');

if (std::find(event_list.begin(), event_list.end(), "pregnancy") !=
event_list.end()) {

return "SELECT age_years, gender, drug_behavior, pregnancy, " +
column + " FROM screening_and_linkage;";
}

return "SELECT age_years, gender, drug_behavior, -1, " + column +
" FROM screening_and_linkage;";
}

Expand Down Expand Up @@ -167,9 +182,9 @@ class Linking::LinkingIMPL {
}

std::string error;
rc = dm->SelectCustomCallback(LinkSQL("background_link_probability"),
this->callback_link,
&background_link_data, error);
rc = dm->SelectCustomCallback(
LinkSQL("background_link_probability", dm), this->callback_link,
&background_link_data, error);
if (rc != 0) {
spdlog::get("main")->error(
"Error extracting Background Linking Data from "
Expand All @@ -178,9 +193,9 @@ class Linking::LinkingIMPL {
error);
}

rc = dm->SelectCustomCallback(LinkSQL("intervention_link_probability"),
this->callback_link,
&intervention_link_data, error);
rc = dm->SelectCustomCallback(
LinkSQL("intervention_link_probability", dm), this->callback_link,
&intervention_link_data, error);
if (rc != 0) {
spdlog::get("main")->error(
"Error extracting Intervention Linking Data from "
Expand Down
18 changes: 14 additions & 4 deletions tests/src/eventtests/LinkingTest.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
////////////////////////////////////////////////////////////////////////////////
// File: LinkingTest.cpp //
// Project: HEPCESimulationv2 //
// Project: eventtests //
// Created: 2025-01-06 //
// Author: Matthew Carroll //
// ----- //
// Last Modified: 2025-03-10 //
// Modified By: Dimitri Baptiste //
// Last Modified: Mon Mar 10 2025 //
// Modified By: Matthew Carroll //
// ----- //
// Copyright (c) 2025 Syndemics Lab at Boston Medical Center //
////////////////////////////////////////////////////////////////////////////////
Expand All @@ -22,11 +22,21 @@ using ::testing::SetArgReferee;
class LinkingTest : public EventTest {};

std::string const BACKGROUND_LINK_QUERY =
"SELECT age_years, gender, drug_behavior, pregnancy, "
"SELECT age_years, gender, drug_behavior, -1, "
"background_link_probability FROM "
"screening_and_linkage;";

std::string const INTERVENTION_LINK_QUERY =
"SELECT age_years, gender, drug_behavior, -1, "
"intervention_link_probability FROM "
"screening_and_linkage;";

std::string const P_BACKGROUND_LINK_QUERY =
"SELECT age_years, gender, drug_behavior, pregnancy, "
"background_link_probability FROM "
"screening_and_linkage;";

std::string const P_INTERVENTION_LINK_QUERY =
"SELECT age_years, gender, drug_behavior, pregnancy, "
"intervention_link_probability FROM "
"screening_and_linkage;";
Expand Down