All Projects → johnmackintosh → patientcounter

johnmackintosh / patientcounter

Licence: Unknown, GPL-3.0 licenses found Licenses found Unknown LICENSE GPL-3.0 LICENSE.md
fast, flexible patient census tables. Quickly count patients or resources by interval. No SQL, no problem.

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to patientcounter

runcharter
Automating run chart analysis for faceted displays of data across multiple metrics or locations
Stars: ✭ 31 (+63.16%)
Mutual labels:  nhs, rstats-package, rdatatable
rpostgis
rpostgis: R Interface to a 'PostGIS' Database
Stars: ✭ 60 (+215.79%)
Mutual labels:  rstats-package
GOSH-FHIRworks2020-React-Dashboard
🩺 Fully Responsive FHIR Dashboard written using @reactjs for NHS and GOSH hackathon
Stars: ✭ 21 (+10.53%)
Mutual labels:  nhs
DoReMIFaSol
Téléchargement des données sur le site de l'Insee
Stars: ✭ 25 (+31.58%)
Mutual labels:  rstats-package
open-health-statistics
Statistics on open source healthcare repositories
Stars: ✭ 20 (+5.26%)
Mutual labels:  nhs
netplot
Beautiful graph drawing
Stars: ✭ 47 (+147.37%)
Mutual labels:  rpackage
tenzing
tenzing: documening contributorship with CRediT
Stars: ✭ 42 (+121.05%)
Mutual labels:  rpackage
nhsuk-prototype-kit
NHS.UK prototype kit enables you to make interactive prototypes that will look like pages on NHS.UK. The prototypes you make are a great way to show ideas to others and for conducting user research.
Stars: ✭ 41 (+115.79%)
Mutual labels:  nhs
coronabr
Pacote para fazer o download dos casos diários de coronavirus no Brasil desde diferentes fontes
Stars: ✭ 50 (+163.16%)
Mutual labels:  rstats-package
rmetalog
R package for the metalog probability distribution
Stars: ✭ 27 (+42.11%)
Mutual labels:  rpackage
rawDiag
Brings Orbitrap Mass Spectrometry Data to Life; Multi-platform, Fast and Colorful R package.
Stars: ✭ 29 (+52.63%)
Mutual labels:  rpackage
rtweetXtras
Twitter analysis functions built for use with rtweet package (by mkearney)
Stars: ✭ 21 (+10.53%)
Mutual labels:  rstats-package
xsitemap
An R' 📦 to deal with XML sitemaps and help SEO
Stars: ✭ 15 (-21.05%)
Mutual labels:  rpackage
openeobs
An e-observations and ward management tool for Acute and Mental Health hospitals.
Stars: ✭ 24 (+26.32%)
Mutual labels:  nhs
NHSRdatasets
NHS and healthcare related datasets for training and learning R
Stars: ✭ 54 (+184.21%)
Mutual labels:  nhs
awesome-missing-nhs-things
a unAwesome list of missing NHS and Social Care interfaces, services, registers, and data sources.
Stars: ✭ 19 (+0%)
Mutual labels:  nhs
slurmR
slurmR: A Lightweight Wrapper for Slurm
Stars: ✭ 43 (+126.32%)
Mutual labels:  rpackage
stantargets
Reproducible Bayesian data analysis pipelines with targets and cmdstanr
Stars: ✭ 31 (+63.16%)
Mutual labels:  rstats-package
logitr
Fast estimation of multinomial (MNL) and mixed logit (MXL) models in R with "Preference" space or "Willingness-to-pay" (WTP) space utility parameterizations in R
Stars: ✭ 24 (+26.32%)
Mutual labels:  rstats-package
pagespeedParseR
pagespeedParseR is an R wrapper for Google Pagespeed Insights API, that also enables convenient parsing
Stars: ✭ 20 (+5.26%)
Mutual labels:  rstats-package

patientcounter

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Build Status

AppVeyor build status

codecov

R-CMD-check

How many patients were in the hospital at 10 AM yesterday?
How many were in during each 15 minute spell between 2pm and 6pm?
How many were in during the last week, by hour?

This package aims to make answering these questions easier and quicker.

No SQL? No problem!

If you have time in, time out, a unique patient identifier, and optionally, a grouping variable to track moves between departments, this package will tell you how many patients were ‘IN’ at any time, at whatever granularity you need.

Installation

patientcounter is not on CRAN yet, so install the development version from GitHub with:

# install.packages("remotes") # if not already installed
remotes::install_github("johnmackintosh/patientcounter")

Example

Obtain data for each individual patient, by hour, for each hour of their stay.
Note we are restricting the outputs to keep this readable

library(patientcounter)
patient_count <- interval_census(beds, 
identifier = 'patient',
admit = 'start_time', 
discharge = 'end_time', 
group_var = 'bed', 
time_unit = '1 hour', 
results = "patient", 
uniques = TRUE)

head(patient_count)
#>    bed patient          start_time            end_time  interval_beginning
#> 1:   A       1 2020-01-01 09:34:00 2020-01-01 10:34:00 2020-01-01 09:00:00
#> 2:   B       5 2020-01-01 09:45:00 2020-01-01 14:45:00 2020-01-01 09:00:00
#> 3:   A       1 2020-01-01 09:34:00 2020-01-01 10:34:00 2020-01-01 10:00:00
#> 4:   B       5 2020-01-01 09:45:00 2020-01-01 14:45:00 2020-01-01 10:00:00
#> 5:   C       9 2020-01-01 10:05:00 2020-01-01 10:35:00 2020-01-01 10:00:00
#> 6:   A       2 2020-01-01 10:55:00 2020-01-01 11:15:24 2020-01-01 10:00:00
#>           interval_end  base_date base_hour
#> 1: 2020-01-01 10:00:00 2020-01-01         9
#> 2: 2020-01-01 10:00:00 2020-01-01         9
#> 3: 2020-01-01 11:00:00 2020-01-01        10
#> 4: 2020-01-01 11:00:00 2020-01-01        10
#> 5: 2020-01-01 11:00:00 2020-01-01        10
#> 6: 2020-01-01 11:00:00 2020-01-01        10

To obtain summary data for every hour, for all combined patient stays:

library(patientcounter)
patient_count_hour <- interval_census(beds, 
identifier = 'patient',
admit = 'start_time', 
discharge = 'end_time', 
group_var = 'bed', 
time_unit = '1 hour', 
results = "total", 
uniques = TRUE)

head(patient_count_hour)
#>     interval_beginning        interval_end  base_date base_hour N
#> 1: 2020-01-01 09:00:00 2020-01-01 10:00:00 2020-01-01         9 2
#> 2: 2020-01-01 10:00:00 2020-01-01 11:00:00 2020-01-01        10 5
#> 3: 2020-01-01 11:00:00 2020-01-01 12:00:00 2020-01-01        11 4
#> 4: 2020-01-01 12:00:00 2020-01-01 13:00:00 2020-01-01        12 3
#> 5: 2020-01-01 13:00:00 2020-01-01 14:00:00 2020-01-01        13 3
#> 6: 2020-01-01 14:00:00 2020-01-01 15:00:00 2020-01-01        14 3

Note that you also receive the base date and base hour for each interval to enable easier filtering of the results.

Grouped values

This example shows grouping results by bed and hour.
The first ten rows of the resulting grouped values are shown

library(patientcounter)
grouped <- interval_census(beds, 
identifier = 'patient',
admit = 'start_time', 
discharge = 'end_time', 
group_var = 'bed', 
time_unit = '1 hour',
results = "group", 
uniques = FALSE)

head(grouped[bed %chin% c('A', 'B')],10)
#>     bed  interval_beginning        interval_end  base_date base_hour N
#>  1:   A 2020-01-01 09:00:00 2020-01-01 10:00:00 2020-01-01         9 1
#>  2:   B 2020-01-01 09:00:00 2020-01-01 10:00:00 2020-01-01         9 1
#>  3:   A 2020-01-01 10:00:00 2020-01-01 11:00:00 2020-01-01        10 2
#>  4:   B 2020-01-01 10:00:00 2020-01-01 11:00:00 2020-01-01        10 1
#>  5:   B 2020-01-01 11:00:00 2020-01-01 12:00:00 2020-01-01        11 1
#>  6:   A 2020-01-01 11:00:00 2020-01-01 12:00:00 2020-01-01        11 2
#>  7:   B 2020-01-01 12:00:00 2020-01-01 13:00:00 2020-01-01        12 1
#>  8:   A 2020-01-01 12:00:00 2020-01-01 13:00:00 2020-01-01        12 1
#>  9:   B 2020-01-01 13:00:00 2020-01-01 14:00:00 2020-01-01        13 1
#> 10:   A 2020-01-01 13:00:00 2020-01-01 14:00:00 2020-01-01        13 1

General Help

  • You must ‘quote’ your variables, for the time being at least..

Results

  • Set results to ‘patient’ for 1 row per patient per interval for each interval in the patient stay.
  • Set results to ‘group’ to get a count per group per interval.
    Remember this will also be influenced by the ‘uniques’ argument - set it to FALSE to ensure each move in each location is counted.
  • Set results to ‘total’ for a summary of the data set - interval, base_hour and count.

Tracking moves within the same interval with ‘uniques’

  • To count individual patients ONLY, leave ‘uniques’ at the default value of ‘TRUE’.
  • To count patient moves between locations during intervals, set uniques to ‘FALSE’. Patients who occupy beds in different locations during each interval are accounted for in each location. They will be counted at least twice during an interval - both in their initial location and their new location following a move.

Timezones

  • Everything is easier if you use “UTC” by default. You can attempt to coerce the final results yourself using lubridate::force_tz()

To find your system timezone:

Sys.timezone()

Time Unit

See ? seq.POSIXt for valid values

E.G. ‘1 hour’, ‘15 mins’, ‘30 mins’

Time Adjust

Want to count those in between 10:01 to 11:00? You can do that using ‘time_adjust_period’ - set it to ‘start_min’ and then set ‘time_adjust_interval’ to 1.

10:00 to 10:59?
Yes, that’s possible as well - set ‘time_adjust_period’ to ‘end_min’ and set ‘time_adjust_interval’ as before. You can set these periods to any value, as long as it makes sense in relation to your chosen time_unit.

Here we adjust the start_time by 5 minutes

library(patientcounter)
patient_count_time_adjust <- interval_census(beds, 
identifier = 'patient',
admit = 'start_time', 
discharge = 'end_time', 
group_var = 'bed', 
time_unit = '1 hour', 
time_adjust_period = 'start_min',
time_adjust_value = 5,
results = "total", 
uniques = TRUE)

head(patient_count_time_adjust)
#>     interval_beginning        interval_end  base_date base_hour N
#> 1: 2020-01-01 09:05:00 2020-01-01 10:00:00 2020-01-01         9 2
#> 2: 2020-01-01 10:05:00 2020-01-01 11:00:00 2020-01-01        10 5
#> 3: 2020-01-01 11:05:00 2020-01-01 12:00:00 2020-01-01        11 4
#> 4: 2020-01-01 12:05:00 2020-01-01 13:00:00 2020-01-01        12 3
#> 5: 2020-01-01 13:05:00 2020-01-01 14:00:00 2020-01-01        13 3
#> 6: 2020-01-01 14:05:00 2020-01-01 15:00:00 2020-01-01        14 3

Valid values for time_adjust_period are ‘start_min’, ‘start_sec’, ‘end_min’ and ‘end_sec’

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].