@@ -514,8 +514,7 @@ getRelevantRecords <- function(cdm,
514514 .env $ standardConceptIdName [[1 ]],
515515 .env $ sourceConceptIdName [[1 ]],
516516 .env $ sourceConceptValueName [[1 ]],
517- .env $ typeConceptIdName [[1 ]]) | >
518- dplyr :: mutate(table = !! omopgenerics :: tableName(cdm [[tableName [[1 ]]]]))
517+ .env $ typeConceptIdName [[1 ]])
519518 if (! is.null(cohortTable )){
520519 # keep only records of those in the cohorts of interest
521520 if (timing == " entry" ){
@@ -529,11 +528,10 @@ getRelevantRecords <- function(cdm,
529528 dplyr :: inner_join(cohortSubjects ,
530529 by = " person_id" )
531530 }
531+ codeRecords <- codeRecords | >
532+ dplyr :: compute(name = tmpTblName1 )
532533 }
533534
534- codeRecords <- codeRecords | >
535- dplyr :: compute(name = tmpTblName1 )
536-
537535 if (is.null(codeRecords )){
538536 return (NULL )
539537 }
@@ -549,26 +547,19 @@ getRelevantRecords <- function(cdm,
549547 temporary = FALSE )
550548 codeRecords <- codeRecords | >
551549 dplyr :: mutate(start_date = !! dplyr :: sym(startDateName [[1 ]]),
552- end_date = !! dplyr :: sym( endDateName [[ 1 ]])) | >
553- dplyr :: mutate( year = clock :: get_year( .data $ start_date ) ) | >
550+ table = !! omopgenerics :: tableName( cdm [[ tableName [[ 1 ]]]])
551+ ) | >
554552 dplyr :: select(dplyr :: all_of(c(" person_id" ,
555553 standardConceptIdName [[1 ]],
556554 sourceConceptIdName [[1 ]],
557555 sourceConceptValueName [[1 ]],
558556 typeConceptIdName [[1 ]],
559557 " table" ,
560- " start_date" , " end_date " , " year " ))) | >
558+ " start_date" ))) | >
561559 dplyr :: rename(" standard_concept_id" = .env $ standardConceptIdName [[1 ]],
562560 " source_concept_id" = .env $ sourceConceptIdName [[1 ]],
563561 " source_concept_value" = .env $ sourceConceptValueName [[1 ]],
564- " type_concept_id" = .env $ typeConceptIdName [[1 ]]) | >
565- dplyr :: compute(
566- name = paste0(intermediateTable ," _grr" ),
567- temporary = FALSE ,
568- schema = attr(cdm , " write_schema" ),
569- overwrite = TRUE ,
570- logPrefix = " CodelistGenerator.getRelevantRecords_join"
571- )
562+ " type_concept_id" = .env $ typeConceptIdName [[1 ]])
572563
573564 if (isTRUE(useSourceCodes )){
574565 codeRecords <- codeRecords | >
@@ -626,25 +617,21 @@ getRelevantRecords <- function(cdm,
626617 dplyr :: select(" concept_id" , " domain_id" ),
627618 overwrite = TRUE ,
628619 temporary = FALSE )
620+
629621 workingRecords <- workingRecords | >
630- dplyr :: mutate(start_date = !! dplyr :: sym(startDateName [[i + 1 ]])) | >
631- dplyr :: mutate( year = clock :: get_year( .data $ start_date ),
632- table = !! omopgenerics :: tableName( cdm [[ tableName [[ 1 ]]]]) ) | >
622+ dplyr :: mutate(start_date = !! dplyr :: sym(startDateName [[i + 1 ]]),
623+ table = !! omopgenerics :: tableName( cdm [[ tableName [[ i + 1 ]]]])
624+ ) | >
633625 dplyr :: select(dplyr :: all_of(c(" person_id" ,
634626 standardConceptIdName [[i + 1 ]],
635627 sourceConceptIdName [[i + 1 ]],
628+ sourceConceptValueName [[i + 1 ]],
636629 typeConceptIdName [[i + 1 ]],
637- " start_date " , " year " ))) | >
630+ " table " , " start_date " ))) | >
638631 dplyr :: rename(" standard_concept_id" = .env $ standardConceptIdName [[i + 1 ]],
639632 " source_concept_id" = .env $ sourceConceptIdName [[i + 1 ]],
640- " type_concept_id" = .env $ typeConceptIdName [[i + 1 ]]) | >
641- dplyr :: compute(
642- name = paste0(intermediateTable ," _grr1" ),
643- temporary = FALSE ,
644- schema = attr(cdm , " write_schema" ),
645- overwrite = TRUE ,
646- logPrefix = " CodelistGenerator.getRelevantRecords_join1"
647- )
633+ " source_concept_value" = .env $ sourceConceptValueName [[i + 1 ]],
634+ " type_concept_id" = .env $ typeConceptIdName [[i + 1 ]])
648635
649636 if (isTRUE(useSourceCodes )){
650637 workingRecords <- workingRecords | >
@@ -817,6 +804,11 @@ getSummaryCounts <- function(records,
817804 personSummary <- dplyr :: tibble()
818805 }
819806
807+ if (byYear == TRUE ) {
808+ records <- records | >
809+ dplyr :: mutate(year = clock :: get_year(.data $ start_date ))
810+ }
811+
820812 if (" record" %in% countBy & byYear == TRUE ) {
821813 recordSummary <- dplyr :: bind_rows(
822814 recordSummary ,
0 commit comments