کوئری زیر اطلاعات مربوط به اقلام (دارو/خدمت) ارائه شده به بیمه شده را در نسخه الکترونیک استخراج می کند. این اطلاعات بیشتر برای استفاده در محاسبه نسخه باز و پاسخ به کارفرما کاربرد دارد.

select 
   p.membernn
,(select nationalnumber from PARTNERCARE.tpncpartner where id=dpre.partner_id) as deliveredPartner
,(case when dsub.service_id>0 then 'خدمت' else 'دارو' end) as serviceorproduct
,nvl((select to_char(nationalnumber) from PARTNERCARE.tpncproduct where id=dsub.service_id),
(select to_char(nationalnumber) from PARTNERCARE.tpncservice where id=dsub.service_id)) as servicenn
,nvl((select cscode from PARTNERCARE.tpncproduct where id=dsub.service_id),
(select cscode from PARTNERCARE.tpncservice where id=dsub.service_id)) as genericcode
,nvl((select name from PARTNERCARE.tpncproduct where id=dsub.service_id),
(select name from PARTNERCARE.tpncservice where id=dsub.service_id)) as servicename
,to_char(pkgiutil.fncepochtodate(dpre.delivereddate),'yyyy/mm/dd','nls_calendar=persian') as delivereddate
,dsub.maxcoveredcount
,dsub.numberofdelivered
,dsub.amount
,dsub.paitentpayment
,dsub.consumption
,( case s.consumption
when 'A' then 'هر 3 ساعت'
when 'B' then 'هر 4 ساعت'
when 'C' then 'هر 6 ساعت'
when 'D' then 'هر 8 ساعت'
when 'E' then 'هر 12 ساعت'
when 'F' then 'روزی یک عدد'
when 'G' then 'یک روز در میان'
when 'H' then 'هر هفته'
when 'I' then 'TDS'
when 'J' then 'QD'
when 'K' then 'BID'
when 'L' then 'هر ساعت'
when 'M' then 'هر ماه'
when 'N' then 'هر سال'
when 'O' then 'هر شب'
when 'P' then 'هر صبح'
when 'Q' then 'یک شب در میان'
when 'R' then 'هر دو هفته'
when 'S' then 'هر سه هفته'
when 'T' then 'دو روز در هفته'
when 'U' then 'هر سه ماه'
when 'V' then 'هر شش ماه'
when 'W' then 'پنج روز در هفته'
else s.consumption end) as consumption
from thdkdeliveredprescription dpre join thdkdeliveredsubscription dsub
on dpre.id=dsub.dprescription_id
join thdkprescription p
on dpre.prescriptionowner_id=p.id
left join thdksubscription s
on p.id=s.prescription_id and dsub.subscriptionowner_id=s.id
where
p.membernn=:membernn
order by p.membernn, dpre.delivereddate;