Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel #22

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Rel #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions doc/BestillingerOgUtleveringer.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,134 @@ library(norgast)
# library(tidyverse)
rm(list=ls())

##### Uttrekk Søreide, pankreas 2016-2022, 22.10.2024 ##########################
varnavn_kobl <- data.frame(
kol = c("mce.MCEID AS ForlopsID",
"mce.PATIENT_ID AS PasientId",
"mce.CENTREID AS AvdRESH",
"patient.SSN AS Fodselsnummer",
"patient.DECEASED AS Avdod",
"patient.DECEASED_DATE AS AvdodDato",
"centre.CENTRENAME AS SenterNavn",
"registration.PREVIOUS_WEIGHT AS Vekt6MndFoer",
"registration.PREVIOUS_WEIGHT_MISS AS Vekt6MndFoerUkjent",
"registration.ADMISSION_WEIGHT AS VektVedInnleggelse",
"registration.ADMISSION_WEIGHT_MISS AS VektVedInnleggelseUkjent",
"registration.HEIGHT AS Hoyde",
"registration.HEIGHT_MISS AS HoydeUkjent",
"registration.BMI AS BMI",
"registration.BMI_CATEGORY AS BMIKategori",
"registration.WEIGHTLOSS AS VekttapProsent",
"registration.DIABETES AS MedDiabetes",
"registration.CHEMOTHERAPY_ONLY AS KunCytostatika",
"registration.RADIATION_THERAPY_ONLY AS KunStraaleterapi",
"registration.CHEMORADIOTHERAPY AS KjemoRadioKombo",
"registration.WHO_ECOG_SCORE AS WHOECOG",
"registration.ALBUMIN AS Albumin",
"registration.CRP AS CRP",
"registration.GLASGOW_SCORE AS GlasgowScore",
"registration.MODIFIED_GLASGOW_SCORE AS ModGlasgowScore",
"registration.ASA AS ASA",
"registration.LUNG_DISEASE AS Lungesykdom",
"registration.HEART_DISEASE AS Hjertesykdom",
"registration.URGENCY AS Hastegrad",
"registration.ANESTHESIA_START AS AnestesiStartKl",
"registration.PRS_SCORE AS PRSScore",
"registration.OPERATION_DATE AS OpDato",
"registration.NCSP AS Hovedoperasjon",
"registration.ABLATION AS LeverAblasjon",
"registration.RECONSTRUCTION AS Rekonstruksjon",
"registration.RECONSTRUCTION_TYPE AS Rekonstruksjonstype",
"registration.ANASTOMOSIS_LEVEL AS Anastomoseniva",
"registration.ANASTOMOSIS AS NyAnastomose",
"registration.ANAL_GUARD_DISTANCE AS AvstandAnalVerge",
"registration.ANAL_GUARD_DISTANCE_MISS AS AvstandAnalVergeIkkeAkt",
"registration.TATME AS TaTME",
"registration.OSTOMY AS NyStomi",
"registration.ABDOMINAL_ACCESS AS Tilgang",
"registration.ROBOTASSISTANCE AS Robotassistanse",
"registration.THORAX_ACCESS AS ThoraxTilgang",
"registration.RELAPAROTOMY AS ReLapNarkose",
"registration.RELAPAROTOMY_YES AS ViktigsteFunn",
"registration.FINDINGS_SPESIFISER AS FunnSpesifiser",
"registration.RELAPAROTOMY_NO AS AnnenOpIAnestsi",
"registration.INTERVENTION_WITHOUT_ANESTHESIA AS IntUtenAnestesi",
"registration.PERCUTANEOUS_DRAINAGE AS PerkDrenasje",
"registration.HIGH_AMYLASE_CONCENTRATION AS HoyAmylaseKons",
"registration.LEAK_INTERVENTION AS EndoInterLekkasje",
"registration.BLEED_INTERVENTION AS EndoInterBlod",
"registration.ANGIO_INTERVENTION AS AngioInter",
"registration.LIQUID_DRAINAGE AS KunDrenasje",
"registration.SINGLE_ORGAN_FAILURE AS EttOrganSvikt",
"registration.MULTI_ORGAN_FAILURE AS MultiOrganSvikt",
"registration.IN_HOUSE_DEATH AS DodUnderOpphold",
"registration.IN_HOUSE_DEATH_DATE AS DodUnderOppholdDato",
"registration.ACCORDION_SCORE AS AccordionGrad",
"registration.DISCHARGE_DATE AS UtskrivelseDato",
"registration.BED_DAYS AS PostopLiggedogn",
"registration.ICD10 AS Hoveddiagnose",
"registration.DISCHARGE_TO AS UtskrevetTil",
"registration.STATUS AS RegistreringStatus",
"readmission.OWN_INSTITUTION AS ReinnlEgenInst",
"readmission.OTHER_INSTITUTIONS AS ReinnlAndreInst",
"readmission.CONTROL AS AktivKontroll",
"readmission.PHYSICAL_CONTROL AS FysiskKontroll",
"readmission.PHONE_CONTROL AS TelefonKontroll",
"readmission.RELAPAROTOMY AS OppfReLapNarkose",
"readmission.RELAPAROTOMY_YES AS OppfViktigsteFunn",
"readmission.FINDINGS_SPESIFISER AS OppfFunnSpesifiser",
"readmission.RELAPAROTOMY_NO AS OppfAnnenOpIAnestsi",
"readmission.INTERVENTION_WITHOUT_ANESTHESIA AS OppfIntUtenAnestesi",
"readmission.PERCUTANEOUS_DRAINAGE AS OppfPerkDrenasje",
"readmission.HIGH_AMYLASE_CONCENTRATION AS OppfHoyAmylaseKons",
"readmission.LEAK_INTERVENTION AS OppfEndoInterLekkasje",
"readmission.BLEED_INTERVENTION AS OppfEndoInterBlod",
"readmission.ANGIO_INTERVENTION AS OppfAngioInter",
"readmission.LIQUID_DRAINAGE AS OppfKunDrenasje",
"readmission.SINGLE_ORGAN_FAILURE AS OppfEttOrganSvikt",
"readmission.MULTI_ORGAN_FAILURE AS OppfMultiOrganSvikt",
"readmission.IN_HOUSE_DEATH AS OppfDodUnderOpphold",
"readmission.IN_HOUSE_DEATH_DATE AS OppfDodUnderOppholdDato",
"readmission.ACCORDION_SCORE AS OppfAccordionGrad",
"readmission.STATUS AS OppfStatus")) %>%
tidyr::separate(col="kol", into=c("dbnavn", "rapporteket"), sep = " AS ") %>%
dplyr::mutate(dbnavn = toupper(dbnavn))
# dplyr::as_tibble() %>%
# tidyr::separate(col="dbnavn", into=c("skjema", "dbnavn"), sep = "\\." )

