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.

ipertensione polmonare

3 partecipanti

Andare in basso

ipertensione polmonare Empty ipertensione polmonare

Messaggio  nanci giacinto Dom 30 Apr 2017 - 22:56

buona sera ho avuto l'incarico di estrarre dal mio gruppo MEDIASS sette medici collegati in rete geografica con RRS Server quanto segue. Ho adattato una precedente query alla bisogna ma mi da "Errore di sintassi a o presso "code". La query che ho adattato è in coda alla  richiesta. 


Caro Dr. Nanci,

come da accordi Ti invio una serie di caratteristiche dei potenziali pazienti da screenare nel sospetto di ipertensione polmonare:

Sintomi registrati:

1) Sincope 

2) Dispnea da sforzo lieve (senza apparente causa etiologica)

3) Cianosi


Diagnosi registrate:

1) Diagnosi già registrata (o storia familiare) di ipertensione polmonare o ipertensione arteriosa polmonare

2) Diagnosi di embolia polmonare 

3) Diagnosi di trombosi venosa profonda

4) Diagnosi di cuore polmonare cronico

5) Diagnosi di sclerodermia/sclerosi sistemica

6) Diagnosi di Talassemia

7) Diagnosi di pregressa splenectomia

Cool Diagnosi di LES

9) Diagnosi di sindrome da anticorpi antifosfolipidi

10) Diagnosi di HIV

11) Diagnosi di interstiziopatia

12) Diagnosi di sarcoidosi

13) Diagnosi di cardiopatia congenita (DIV, DIA, PFO, etc) corretta e/o non corretta

14) nessuna diagnosi di cardiopatia ischemica rivascolarizzata e/o valvulopatia moderata-severa e/o disfunzione ventricolare sinistra e/o aritmie croniche e/o BPCO/Enfisema/Fibrosi polmonare in forme avanzate

Accertamenti registrati:

1) Ecocardiogramma con di PAPs > 37 mm Hg  (probabilità elevata con PAPs > 50 mm Hg) e/o ventricolo destro dilatato e/o arteria polmonare dilatata e/o vena cava dilatata e/o versamento pericardico

2) Spirometria (preferibilmente con DLCO) senza grave compromissione parenchimale del polmone

3) Angio-TC polmonare positiva 

4) Ipossiemia all'EGA (senza BPCO, etc)

5) Scintigrafia polmonare positiva

Terapie registrate:

1) Bosentan (Tracleer)

2) Macitentan (Opsumit)

3) Ambrisentan (Volibris)

4) Sildenafil (Revatio)

5) Tadalafil (Adcirca)

6) Riociguat (Adempas)

7) Iloprost (Ventavis)

Cool Treprostinil (Remodulin)

9) Epoprostenolo (Caripul/Flolan)

10) TAO e/o NAO (senza FA)

11) Ossigeno terapia (in soggetti giovani senza fibrosi polmonare)


Incrociando queste caratteristiche (soprattutto nei pazienti più giovani) copriamo la maggior parte delle situazioni cliniche, strumentali e terapeutiche in cui avere un sospetto di ipertensione polmonare.

Convinto che questa sia la strada giusta e innovativa per fare diagnosi precoce e corretta di una malattia mortale, Ti ringrazio anticipatamente per il Tuo supporto e resto a Tua disposizione. 

Cordiali saluti.

MIA QUERY

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 '780.2%')
____sincope____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '786.%')
____sincope____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '782.5%')
______cianosi____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '416.%%')
______ipert_polmonare_________,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '415.1%')
___embolia_____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '451.1%')
____tvp______,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '416.9%')
_____cuore_polmon_cronico____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '710.1%')
_____sclerodermia_ss__,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and  a.cp_code  '701.0%')
_____sclerodermiauno______,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '282.4%')
___talassemia____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '695.4%')
___les____,
 
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like 'v08%')
___hiv____,
(select max(a.cp_code) from cart_pazpbl a
where a.codice=p.codice and a.cp_code like '135%')
___sarcoidosi____,
 
(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%ecocardiogramma%'
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 '%ecocardiogramma%' 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())____eco_ultimo15mesi,
 
(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())____spirometria_ultimo15mesi,
 
 
(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%angiormdistrettotoracico%'
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 '%angiormdistrettotoracico%' 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())____angio_rm_distretto_toracico_ultimo15mesi,
 
 
(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%emogasanilisi%'
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 '%emogasanalisi%' 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())____emogasanalisi_ultimo15mesi,
 
(select a.ac_val from cart_accert a
where a.codice=p.codice and a.ac_des like '%scintipolmonare%'
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 '%scintipolmonare%' 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())____scinti_polmonare_ultimo15mesi,
 
 
 
 
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX01'
and a.data_open between today()-365 and today() and right(co_des,4)like '32%')
____tracleer_32___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX01'
and a.data_open between today()-365 and today() and right(co_des,4)like '125%')
____TRACLEER_125___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX01'
and a.data_open between today()-365 and today() and right(co_des,4)like '62%')
____TRACLEER_62____,
 
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX04'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____OPSUMIN_10___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX02'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____VOLIBRIS_10___,
 
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX02'
and a.data_open between today()-365 and today() and right(co_des,4)like '5%')
____VOLUBRIS_5___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='G04BE03'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____REVATIO_20___,
 
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='G04BE03'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____REVATIO_10___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='G04BE08'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____ADCIRCA_20___,
 
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX05'
and a.data_open between today()-365 and today() and right(co_des,4)like '0,5%')
____ADEMPAS_0_5___,
 
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX05'
and a.data_open between today()-365 and today() and right(co_des,4)like '1,5%')
____ADEMPAS_1_5___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='C02KX08'
and a.data_open between today()-365 and today() and right(co_des,4)like '2%')
____ADEMPAS_2___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC11'
and a.data_open between today()-365 and today() and right(co_des,4)like '10%')
____VENTAVIS_10___,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC11'
and a.data_open between today()-365 and today() and right(co_des,4)like '20%')
____VENTAVIS_20___,
 
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC21'
and a.data_open between today()-365 and today() and right(co_des,3)like '1%')
____REMODULIN_1___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC21'
and a.data_open between today()-365 and today() and right(co_des,4)like '2,5%')
____REMODULIN__2_5__,
(select distinct  'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC21'
and a.data_open between today()-365 and today() and right(co_des,4)like '5%')
____REMODULIN__5___,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC09'
and a.data_open between today()-365 and today() and right(co_des,4)like '0,5%')
____CARIPUL_PLOLAN__0_5__,
(select  distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_atc ='B01AC09'
and a.data_open between today()-365 and today() and right(co_des,4)like '15%')
____CARIPUL_PLOLAN_1_5__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'eliquis%2,5%'
and a.data_open between today()-365 and today())___eliquis_2_5__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'eliquis%5%'
and a.data_open between today()-365 and today())__eliquis_5____,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'pradaxa%75%'
and a.data_open between today()-365 and today())__pradaxa__75___,
 
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'pradaxa%110%'
and a.data_open between today()-365 and today())___pradaxa_110__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'pradaxa%150%'
and a.data_open between today()-365 and today())__pradaxa_150____,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'xarelto%10%'
and a.data_open between today()-365 and today())__xarelto__10____,
 
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'xarelto%15%'
and a.data_open between today()-365 and today())___xarelto_15__,
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'xarelto%20%'
and a.data_open between today()-365 and today())__xarelto_20____,
 
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'sintrom%1%'
and a.data_open between today()-365 and today())__sintrom__1__,
 
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'sintrom%4%'
and a.data_open between today()-365 and today())__sintrom__4__,
 
(select distinct 'si' from cart_terap a
where a.codice=p.codice and a.co_des like 'coumadin%5%'
and a.data_open between today()-365 and today())__coumadin__5__
 
 
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 ‘780' or c.cp_code like ‘786' or c.cp_code like '782%%' or c.cp_code like '416.0%%' or c.cp_code like '415.1%' or c.cp_code like '451.1%'or c.cp_code like '416.9%' or c.cp_code like '710.1%' or c.cp_code like '701.0%' or c.cp_code like '431%' or c.cp_code like '282.4%'or c.cp_code like '695.4%' or c.cp_code like 'v08%' or c.cp code like ‘135%’)
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
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Sab 6 Mag 2017 - 1:53

nanci giacinto ha scritto:buona sera ho avuto l'incarico di estrarre dal mio gruppo MEDIASS sette medici collegati in rete geografica con RRS Server quanto segue. Ho adattato una precedente query alla bisogna ma mi da "Errore di sintassi a o presso "code". La query che ho adattato è in coda alla  richiesta. ...
La query contiene svariati errori e/o imprecisioni non facili da correggere ; inoltre da MU non si puo' fare nulla in pratica , in quanto ad ogni tentativo di eseguire la query, il programma si chiude inesorabilmente ; bisogna riaprire MU , correggere l' errore rieseguire la query e cosi proseguire per passi successivi, correggendo prima la query principale e poi le varie subquery, un lavoro tedioso ed estenuante ...
 Inoltre cercare di utilizzare per una ricerca raffinata e non semplice sull' IperTensione Polmonare , la solita query in uso da oltre 10 o 15 anni, adatta x interrogare un database diverso dall' attuale e per ottenere un riepilogo estensivo di dati ... non porta sicuramente a risultati soddisfacenti ; ulteriore ostacolo in questo caso è rappresentato dal MillePs MultiUtente .
 Come suggerimento , se non è possibile utilizzare Viste Personalizzate e WITH query , è necessario assemblare la query progressivamente , per passi successivi , come ad esempio :

SELECT Distinct  p.nome , p.cognome ,
v.codmedico  As  codice_medico,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta , p.sesso ,
Today()  As  data_query
FROM  pazienti p  LEFT Outer JOIN  v_pazienti v  ON  p.codice = v.codice 
ORDER BY  p.cognome , p.nome
 
poi se il risultato è soddisfacente :

SELECT Distinct p.nome , p.cognome ,

v.codmedico As codice_medico,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As eta , p.sesso ,

Today() As data_query

FROM pazienti p LEFT Outer JOIN v_pazienti v ON p.codice = v.codice

WHERE p.codice IN ( SELECT b.codice FROM cart_pazpbl b WHERE b.codice = p.codice AND

( b.cp_code ILike '413%' OR b.cp_code ILike '780' OR b.cp_code ILike '786' OR b.cp_code ILike '782%' OR b.cp_code ILike '416.0%' OR b.cp_code ILike '415.1%' OR b.cp_code ILike '451.1%' OR b.cp_code ILike '416.9%' OR b.cp_code ILike '710.1%' OR b.cp_code ILike '701.0%' OR b.cp_code ILike '431%' OR b.cp_code ILike '282.4%' OR b.cp_code ILike '695.4%' OR b.cp_code ILike 'V08%' OR b.cp_code ILike '135%' ))

ORDER BY p.cognome , p.nome

 
aggiungere  alcune subquery : 
 

SELECT Distinct p.nome , p.cognome ,

v.codmedico As codice_medico,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As eta , p.sesso ,

Today() As data_query ,


( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%' )

____sincope____,


( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')

____sincope____,


( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')

______cianosi____


FROM pazienti p LEFT Outer JOIN v_pazienti v ON p.codice = v.codice

WHERE p.codice IN ( SELECT b.codice FROM cart_pazpbl b WHERE b.codice = p.codice AND

( b.cp_code ILike '413%' OR b.cp_code ILike '780' OR b.cp_code ILike '786' OR b.cp_code ILike '782%' OR b.cp_code ILike '416.0%' OR b.cp_code ILike '415.1%' OR b.cp_code ILike '451.1%' OR b.cp_code ILike '416.9%' OR b.cp_code ILike '710.1%' OR b.cp_code ILike '701.0%' OR b.cp_code ILike '431%' OR b.cp_code ILike '282.4%' OR b.cp_code ILike '695.4%' OR b.cp_code ILike 'V08%' OR b.cp_code ILike '135%' ))

ORDER BY p.cognome , p.nome


 proseguire in tal modo , correggendo meticolosamente discrepanze , errori , incongruenze ...
 
Saluti ,  Sergio ,  Orzivecchi  ( BS )

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  mario shirt Sab 6 Mag 2017 - 20:13

Cervino ha scritto:
nanci giacinto ha scritto:buona sera ho avuto l'incarico di estrarre dal mio gruppo MEDIASS sette medici collegati in rete geografica con RRS Server quanto segue. Ho adattato una precedente query alla bisogna ma mi da "Errore di sintassi a o presso "code". La query che ho adattato è in coda alla  richiesta. ...
La query contiene svariati errori e/o imprecisioni non facili da correggere ; inoltre da MU non si puo' fare nulla in pratica , in quanto ad ogni tentativo di eseguire la query, il programma si chiude inesorabilmente ; bisogna riaprire MU , correggere l' errore rieseguire la query e cosi proseguire per passi successivi, correggendo prima la query principale e poi le varie subquery, un lavoro tedioso ed estenuante ...
 Inoltre cercare di utilizzare per una ricerca raffinata e non semplice sull' IperTensione Polmonare , la solita query in uso da oltre 10 o 15 anni, adatta x interrogare un database diverso dall' attuale e per ottenere un riepilogo estensivo di dati ... non porta sicuramente a risultati soddisfacenti ; ulteriore ostacolo in questo caso è rappresentato dal MillePs MultiUtente .
 Come suggerimento , se non è possibile utilizzare Viste Personalizzate e WITH query , è necessario assemblare la query progressivamente , per passi successivi , come ad esempio :



 
poi se il risultato è soddisfacente :

SELECT Distinct p.nome , p.cognome ,





v.codmedico As codice_medico,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As eta , p.sesso ,





Today() As data_query





FROM pazienti p LEFT Outer JOIN v_pazienti v ON p.codice = v.codice





WHERE p.codice IN ( SELECT b.codice FROM cart_pazpbl b WHERE b.codice = p.codice AND





( b.cp_code ILike '413%' OR b.cp_code ILike '780' OR b.cp_code ILike '786' OR b.cp_code ILike '782%' OR b.cp_code ILike '416.0%' OR b.cp_code ILike '415.1%' OR b.cp_code ILike '451.1%' OR b.cp_code ILike '416.9%' OR b.cp_code ILike '710.1%' OR b.cp_code ILike '701.0%' OR b.cp_code ILike '431%' OR b.cp_code ILike '282.4%' OR b.cp_code ILike '695.4%' OR b.cp_code ILike 'V08%' OR b.cp_code ILike '135%' ))





ORDER BY p.cognome , p.nome





 
aggiungere  alcune subquery : 
 

SELECT Distinct p.nome , p.cognome ,





v.codmedico As codice_medico,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As eta , p.sesso ,





Today() As data_query ,






( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%' )





____sincope____,






( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')





____sincope____,






( Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')





______cianosi____






FROM pazienti p LEFT Outer JOIN v_pazienti v ON p.codice = v.codice





WHERE p.codice IN ( SELECT b.codice FROM cart_pazpbl b WHERE b.codice = p.codice AND





( b.cp_code ILike '413%' OR b.cp_code ILike '780' OR b.cp_code ILike '786' OR b.cp_code ILike '782%' OR b.cp_code ILike '416.0%' OR b.cp_code ILike '415.1%' OR b.cp_code ILike '451.1%' OR b.cp_code ILike '416.9%' OR b.cp_code ILike '710.1%' OR b.cp_code ILike '701.0%' OR b.cp_code ILike '431%' OR b.cp_code ILike '282.4%' OR b.cp_code ILike '695.4%' OR b.cp_code ILike 'V08%' OR b.cp_code ILike '135%' ))





ORDER BY p.cognome , p.nome






 proseguire in tal modo , correggendo meticolosamente discrepanze , errori , incongruenze ...
 
Saluti ,  Sergio ,  Orzivecchi  ( BS )


Grande Sergio, personalmente mi sei di grande aiuto. Concetti semplici e pratici..
Puoi farmi capire qualche passaggio: la seguente query mi estrae tutti i paz, accanto il cod regionale non e' presente nei defunti e non pagati (mi sembra)

SELECT Distinct  p.nome , p.cognome ,
v.codmedico  As  codice_medico,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta , p.sesso ,
Today()  As  data_query
FROM  pazienti p  LEFT Outer JOIN  v_pazienti v  ON  p.codice = v.codice 
ORDER BY  p.cognome , p.nome

Naturalmente la 2 query estrae solo i paz legati ai vari problemi.
Ho qualche problema ad inserire le subquery...
Ancora Grazie Sergio e Buona domenica
Mario

P.S. E' sempre valido il detto che e' meglio insegnare a pescare che dare il pesce..
mario shirt
mario shirt
Membro Junior
Membro Junior

Messaggi : 254
Punti : 5172
Voti per importanza dei messaggi : 4
Data d'iscrizione : 21.02.11
Età : 68

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Dom 7 Mag 2017 - 1:45

Non esagerare Mario , comunque Ti ringrazio x le prove , in questo caso il risultato è quello atteso, come ha già evidenziato : sto solo cercando di comprendere come mai sul MillePS MultiUtente, le query restituiscano o i pazienti di tutti i Medici oppure Nessuno, senza utilizza lo scomodo campo n.pa_medi ( nel tentativo di trovare una soluzione alternativa) .
l' ideale sarebbe poter eseguire le seguenti query su un MillePs MultiUtente ( ringrazio x le eventuali prove ) :


SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  RIGHT JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


  probabile stesso risultato, suppongo , anche con :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  INNER JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


 analogo risultato si dovrebbe ottenere anche con la classica formulazione ( ma spesso dimentico che le due query sono equivalenti ) :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p , v_pazienti v
WHERE  p.codice = v.codice
ORDER BY  p.cognome , p.nome


ma se aggiungo delle clausole del tipo :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p ,  nos_002 n ,  v_pazienti v
WHERE  p.codice = n.codice  AND  p.codice = v.codice
AND   p.pa_convenzione = 'S'
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  And p.decesso Is Null
ORDER BY  p.cognome , p.nome


come cambia il set estratto ?

    riguardo la query principale , per il momento si potrebbe provare con :

SELECT Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  data_query ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')
      ______cianosi____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.%%')
      _____ipert_polmonare____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '415.1%')
      ___embolia_____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '451.1%')
      ____tvp______ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.9%')
      _____cuore_polmon_cronico____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '710.1%')
      _____sclerodermia_ss__,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '701.0%')
      _____sclerodermia_uno____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '282.4%')
      ___talassemia____,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '695.4%')
      ___les____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike 'V08%')
      ___hiv____ ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '135%')
      ___sarcoidosi____ ,
                                      /* Inserire 5 SubQuery x Accertamenti */
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%32%')
       ____tracleer_32___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%125%')
       ____TRACLEER_125___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%62%')
       ____TRACLEER_62____,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX04'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%10%')
       ____OPSUMIN_10___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX02'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%10%')
       ____VOLIBRIS_10___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX02'
And t.data_open > Today()-365 And Right( co_des, 4) ILike '%5%')
       ____VOLUBRIS_5___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE03'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%20%')
       ____REVATIO_20___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE03'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%10%')
       ____REVATIO_10___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE08'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%20%')
       ____ADCIRCA_20___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX05'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%0,5%')
       ____ADEMPAS_0_5___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX05'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%1,5%')
       ____ADEMPAS_1_5___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX08'
And t.data_open > Today()-365 And Right( co_des, 4) ILike '%2%')
       ____ADEMPAS_2___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC11'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%10%')
       ____VENTAVIS_10___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC11'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%20%')
       ____VENTAVIS_20___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And t.data_open > Today()-365 And Right(co_des , 4) ILike '1%')
       ____REMODULIN_1___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%2,5%')
       ____REMODULIN__2_5__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And t.data_open > Today()-365 And Right( co_des, 4) ILike '%5%')
       ____REMODULIN__5___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC09'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%0,5%')
       ____CARIPUL_PLOLAN__0_5__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC09'
And t.data_open > Today()-365 And Right( co_des, 5) ILike '%15%')
       ____CARIPUL_PLOLAN_1_5__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Eliquis%2,5%'
And t.data_open > Today()-365)
       ___eliquis_2_5__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Eliquis%5%'
And t.data_open > Today()-365)
       __eliquis_5____,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Pradaxa%75%'
And t.data_open > Today()-365)
       __pradaxa__75___,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Pradaxa%110%'
And t.data_open > Today()-365)
       ___pradaxa_110__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Pradaxa%150%'
And t.data_open > Today()-365)
       __pradaxa_150____,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Xarelto%10%'
And t.data_open > Today()-365)
       __xarelto__10____,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Xarelto%15%'
And t.data_open > Today()-365)
       ___xarelto_15__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Xarelto%20%'
And t.data_open > Today()-365)
       __xarelto_20____,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Sintrom%1%'
And t.data_open > Today()-365)
       __sintrom__1__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Sintrom%4%'
And t.data_open > Today()-365)
       __sintrom__4__,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'Coumadin%5%'
And t.data_open > Today()-365)
       _coumadin__5__

FROM  pazienti p  INNER JOIN  v_pazienti v  Using( codice)
WHERE  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND
( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome


sul risultato non garantisco ;  saluti e buona Domenica ,  Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  mario shirt Dom 7 Mag 2017 - 13:41

Cervino ha scritto:Non esagerare Mario , comunque Ti ringrazio x le prove , in questo caso il risultato è quello atteso, come ha già evidenziato : sto solo cercando di comprendere come mai sul MillePS MultiUtente, le query restituiscano o i pazienti di tutti i Medici oppure Nessuno, senza utilizza lo scomodo campo n.pa_medi ( nel tentativo di trovare una soluzione alternativa) .
l' ideale sarebbe poter eseguire le seguenti query su un MillePs MultiUtente ( ringrazio x le eventuali prove ) :


SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  RIGHT JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


  probabile stesso risultato, suppongo , anche con :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  INNER JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


 analogo risultato si dovrebbe ottenere anche con la classica formulazione ( ma spesso dimentico che le due query sono equivalenti ) :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p , v_pazienti v
WHERE  p.codice = v.codice
ORDER BY  p.cognome , p.nome


ma se aggiungo delle clausole del tipo :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p ,  nos_002 n ,  v_pazienti v
WHERE  p.codice = n.codice  AND  p.codice = v.codice
AND   p.pa_convenzione = 'S'
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  And p.decesso Is Null
ORDER BY  p.cognome , p.nome


come cambia il set estratto ?

tutte su mille monoutente danno stesso risultato, estraggono tutti i paz presenti (non vengono piu' i deceduti o revocati  come avevo detto nel precedente post) , Caso strano mi dice che lavora su 1577 paz e il totale estratto e' sempre 1 in meno...
Forse stasera provo su mille multiutente e ti faccio sapere.
L'ultima query estrae 176 paz ma la subquery con terapie non mi da nulla.
Mario
mario shirt
mario shirt
Membro Junior
Membro Junior

Messaggi : 254
Punti : 5172
Voti per importanza dei messaggi : 4
Data d'iscrizione : 21.02.11
Età : 68

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Dom 7 Mag 2017 - 14:50

mario shirt ha scritto:


tutte su mille monoutente danno stesso risultato, estraggono tutti i paz presenti (non vengono piu' i deceduti o revocati  come avevo detto nel precedente post) , Caso strano mi dice che lavora su 1577 paz e il totale estratto e' sempre 1 in meno...
Forse stasera provo su mille multiutente e ti faccio sapere.
L'ultima query estrae 176 paz ma la subquery con terapie non mi da nulla.
Mario
 è ancora in fase di elaborazione / test , prova con  :

SELECT Distinct  p.nome , p.cognome , u.userid  As  mmg_code ,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d  ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')
      ______cianosi____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.%%')
      _____ipert_polmonare____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '415.1%')
      ___embolia_____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '451.1%')
      ____tvp______ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.9%')
      _____cuore_polmon_cronico____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '710.1%')
      _____sclerodermia_ss__,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '701.0%')
      _____sclerodermia_uno____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '282.4%')
      ___talassemia____,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '695.4%')
      ___les____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike 'V08%')
      ___hiv____ ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '135%')
      ___sarcoidosi____ ,
                                      /* Inserire 5 SubQuery x Accertamenti */
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Bosentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Ambisentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX04'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX04' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Macitentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX05'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX05' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Riociguat___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE03'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE03' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Sildenafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE08'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE08' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Tadalafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC11'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC11' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Iloprost___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC21' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Treprostinil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC09'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC09' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Epoprostenolo__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Apixaban__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AE07'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AE07' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Dabigatran__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Rivaroxaban__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Sintrom%'
And t.data_open > Today()-365)
       __Acenocumarolo__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Coumadin%'
And t.data_open > Today()-365)
       _Warfarin__
FROM ( pazienti p  LEFT JOIN  nos_002 n  Using( codice) )
                 LEFT JOIN  v_utenti u   ON  n.pa_medi = u.userid
WHERE  u.nome  ILike  '%'     AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
AND  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND
( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome



Grazie ,   Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  mario shirt Dom 7 Mag 2017 - 16:48

Cervino ha scritto:
mario shirt ha scritto:


tutte su mille monoutente danno stesso risultato, estraggono tutti i paz presenti (non vengono piu' i deceduti o revocati  come avevo detto nel precedente post) , Caso strano mi dice che lavora su 1577 paz e il totale estratto e' sempre 1 in meno...
Forse stasera provo su mille multiutente e ti faccio sapere.
L'ultima query estrae 176 paz ma la subquery con terapie non mi da nulla.
Mario
 è ancora in fase di elaborazione / test , prova con  :

SELECT Distinct  p.nome , p.cognome , u.userid  As  mmg_code ,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d  ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')
      ______cianosi____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.%%')
      _____ipert_polmonare____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '415.1%')
      ___embolia_____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '451.1%')
      ____tvp______ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.9%')
      _____cuore_polmon_cronico____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '710.1%')
      _____sclerodermia_ss__,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '701.0%')
      _____sclerodermia_uno____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '282.4%')
      ___talassemia____,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '695.4%')
      ___les____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike 'V08%')
      ___hiv____ ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '135%')
      ___sarcoidosi____ ,
                                      /* Inserire 5 SubQuery x Accertamenti */
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Bosentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Ambisentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX04'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX04' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Macitentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX05'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX05' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Riociguat___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE03'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE03' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Sildenafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE08'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE08' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Tadalafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC11'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC11' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Iloprost___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC21' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Treprostinil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC09'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC09' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Epoprostenolo__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Apixaban__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AE07'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AE07' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Dabigatran__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Rivaroxaban__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Sintrom%'
And t.data_open > Today()-365)
       __Acenocumarolo__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Coumadin%'
And t.data_open > Today()-365)
       _Warfarin__
FROM ( pazienti p  LEFT JOIN  nos_002 n  Using( codice) )
                 LEFT JOIN  v_utenti u   ON  n.pa_medi = u.userid
WHERE  u.nome  ILike  '%'     AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
AND  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND
( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome



Grazie ,   Sergio

Ok estrae terapie. Pero' mi sembra di aver capito che la richiesta e': paz con una diagnosi , o un sintomo, o un acceramento o una terapia.
La query mi da tutti i paz con 1 diagnosi registrata (non so se anche sintomo) che hanno qiella terapia ricercata.
Mario
mario shirt
mario shirt
Membro Junior
Membro Junior

Messaggi : 254
Punti : 5172
Voti per importanza dei messaggi : 4
Data d'iscrizione : 21.02.11
Età : 68

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  mario shirt Dom 7 Mag 2017 - 18:24

mario shirt ha scritto:
Cervino ha scritto:
l' ideale sarebbe poter eseguire le seguenti query su un MillePs MultiUtente ( ringrazio x le eventuali prove ) :


SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  RIGHT JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


  probabile stesso risultato, suppongo , anche con :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p  INNER JOIN  v_pazienti v  Using( codice)
ORDER BY  p.cognome , p.nome


 analogo risultato si dovrebbe ottenere anche con la classica formulazione ( ma spesso dimentico che le due query sono equivalenti ) :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p , v_pazienti v
WHERE  p.codice = v.codice
ORDER BY  p.cognome , p.nome


ma se aggiungo delle clausole del tipo :

SELECT  Distinct  p.nome , p.cognome , v.codmedico  As  codice_medico ,  Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt ) As  eta ,  p.sesso ,  Today()  As  data_query
FROM  pazienti p ,  nos_002 n ,  v_pazienti v
WHERE  p.codice = n.codice  AND  p.codice = v.codice
AND   p.pa_convenzione = 'S'
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  And p.decesso Is Null
ORDER BY  p.cognome , p.nome


come cambia il set estratto ?

tutte su mille monoutente danno stesso risultato, estraggono tutti i paz presenti (non vengono piu' i deceduti o revocati  come avevo detto nel precedente post) , Caso strano mi dice che lavora su 1577 paz e il totale estratto e' sempre 1 in meno...
Forse stasera provo su mille multiutente e ti faccio sapere.
L'ultima query estrae 176 paz ma la subquery con terapie non mi da nulla.
Mario
  Su mille multiutente estrae sempre e solo i miei paz.
La tua ultima query con le subquery terapie e accertamenti su multiutente estrae anche quelli dell'altro medico. Il totale mi sembra il solito (avevi messo un limite?) ottenuto sul monoutente.
Rimane il mio dubbio sulla richiesta: andrebbe utilizzato OR? Giacinto toglici i dubbi...
Mario
mario shirt
mario shirt
Membro Junior
Membro Junior

Messaggi : 254
Punti : 5172
Voti per importanza dei messaggi : 4
Data d'iscrizione : 21.02.11
Età : 68

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Dom 7 Mag 2017 - 23:28

mario shirt ha scritto:

  Su mille multiutente estrae sempre e solo i miei paz.
La tua ultima query con le subquery terapie e accertamenti su multiutente estrae anche quelli dell'altro medico. Il totale mi sembra il solito (avevi messo un limite?) ottenuto sul monoutente.
Rimane il mio dubbio sulla richiesta: andrebbe utilizzato OR? Giacinto toglici i dubbi...
Mario
Grazie Mario x le prove e le delucidazioni ; quindi sembra chiaro che con l' utilizzo di v_pazienti , il MillePs MultiUtente si riduce a ... MonoUtente, in quanto nella vista sono presente solo i pazienti del Medico Utente ;
invece il link fra la tabella : pazienti ( tramite nos_002 ) e la vista v_utenti sul MillePs MultiUtente sembrerebbe non funzionare, come già tante volte verificato .
nella seguente query :


SELECT Distinct  p.nome , p.cognome , u.userid  As  mmg_code , Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d
FROM ( pazienti p  LEFT JOIN  nos_002 n  Using( codice) )
                 LEFT JOIN  v_utenti u   ON  n.pa_medi = u.userid
WHERE  u.nome  ILike  '%'   AND  u.codice_regionale  ILike  '%'   AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
ORDER BY  p.cognome , p.nome


se immetto le iniziali dell' Utente o del Codice Regionale sul MillePS MonoUtente ottengo Tutti i pazienti del Medico ma sul MillePS MultiUtente Nessun Paziente : quindi la clausola limitativa non è efficace e bisogna utilizzare il campo pa_medi della tabella nos_002 per ottenere l' effetto desiderato, soluzione non certo ottimale .

Riguardo alla query sull' IperTensione Polmonare, mi sono limitato a correggere alcuni aspetti formali del linguaggio SQL, senza entrare nel problema medico: rappresenta una sfida ardua e con numerose questioni di non univoca interpretazione, che supera le mie capacità e che comunque evidenzia le limitazioni dei programmi attualmente in uso, nell' affrontare simili sfide .

Saluti , Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty ipertensione polmonare

Messaggio  nanci giacinto Lun 8 Mag 2017 - 16:07

Caro Cervino la tua query funziona benissimo, anche aggiungendo le subquery sugli accertamenti, sul mio portatile come postazione singola ma se la stessa la provo sul server dell'associazione sempre e solo con la mia pw e per i miei pz mi da il seguente errore: sqlstate 42601 error sintax. error at or near "." no query has been executed with that handle. Mi da lo stesso errore se la testo anche  come amministratore su tutti i medici. La cosa che non capisco è che il comando "." che dovrebbe essere l'errore non lo riscontro nella tua query. Si tratta ribadisco della stessa identica query.
Caro Mario il quesito della query è indicato nella lettera dei colleghi dell'ospedale che hanno richiesto i dati per lo studio e che si trova all'inizio della mia domanda. Purtroppo non sono riuscito a capire cosa significhi il tuo acronimo OR. grazie ad entrambi per il grande aiuto.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Mar 9 Mag 2017 - 0:25

nanci giacinto ha scritto:Caro Cervino la tua query funziona benissimo, anche aggiungendo le subquery sugli accertamenti, sul mio portatile come postazione singola ma se la stessa la provo sul server dell'associazione sempre e solo con la mia pw e per i miei pz mi da il seguente errore: sqlstate 42601 error sintax. error at or near "." no query has been executed with that handle. Mi da lo stesso errore se la testo anche  come amministratore su tutti i medici. La cosa che non capisco è che il comando "." che dovrebbe essere l'errore non lo riscontro nella tua query. Si tratta ribadisco della stessa identica query.
Caro Mario il quesito della query è indicato nella lettera dei colleghi dell'ospedale che hanno richiesto i dati per lo studio e che si trova all'inizio della mia domanda. Purtroppo non sono riuscito a capire cosa significhi il tuo acronimo OR. grazie ad entrambi per il grande aiuto.
Non è un errore di Sintassi ma di formattazione del Testo, che riscontro inesorabilmente da tempo nel riprendere le query dal Forum ( da quando sono passato a W10 , credo; da allora è diventato spesso problematico, anche scrivere Post sul Forum)) ;
comunque basta solo riformattare il testo della query ( procedura semplice ma comunque alquanto fastidiosa ) .
              Una soluzione puo' essere :  
aprire un nuovo documento di Testo in Office o OpenOffice o Libreoffice --> incollare la query ripresa dal Forum : verrà evidenziata la presenza di numerosi caratteri anomali (di solito un rettangolo grigio )
--> selezionare un carattere anomalo ( rettangolo grigio verticale di solito ) con il mouse ( o Tastiera ) --> dal menu dei comandi selezionare : Edit ( di fianco alla prima voce : File di solito )  --> Find & Replace ( Modifica --> Trova e Sostituisci )
--> incollare il carattere anomalo selezionato nel Rettangolo Find / Trova se non già presente ( ma di solito non è necessario ) --> Fare click con il mouse nel rettangolo sottostante Replace / Sostituisci e d introdurre un carattere spazio premendo la relativa  barra --> Replace All / Rimpimpiazza Tutti ( ripetere eventualmente la procedura in caso di presenza di altri caratteri anomali )    --> Selezionare la query e Ricopiarla in MU o PgAdmin e rieseguirla 
( procedura difficile da illustrare ma semplice da fare )

Saluti ,  Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty ipertensione polmonare

Messaggio  nanci giacinto Mar 9 Mag 2017 - 22:28

Grazie per la pazienza. Purtroppo non vedo nessun segno strano nella query, quella applicata in milleutilità è identica a quella del forum. Quello che non capisco è il fatto che sul mio portatile funziona benissimo invece sul mio stesso archivio del server RRS mi da l'errore che ho scritto nella precedente email. Una cosa che ho notato è che nella sintassi delle query ho visto molti segni cancelletto (che comunque si trovano sia sul forum, sia nella copia word e sia in milleutilità) che normalmente non ritrovo nelle query. Domanda finale: perchè sul mio archivio del portatile la query funziona mentre sul mio stesso archivio del server non funziona?.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Mer 10 Mag 2017 - 1:12

nanci giacinto ha scritto:Grazie per la pazienza. Purtroppo non vedo nessun segno strano nella query, quella applicata in milleutilità è identica a quella del forum. Quello che non capisco è il fatto che sul mio portatile funziona benissimo invece sul mio stesso archivio del server RRS mi da l'errore che ho scritto nella precedente email. Una cosa che ho notato è che nella sintassi delle query ho visto molti segni cancelletto (che comunque si trovano sia sul forum, sia nella copia word e sia in milleutilità) che normalmente non ritrovo nelle query. Domanda finale: perchè sul mio archivio del portatile la query funziona mentre sul mio stesso archivio del server non funziona?.
Sono sorpreso : non ho mai visto nessun simbolo tipo # (carattere Ascii 35 ) nelle svariate operazioni di Copia & Incolla delle query dal Forum o da siti web ; comunque la query si blocca x la presenza di caratteri non stampabili negli spazi bianchi del testo ( nel mio caso è sempre il carattere Ascii 160 ( Non-breaking space , evidenziato in PgAdmin con una annotazione molto simile ad una a accentata : á   ed in LibreOffice come un piccolo rettangolo grigio verticale ) .   L' unica soluzione che conosco rimane quella già suggerita : sostituire in blocco tutti gli spazi bianchi del testo della query ed eventuali caratteri anomali con uno spazio ( carattere Ascii 32 ) tramite la procedura sopradescritta o con una a piacere .
...  purtroppo non avendo un MillePS MultiUtente a numerose questioni ... non so rispondere
Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty ipertensione polmonare

Messaggio  nanci giacinto Sab 13 Mag 2017 - 10:05

buon giorno ma cosa succede io vedo i segni cancelletto # anche nella query qui sul forum
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  mario shirt Sab 13 Mag 2017 - 15:47

nanci giacinto ha scritto:buon giorno ma cosa succede io vedo i segni cancelletto # anche nella query qui sul forum

io non vedo cancelletti o porte!!!
Mario
mario shirt
mario shirt
Membro Junior
Membro Junior

Messaggi : 254
Punti : 5172
Voti per importanza dei messaggi : 4
Data d'iscrizione : 21.02.11
Età : 68

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  nanci giacinto Sab 13 Mag 2017 - 23:46

/* Inserire 5 SubQuery x Accertamenti */
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX01' And (t1.data_open > t.data_open 
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )


(Select Distinct Substring( t.co_des From '%è a questo punto che sul mio computer dopo From '%appare il segno cancelletto # e poi si ripete più volte sempre leggendo direttamente sul forum.  Questa parte  la ho riscritta quella di sopra la ho copiata con copia e incolla sempre dalla query del forum. Mi pare di essere su scherzi a parte.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Dom 14 Mag 2017 - 1:42

nanci giacinto ha scritto:/* Inserire 5 SubQuery x Accertamenti */
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01' And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX01' And (t1.data_open > t.data_open Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )

(Select Distinct Substring( t.co_des From '% è a questo punto che sul mio computer dopo From '% appare il segno cancelletto # e poi si ripete più volte sempre leggendo direttamente sul forum.  Questa parte  la ho riscritta quella di sopra la ho copiata con copia e incolla sempre dalla query del forum. Mi pare di essere su scherzi a parte.
ovviamente trattasi di un qui pro quo : il segno # presente nelle sintassi delle query serve per ottenere un dato specifico in modo appropriato ( nell' esempio la dose del Farmaco Prescritto ) ed è quindi indispensabile ; nei post precedenti mi riferivo ai simboli di formattazione e/o caratteri non stampabili che compaiono in alcuni spazi bianchi, dopo aver ripreso la query dal Forum : nel mio caso, in numerosi punti della query, uno spazio bianco ( codificato con il carattere Ascii 32 ) viene sostituito ( in MU e PgAdmin , NotePad ... ) con uno spazio apparentemente bianco ma codificato in modo diverso ( il carattere Ascii 160 : Non-breaking space ) con conseguente blocco dell' esecuzione della query ; quindi devo in LibreOffice selezionare il Carattere Ascii 160 e sostituirlo con il carattere Ascii 32 , come era in origine ( quando ad es. ho incollato la query sul Post ) con il metodo sovra descritto ( Suggerimenti per evitare la noiosa ... Procedura , sono auspicabili ) .

Spero di aver chiarito l' equivoco ,  saluti  Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty ipertensione polmonare

Messaggio  nanci giacinto Dom 14 Mag 2017 - 19:28

Grazie per la pazienza. La query non ha spazi vuoti o altri simboli strani per cui la domanda che mi faccio è perchè sul mio portatile funziona benissimo ed invece sul mio stesso archivio del server RRs non funziona?.
nanci giacinto
nanci giacinto
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Cervino Dom 14 Mag 2017 - 22:09

nanci giacinto ha scritto:Grazie per la pazienza. La query non ha spazi vuoti o altri simboli strani per cui la domanda che mi faccio è perchè sul mio portatile funziona benissimo ed invece sul mio stesso archivio del server RRs non funziona?.
Mi risulta difficile dare consigli , dato che non posso eseguire nessuna prova sul MillePS MultiUtente , a parte i soliti suggerimenti già piu' volte elencati :

1 - Ridurre la query principale ai minimi termini , togliendo o disattivando le subquery :

SELECT Distinct  p.cognome ,  p.nome , u.userid  As  mmg_code ,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d  
FROM ( pazienti p  LEFT JOIN  nos_002 n  Using( codice) )
                      LEFT JOIN  v_utenti u   ON  n.pa_medi = u.userid
WHERE  u.nome  ILike  '%'     AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
AND  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND ( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome


 se anche cosi non dovesse funzionare , provare con :

SELECT Distinct  p.cognome ,  p.nome ,  n.pa_medi  As  mmg_code ,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d  
FROM  pazienti p  LEFT JOIN  nos_002 n  Using( codice) 
WHERE  n.pa_medi  ILike  '%'     AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
AND  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND ( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome



In caso di esito positivo aggiungere progressivamente subquery  :

SELECT Distinct  p.cognome ,  p.nome , u.userid  As  mmg_code ,   Cast( Days( p.nascita , Today()+1)*24/8766 As SmallInt )  As  eta , p.sesso , Today()  As  query_d  ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '780.2%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '786.%')
      ____sincope____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '782.5%')
      ______cianosi____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.%%')
      _____ipert_polmonare____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '415.1%')
      ___embolia_____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '451.1%')
      ____tvp______ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '416.9%')
      _____cuore_polmon_cronico____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '710.1%')
      _____sclerodermia_ss__,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '701.0%')
      _____sclerodermia_uno____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '282.4%')
      ___talassemia____,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '695.4%')
      ___les____ ,
 (Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike 'V08%')
      ___hiv____ ,
(Select Distinct 'Si' From cart_pazpbl b Where b.codice=p.codice And b.cp_code ILike '135%')
      ___sarcoidosi____ ,
(Select a.ac_val From cart_accert a Where a.codice=p.codice And a.ac_des ILike '%EcoCardio%'
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_des ILike '%EcoCardio%'
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 Between Today()-455 And Today() )
     ___EcoCardio_last_15m___ ,
(Select a.ac_val From cart_accert a Where a.codice=p.codice And a.ac_des ILike '%Spirometr%'
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_des ILike '%Spirometr%'
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 Between Today()-455 And Today() )
     __spirometria_last_15m__ ,
(Select a.ac_val From cart_accert a Where a.codice=p.codice And a.ac_des ILike '%Angio%RM%Torac%'
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_des ILike '%Angio%Rm%Torac%'
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 Between Today()-455 And Today() )
      __angio_rm_torace_last_15M___ ,
(Select a.ac_val From cart_accert a Where a.codice=p.codice And a.ac_des ILike '%EmoGasAnalisi%'
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_des ILike '%EmoGasAnalisi%'
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 Between Today()-455 And Today() )
    ___emogasanalisi_last_15m___ ,
(Select a.ac_val From cart_accert a Where a.codice=p.codice And a.ac_des ILike '%Scinti%Polmon%'
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_des ILike '%Scinti%Polmon%'
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 Between Today()-455 And Today() )
     __scinti_polmone_last_15m___,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Bosentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Ambisentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX04'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX04' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Macitentan___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'C02KX05'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'C02KX05' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Riociguat___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE03'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE03' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Sildenafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'G04BE08'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'G04BE08' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Tadalafil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC11'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC11' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Iloprost___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC21'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC21' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Treprostinil___ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AC09'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AC09' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Epoprostenolo__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF02'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF02' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Apixaban__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AE07'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AE07' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Dabigatran__ ,
(Select Distinct SubString( t.co_des From '%#" %#"MG%' For '#' ) From cart_terap t Where t.codice=p.codice And t.co_atc ILike 'B01AF01'
And Not Exists (Select t1.co_des From cart_terap t1 Where t1.codice = t.codice And t1.co_atc ILike 'B01AF01' And (t1.data_open > t.data_open
Or (t1.data_open = t.data_open And t1.rowid > t.rowid))) And t.data_open > Today()-365 )
       ____Rivaroxaban__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Sintrom%'
And t.data_open > Today()-365)
       __Acenocumarolo__ ,
(Select Distinct 'Si' From cart_terap t Where t.codice=p.codice And t.co_des ILike 'Coumadin%'
And t.data_open > Today()-365)
       _Warfarin__
FROM ( pazienti p  LEFT JOIN  nos_002 n  Using( codice) )
                      LEFT JOIN  v_utenti u   ON  n.pa_medi = u.userid
WHERE  u.nome  ILike  '%'     AND   p.pa_convenzione = 'S'
AND  Year( p.nascita) Between 1910 And 2017  
AND ( n.pa_drevoca Is Null  Or  n.pa_drevoca >  Today()  Or  ( n.pa_drevoca Between
Date( Today())-365  And Today() And motivo_revoca = 'S'))  AND  p.decesso Is Null
AND  p.codice  IN ( SELECT  b.codice  FROM  cart_pazpbl b   WHERE  b.codice = p.codice  AND ( b.cp_code ILike '413%'  OR  b.cp_code ILike  '780'  OR  b.cp_code ILike  '786'  OR  b.cp_code ILike  '782%'  OR  b.cp_code ILike  '416.0%'  OR  b.cp_code ILike  '415.1%'  OR  b.cp_code ILike '451.1%'  OR  b.cp_code ILike  '416.9%'  OR  b.cp_code ILike  '710.1%'  OR  b.cp_code ILike '701.0%'  OR  b.cp_code ILike  '431%'  OR  b.cp_code ILike  '282.4%'  OR  b.cp_code ILike  '695.4%'  OR  b.cp_code ILike  'V08%'  OR  b.cp_code ILike  '135%' ))
ORDER BY  p.cognome , p.nome

 
Saluti ,  Sergio

Cervino
Membro Junior
Membro Junior

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

Torna in alto Andare in basso

ipertensione polmonare Empty Re: ipertensione polmonare

Messaggio  Contenuto sponsorizzato


Contenuto sponsorizzato


Torna in alto Andare in basso

Torna in alto


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