Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Subquery Help Part 2

Author  Topic 

JeffS23
Posting Yak Master

212 Posts

Posted - 2008-01-17 : 17:04:54
Earlier today, I recvd fast accurate help on my question. In testing my data, I found one minor issue, I did not plan for in my original post.

My issue has to do with the ProcedureFiled.

For example, in testing, I had a claim filed with 6 procedures. The totalallowed subquery calculated right on this one, because it contained all the procedure. In another filing only one of the 6 procedures was filed and the subquery told it to produce a result as if all 6 codes had been filed. So I think I need to factor in the ProcedureFiled.



/* Claims report */
SET NOCOUNT ON

-- paper claims and claim status
SELECT pv.TicketNumber,
dbo.FormatName(pp.Prefix, pp.First, pp.Middle, pp.Last, pp.Suffix) AS Name,
pv.Visit,
'' AS FileName,
FilingMethod = ISNULL(fm.Description, '<unknown>') + CASE WHEN ISNULL(pvpc.ClaimStatus, 0) <> 0 THEN ' Claim Status' ELSE '' END,
pv.FilingType,
'' AS Clearinghouse,
pvpc.CreatedBy AS FiledBy,
pvpc.Name AS FiledTo,
NULL AS SubmissionNumber,
pvpc.CreatedBy AS CreatedBy,
pvpc.Created AS DateCreated,
pvpc.Created AS DateTransmitted,
pvpc.Procedures AS ProcedureFiled,
pvpc.Charges AS AmountFiled,
tmp.TotalAllowed

FROM PatientVisitPaperClaim pvpc
INNER JOIN PatientVisit pv ON pvpc.PatientVisitId = pv.PatientVisitId
INNER JOIN (SELECT pv1.PatientVisitId ,SUM(pvp.totalallowed) AS TotalAllowed
FROM PatientVisitProcs pvp
JOIN PatientVisit pv1 ON pvp.PatientVisitId = pv1.PatientVisitId
GROUP BY pv1.PatientVisitId
)tmp ON tmp.PatientVisitId =pv.PatientVisitId
LEFT JOIN MedLists fm ON pvpc.FilingMethodMId = fm.MedListsId
INNER JOIN PatientProfile pp ON pv.PatientProfileId = pp.PatientProfileId

WHERE etc, etc, etc .....

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-18 : 05:54:18
what designates the information that a procedure has been filed?
Go to Top of Page
   

- Advertisement -