Bug #194
Etiqueta automática 1
0%
Description
Título: Esquema terapêutico com alteração
Sempre que o usuário:
- suspender o uso de algum medicamento do esquema em uso;
- adicionar algum medicamento ao esquema em uso (mesmo que esse medicamento já tenha sido usado anteriormente no mesmo esquema);
- mudança de período.
History
#1
Updated by Maurício Dos Santos over 12 years ago
Smente os em tto...
#2
Updated by Maurício Dos Santos over 12 years ago
- Tracker changed from Melhoria to Feature
- Status changed from New to In Progress
Tive que paralisar essa tarefa para priorizar outra... Segue ponto onde parei:
select *
from tbcase c
inner join regimen r on c.regimen_id = r.id
inner join medicineregimen mr on c.regimen_id = mr.regimen_id
where c.state in (1,2);
select * from medicineregimen
where regimen_id = 940604;
select * from prescribedmedicine where case_id = 1108738;
-- suspender o uso de algum medicamento do esquema em uso
select c.id as case_id, mr.id as medicineregimen_id, pm.id as prescribedmedicine, c.inicontinuousphase, pm.inidate, pm.enddate, pm.medicine_id, mr.phase, mr.monthstreatment
usedTimeIntensivePhase, usedTimeCotinuousPhase
from tbcase c
inner join medicineregimen mr on c.regimen_id = mr.regimen_id
inner join prescribedmedicine pm on c.id = pm.case_id
where c.state in (1,2) and pm.medicine_id = mr.medicine_id
;
-- adicionar algum medicamento ao esquema em uso (mesmo que esse medicamento já tenha sido usado anteriormente no mesmo esquema);
-- mudança de período.
#3
Updated by Maurício Dos Santos over 12 years ago
Quase resolvido, falta só retirar os indivisualizados:
-- Usando a subquery e colocando as condições... Foi dado 6 dias de tolerancia através da soma e subtr. do 0,2
exists(select *
from (select c.id as case_id, mr.id as medicineregimen_id, pm.id as prescribedmedicine, c.inicontinuousphase, pm.inidate, pm.enddate, pm.medicine_id, mr.phase, mr.monthstreatment,
DATEDIFF/30 as usedTimeIntensivePhase, DATEDIFF/30 as usedTimeContinuousPhase
from tbcase c
inner join medicineregimen mr on c.regimen_id = mr.regimen_id
inner join prescribedmedicine pm on c.id = pm.case_id
where c.state in (1,2) and pm.medicine_id = mr.medicine_id) as abc
where (phase = 0 and usedTimeIntensivePhase > 0 and ((monthstreatment < (usedTimeIntensivePhase-0.2)) or (monthstreatment > (usedTimeIntensivePhase+0.2))))
or (phase = 1 and usedTimeContinuousPhase > 0 and ((monthstreatment < (usedTimeContinuousPhase-0.2)) or (monthstreatment > (usedTimeContinuousPhase+0.2))))
and case_id = a.id) ;
-- adicionar algum medicamento ao esquema em uso (mesmo que esse medicamento já tenha sido usado anteriormente no mesmo esquema);
exists(select *
from tbcase c
inner join prescribedmedicine pm on c.id = pm.case_id
where c.state in (1,2)
and pm.medicine_id not in(select mr.medicine_id from tbcase ca inner join medicineregimen mr on ca.regimen_id = mr.regimen_id where ca.id = c.id)
and c.id = a.id)
-- mudança de período. : Incluso na primeira consulta
#4
Updated by Maurício Dos Santos over 12 years ago
exists(select *
from (select c.id as case_id, mr.id as medicineregimen_id, pm.id as prescribedmedicine, c.inicontinuousphase, pm.inidate, pm.enddate, pm.medicine_id, mr.phase, mr.monthstreatment,
DATEDIFF/30 as usedTimeIntensivePhase, DATEDIFF/30 as usedTimeContinuousPhase
from tbcase c
inner join medicineregimen mr on c.regimen_id = mr.regimen_id
inner join prescribedmedicine pm on c.id = pm.case_id
where c.state in (1,2) and pm.medicine_id = mr.medicine_id) as abc
where (phase = 0 and usedTimeIntensivePhase > 0 and ((monthstreatment < (usedTimeIntensivePhase-0.2)) or (monthstreatment > (usedTimeIntensivePhase+0.2))))
or (phase = 1 and usedTimeContinuousPhase > 0 and ((monthstreatment < (usedTimeContinuousPhase-0.2)) or (monthstreatment > (usedTimeContinuousPhase+0.2))))
and case_id = a.id)
or
exists(select *
from tbcase c
inner join prescribedmedicine pm on c.id = pm.case_id
where c.state in (1,2)
and pm.medicine_id not in(select mr.medicine_id from tbcase ca inner join medicineregimen mr on ca.regimen_id = mr.regimen_id where ca.id = c.id)
and c.id = a.id)
#5
Updated by Maurício Dos Santos over 12 years ago
- Status changed from In Progress to Resolved
Feito, verificar no ambiente em produção
#6
Updated by Maurício Dos Santos over 12 years ago
- Status changed from Resolved to Feedback
- Assignee changed from Maurício Dos Santos to Jorge Luiz da Rocha
Feito, verificar no ambiente em produção
#7
Updated by Maurício Dos Santos over 12 years ago
- Status changed from Feedback to Closed
#8
Updated by Maurício Dos Santos over 12 years ago
- Tracker changed from Feature to Bug
- Status changed from Closed to In Progress
- Assignee changed from Jorge Luiz da Rocha to Maurício Dos Santos
Essa etiqueta esta consideranco a transferencia como se fosse uma alteração, o que nao é regra.
#9
Updated by Maurício Dos Santos over 12 years ago
- Status changed from In Progress to New
#10
Updated by Maurício Dos Santos over 12 years ago
Pronto...
Precisamos testar...
Vale frisar que muitos casos estao com a vitamina B6 prescrita e isso acaba incluindo a etiqueta...
select *
from tbcase a
where
a.state in (1,2)
and
(
(a.regimen_id is not null and
exists(select *
from prescribedmedicine pm
where a.id = pm.case_id
and pm.medicine_id not in(select mr.medicine_id
from medicineregimen mr
where a.regimen_id = mr.regimen_id))
)
or
exists(select *
from (select pm.id, pm.medicine_id, pm.case_id, pm.inidate, c.iniContinuousPhase, sum(DATEDIFF/30) as prescMonths,
mr.monthsTreatment, (pm.inidate >= c.iniContinuousPhase) as prescPhase
from prescribedmedicine pm
inner join tbcase c on c.id = pm.case_id
inner join medicineregimen mr on mr.regimen_id = c.regimen_id and mr.medicine_id = pm.medicine_id and (pm.inidate >= c.iniContinuousPhase) = mr.phase
group by medicine_id, prescPhase) as abc
where not(monthsTreatment-0.1 <= prescMonths and monthsTreatment+0.1 >= prescMonths) and a.id = case_id
))
#11
Updated by Maurício Dos Santos over 12 years ago
- Status changed from New to Closed