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

Heracles 109 Number of persons with continuous observation in each year #318

Closed
gowthamrao opened this issue Feb 13, 2018 · 0 comments · Fixed by #695
Closed

Heracles 109 Number of persons with continuous observation in each year #318

gowthamrao opened this issue Feb 13, 2018 · 0 comments · Fixed by #695
Assignees
Labels

Comments

@gowthamrao
Copy link
Member

gowthamrao commented Feb 13, 2018

DATEFROMPARTS(YEAR(observation_period_start_date),1,1) as obs_year_start,

-- 109 Number of persons with continuous observation in each year

What we want is all the possible calendar years between min(observation_period_start_date) and max(observation_period_end_date) for the population in cohort.

All this SQL seems to be doing is

  SELECT DISTINCT 
  YEAR(observation_period_start_date) AS obs_year,
	DATEFROMPARTS(YEAR(observation_period_start_date),1,1) as obs_year_start,
	DATEFROMPARTS(YEAR(observation_period_start_date),12,31) as obs_year_end
  INTO
  #temp_dates_1
  from @CDM_schema.PERSON p1
  inner join (select subject_id, cohort_definition_id as cohort_definition_id from @results_schema.COHORT where cohort_definition_id in (@cohort_definition_id)) c1
  on p1.person_id = c1.subject_id
  inner join
  @CDM_schema.observation_period op1
  on p1.person_id = op1.person_id
  ;

creating a list of unique calendar years corresponding to observation_period_start_date for any person in the cohort. This approach will skip some calendar years, if the observation_periods pans across years.

One approach is to do something like this for all dates between min(observation_period_start_date) and max(observation_period_start_date)

https://stackoverflow.com/questions/21425546/how-to-generate-a-range-of-numbers-between-two-numbers
where the low number is min(year(observation_period_start_date)) and high number is max(year(observation_period_start_date))

Same applies to Heracles 110, 116, 117,

@gowthamrao gowthamrao changed the title 109 Number of persons with continuous observation in each year Heracles 109 Number of persons with continuous observation in each year Feb 13, 2018
@pavgra pavgra added the bug label Nov 12, 2018
@pavgra pavgra added this to the V2.7.0. "Bug free" milestone Nov 12, 2018
@wivern wivern self-assigned this Nov 14, 2018
@wivern wivern closed this as completed Nov 14, 2018
@wivern wivern reopened this Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants