Using Crystal Reports and SQL to Create a Custom Report to Help
Total Page:16
File Type:pdf, Size:1020Kb
Using Crystal Reports and SQL to Create a Custom Report to Help Close the Care Gaps in Your Practice Steve King North Country HealthCare October 2019 Three Objectives: 1. Learn how to upload a report to Centricity, how to use parameters, and how to use formulas 2. Learn how to use SQL Server Management Studio to explore the data in Centricity 3. Create a report that can close the gaps of care in your practice 1. Mammogram 2. Expand to Diabetes • Session is for Beginner to Immediate Report creators • Assumes you are a CPS 12.X user • And you use clinical content, not CCC • Bonus Content SDID is a filed that is used to link DOCUMENT (where all EHR transactions start) to the various medical tables in the EHR (e.g. PROBLEM, ORDERS, OBS, ALLERGY, MEDICATE) Translating a EHR timestamp date to a normal date: DATEADD(ss, DOCUMENT.CLINICALDATE / 1000000, ‘01/01/1960’) SQL Keywords used in this presentation NULL: there is no value. It is neither true or false, doesn’t have a value. To do a comparison, must use <variable> IS [NOT] NULL, not an equality statement: (this is wrong) <variable> = NULL GETDATE():returns the current date/time ISNULL(var1, var2): If var1 IS NULL, use var2. Also see COALESCE JOIN – join 2 tables or datasets together About me Steve King, North Country HealthCare [email protected] Employed at North Country for over 9 years North Country has 14 access points throughout northern Arizona and parts of central Arizona Main campus is in Flagstaff, AZ 55,000 patients a year 160,000 visits 80 providers Tools to Develop Reports For Centricity Crystal Reports XI I don’t know how to acquire – your VAR should be able to help Crystal Report can be integrated differently in Centricity – this session uses Crystal Reports as a stand-alone application Microsoft SQL Server Management Studio Free with your version of SQL Server Centricity Data Dictionary Download from aethenahealth web site Crystal Report: Objectives 1. Using Parameters 2. Adding parameters to a SQL query 3. Creating formulas to show parameters in Centricity 4. Toggling the footer Upload a Crystal Report Into Centricity The Main Report Parameters in Centricity, Parameters and Formulas in Crystal Reports A footer that toggles visibility Crystal Report: Parameters Because these parameters are used to build formulas in Crystal Report, the Crystal Report data type may not be the same if this was a stand-alone report 1. STARTDATE and ENDATE– although they will be a date in Centricity, for the report they are strings 2. FACILITY and PROVIDER – although these will be used in Centricity as number, for the report they are strings 3. HIDE_FOOTER: used as a number in both Crystal Reports and Centricity Crystal Report: Formulas Formulas are used to 1. Display information 2. Change information 3. Store information For this report we are only displaying the data in the parameters FACILITY_CRITERIA and PROVIDER_CRITERIA Used to show the facility and the provider 1. Because this report requires to choose a facility this formula is different than one that allows the user to choose one or more facilities 'Facility: ' + {?FACILITY} Formulas to show all facilities or selected facilities/providers or selected providers If {?FACILITY} = 'NULL' THEN If {?Provider} = 'NULL' THEN "Facilities: all" “Providers: all" ELSE ELSE "Facilities: " & {?FACILITY} “Providers: " & {?Provider} DATE_CRITERIA Because we force the user to enter dates, we know that there will be a start date and end date "Dates from " & {?STARTDATE} & " to " & {?ENDDATE} Toggle a Report Section in Crystal Reports In Crystal Reports Create a parameter named HIDE_FOOTER Field type: number In the Report footer enter the text you want to show In Section Expert make sure Suppress (No Drill-Down is unchecked and enter this formula: {?HIDE_FOTTER}=1 This can be done for any section you want to hide Report Design Mode Toggle between design mode and report mode Centricity: Parameters To transfer parameters values from Centricity to Crystal Report, usually use text The are different ways use parameters from Centricity to the SQL query Select Boxes: ?CONTROLNAME.ITEMDATA.U? or ?CONTROLNAME.ITEMDATA? “U” shows actual numbers No “U” shows numbers as quoted string Dates To And FROM: ?CONTROLNAME.DATE1? or ?CONTROLNAME.DATE2? Check boxes and radio buttons: ?CONTROLNAME.VALUE? Centricity: Parameters As a Filter in a Query This will let you filter on None, One, or Multiple Providers AND ( (?PROVIDER.ITEMDATA? IS NOT NULL AND a.DoctorID IN (?PROVIDER.ITEMDATA.U?)) OR (?PROVIDER.ITEMDATA? IS NULL) ) Note the use or non-use of “U” AND ( ('2972' IS NOT NULL AND a.DoctorID IN (2972)) OR ('2972' IS NULL) ) Centricity and Crystal Reports: Tying the Parameters Together If {?Provider} = 'NULL' THEN “Providers: all" ELSE “Providers: " & {?Provider} Centricity and Report Dates If your report is date sensitive, always require dates You can use a default statement ISNULL(<entered date>,’01/01/1900’), but then you run the chance of getting too much data We’ve been on Centricity for 10 years – do I really want 10 years of data for an appointment report? RAISERROR You can use a RAISERROR statement if your user enters a wrong date SQL keyword that raises an error, causing the query to stop Centricity has no way to capture the error You get an ID Dispatch error Full use of the keyword is outside of this discussion IF @StartDate <= '12/31/2018' RAISERROR ('StartDate is too small', 16, 1) Centricity SQL Preview Button Lets you see the SQL in the report Don’t Forget to Assign Security! Right click on the Report Assign by Group, not by User Always uncheck the Delete Column Checking Edit will allow user/group to save criteria report Carefully think about allowing that – otherwise your report folders will get cluttered. Exploring Data in Your Database OBSTERMs OBSTERMs (or Observation Terms) are what determines what is shown in the Flowsheet The actual observation lives in the table OBS, or in the view RPTOBS Key fields are OBSDATE, OBSVALUE, PID, and XID OBSHEAD is a table that contains observation codes and descriptions for OBSTERM Key fields are HDID, NAME, and DESCRIPTION OBSTERMs to Close a Gap: Mammogram Three ways to determine if a mammogram was performed: 1. OBSTERMS 2. ICD-10 Codes 3. CPT Codes What to use depends on your clinical workflow – for this example we’re using OBSTERM How to Find The OBSTERM: Clinical Content Find forms where the OBSTERM might be used Start a visit with the form End the visit Click “View Clinical Content” How to Find The OBSTERM: Export a Clinical Kit • Administration > System > Export Clinical Kits > Form Component will bring up the Search Screen • Then click Export Clinical Kit, and save it to your computer Clinical Kit: Includes a Lot of Files • The Microsoft Excel Template file has the OBSTERMS by NAME used in the form • Excel will complain when you open the file – just answer yes • You’ll have to do some detective work to find the possible OBSTERM you’re looking for [This is from the XLT file] /*Function for RUNPROCESS Button Record Mammogram*/ fn fn1151_1503350234_635(){ if (PATIENT._AGEINMONTHS >= 480 and PATIENT._AGEINMONTHS < 600) then fnRecObs_CSF(DOCUMENT.RESULTMAM_1151_1503350234_633,DOCUMENT.DATEMAM_1151_1503350234_634,"MAMMOGRAM","MAMMO DUE",731) else fnRecObs_CSF(DOCUMENT.RESULTMAM_1151_1503350234_633,DOCUMENT.DATEMAM_1151_1503350234_634,"MAMMOGRAM","MAMMO DUE",365) endif View Clinical Content is a lot easier! Finding the OBSTERM HDID OBSHEAD is a table that stores all the OBSTERMs OBSHEAD.NAME is the field that was returned when you clicked View Clinical Content OBSHEAD.HDID is the field that identifies the OBSTERM in OBS To get OBSHEAD.HDID for MAMMOGRAM run a query on OBSHEAD OR do a Join (Shown on next slide) Verifying Your OBSTERM is Being Used SET NOCOUNT ON SET NOCOUNT ON OBS is the actual Table; SELECT SELECT RPTOBS is a view COUNT(*) COUNT(*) AS [Count] , oh.Name , oh.Name , oh.Description , oh.Description FROM OBS o FROM RPTOBS o JOIN OBSHEAD oh ON o.HDID = oh.HDID JOIN OBSHEAD oh ON o.HDID = oh.HDID WHERE (oh.Name = 'MAMMOGRAM') WHERE o.HDID = 71 GROUP BY GROUP BY oh.Name oh.Name , oh.Description , oh.Description That’s a lot of mammograms – Guess we have the correct OBSTERM Verifying Your OBSTERM is Being Used Correctly SET NOCOUNT ON DECLARE @StartDate datetime = '08/01/2019' , @EndDate datetime = '08/31/2019' DECLARE @Lookback date = DATEADD(mm, -14, @EndDate) /* 15 months from end of measurement period. Zero month counts as a month */ SELECT DISTINCT o.OBSVALUE FROM OBS o WHERE (o.HDID = 71) AND (o.OBSDATE >= @Lookback AND o.OBSDATE < DATEADD(d, 1, @EndDate)) Hmm, some of those values don’t look valid Verifying the Correct OBSVALUE Work with your clinical team Some of the results are obviously not valid: Declines Assessment Incomplete After talking to the clinical team, results that are either Normal, Abnormal, or contain the phrase BIRAD are valid mammograms The OBSVALUE is not case sensitive How to Return the Correct OBSVALUE? Hold that thought! Will explain when we look at the report query! Developing a Care Gap Report Thinking ahead… Looking for appointments Looking for patients that meet the denominator for the gaps we are trying to close Numerator include an observation during a measurement period – but do we need to look outside the measurement period? Denominators usually only include medical visits Looking for patients that DON’T meet the numerator for the gaps we are trying to close There could be a lot of appointments, which can impact the performance of Centricity Limit the time of day when the report is ran? Limit the data that is being returned? Understanding the Requirements: What is a Medical Visit? Can use document type (EHR) or CPT code Internally, we decided to use CPT codes Document types are too “fuzzy”, i.e.