SORMAS-Foundation / SORMAS-Glossary

This glossary contains definitions of all the entities and attributes in SORMAS.
https://hzi-braunschweig.github.io/SORMAS-Glossary/en
GNU General Public License v3.0
5 stars 6 forks source link

How to identify contacts that converted into new cases? #33

Closed MallerBeach closed 3 years ago

MallerBeach commented 3 years ago

Dear all,

a further question for clarification regarding SORMAS ÖGD. How to identify contacts that converted into new cases?

The table contacts contains the variable contactstatus, but in our cases it does not seem to be a valid representation of the current dynamic of the COVID19 pandemic bearing in mind the Variants of Concern.

Any clearification would be appreciated!

VitaliHZI commented 3 years ago

Hey @MallerBeach, I think this GitHub Repo is not the right space for this question. Maybe you could write an Email to sormas-covid@helmholtz-hzi.de and the support there can help you with this question.

BR Vitali

MallerBeach commented 3 years ago

@VitaliHZI Thanks for that hint.

I am not expecting a code review....below I am just sharing some thoughts...

#### Using the example-data from the statistics-export

# sormas_path <-  # ...path to data

library(data.table)
library(dplyr)

##### Cases -----
cases <- fread(paste0(sormas_path, "cases.csv"), skip = 1, encoding = "UTF-8") %>%
  tibble() %>%
  filter(deleted == "f" & !caseclassification == "NO_CASE")

##### Contacts -----
contacts <- fread(paste0(sormas_path, "contacts.csv"), skip = 1, encoding = "UTF-8") %>%
  tibble() %>%
  filter(deleted == "f" & !is.na(caze_id))

##### Convertd contacts -----
converted_contacts <- filter(contacts, contactstatus == "CONVERTED") %>%
  group_by(person_id) %>%
  mutate(first_conversion = case_when(creationdate == min(creationdate) ~ 1)) %>%
  select(first_conversion, person_id, creationdate, contactstatus) %>%
  arrange(person_id, creationdate) %>%
  filter(first_conversion == 1) 

##### Converted cases that were contacts -----
cases <- mutate(cases, converted_contact = case_when(person_id %in% converted_contacts$person_id ~ "converted_contact",
                                                              TRUE ~ "case"))

table(cases$converted_contact)