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.

pz con alcuni accertamenti

2 partecipanti

Andare in basso

pz con alcuni accertamenti Empty pz con alcuni accertamenti

Messaggio  nanci giacinto Mer 13 Giu 2012 - 14:31

Salve. E' possibile estrarre gli assistiti con i seguenti accertamenti negli ultimi tre o sei mesi? accertamenti: colesterolo tot, ldl, hdl, trigliceridi, ac urico, PCRhs, glicemia, insulinemia, Hb glicata, BMI. E' altresi possibile estrarre solo gli assistiti che hanno almeno sette o sei degli accertamenti sopra elencati?. saluti e grazie Dott. Nanci Giacinto associazione MEDIASS otto medici in rete a Catanzaro.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

pz con alcuni accertamenti Empty pz con più accertamenti

Messaggio  nanci giacinto Lun 18 Giu 2012 - 11:05

Salve forse non mi ero spiegato bene. Ho trovato questa query la mia difficoltà e dire al computer di estrarre i pazienti che hanno, negli ultimi 3 o sei mesi, almeno quattro o cinque accertamenti registrati. Attualmente estrae anche i pazienti con un solo accertamento e quindi li estrae tutti. garzie saluti dott. Nanci associazione MEDIASS otto emdici in rete a Catanzaro.



select distinct p.nome nome, p.cognome cognome, indirizzo, telefono, n.pa_uslcode cod_reg,

v.codmedico codice_medico,

days(p.nascita, today())/365 eta, p.sesso sesso,

today() data_odierna,

(select a.ac_val from cart_accert a

where a.codice=p.codice

and (a.ac_des like '%creatinina%' and a.ac_des not like '%clearance%creatinina%') 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 '%creatinina%'

and b.ac_des not like '%clearance%creatinina%') 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() ) ______creatinina_ultima6mesi______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%colesterolo%totale%'

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 '%colesterolo%totale%' 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()) ______colest_tot_ultimo6mesi______,







(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%trigliceridi%'

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 '%trigliceridi%' 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()) ______trigliceridi_ultimo6mesi______,



(select count(a.ac_val) from cart_accert a

where a.codice=p.codice and a.ac_des

like '%HDL%' and

a.data_open between today()-1095 and today()

and a.ac_val is not null group by a.codice) ______N_HDL_5anni______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%HDL%'

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 '%HDL%' 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()) ______HDL_ultimo6mesi______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%LDL%'

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 '%LDL%' 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()) LDL_ultimo6mesi,



(select count(a.ac_val) from cart_accert a

where a.codice=p.codice and a.ac_des

like '%urine%esame%completo%' and

a.data_open between today()-1095 and today() group by a.codice) ______N_urine_3anni______,



(select count(a.ac_val) from cart_accert a

where a.codice=p.codice and a.ac_des

like '%potassio%' and

a.data_open between today()-1095 and today()

and a.ac_val is not null group by a.codice) ______N_potassio_3anni______,











(select avg(a.ac_val) from cart_accert a

where a.codice=p.codice

and (a.ac_des like '%glicemia%' and a.ac_des not like '%glicemia%post%prandiale%'

and a.ac_des not like '%ultima%misurazione%glicemia%') and

a.data_open between today()-1095 and today()

and a.ac_val is not null group by a.codice) ______media_glicemia_3anni______,



(select a.ac_val from cart_accert a

where a.codice=p.codice

and (a.ac_des like '%glicemia%' and a.ac_des not like '%glicemia%post%prandiale%'

and a.ac_des not like '%ultima%misurazione%glicemia%') 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 '%glicemia%' and b.ac_des not like '%glicemia%post%prandiale%' and a.ac_des not like '%ultima%misurazione%glicemia%') 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() ) ______glicemia_ultima6mesi______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%microalbuminuria%'

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 '%microalbuminuria%' 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()) ______microalb_ultimi15mesi______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%EMOGLOBINA%GLICATA%'

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 '%EMOGLOBINA%GLICATA%' 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()) ______emoglobina_glicata_ultimi12mesi______,



(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%insulina%'

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 '%insulina%' 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()) ______insulina_ultimi12mesi______,







(select avg(a.p_max) from cart_press a where a.codice=p.codice and

a.data_open between today()-455 and today()

and a.p_max is not null group by a.codice) ______media_p_max_15mesi______,

(select avg(a.p_min) from cart_press a where a.codice=p.codice and

a.data_open between today()-455 and today()

and a.p_min is not null group by a.codice) ______media_p_min_6mesi______,

(select a.p_max from cart_press a

where a.codice=p.codice

and not exists (select b.codice from cart_press b where a.codice=b.codice and

(b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid))

and a.p_max is not null)

and a.data_open between today()-180 and today()) ______p_max_ultima_6mesi______,

(select a.p_min from cart_press a

where a.codice=p.codice

and not exists (select b.codice from cart_press b where a.codice=b.codice and

(b.data_open>a.data_open or (b.data_open=a.data_open and b.rowid>a.rowid))

and a.p_min is not null)

and a.data_open between today()-180 and today()) ______p_min_ultima_6mesi______,







(select avg(a.ac_val) from cart_accert a

where a.codice=p.codice and a.ac_des like '%bmi%' and

a.data_open between today()-1095 and today()

and a.ac_val is not null group by a.codice) ______media_bmi_3anni______,

(select a.ac_val from cart_accert a

where a.codice=p.codice and a.ac_des like '%bmi%'

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 '%bmi%' 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() ) ______bmi_val_ultimo_15mesi______



from pazienti p , nos_002 n, cart_pazpbl c, v_pazienti v

where p.codice=n.codice and days(p.nascita, today())/365 between 18 and 70

and c.codice=n.codice

and v.codice=p.codice



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 : 5022
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11

Torna in alto Andare in basso

pz con alcuni accertamenti Empty pz con alcuni accertamenti

Messaggio  nanci giacinto Mer 20 Giu 2012 - 23:06

Salve. Da cosa può dipendere che la query sopraesposta funziona sugli archivi di sei degli otto medici dell'associazione e su due di essi da inesorabilmente risultato zero?. grazie saluti dott. nanci associazione MEDIASS otto medici in rete geografica a Catanzaro
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

pz con alcuni accertamenti Empty Re: pz con alcuni accertamenti

Messaggio  Cervino Gio 21 Giu 2012 - 8:09

nanci giacinto ha scritto:Salve. Da cosa può dipendere che la query sopraesposta funziona sugli archivi di sei degli otto medici dell'associazione e su due di essi da inesorabilmente risultato zero?. grazie saluti dott. nanci associazione MEDIASS otto medici in rete geografica a Catanzaro

La query estrae i dati richiesti dalle Tabelle del Mille.db ma restituisce solo i pazienti presenti nella vista Utenti ( purtoppo la Tabella Users del Mille.db è blindata per evitarne l' eventuale manipolazione ) con esclusione dei pazienti con Iscrizione a termine al SSR ; inoltre evita di dover ricorrere ad una peraltro semplicissima modifica di una delle clausole finali della query, in caso di database MultiUtente ( i due problemi sono già stati piu' volte ampiamente discussi ) .
Query con la medesima impostazione vengono usate da vari anni ( almeno 6-7 ) nella mia ASL per l' invio annuale dei report da un sempre piu' numeroso gruppo di medici ma nessuno sulla nostra mailing list ( Rete Unire Asl di Brescia ) ha mai evidenziato un problema analogo ; varie sono le ipotesi da vagliare ma avendo un Mille.db MonoUtente , non posso esserTi di grande aiuto se non proporti una piccola modifica dopo l' ultima subquery :

FROM ( pazienti p Left Outer Join nos_002 n On p.codice = n.codice ) Left Outer Join v_utenti u
On n.pa_medi = u.userid
Where codice_medico Like '%' And n.pa_medi Like '%'
And u.nome Like '%' And p.pa_convenzione = 'S'
And DateDiff ( hh, nascita, Today())/8766 Between 90 And 110
And ( n.pa_drevoca Is Null Or n.pa_drevoca > Today() Or (n.pa_drevoca > Today()-365 And n.motivo_revoca ='S' )) And p.decesso Is Null
Order By 1, 2


ogni medico deve digitare il proprio codice regionale ( almeno in parte : ad es, : And codice_medico Like '123%' ) oppure il proprio nome utente utilizzato per accedere a Millewin ( And u.nome Like 'ser%' ) in modo da differenziarsi dagli altri Utenti .

Per avere solo pazienti con almeno un risultato non nullo nelle subquery , basta aggiungere prima dell' ultima riga, la clausola :
nome colonna ( o subquery ) Non Vuota , ad. es.

( ______creatinina_ultima6mesi______ <> ' ' Or ______colest_tot_ultimo6mesi______ <> ' ' Or .... )

Un saluto da Sergio , Tomasini , Orzivecchi ( BS )

Cervino
Membro Junior
Membro Junior

Messaggi : 245
Punti : 5094
Voti per importanza dei messaggi : 22
Data d'iscrizione : 03.03.11
Età : 69
Località : Orzivecchi (BS)

Torna in alto Andare in basso

pz con alcuni accertamenti Empty pz con alcuni accertamenti

Messaggio  nanci giacinto Gio 21 Giu 2012 - 9:51

Grazie per l'aiuto, purtroppo con la tua implementazione la query mi da il seguente errore:table or view not found: correlation name 'v' not found.

Per quanto riguarda il secondo suggerimento a noi servirebbe l'estrazione solo dei pazienti che abbiano contemporaneamente più accertamenti tra quelli elencati nella query (almeno 4 o 5) e non i pazienti con uno o due acceramenti negli ultimi tre o sei mesi. grazie saluti dott. nanci
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

pz con alcuni accertamenti Empty Re: pz con alcuni accertamenti

Messaggio  Cervino Ven 22 Giu 2012 - 1:02

nanci giacinto ha scritto:Grazie per l'aiuto, purtroppo con la tua implementazione la query mi da il seguente errore:table or view not found: correlation name 'v' not found.

Per quanto riguarda il secondo suggerimento a noi servirebbe l'estrazione solo dei pazienti che abbiano contemporaneamente più accertamenti tra quelli elencati nella query (almeno 4 o 5) e non i pazienti con uno o due acceramenti negli ultimi tre o sei mesi. grazie saluti dott. nanci

Prova con una query del tipo ( il periodo considerato ad es. è di 180 gg ) :

Select Distinct u.codice_regionale As codice_medico, Cast( p.cognome As Char(16)), p.nome, p.nascita, p.sesso, p.codice_fiscale, p.provincia_nascita As prov_nascita,
(Select Cast( a.ac_val As Int) From cart_accert a Where a.codice=p.codice And ( a.ac_code Like ' 697' And a.ac_val Is Not Null ) And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice = a.codice And a1.ac_code Like ' 697' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid > a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_glicemia_,
(Select Cast( Round( a.ac_val, 0) As Int) From cart_accert a Where a.codice=p.codice And (a.ac_code Like ' 703') And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice=a.codice And a1.ac_code Like ' 703' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid>a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_HbA1c_,
(Select Cast( a.ac_val As Int) From cart_accert a Where a.codice=p.codice And a.ac_code Like ' 618' And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice = a.codice And a1.ac_code Like ' 618' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid > a.rowid)) And a1.ac_val Is Not Null) And a.data_open > Today()-180 )
_Col_Tot_,
(Select Cast( a.ac_val As Int) From cart_accert a Where a.codice = p.codice And a.ac_code Like ' 616' And a.ac_val Is Not Null And Not Exists ( Select a1.codice From cart_accert a1 Where a1.codice = a.codice And a1.ac_code Like ' 616' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid > a.rowid)) And a1.ac_val Is Not Null) And a.data_open > Today()-180 )
_HDL_,
(Select Cast( a.ac_val As Int) From cart_accert a Where a.codice=p.codice And ( a.ac_code Like ' 785' And a.ac_val Is Not Null ) And Not Exists ( Select a1.codice From cart_accert a1 Where a1.codice = a.codice And a1.ac_code Like ' 785' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid > a.rowid)) And a1.ac_val Is Not Null) And a.data_open > Today()-180 )
_trigliceridi_,
(Select Cast( a.ac_val As Dec (3,1)) From cart_accert a Where a.codice=p.codice And a.ac_code Like ' 629' And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice=a.codice And a1.ac_code Like ' 629' And (a1.data_open > a.data_open Or (a1.data_open=a.data_open And a1.rowid>a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_creatinina_,
(Select Cast( a.ac_val As Dec (3,1)) From cart_accert a Where a.codice=p.codice And ( a.ac_code Like ' 731' Or a.ac_code Like '3682' ) And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice=a.codice And ( a1.ac_code Like ' 731' Or a1.ac_code Like '3682' ) And (a1.data_open > a.data_open Or (a1.data_open=a.data_open And a1.rowid>a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_mAlb_Ur_,
(Select Max( a.ac_val) From cart_accert a Where a.codice=p.codice And a.ac_code Like '3928' And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice=a.codice And a1.ac_code Like '3928' And (a1.data_open > a.data_open Or (a1.data_open=a.data_open And a1.rowid>a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_es_urine_,
(Select Cast( a.ac_val As Dec (3,1)) From cart_accert a Where a.codice=p.codice And a.ac_code Like ' 757' And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a1.codice=a.codice And a1.ac_code Like ' 757' And (a1.data_open > a.data_open Or (a1.data_open=a.data_open And a1.rowid>a.rowid)) And a1.ac_val Is Not Null ) And a.data_open > Today()-180 )
_potassio_,
(Select Cast( a.ac_val As Dec(4,1)) From cart_accert a Where a.codice = p.codice And a.ac_code Like
'2609' And a.ac_val Is Not Null And Not Exists (Select a1.codice From cart_accert a1 Where a.codice = a1.codice And a1.ac_code Like '2609' And (a1.data_open > a.data_open Or (a1.data_open = a.data_open And a1.rowid>a.rowid)) And a1.ac_val is Not Null) And a.data_open >Today()-180 )
_Bmi_,
(Select Cast( Max( e.p_max+0) As Integer) From cart_press e Where e.codice = p.codice And e.p_max Is Not Null And Not Exists (Select e1.codice From cart_press e1 Where e1.codice = e.codice And e1.p_max Is Not Null And (e1.data_open > e.data_open Or (e1.data_open = e.data_open And e1.rowid > e.rowid))) And e.data_open > Today()-180 )
_PAS_,
(Select Cast( Max( e.p_min+0) As Integer) From cart_press e Where e.codice = p.codice And e.p_min Is Not Null And Not Exists (Select e1.codice From cart_press e1 Where e1.codice = e.codice And e1.p_min Is Not Null And (e1.data_open > e.data_open Or (e1.data_open = e.data_open And e1.rowid > e.rowid))) And e.data_open > Today()-180 )
_PAD_,
( Case When _glicemia_ > 0 Then 1 Else 0 End + Case When _HbA1c_ > 0 Then 1 Else 0 End +
Case When _Col_Tot_ > 0 Then 1 Else 0 End + Case When _HDL_ > 0 Then 1 Else 0 End ) +
( Case When _trigliceridi_ > 0 Then 1 Else 0 End + Case When _creatinina_ > 0 Then 1 Else 0 End +
Case When _mAlb_Ur_ > 0 Then 1 Else 0 End + Case When _es_urine_ Is Not Null Then 1 Else 0 End
+ Case When _potassio_ > 0 Then 1 Else 0 End + Case When _bmi_ > 0 Then 1 Else 0 End
+ Case When _pas_ > 0 Then 1 Else 0 End )
_eec_p_,
Today() As data_estrazione
FROM ( pazienti p Left Outer Join nos_002 n On p.codice = n.codice ) Left Outer Join v_utenti u
On n.pa_medi = u.userid
Where codice_medico Like '%' And n.pa_medi Like '%'
And u.nome Like '%' And p.pa_convenzione = 'S'
And DateDiff ( hh, nascita, Today())/8766 Between 0 And 110
And ( n.pa_drevoca Is Null Or n.pa_drevoca > Today() Or (n.pa_drevoca > Today()-365 And n.motivo_revoca ='S' )) And p.decesso Is Null
And _eec_p_ > 4
Order By 2, 3


Le varie clausole vanno eventualmente modificate secondo necessità .

Ti saluto , Sergio

Cervino
Membro Junior
Membro Junior

Messaggi : 245
Punti : 5094
Voti per importanza dei messaggi : 22
Data d'iscrizione : 03.03.11
Età : 69
Località : Orzivecchi (BS)

Torna in alto Andare in basso

pz con alcuni accertamenti Empty Re: pz con alcuni accertamenti

Messaggio  nanci giacinto Gio 28 Giu 2012 - 13:45

Grazie la query funziiona perfettamente sugli archivi di sei degli otto medici dell'associazione MEDIASS, su quelli di altri due da sempre risultato zero. Sicuramente sbaglio ad inserire i dati in questa parte della query che ho riprodotto qui sotto. Ho provato in tutte le maniere ma mi da sempre zero. Grazie comunque perchè il grosso del lavoro l'ho fatto con facilità.

Where codice_medico Like '%' And n.pa_medi Like '%'
And u.nome Like '%' And p.pa_convenzione = 'S'
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

pz con alcuni accertamenti Empty Re: pz con alcuni accertamenti

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.