setwd("D://dataextractdumai//buban bojonegoro//data_lama")
library(stats)
library(dplyr, warn.conflicts = FALSE)
library(tidyverse)
library(ggplot2)
library(kableExtra)
df_usg <- read.csv("datasplit_3.csv", sep = ",") %>%
select(SEP, Nokapst, Jkpst, Kdcmg, Kdinacbgs, DM, NmDM, DU, NmDU, DS,
Procedure, Nmjnsplg, Tglpelayanan, Tglstjkeu, Tgldtgsjp, Tglplgsjp,
LOS, Umur, Biaya) %>%
filter(str_detect(Procedure, c("8878")))
df_usg$Tglpelayanan <- as.Date(df_usg$Tglpelayanan, format = "%d/%m/%Y")
df_usg$Tglstjkeu <- as.Date(df_usg$Tglstjkeu, format = "%d/%m/%Y")
df_usg$Tgldtgsjp <- as.Date(df_usg$Tgldtgsjp, format = "%d/%m/%Y")
df_usg$Tglplgsjp <- as.Date(df_usg$Tglplgsjp, format = "%d/%m/%Y")
Tabel
dt <- df_usg %>%
select("SEP", "Nokapst", "Kdinacbgs", "DU", "Procedure", "Umur", "Biaya")
class(dt)
## [1] "data.frame"
dt_1 <- dt [1:5, ]
dt_1 %>%
kbl() %>%
kable_styling()
|
SEP
|
Nokapst
|
Kdinacbgs
|
DU
|
Procedure
|
Umur
|
Biaya
|
|
0202R01102160000002
|
36434875
|
Z-3-25-0
|
Z090
|
8878 - Diagnostic ultrasound of gravid uterus
|
24
|
281500
|
|
0203R00502160000001
|
98671387
|
Z-3-25-0
|
O200
|
8878 - Diagnostic ultrasound of gravid uterus
|
29
|
281500
|
|
0203R00502160000006
|
26954594
|
Z-3-25-0
|
O48
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
0203R00502160000007
|
20845278
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
1302R00302160000015
|
74956352
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
18
|
281500
|
dt_1 %>%
kbl() %>%
kable_paper("hover", full_width = F)
|
SEP
|
Nokapst
|
Kdinacbgs
|
DU
|
Procedure
|
Umur
|
Biaya
|
|
0202R01102160000002
|
36434875
|
Z-3-25-0
|
Z090
|
8878 - Diagnostic ultrasound of gravid uterus
|
24
|
281500
|
|
0203R00502160000001
|
98671387
|
Z-3-25-0
|
O200
|
8878 - Diagnostic ultrasound of gravid uterus
|
29
|
281500
|
|
0203R00502160000006
|
26954594
|
Z-3-25-0
|
O48
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
0203R00502160000007
|
20845278
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
1302R00302160000015
|
74956352
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
18
|
281500
|
dt_1 %>%
kbl(caption = "Menampilkan tabel") %>%
kable_classic(full_width = F, html_font = "Cambria")
Menampilkan tabel
|
SEP
|
Nokapst
|
Kdinacbgs
|
DU
|
Procedure
|
Umur
|
Biaya
|
|
0202R01102160000002
|
36434875
|
Z-3-25-0
|
Z090
|
8878 - Diagnostic ultrasound of gravid uterus
|
24
|
281500
|
|
0203R00502160000001
|
98671387
|
Z-3-25-0
|
O200
|
8878 - Diagnostic ultrasound of gravid uterus
|
29
|
281500
|
|
0203R00502160000006
|
26954594
|
Z-3-25-0
|
O48
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
0203R00502160000007
|
20845278
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
1302R00302160000015
|
74956352
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
18
|
281500
|
dt_1 %>%
kbl() %>%
kable_classic_2(full_width = F)
|
SEP
|
Nokapst
|
Kdinacbgs
|
DU
|
Procedure
|
Umur
|
Biaya
|
|
0202R01102160000002
|
36434875
|
Z-3-25-0
|
Z090
|
8878 - Diagnostic ultrasound of gravid uterus
|
24
|
281500
|
|
0203R00502160000001
|
98671387
|
Z-3-25-0
|
O200
|
8878 - Diagnostic ultrasound of gravid uterus
|
29
|
281500
|
|
0203R00502160000006
|
26954594
|
Z-3-25-0
|
O48
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
0203R00502160000007
|
20845278
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
34
|
281500
|
|
1302R00302160000015
|
74956352
|
Z-3-25-0
|
Z348
|
8878 - Diagnostic ultrasound of gravid uterus
|
18
|
281500
|
df_usg$specific <- as.character(trimws(substr(df_usg$Kdinacbgs,1,6)), "both")
str(df_usg)
## 'data.frame': 31746 obs. of 20 variables:
## $ SEP : chr "0202R01102160000002" "0203R00502160000001" "0203R00502160000006" "0203R00502160000007" ...
## $ Nokapst : int 36434875 98671387 26954594 20845278 74956352 43632683 101599071 57895853 49891574 46235927 ...
## $ Jkpst : chr "Perempuan" "Perempuan" "Perempuan" "Perempuan" ...
## $ Kdcmg : chr "Z" "Z" "Z" "Z" ...
## $ Kdinacbgs : chr "Z-3-25-0" "Z-3-25-0" "Z-3-25-0" "Z-3-25-0" ...
## $ DM : chr "O601" "O209" "Z349" "Z349" ...
## $ NmDM : chr "Preterm labour with preterm delivery" "Haemorrhage in early pregnancy, unspecified" "Supervision of normal pregnancy, unspecified" "Supervision of normal pregnancy, unspecified" ...
## $ DU : chr "Z090" "O200" "O48" "Z348" ...
## $ NmDU : chr "Follow-up examination after surgery for other conditions" "Threatened abortion" "Prolonged pregnancy" "Supervision of other normal pregnancy" ...
## $ DS : chr "" "" "" "" ...
## $ Procedure : chr "8878 - Diagnostic ultrasound of gravid uterus" "8878 - Diagnostic ultrasound of gravid uterus" "8878 - Diagnostic ultrasound of gravid uterus" "8878 - Diagnostic ultrasound of gravid uterus" ...
## $ Nmjnsplg : chr "Sehat" "Sehat" "Sehat" "Sehat" ...
## $ Tglpelayanan: Date, format: "2016-02-01" "2016-02-01" ...
## $ Tglstjkeu : Date, format: "2016-03-30" "2016-03-30" ...
## $ Tgldtgsjp : Date, format: "2016-02-01" "2016-02-01" ...
## $ Tglplgsjp : Date, format: "2016-02-01" "2016-02-01" ...
## $ LOS : int 1 1 1 1 1 1 1 3 1 1 ...
## $ Umur : int 24 29 34 34 18 20 32 53 38 29 ...
## $ Biaya : int 281500 281500 281500 281500 281500 281500 281500 2102400 281500 281500 ...
## $ specific : chr "Z-3-25" "Z-3-25" "Z-3-25" "Z-3-25" ...
df_usg$Kdppk <- as.character(trimws(substr(df_usg$SEP,1,8)), "both")
df_usg <- df_usg %>%
mutate(
NmFKRTL = case_when(
Kdppk == "0202R004" ~ "RS Bhayangkara Wahyu Tutuko",
Kdppk == "0202R011" ~ "RSI Muhammadiyah Sumberrejo",
Kdppk == "0202R012" ~ "RS Muhammadiyah Kalitidu",
Kdppk == "0202S001" ~ "KU Muh Kedungadem",
Kdppk == "0202R016" ~ "RSIA Fatma",
Kdppk == "0203R005" ~ "RS Muhammadiyah Tuban",
Kdppk == "0203R007" ~ "RS Medika Mulia",
Kdppk == "1302R003" ~ "RS NU Tuban",
Kdppk == "1304R001" ~ "RSUD dr R Sosodoro",
Kdppk == "1304R002" ~ "RSUD Sumberrejo",
Kdppk == "1304R003" ~ "RSUD Padangan",
Kdppk == "1305R001" ~ "RSUD dr R. Koesma",
Kdppk == "0202R005" ~ "RS Aisyiyah",
Kdppk == "0202R015" ~ "RS MNU Muna Anggita",
Kdppk == "0203R008" ~ "RSUD Ali Manshur Jatirogo",
TRUE ~ Kdppk))
df_usg <- df_usg %>%
select(-Kdppk) %>%
arrange(NmFKRTL)
# check the structure of a df
glimpse(df_usg)
## Rows: 31,746
## Columns: 21
## $ SEP <chr> "0202S00110170000087", "0202S00108170000043", "0202S00...
## $ Nokapst <int> 66830576, 51902606, 54191468, 51902606, 7791388, 46150...
## $ Jkpst <chr> "Perempuan", "Perempuan", "Perempuan", "Perempuan", "P...
## $ Kdcmg <chr> "W", "O", "Z", "Z", "Z", "Z", "W", "W", "W", "O", "W",...
## $ Kdinacbgs <chr> "W-4-16-I", "O-6-13-II", "Z-3-25-0", "Z-3-25-0", "Z-3-...
## $ DM <chr> "O211", "O429", "O410", "O365", "O758", "N841", "O809"...
## $ NmDM <chr> "Hyperemesis gravidarum with metabolic disturbance", "...
## $ DU <chr> "O211", "O410", "O410", "O365", "O758", "N939", "O422"...
## $ NmDU <chr> "Hyperemesis gravidarum with metabolic disturbance", "...
## $ DS <chr> "E86 - Volume depletion", "Z370 - Single live birth;O8...
## $ Procedure <chr> "8878 - Diagnostic ultrasound of gravid uterus", "8878...
## $ Nmjnsplg <chr> "Sehat", "Sehat", "Rujuk", "Sehat", "Sehat", "Sehat", ...
## $ Tglpelayanan <date> 2017-11-01, 2017-08-01, 2017-08-01, 2017-08-01, 2017-...
## $ Tglstjkeu <date> 2017-12-29, 2017-09-22, 2017-09-22, 2017-09-22, 2017-...
## $ Tgldtgsjp <date> 2017-10-30, 2017-08-18, 2017-08-14, 2017-08-14, 2017-...
## $ Tglplgsjp <date> 2017-11-01, 2017-08-19, 2017-08-14, 2017-08-14, 2017-...
## $ LOS <int> 3, 2, 1, 1, 1, 1, 5, 2, 2, 2, 3, 4, 3, 2, 1, 1, 1, 1, ...
## $ Umur <int> 34, 20, 26, 20, 30, 37, 28, 26, 27, 22, 30, 24, 41, 32...
## $ Biaya <int> 2348200, 1789200, 295500, 295500, 295500, 295500, 2754...
## $ specific <chr> "W-4-16", "O-6-13", "Z-3-25", "Z-3-25", "Z-3-25", "Z-3...
## $ NmFKRTL <chr> "KU Muh Kedungadem", "KU Muh Kedungadem", "KU Muh Kedu...
Bln_layan <- df_usg %>%
subset(NmFKRTL == "RSIA Fatma") %>%
dplyr::group_by(Tglpelayanan)%>%
summarize(Biaya = sum(Biaya),
Kasus = n_distinct(SEP))
head(Bln_layan, n = 20)
specific_cbgs <- df_usg %>%
subset(NmFKRTL == "RSIA Fatma") %>%
dplyr::group_by(Kdcmg, specific)%>%
summarize(Biaya = sum(Biaya),
Kasus = n_distinct(SEP))
head(specific_cbgs, n = 20)
ggplot(Bln_layan, aes(x = Tglpelayanan, y = Biaya)) +
geom_point() +
geom_smooth(method = "gam", formula = y ~ s(x)) +
geom_line(color="#fc4e07") +
labs(x="Bulan Layan (Bulan/Tahun)",
y="Biaya (Rupiah)",
title="Trend Biaya USG RSIA Fatma")

ggplot(Bln_layan, aes(x = Tglpelayanan, y = Kasus)) +
geom_point() +
geom_smooth(method = "gam", formula = y ~ s(x)) +
geom_line(color="#fc4e07") +
labs(x="Bulan Layan (Bulan/Tahun)",
y="Kasus",
title="Trend Kasus USG RSIA Fatma")
