Skip to content

Commit

Permalink
Merge pull request #229 from PEDSnet/issue-186-prebirth-logic-error
Browse files Browse the repository at this point in the history
comparing with date instead of datetime
  • Loading branch information
writetoritu authored Jan 17, 2018
2 parents 79472f6 + a9a4496 commit 4c8439d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Library/PreBirth.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,25 @@ applyCheck.PreBirth<- function(theObject, table_list, field_list, my_db)
field_name_1<-field_list[1]
field_name_2<-field_list[2]

check_list_entry<-get_check_entry_two_variables_diff_tables(theObject$check_code, table_name_1, field_name_1,
table_name_2, paste0("extract(date from ",field_name_2,")"))

#print(check_list_entry)
fact_tbl <- tbl(my_db, table_name_1)


patient_tbl<-tbl(my_db, table_name_2)

patient_tbl<-tbl(my_db, table_name_2) %>%
mutate(birth_date = sql('cast(birth_datetime as date)'))

#glimpse(patient_tbl)
field_name_2<-"birth_date"

df_before_dob<-as.data.frame(
select_(
filter_(inner_join(fact_tbl,patient_tbl, by =c("person_id"="person_id")),
paste0(field_name_1, '<', field_name_2))
,quote(person_id), field_name_1
))


print(nrow(df_before_dob))
if(nrow(df_before_dob)>0)
{
# create an issue
Expand Down

0 comments on commit 4c8439d

Please sign in to comment.