FORUM PER UTENTI MILLEWIN
Attenzione !
Per intervenire sul forum è necessario essere registrati e connessi.

L'Amministratore

****************************************************
“Se tu hai una mela ed io ho una mela, e ce la scambiamo, alla fine tu ed io avremo sempre una mela ciascuno.
Ma se tu hai un’idea ed io ho un’idea, e ce la scambiamo, allora avremo entrambi due idee”.

George Bernard Shaw
****************************************************

Unisciti al forum, è facile e veloce

FORUM PER UTENTI MILLEWIN
Attenzione !
Per intervenire sul forum è necessario essere registrati e connessi.

L'Amministratore

****************************************************
“Se tu hai una mela ed io ho una mela, e ce la scambiamo, alla fine tu ed io avremo sempre una mela ciascuno.
Ma se tu hai un’idea ed io ho un’idea, e ce la scambiamo, allora avremo entrambi due idee”.

George Bernard Shaw
****************************************************
FORUM PER UTENTI MILLEWIN
Vuoi reagire a questo messaggio? Crea un account in pochi click o accedi per continuare.

bpco e dato fumo aggiornato

2 partecipanti

Andare in basso

bpco e dato fumo aggiornato Empty bpco e dato fumo aggiornato

Messaggio  nanci giacinto Dom 23 Nov 2014 - 22:41

Salve questa query estrae tutte le registrazioni del dato fumo per cui se un paziente che non fumava e poi ha iniziato a fumare e poi ha smesso di fumare estrae contemporaneamente "fumo no" e "fumo si" e "fumo ex". Come si fa ad estrarre in queta query soltanto l'ultimo dato fumo? E ancora, non per questa query, ma in generale, è possibile estrarre i pazienti a cui non è stato registrato nessun dato fumo? grazie

select distinct  p.cognome cognome, p.nome nome,
v.codmedico codice_medico,
days(p.nascita, today())/365 eta, p.sesso sesso,
today() data_odierna,

(select count(a.codice) from cart_accert a 
where a.codice=p.codice and a.ac_des like '%spirometria%' 
group by a.codice)  ____Tot_spirometria____,

(select count(a.codice) from cart_accert a 
where a.codice=p.codice and a.ac_des 
like '%spirometria%' 
and a.data_open between today()-455 and today() group by a.codice)  ____Tot_spirometria_15mesi___,

(select count(a.ac_val) from cart_accert a 
where a.codice=p.codice and a.ac_des 
like '%spirometria%' and a.ac_val is not null group by a.codice) 
___N_spirometria_conreferto___,

(select avg(a.ac_val) from cart_accert a where a.codice=p.codice
and a.ac_des like '%spirometria%' and
a.data_open between today()-1095 and today() 
and a.ac_val is not null group by a.codice) ______media_spirometria_3anni______, 

(select a.ac_val from cart_accert a 
where a.codice=p.codice and a.ac_des like '%spirometria%' 
and (a.ac_val is not null)
and not exists (select b.codice from cart_accert b where a.codice=b.codice and b.ac_des like '%spirometria%' and 
(b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) 
and b.ac_val is not null)
and a.data_open between today()-455 and today() ) ______VEMS_spirometria_ultima15mesi______,

(select distinct 'fumoEX' from cart_accert a 
where a.codice=p.codice and a.ac_des like 'fumo'
and (a.ac_val like 'm' or a.ac_val like 'z' 
or a.ac_val like 'e' or a.ac_val like 'f' or a.ac_val like 'u')) ____fumoEX____,

(select distinct 'fumoNO' from cart_accert a 
where a.codice=p.codice and a.ac_des like 'fumo'
and (a.ac_val like 'x' or a.ac_val like 'n')) ____fumoNO____,

(select distinct 'fumoSI' from cart_accert a 
where a.codice=p.codice and a.ac_des like 'fumo'
and (a.ac_val like 'p' or a.ac_val 
like 's' or a.ac_val like '1' or a.ac_val like '2' or a.ac_val like '3')) ____fumoSI____,

(select distinct 'si' from cart_terap a 
where a.codice=p.codice and a.co_atc like 'R03%'
and a.data_open between today()-365 and today()) ___ter_beta2_cort_ultimoanno___,

