Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with converting to Json when using nestedAttribute when defining Cohort #106

Open
JetKinTanAccelteam opened this issue Oct 30, 2024 · 0 comments

Comments

@JetKinTanAccelteam
Copy link

This code is taken from the Cohort Definition Examples pdf, but when I try to run it it gives me an error when converting to Json. I found out that it only gives an error when nestedAttribute (such as nestedWithAny) is used

Sample code available here

code:

library(Capr)

cs0 <- cs(descendants(313217),
          name = "Atrial fibrillation")
ch <- cohort(conditionOccurrence(cs0))


afib <- cs(descendants(313217),
           name = "Atrial fibrillation")
ip <- cs(descendants(262, 9201),
         name = "Inpatient or inpatient ER visit")
op <- cs(descendants(9202, 9203),
         name = "Outpatient or ER visit")
op

ch <- cohort(
  entry = entry(
    conditionOccurrence(afib,
                        nestedWithAny(
                          atLeast(1, visit(ip), duringInterval(eventStarts(-Inf, 0), eventEnds(0, Inf))),
                          nestedWithAll(
                            atLeast(1, visit(op, duringInterval(eventStarts(-Inf, 0), eventEnds(0, Inf)),
                                             nestedWithAll(
                                               atLeast(1, conditionOccurrence(afib, duringInterval(eventStarts(7, 365)),
                                                                              nestedWithAll(
                                                                                atLeast(1, visit(op, duringInterval(eventStarts(-Inf, 0), eventEnds(0, Inf))))
                                                                              )
                                               ))
                                             )
                            ))
                          )
                        )
    )
  )
)
ch



miCohort <- compile(ch,pretty = TRUE)
outputPath <- fs::path(here::here("cohorts"), "miCohort", ext = "json")

readr::write_file(miCohort, file = outputPath)

result:

> miCohort <- compile(ch,pretty = TRUE)
Error in purrr::map():
ℹ In index: 1.
Caused by error in purrr::map()
ℹ In index: 2.
Caused by error:
! unable to find an inherited method for function collectGuid for signature "nestedAttribute"
Run rlang::last_trace() to see where the error occurred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant