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
****************************************************

# ESTRAZIONE ULTIMO E PENULTIMO LDL ## ESTRAZIONE ULTIMO E PENULTIMO LDL

BUON POMERIGGIO DOVREI ESTRARRE L'ULTIMO E IL PENULTIMO LDL CON RELATIVA DATA MODIFICANDO LA SEGUENTE QUERY CHE ESTRAE SOLTANTO L'ULTIMO (QUINDI SEMPRE LO STESSO) LDL SIA NELLA COLONNA "LDL DEGLI ULTIMI 4 MESI" CHE IN QUELLA "LDL DEGLI ULTIMI 15 MESI". INOLTRE LA ESTRAZIONE DELL'LDL DOVREBBE ESSERE ABBINATA ALLA RELATIVA STATINA PER VERIFICARE SE LA  EVENTUALE VARIAZIONE DELLA TERAPIA MODIFICA L'LDL. E' COSA POSSIBILE? GRAZIE

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

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '272%')
____dislipidemia____,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '401%')
_____ipertensione________,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '250%')
______diabete____,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '414%')
______CARD_ISCH__________,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '413%')
___ANGINA_PECT_____,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and (a.cp_code like '410%' or a.cp_code like '412%%'))
_____INFARTO_MIOCARDIO_______,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '436%')
_____ICTUS______,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '411%')
_____SINDRO_CORON___,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and (a.cp_code like '431%' or a.cp_code like '430%'))
_____EMORRAGIA_CEREBRALE______,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like 'v45.82%')
___ANGIOPLASTICA_CORONARICA____,

(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and (a.cp_code like '414.5%%' or a.cp_code like 'v45.81%'))
______BYPASS_AORTOCORONARICO____,

(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()-130 and today())____LDL_ultimo4mesi,
(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_ultimo15mesi,

(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%COLESTEROLO%'
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%' 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())____COLESTEROLO_ultimo15mesi,

(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_ultimo15mesi,

(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_ultimo15mesi,

(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA01'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____simvastatina_10___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA01'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____simvastatina_20___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA01'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____simvastatina_40____,

(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA02'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____lovastatina_20___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA02'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____lovastatina_40___,

(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA03'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____pravastatna_20___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA03'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____pravastatina_40___,

(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA04'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____fluvastatina_20___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA04'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____fluvastatina_40___,

(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA04'
and a.data_open between today()-365 and today() and right(co_des,4)like '80%')
____fluvastatina_80___,

(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA05'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____atorvastatina_10___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA05'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____atorvastatina_20___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA05'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____atorvastatina_40___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA05'
and a.data_open between today()-365 and today() and right(co_des,4)like '80%')
____atorvastatina_80___,

(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA07'
and a.data_open between today()-365 and today() and right(co_des,3)like '5%')
____rosuvastatina_5___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA07'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____rosuvastatina__10___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA07'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____rosuvastatina__20___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AA07'
and a.data_open between today()-365 and today() and right(co_des,4)like '40%')
____rosuvastatina__40___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C10AX09'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____EZETEMIBE__10___,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'inegy%%10%%10%%'
and a.data_open between today()-365 and today())___inegy_10_10__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'inegy%%10%%20%%'
and a.data_open between today()-365 and today())__inegy_10_20____,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'inegy%%10%%40%%'
and a.data_open between today()-365 and today())__inegy__10_40___,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'vytorin%%10%%10%%'
and a.data_open between today()-365 and today())___vytorin_10_10__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'vytorin%%10%%20%%'
and a.data_open between today()-365 and today())__vytorin_10_20____,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'vytorin%%10%%40%%'
and a.data_open between today()-365 and today())__vytorin__10__40__,

(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'goltor%%10%%10%%'
and a.data_open between today()-365 and today())___goltor_10_10__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'goltor%%10%%20%%'
and a.data_open between today()-365 and today())__goltor_10_20____,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'goltor%%10%%40%%'
and a.data_open between today()-365 and today())__goltor__10__40__

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 '413%' or c.cp_code like '414%' or c.cp_code like '272%'or c.cp_code like '401%' or c.cp_code like '250%' or c.cp_code like '410%' or c.cp_code like '411%'or c.cp_code like '412%' or c.cp_code like '436%' or c.cp_code like '430%' or c.cp_code like '431%' or c.cp_code like '414.5%'or c.cp_code like 'v45.81%' or c.cp_code like 'v45.82%')
and n.pa_drevoca is null
and p.decesso is null
and p.pa_convenzione not like 'I'

order by p.cognome, p.nome nanci giacinto
Membro Junior Messaggi : 126
Punti : 3136
Voti per importanza dei messaggi : -1
Data d'iscrizione : 02.03.11  Permessi di questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum