Skip to content

Commit

Permalink
Fix failure on export of empty reports
Browse files Browse the repository at this point in the history
  • Loading branch information
Gennadiy Anisimov committed Oct 9, 2023
1 parent 7ba3926 commit dec19dc
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion R/exportToAres.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ generateAOProcedureReports <- function(connectionDetails, proceduresData, cdmDat
dataAgeAtFirstOccurrence <- DatabaseConnector::querySql(conn,queryAgeAtFirstOccurrence)
dataProcedureFrequencyDistribution <- DatabaseConnector::querySql(conn,queryProcedureFrequencyDistribution)

if (nrow(proceduresData) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(proceduresData$CONCEPT_ID),
CDM_TABLE_NAME = "PROCEDURE_OCCURRENCE"
Expand Down Expand Up @@ -483,7 +486,10 @@ generateAOVisitReports <- function(connectionDetails, cdmDatabaseSchema, results
dataPrevalenceByMonth <- DatabaseConnector::querySql(conn,queryPrevalenceByMonth)
dataVisitDurationByType <- DatabaseConnector::querySql(conn,queryVisitDurationByType)
dataAgeAtFirstOccurrence <- DatabaseConnector::querySql(conn,queryAgeAtFirstOccurrence)


if (nrow(dataVisits) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataVisits$CONCEPT_ID),
CDM_TABLE_NAME = "VISIT_OCCURRENCE"
Expand Down Expand Up @@ -617,6 +623,9 @@ generateAOVisitDetailReports <- function(connectionDetails, cdmDatabaseSchema, r
dataVisitDetailDurationByType <- DatabaseConnector::querySql(conn,queryVisitDetailDurationByType)
dataAgeAtFirstOccurrence <- DatabaseConnector::querySql(conn,queryAgeAtFirstOccurrence)

if (nrow(dataVisitDetails) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataVisitDetails$CONCEPT_ID),
CDM_TABLE_NAME = "VISIT_DETAIL"
Expand Down Expand Up @@ -759,6 +768,9 @@ generateAOObservationReports <- function(connectionDetails, observationsData, cd
dataAgeAtFirstOccurrence <- DatabaseConnector::querySql(conn,queryAgeAtFirstOccurrence)
dataObsFrequencyDistribution <- DatabaseConnector::querySql(conn,queryObsFrequencyDistribution)

if (nrow(observationsData) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(observationsData$CONCEPT_ID),
CDM_TABLE_NAME = "OBSERVATION"
Expand Down Expand Up @@ -969,6 +981,9 @@ generateAOMeasurementReports <- function(connectionDetails, dataMeasurements, cd
dataValuesRelativeToNorm <- DatabaseConnector::querySql(conn,queryValuesRelativeToNorm)
dataFrequencyDistribution <- DatabaseConnector::querySql(conn,queryFrequencyDistribution)

if (nrow(dataPrevalenceByMonth) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataPrevalenceByMonth$CONCEPT_ID),
CDM_TABLE_NAME = "MEASUREMENT"
Expand Down Expand Up @@ -1138,6 +1153,9 @@ generateAODrugEraReports <- function(connectionDetails, dataDrugEra, cdmDatabase
dataPrevalenceByMonth <- DatabaseConnector::querySql(conn,queryPrevalenceByMonth)
dataLengthOfEra <- DatabaseConnector::querySql(conn,queryLengthOfEra)

if (nrow(dataDrugEra) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataDrugEra$CONCEPT_ID),
CDM_TABLE_NAME = "DRUG_ERA"
Expand Down Expand Up @@ -1289,6 +1307,9 @@ generateAODrugReports <- function(connectionDetails, dataDrugs, cdmDatabaseSchem
dataRefillsDistribution <- DatabaseConnector::querySql(conn,queryRefillsDistribution)
dataDrugFrequencyDistribution <- DatabaseConnector::querySql(conn,queryDrugFrequencyDistribution)

if (nrow(dataPrevalenceByMonth) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataPrevalenceByMonth$CONCEPT_ID),
CDM_TABLE_NAME = "DRUG_EXPOSURE"
Expand Down Expand Up @@ -1449,6 +1470,9 @@ generateAODeviceReports <- function(connectionDetails, dataDevices, cdmDatabaseS
dataPrevalenceByMonth <- DatabaseConnector::querySql(conn,queryPrevalenceByMonth)
dataDeviceFrequencyDistribution <- DatabaseConnector::querySql(conn,queryDeviceFrequencyDistribution)

if (nrow(dataDevices) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataDevices$CONCEPT_ID),
CDM_TABLE_NAME = "DEVICE_EXPOSURE"
Expand Down Expand Up @@ -1580,6 +1604,9 @@ generateAOConditionReports <- function(connectionDetails, dataConditions, cdmDat
dataConditionsByType <- DatabaseConnector::querySql(conn,queryConditionsByType)
dataAgeAtFirstDiagnosis <- DatabaseConnector::querySql(conn,queryAgeAtFirstDiagnosis)

if (nrow(dataPrevalenceByMonth) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataPrevalenceByMonth$CONCEPT_ID),
CDM_TABLE_NAME = "CONDITION_OCCURRENCE"
Expand Down Expand Up @@ -1703,6 +1730,9 @@ generateAOConditionEraReports <- function(connectionDetails, dataConditionEra, c
dataLengthOfEra <- DatabaseConnector::querySql(conn, queryLengthOfEra)
dataAgeAtFirstDiagnosis <- DatabaseConnector::querySql(conn, queryAgeAtFirstDiagnosis)

if (nrow(dataConditionEra) == 0) {
return()
}
uniqueConcepts <- data.frame(
CONCEPT_ID = unique(dataConditionEra$CONCEPT_ID),
CDM_TABLE_NAME = "CONDITION_ERA"
Expand Down

0 comments on commit dec19dc

Please sign in to comment.