(select distinct 'si' from cart_terap a 
where a.codice=p.codice and a.co_atc like 'R03DC%'
and a.data_open between today()-365 and today()) ___ter_antileucotr_ultimoanno___,

(select distinct 'si' from cart_terap a 
where a.codice=p.codice and a.co_atc like 'R03AC02%'
and a.data_open between today()-365 and today()) ___ter_salbutamolo_ultimoanno___,

(select distinct 'si' from cart_terap a 
where a.codice=p.codice and a.co_atc like 'R03AK07%'
and a.data_open between today()-365 and today()) ___ter_formo_ste___,

(select distinct 'si' from cart_terap a 
where a.codice=p.codice and a.co_atc like 'R03AK06%'
and a.data_open between today()-365 and today()) ___ter_salme_fluti___,


(select distinct 'si' from cart_vaccini a 
where a.codice=p.codice 
and a.va_tipo like '%influenza%'
and a.data_open between today()-425 and today()) ___vaccino_influenza___,

(select distinct 'si' from cart_vaccini a 
where a.codice=p.codice 
and a.va_tipo like '%pneumococco%'
and a.data_open between today()-1885 and today()) __vaccino_pneumococco__
from pazienti p , nos_002 n, cart_pazpbl c, v_pazienti v
where p.codice=n.codice
and c.codice=n.codice
and v.codice=p.codice
and (c.cp_code like '496%' or c.cp_code like '492.1%') 
and n.pa_drevoca is null
and p.decesso is null
and p.pa_convenzione not like 'l'

order by p.cognome, p.nome
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

Messaggi : 128
Punti : 5010
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty Re: bpco e dato fumo aggiornato

Messaggio  Admin Gio 27 Nov 2014 - 11:31

Forse potrebbe esserti utile la seguente estrazione per l'ultimo dato fumo (La parte in rosso specifica solo l'ultimo dato):

Select cognome, nome,
CAST((case a.ac_val
WHEN 'O' THEN 'fumatore occasionale'
WHEN 'V' THEN 'fumatore passivo'
WHEN '1' THEN 'meno di 10 sigarette al giorno'
WHEN '2' THEN 'tra 10 e 20 sigarette al giorno'
WHEN '3' THEN 'oltre 20 sigarette al giorno'
WHEN 'X' THEN 'mai fumato e mai fumerà'
WHEN 'N' THEN 'mai fumato'
WHEN 'E' THEN 'ex fumatore da oltre 1 anno'
WHEN 'M' THEN 'ex fumatore'
WHEN 'F' THEN 'ex forte fumatore da oltre 10 anni'
WHEN 'Z' THEN 'ex forte fumatore da oltre 1 anno'
WHEN 'U' THEN 'ex forte fumatore'
WHEN 'P' THEN 'fumatore di pipa'
WHEN 'S' THEN 'fumatore di sigaro'
ELSE 'Non_Registrato' END) as char(31)) Tipo_fumatore
FROM cart_accert a , pazienti p
WHERE a.codice=p.codice AND a.ac_code like '2832' and not exists (select b.codice from cart_accert b where a.codice = b.codice and b.ac_code Like '2832' and (b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) and b.ac_val is not null)
ORDER BY 3