utlevernavn <- readr::read_csv2("~/mydata/norgast/utlevering_soreide.csv",
locale = readr::locale(encoding = "Latin1"))
utlevernavn <- utlevernavn %>% dplyr::mutate(variabel_id = sub("_", ".", variabel_id))
utlevernavn1 <- utlevernavn$variabel_id %>% unique()
utlevernavn <- readr::read_csv2("~/mydata/norgast/varnavn_utlevering_v2.csv",
locale = readr::locale(encoding = "Latin1"))
utlevernavn <- utlevernavn %>% dplyr::mutate(variabel_id = sub("_", ".", variabel_id))
utlevernavn2 <- utlevernavn$variabel_id %>% unique()
rappnavn_utlevering <- varnavn_kobl %>%
dplyr::filter(dbnavn %in% c(utlevernavn1, utlevernavn2))

RegData <- norgast::NorgastHentRegData()
RegData <- norgast::NorgastPreprosess(RegData)
kobling <- readr::read_csv2("~/mydata/norgast/NoRGast_koblingstabell_datadump_30.09.2024.csv")

utlevering <- RegData %>%
dplyr::filter(Aar %in% 2016:2022 &
ncsp_lowercase %in% c("jlc10", "jlc11", "jlc30", "jlc31")) %>%
dplyr::select(c(rappnavn_utlevering$rapporteket,
"PasientID", "PasientKjonn", "AvdRESH", "SykehusNavn", "ForlopsID", "Alder")) %>%
merge(kobling, by.x = "PasientID", by.y = "PID") %>%
mutate(fdato = paste0(substr(SSN, 1,2), ".", substr(SSN, 3,4), ".", substr(SSN, 5,6))) %>%
select(-"SSN") %>%
mutate(ncsp_kode = stringr::str_extract(Hovedoperasjon, "^[^\\s]+"),
ncsp_tekst = stringr::str_extract(Hovedoperasjon, "\\s.+"),
icd10_kode = stringr::str_extract(Hoveddiagnose, "^[^\\s]+"),
icd10_tekst = stringr::str_extract(Hoveddiagnose, "\\s.+"))

openxlsx::write.xlsx(utlevering, "~/mydata/norgast/textbook_outcomes_pancreas_okt2024.xlsx")
write.csv2(utlevering, "~/mydata/norgast/textbook_outcomes_pancreas_okt2024.csv",
row.names = F, fileEncoding = "Latin1", na = "")


###### Komorbiditet NPR 30.09.2024 ########################################
RegData <- norgast::NorgastHentRegData() %>%
norgast::NorgastPreprosess() %>%
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
dev:
depends_on:
- db
image: rapporteket/norgast-dev:main
image: rapporteket/norgast-dev:weekly
volumes:
- ~/.ssh:/home/rstudio/.ssh
- ~/.gitconfig:/home/rstudio/.gitconfig
Expand Down
Loading