Main Functions
The two main functions in this package are write_reports and write_reports_local.
write_reports
This function calls upon nearly all of the other functions in the package to run the entire quality report generation. Here’s what it does:
Executes a SQL query to a database named BioSense_Platform and a specific table that you specify in the
tableparameter. Note that this function is only going to run on the processed tables; that is, it is not capable of parsing raw HL7 messages from facilities. For the call to the processed table, it will draw down all variables for records where the visit date was between two dates that you specify (i.e.,startandend). The function will also make a query to the master facilities table (MFT) that you specify (using themftparameter), pulling down all rows, but only the C_Biosense_Facility_ID and Facility_Name columns. This second call is just so that we are able to identify facilities by their name and not just facility ID number. The function uses theRODBCpackage to make these queries. If you wish to make a pull using this function outside of thewrite_reportsfunction, please see the documentation forpull_data.Checks how many fields are null. This is done along a specific process: first, there are required and optional fields. We determined which are “required” or “optional” based on the Public Health Information Network (PHIN) guide and what we needed at KDHE; second, some are counted null at the record level, while others are counted null at the visit level. What does this second point mean? We can get multiple records sent to us for one patient’s visit. A small number of fields are required to be non-null for every single record. A list of these can be found in the
get_req_nullsdocumentation. For these few fields, the null check will count how many records have these fields as null and will also generate a percentage for null fields (where the number of total records is the denominator). For all of the others, we only count it as null if it was null in all of the records for one patient visit. This means that the percentages are based on the denominator that is the number of patient visits.Checks how many fields are invalid. If fields are filled in, are they filled in correctly? Invalid checks are done based on the PHIN VADS value codes, found at the NSSP website. An entire list of invalid checks and full details on what is checked can be found at the documentation for all of the functions that end with
_invalid, such asadmit_source_invalid. This package also includes datasets that include that concept codes or concept names that are considered valid by the PHIN VADS. See the documentation for*_invalidfunctions to see these. These are done at the patient visit level (i.e., grouped by C_BioSense_ID). If one field from this visit is entered as invalid, then the whole visit gets returned as invalid. Therefore, percentages are calculated with the number of patient visits as the denominator.All of the previous checks are done grouped by facility. This function also generates the counts and percentages at the state level (or table level, if your processed table is not pulling down data from the entire state).
Timeliness reports. For each facility, this function will calculate the average time, in hours, between (a) when the patient visited the emergency department and (b) when the first record for this visit arrived to the NSSP BioSense Platform. For this, you need to specify an
offsettime. The time that the record arrives is in UTC, so you must choose how much to offset that by. You can easily Google how far your time zone is from UTC. For example, Central Time would enter in5or6, depending on if it is daylight savings or not. You can see more information about this in the documentation for bothwrite_reportsandva_lag.Writes an Excel workbook to a specified directory called “State_Summary” that includes information described in 2 through 5.
Writes a similar Excel workbook for every single facility in the raw data. In these facility-specific workbooks, only that facility (and the statewide information) is presented.
Writes an Excel workbook for every single facility in the raw data that includes examples of records that are null or invalid, specifying which fields are invalid. You can specify how many examples you want for every type of check. If you do not want example workbooks to be written, you can specify
0as the number of examples.
What does this look like? For example, let’s say someone with a username lskywalker with password xwingred5 wanted data from the Kansas production data (KS_PR_Processed table) for the month of June. He wanted these reports to be saved to a folder called “JuneReports” in this “Documents” folder, and he wants 20 null and invalid examples per field. He would open the R session and enter:
library(biosensequality)
write_reports(username="lskywalker", password="xwingred5",
table="KS_PR_Processed", mft="KS_MFT",
start="2017-06-01 00:00:00",
end="2017-06-30 23:59:59",
directory="~/Documents/JuneReports",
nexamples=20, offset=5)
write_reports_local
This function does the exact same as above, except it skips Step 1 of pulling down all of the data. The user must provide data themselves. Let’s say someone wanted to do write the same reports as above, but they loaded the data into their R session as df and namekey already (see the documentation, ?write_reports_local, for how the two data frames should look). They would enter:
library(biosensequality)
write_reports_local(data=df, fnames=namekey,
directory="~/Documents/JuneReports",
nexamples=20, offset=5)
write_facility
For a lightweight alternative, one could try the write_facility function. This function also takes a specific C_Biosense_Facility_ID and generates a summary file and an example file for that facility only. This takes far less time to run, and it might be useful in a situation where you are concerned with only what one facility is doing, and do not need an overall assessment of every single facility. The query would be the same as for write_reports, except now you enter a facility argument (and no offset argument, as this does not return a time lag. That can easily be done by using just the va_lag function):
library(biosensequality)
write_facility(username="lskywalker", password="xwingred5",
table="KS_PR_Processed", mft="KS_MFT",
start="2017-06-01 00:00:00",
end="2017-06-30 23:59:59",
facility=3889
directory="~/Documents/JuneReports",
nexamples=20)