Sie sind auf Seite 1von 2

--------------------------------------------------------------LAB EXAM REPORT

select
a.doctype+ ' ' + cast(a.docno AS VARCHAR(10)) [Document No.],
b.FK_iwItemsREN [Item Code],
dbo.udf_getitemdescription(b.FK_iwItemsREN) [Item Description],
b.renqty [Quantity],
a.rendate AS DATE,
dbo.udf_GetFullName(a.fk_emdpatients) [Name of Patient],
CASE
when a.pattrantype = 'I' then 'Inpatient'
when a.pattrantype = 'O' then 'Outpatient'
else 'Emergency'
end as
[Patient Type],
dbo.udf_GetFullName(a.FK_ASURenUser) [Render By]
from pspatinv A
inner join
psPatitem B on b.FK_TRXNO = a.PK_TRXNO
where b.itemgroup = 'EXM'
and a.rendate between '2019-02-23 00:00:01' and '2019-02-23 23:59:59'
order by DATE, [Name of Patient], [Document No.]

---------------------------------------------------------------------FINAL
CF4
select
b.FK_iwItemsREN [Item Code],
dbo.udf_getitemdescription(b.FK_iwItemsREN) [Item Description],
sum(b.renqty) [Quantity],
B.renprice [Price],
sum(B.renprice*B.renqty) [Amount]
from pspatinv A
inner join
psPatitem B on b.FK_TRXNO = a.PK_TRXNO
where a.fk_emdpatients = @realname
and a.rendate between @pDateRangeFrom and @pDateRangeTo
and b.itemgroup in ('MED','SUP')
and a.doctype = 'CH'
group by FK_iwItemsREN, B.renprice
ORDER BY b.FK_iwItemsREN
---------------------------------------------------debit credit
select dbo.udf_GetFullName(FK_emdPatients),* from psPatLedgers where
FK_psPatRegisters = '151907' --registry tracking number
delete from psPatAdjustments where FK_psPatRegisters = '151907' --registry
tracking number
delete from psPatLedgers where FK_psPatRegisters = '151907' and billtrancode
= 'CADJ' --credit
delete from psPatLedgers where FK_psPatRegisters = '151907' and billtrancode
= 'DADJ' --credit
----------------------------------------------------cash reciept unapplied
amount
select cancelflag, appliedamount,payername, * from facrmstr where orno=332219
update facrmstr set cashamount=12384.50,cashinput=12384.50,
totalamount=12384.50 where pk_trxno=2589525
----------------------------------------------------DOH BED OCCUPANCY
declare @from nvarchar(max) = '01/01/2019'
declare @to nvarchar(max) = '12/31/2019'
select DATEDIFF (day, registrydate,dischdate
),REGISTRYDATE,dischdate,registryno,
DBO.udf_GetFullName(FK_emdPatients)PATIENT,* from psPatRegisters
where convert(date,registrydate) between @from and @to
and pattrantype = 'I' AND registrystatus = 'D'

--------------------------------------------------- HOLD/UNHOLD
select
dbo.udf_GetFullName(FK_emdPatients) as [Patient Name]
,dbo.udf_GetFullName(FK_ASUHold) as [User Hold]
,holddatetime as [Hold Date/Time]
,dbo.udf_GetFullName(FK_ASURelease) as [User Unhold]
,releasedatetime as [Unhold Date/Time]
,case when ishold = 1 then 'YES'
else 'NO' end as [Is Hold?]
,dbo.udf_GetDepartmentName(FK_mscWarehouse) as [Department]
from psAcctHoldDept
where FK_psPatRegisters = '158180'