Per la seconda richiesta basta estrarre tutti i pazienti il cui codice non è in questa estrazione sopra riportata.
(es. Select cognome nome, ....... FROM pazienti p WHERE codice NOT IN (Select b.codice FROM cart_accert a , pazienti p WHERE a.codice=p.codice AND a.ac_code like '2832' and not exists (select b.codice from cart_accert b where a.codice = b.codice and b.ac_code Like '2832' and (b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) and b.ac_val is not null))


Naturalmente occorre adattare la sintassi al caso specifico.
Admin
Admin
Admin
Admin

Messaggi : 537
Punti : 5493
Voti per importanza dei messaggi : 89
Data d'iscrizione : 20.02.11
Località : CASERTA

https://utentimillewin.forumattivo.it

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty bpco e dato fumo aggiornato

Messaggio  nanci giacinto Sab 29 Nov 2014 - 23:02

Grazie per le query funzionano, ma come si integra la tua prima query in quella da me proposta?, a me serve l'ultimo dato fumo integrato con tutti gli altri dati estratti dalla query da me proposta. Per quanto riguarda la tua seconda query funziona bene ma estrae tutti gli assisti dell'archivio pure quelli deceduti e con revoca anche se io seleziono solo pz attivi SSN. grazie
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

Messaggi : 128
Punti : 5010
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty Re: bpco e dato fumo aggiornato

Messaggio  Admin Dom 30 Nov 2014 - 18:22

select distinct  p.cognome cognome, p.nome nome,
v.codmedico codice_medico,
days(p.nascita, today())/365 eta, p.sesso sesso,
today() data_odierna,

(select count(a.codice) from cart_accert a
where a.codice=p.codice and a.ac_des like '%spirometria%'
group by a.codice)  ____Tot_spirometria____,

(select count(a.codice) from cart_accert a
where a.codice=p.codice and a.ac_des
like '%spirometria%'
and a.data_open between today()-455 and today() group by a.codice)  ____Tot_spirometria_15mesi___,

(select count(a.ac_val) from cart_accert a
where a.codice=p.codice and a.ac_des
like '%spirometria%' and a.ac_val is not null group by a.codice)
___N_spirometria_conreferto___,

(select avg(a.ac_val) from cart_accert a where a.codice=p.codice
and a.ac_des like '%spirometria%' and
a.data_open between today()-1095 and today()
and a.ac_val is not null group by a.codice) ______media_spirometria_3anni______,

(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%spirometria%'
and (a.ac_val is not null)
and not exists (select b.codice from cart_accert b where a.codice=b.codice and b.ac_des like '%spirometria%' and
(b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid))
and b.ac_val is not null)
and a.data_open between today()-455 and today() ) ______VEMS_spirometria_ultima15mesi______,

(Select
CAST((case a.ac_val
WHEN 'O' THEN 'fumatore occasionale'
WHEN 'V' THEN 'fumatore passivo'
WHEN '1' THEN 'meno di 10 sigarette al giorno'
WHEN '2' THEN 'tra 10 e 20 sigarette al giorno'
WHEN '3' THEN 'oltre 20 sigarette al giorno'
WHEN 'X' THEN 'mai fumato e mai fumerà'
WHEN 'N' THEN 'mai fumato'
WHEN 'E' THEN 'ex fumatore da oltre 1 anno'
WHEN 'M' THEN 'ex fumatore'
WHEN 'F' THEN 'ex forte fumatore da oltre 10 anni'
WHEN 'Z' THEN 'ex forte fumatore da oltre 1 anno'
WHEN 'U' THEN 'ex forte fumatore'
WHEN 'P' THEN 'fumatore di pipa'
WHEN 'S' THEN 'fumatore di sigaro'
ELSE 'Non_Registrato' END) as char(35))
FROM cart_accert a
WHERE a.codice=p.codice AND a.ac_des like 'FUMO' and not exists (select b.codice from cart_accert b where a.codice = b.codice and b.ac_des Like 'FUMO' and (b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) and b.ac_val is not null)) _Fumo_,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc like 'R03%'
and a.data_open between today()-365 and today()) ___ter_beta2_cort_ultimoanno___,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc like 'R03DC%'
and a.data_open between today()-365 and today()) ___ter_antileucotr_ultimoanno___,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc like 'R03AC02%'
and a.data_open between today()-365 and today()) ___ter_salbutamolo_ultimoanno___,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc like 'R03AK07%'
and a.data_open between today()-365 and today()) ___ter_formo_ste___,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc like 'R03AK06%'
and a.data_open between today()-365 and today()) ___ter_salme_fluti___,


(select distinct 'si' from cart_vaccini a
where a.codice=p.codice
and a.va_tipo like '%influenza%'
and a.data_open between today()-425 and today()) ___vaccino_influenza___,

(select distinct 'si' from cart_vaccini a
where a.codice=p.codice
and a.va_tipo like '%pneumococco%'
and a.data_open between today()-1885 and today()) __vaccino_pneumococco__
from pazienti p , nos_002 n, cart_pazpbl c, v_pazienti v
where p.codice=n.codice
and c.codice=n.codice
and v.codice=p.codice
and (c.cp_code like '496%' or c.cp_code like '492.1%')
and n.pa_drevoca is null
and p.decesso is null
and p.pa_convenzione not like 'l'

order by p.cognome, p.nome

Per la seconda richiesta:
Select cognome, nome FROM pazienti p, nos_002 n  WHERE p.codice=n.codice AND (n.pa_drevoca is null OR n.pa_drevoca > Today()) and p.decesso is null
AND p.codice NOT IN (Select a.codice FROM cart_accert a , pazienti p WHERE a.codice=p.codice AND a.ac_code like '2832' and not exists (select b.codice from cart_accert b where a.codice = b.codice and b.ac_code Like '2832' and (b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) and b.ac_val is not null))
ORDER BY 1,2
Admin
Admin
Admin
Admin

Messaggi : 537
Punti : 5493
Voti per importanza dei messaggi : 89
Data d'iscrizione : 20.02.11
Località : CASERTA

https://utentimillewin.forumattivo.it

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty bpco e dato fumo aggiornato

Messaggio  nanci giacinto Lun 1 Dic 2014 - 23:31

GRAZIE LE QUERY FUNZIONANO. LA SECONDA PERO' ESTRAE ANCHE GLI ASSISTITI REGISTRATI NON SOLTANTO COME "ASSISTITO SSN" MA ANCHE QUELLI REGISTRATI COME "ASSISTITO SPECIALE, LIBERA PROFESSIONE, ALTRO" CHE NON SONO ATTIVI E SONO TANTI. HO CERCATO NELLE TABELLE MA NON HO TROVATO QUESTI CAMPI PER MODIFICARE LA TUA QUERY. SE NON C'E' MODO DI ESCLUDERLI DALLA ESTRAZIONE DOVRO' ESTRARLI A PARTE E METTERE UNA DATA DI REVOCA PER NON FARLI ESTRARRE DALLA QUERY, HO GIA' PROVATO E COSI' FUNZIONA.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

Messaggi : 128
Punti : 5010
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty Re: bpco e dato fumo aggiornato

Messaggio  Admin Mar 2 Dic 2014 - 0:10

nanci giacinto ha scritto:GRAZIE LE QUERY FUNZIONANO. LA SECONDA PERO' ESTRAE ANCHE GLI ASSISTITI REGISTRATI NON SOLTANTO COME "ASSISTITO SSN" MA ANCHE QUELLI REGISTRATI COME "ASSISTITO SPECIALE, LIBERA PROFESSIONE, ALTRO" CHE NON SONO ATTIVI E SONO TANTI. HO CERCATO NELLE TABELLE MA NON HO TROVATO QUESTI CAMPI PER MODIFICARE LA TUA QUERY. SE NON C'E' MODO DI ESCLUDERLI DALLA ESTRAZIONE DOVRO' ESTRARLI A PARTE E METTERE UNA DATA DI REVOCA PER NON FARLI ESTRARRE DALLA QUERY, HO GIA' PROVATO E COSI' FUNZIONA.

Basta aggiungere AND p.Pa_convenzione ='S'

Select cognome, nome FROM pazienti p, nos_002 n  WHERE p.codice=n.codice AND (n.pa_drevoca is null OR n.pa_drevoca > Today()) and p.decesso is null AND p.Pa_convenzione ='S'
AND p.codice NOT IN (Select a.codice FROM cart_accert a , pazienti p WHERE a.codice=p.codice AND a.ac_code like '2832' and not exists (select b.codice from cart_accert b where a.codice = b.codice and b.ac_code Like '2832' and (b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid)) and b.ac_val is not null))
ORDER BY 1,2
Admin
Admin
Admin
Admin

Messaggi : 537
Punti : 5493
Voti per importanza dei messaggi : 89
Data d'iscrizione : 20.02.11
Località : CASERTA

https://utentimillewin.forumattivo.it

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty BPCO E DATO FUMO AGGIORNATO

Messaggio  nanci giacinto Sab 6 Dic 2014 - 18:01

BUONA SERA OK PERFETTO GRAZIE
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

Messaggi : 128
Punti : 5010
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11

Torna in alto Andare in basso

bpco e dato fumo aggiornato Empty Re: bpco e dato fumo aggiornato

Messaggio  Contenuto sponsorizzato


Contenuto sponsorizzato


Torna in alto Andare in basso

Torna in alto

- Argomenti simili

 
Permessi in questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum.