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

Setup PETL with jobs "diagnosis," "services," and "visit" #28

Merged
merged 18 commits into from
Jul 28, 2021

Conversation

mhuamani98
Copy link
Contributor

No description provided.

@mogoodrich
Copy link
Member

@MiguelAHPpih was this PR supposed to just have the PETL reports in it? It seems to have a bunch of other stuff as well.

@mhuamani98
Copy link
Contributor Author

@mogoodrich It should be only about petl, but looks like it merged with the sample-collection branch. This was unexpected.

@mogoodrich
Copy link
Member

Ah... is the sample-collection branch something we want to merge as well, or does the PR need to be reworked?

@brandones
Copy link
Contributor

You can git rebase -i origin/master to just select the commits you want to include. And then git push --force this branch (since we will have rewritten its history).

@mhuamani98
Copy link
Contributor Author

I'm going to clear any issues it has and then merge it, if that's okay with you.
PD: Have you got any errors while loading the seslab.csv file again? Because in that PR you mentioned that it happened.

@brandones
Copy link
Contributor

Sure, that's fine.

Me? I don't remember, can you link to the PR you're talking about?

@mhuamani98
Copy link
Contributor Author

I was refering to @mogoodrich , since he mentioned it in the sample-collection PR #26

@brandones
Copy link
Contributor

Oh yeah, right, we already have a PR for that, and there are a bunch of JavaScript issues we were talking about there: #26 . It would be great if we could deal with that separately from all this PETL stuff.

@brandones
Copy link
Contributor

@MiguelAHPpih If you just git rebase to get rid of the sample-collection commits, I think we can go ahead and merge this

@brandones
Copy link
Contributor

@MiguelAHPpih Now this branch is deleting files, while master is editing those same files, causing conflicts.

Instead of deleting those files, you can git checkout master [path/to/file] to reset them to whatever's in master (make sure master is up to date). Or you can git rebase -i master.

@mhuamani98
Copy link
Contributor Author

@brandones All done!. Thanks for the help

(count(encounter_type)/(WEEK(MAX(encounter_datetime)) - WEEK(MIN(encounter_datetime))+1)) as frecuencia_mes,
(count(encounter_type)/(MONTH(MAX(encounter_datetime))-MONTH(MIN(encounter_datetime))+1)) as frecuencia_mes,
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 01 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 12 AND 23 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 ) as frecuencia_tarde
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tal vez queriras excluyir 00:00 y 23:59, que son horas associadas con encuentros sin hora exacto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incluyo las 24 horas para contar todos los encuentros que se hayan hecho, ya que por motivos de red algunas citas puede que no se registren ese mismo día en que se realizo el registro y tenga que hacerlo el siguiente.
No se si eso te parece correcto.

select 'tuberculosis',(count(encounter_type))/251 as frecuencia_dia,
(count(encounter_type)/(WEEK(MAX(encounter_datetime)) - WEEK(MIN(encounter_datetime))+1)) as frecuencia_mes,
(count(encounter_type)/(MONTH(MAX(encounter_datetime))-MONTH(MIN(encounter_datetime))+1)) as frecuencia_mes,
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 01 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 01 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 00 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,

no? Para la hora despues de medianoche?

(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 01 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,
(select count(encounter_type)/251 from encounter where HOUR (encounter_datetime) BETWEEN 12 AND 23 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 ) as frecuencia_tarde
from encounter
where encounter_type=@tb_general and YEAR(encounter_datetime) = @YEAR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El calculacion que quieres es para este año del calendario?

En este caso, debes adaptar el numero de dias de trabajo (251) para ser el numero aproximo de estos dias que han pasado, no? Algo como DATEDIFF(NOW(), YEAR(NOW) + "-1-1") / 365 * 251?

O quieres calcular por los ultimos 365 dias?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Que hace el "-1-1"(puedes explicarlo en ingles para mayor precisión)?
PD: Gracias por el tip, la idea era al principio esa pero no encontré un modo de aplicarla en el momento..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YEAR(NOW) + "-1-1" debe producir 2021-1-1, la fecha.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Se supone que arroja un null en lugar de un decimal o un integer ?. Además, ejecutar YEAR (NOW) +" -1-1 ", muestra solo el año 2020 en lugar del formato de fecha completo y el año correcto. Quizás sería mejor dejarlo con "2021-01-01" por ahora.¿?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh noooo, SQL es un fracaso. Hace CONCAT(YEAR(NOW()), '-01-01')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done!

@brandones
Copy link
Contributor

@MiguelAHPpih Hay unos errores y unas preguntas.

select 'covid',(count(encounter_type))/@diaslaborales as frecuencia_dia,
(count(encounter_type)/(WEEK(MAX(encounter_datetime)) - WEEK(MIN(encounter_datetime))+1)) as frecuencia_semana,
(count(encounter_type)/(MONTH(MAX(encounter_datetime))-MONTH(MIN(encounter_datetime))+1)) as frecuencia_mes,
(select count(encounter_type)/@diaslaborales from encounter where HOUR (encounter_datetime) BETWEEN 01 AND 11 AND MINUTE (encounter_datetime) BETWEEN 00 AND 59 )as frecuencia_manana,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're still missing the hour after midnight, from 0:00 to 0:59. But you might want to just do 0:01 to 0:59 to exclude dates with no actual time associated with them.

Copy link
Contributor

@brandones brandones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @MiguelAHPpih , thanks!

@brandones brandones changed the title Peru petl Setup PETL with jobs "diagnosis," "services," and "visit" Jul 28, 2021
@brandones brandones merged commit a55712b into master Jul 28, 2021
@brandones brandones deleted the peru-petl branch July 28, 2021 00:19
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

Successfully merging this pull request may close these issues.

3 participants