troubleshooting Question

Crystal reports - SQL question

Avatar of rustypoot
rustypootFlag for United States of America asked on
Crystal Reports
7 Comments1 Solution498 ViewsLast Modified:
Hi, I have the Sql below in the crystal reports; it errors out on MRuN_int field. The error is 'Conversion failed when converting the varchar value 'I2683794' to data type int.

How do I resolve this error?



SET NOCOUNT ON
      SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED


Select Distinct CV3A.ClientDisplayName AS "Patient Name",
CV3A.CurrentLocation as Location,
CV3A.IDCode AS MRUN,
CONVERT(int,REPLACE(CV3A.IDCode, '-', '')) as MRUN_Int,
CONVERT(int, REPLACE([CV3A].[VisitIDCode], '-', '')) as AcctNum_Int,
CV3A.VisitIDCode AS "Account Number",
--CV3FR.Name AS "Primary Insurance",
CV3A.ProviderDisplayName AS "Admitting MD Name",
CV3A.AdmitDtm AS "Admit Date/Time",
CV3O.value AS "LOC from Order",
CV3A.typecode AS "SCM Type",
CV3A.CareLevelCode AS "SCM Care Level",
CV3A.ServiceDescription AS "SCM Service",
O.GUID AS "OrderGuid",
O.OrderCatalogMasterItemGUID,
case  when O.orderstatuscode = 'AUA1' then 'Active'
      when O.orderstatuscode = 'COMP' then 'Complete' End as "OrderStatus" ,
o.createdwhen


from CV3ActiveVisitList CV3A with (nolock)

inner join CV3Order O
on CV3A.ClientGUID = O.ClientGUID
and CV3A.GUID = O.ClientVisitGUID
--and O.orderstatuscode in ('AUA1', 'COMP')


inner  join CV3OrderUserData CV3O
on CV3A.clientguid = CV3O.clientguid
AND CV3O.OrderGUID = O.GUID
 
inner join CV3FRPContract CV3F
on CV3A.clientguid = CV3F.clientguid
inner join CV3FRP CV3FR
on CV3F.frpguid = CV3FR.GUID
 
 --where CV3A.AdmitDtm > DateAdd(hh, -24, GETDATE())
 --AND CV3A.AdmitDtm < DateAdd(hh, 0, GETDATE())
WHERE  CV3FR.Name <>  'PRIVATE PAY SECONDARY'
AND CV3O.Value in ('Outpatient/Overnight', 'Inpatient', 'Outpatient', 'Observation', 'Observation/Overnight')
and O.Name in ('Level of Care', 'Level of Care (HOI)')
--and O.Name in ('Level of Care (HOI)')
and O.orderstatuscode in ('AUA1', 'COMP')
and CV3F.Status = 'Active'
order by CV3A.AdmitDtm desc
ASKER CERTIFIED SOLUTION
dsacker
Contract ERP Admin/Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros