You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
8.4KB

  1. ---
  2. title: Endoscopies
  3. runtime: shiny
  4. output:
  5. html_document:
  6. toc: true
  7. toc_float: true
  8. ---
  9. ```{r setup, message = F, warning = F, echo = F}
  10. library(tidyverse)
  11. library(DT)
  12. library(knitr)
  13. library(magrittr)
  14. library(stringr)
  15. opts_chunk$set(message = F,
  16. echo = F,
  17. warning = F)
  18. options(DT.options = list(paging = F,
  19. searching = F,
  20. info = F,
  21. dom = "Bfrtip",
  22. buttons = c("copy", "excel")),
  23. shiny.maxRequestSize = 100*1024^2)
  24. ```
  25. # {.tabset}
  26. ## Chargement des données
  27. Les fichiers doivent être fournis au format CSV avec les paramètres suivants :
  28. * séparateur de champs = ,
  29. * guillemets = "
  30. * encodage = UTF-8
  31. * séparateur de décimales = ,
  32. ### Endoscopies en externe
  33. Le fichier doit être issu de la [requête suivante](https://livenne.chu-nancy.fr/shiny_files/endoscopies/endoscopies_ext.wid).
  34. ### Endoscopies en hospitalisation
  35. Le fichier doit être issu de la [requête suivante](https://livenne.chu-nancy.fr/shiny_files/endoscopies/endoscopies_hos.wid).
  36. ```{r data}
  37. if (!dir.exists("/var/www/html/shiny_files/endoscopies"))
  38. dir.create("/var/www/html/shiny_files/endoscopies")
  39. file.copy("endoscopies_ext.wid", "/var/www/html/shiny_files/endoscopies", overwrite = T) -> null
  40. file.copy("endoscopies_hos.wid", "/var/www/html/shiny_files/endoscopies", overwrite = T) -> null
  41. inputPanel(
  42. fileInput("ext", "Endoscopies externes", accept = "text/csv"),
  43. fileInput("hos", "Endoscopies hospitalisations", accept = "text/csv"),
  44. downloadButton("report", "Télecharger le rapport")
  45. )
  46. read_csv2("actes.csv") -> liste_actes
  47. endoscopies <- reactive(
  48. {
  49. req(input$ext)
  50. read_csv(input$ext$datapath, locale = locale(decimal_mark = ",")) %>%
  51. setNames(c("Venue", "Intervention", "Acte", "Tarif", "Acte_libelle", "Service", "Type_venue")) %>%
  52. left_join(liste_actes %>% select(Code, Appareil), by = c("Acte" = "Code")) %>%
  53. mutate_if(is.character, factor) %>%
  54. filter(Tarif != 0) %>%
  55. distinct
  56. }
  57. )
  58. endoscopies_ext <- reactive(
  59. {
  60. req(endoscopies())
  61. endoscopies() %>%
  62. filter(Type_venue != 2)
  63. })
  64. endoscopies_hos <- reactive(
  65. {
  66. req(input$hos)
  67. read_csv(input$hos$datapath, locale = locale(decimal_mark = ",")) %>%
  68. setNames(c("RSS", "Durée", "GHM", "GHM_libelle", "Valorisation")) %>%
  69. distinct %>%
  70. mutate(Type_duree = `Durée` %>% cut(c(-Inf, 1.5, Inf), labels = c("0 ou 1 j", "1+ j")))
  71. })
  72. ```
  73. ```{r report}
  74. output$report <- downloadHandler(filename = "endoscopies.html",
  75. content = function(file)
  76. {
  77. rmarkdown::render("endoscopies.rmd", output_file = file, params = list(liste_actes = liste_actes, endoscopies = endoscopies(), endoscopies_ext = endoscopies_ext(), endoscopies_hos = endoscopies_hos()))
  78. })
  79. ```
  80. ## Rapport
  81. ### Codes utilisés {.tabset}
  82. #### ORL
  83. ```{r liste_orl}
  84. liste_actes %>%
  85. filter(Appareil == "ORL") %>%
  86. select(- Appareil) %>%
  87. datatable(rownames = F, options = list(paging = T, searching = T))
  88. ```
  89. #### Digestif
  90. ```{r liste_dig}
  91. liste_actes %>%
  92. filter(Appareil == "Digestif") %>%
  93. select(- Appareil) %>%
  94. datatable(rownames = F, options = list(paging = T, searching = T))
  95. ```
  96. #### Respiratoire
  97. ```{r liste_respi}
  98. liste_actes %>%
  99. filter(Appareil == "Respiratoire") %>%
  100. select(- Appareil) %>%
  101. datatable(rownames = F, options = list(paging = T, searching = T))
  102. ```
  103. #### Génito-urinaire
  104. ```{r liste_uro}
  105. liste_actes %>%
  106. filter(Appareil == "Genito-urinaire") %>%
  107. select(- Appareil) %>%
  108. datatable(rownames = F, options = list(paging = T, searching = T))
  109. ```
  110. ### Global
  111. #### Total
  112. ```{r global_total}
  113. renderDataTable(
  114. {
  115. endoscopies() %>%
  116. summarise(Venues = n_distinct(Venue)) %>%
  117. datatable(rownames = F,
  118. extensions = "Buttons")
  119. })
  120. ```
  121. #### Par service exécutant
  122. ```{r global_par_service}
  123. renderDataTable(
  124. {
  125. endoscopies() %>%
  126. group_by(Service) %>%
  127. summarise(Venues = n_distinct(Venue)) %>%
  128. ungroup %>%
  129. arrange(desc(Venues)) %>%
  130. datatable(rownames = F,
  131. extensions = "Buttons")
  132. })
  133. ```
  134. ### Externe
  135. #### Total
  136. ```{r ext_total}
  137. renderDataTable(
  138. {
  139. endoscopies_ext() %>%
  140. summarise(Venues = n_distinct(Venue),
  141. Valorisation = sum(Tarif)) %>%
  142. datatable(rownames = F,
  143. extensions = "Buttons") %>%
  144. formatCurrency(2, currency = "€", dec.mark = ",", mark = " ", before = F)
  145. })
  146. ```
  147. #### Par appareil
  148. ```{r ext_par_appareil}
  149. renderDataTable(
  150. {
  151. endoscopies_ext() %>%
  152. group_by(Appareil) %>%
  153. summarise(Venues = n_distinct(Venue),
  154. Valorisation = sum(Tarif)) %>%
  155. arrange(desc(Valorisation)) %>%
  156. datatable(rownames = F,
  157. extensions = "Buttons") %>%
  158. formatCurrency(3, currency = "€", dec.mark = ",", mark = " ", before = F)
  159. })
  160. ```
  161. #### Par acte
  162. ```{r ext_par_acte}
  163. renderDataTable(
  164. {
  165. endoscopies_ext() %>%
  166. group_by(Acte, Acte_libelle) %>%
  167. summarise(Venues = n_distinct(Venue),
  168. Valorisation = sum(Tarif)) %>%
  169. ungroup %>%
  170. arrange(desc(Valorisation)) %>%
  171. datatable(options = list(paging = T, searching = T),
  172. colnames = c("Libelle" = "Acte_libelle"),
  173. rownames = F,
  174. extensions = "Buttons") %>%
  175. formatCurrency(4, currency = "€", dec.mark = ",", mark = " ", before = F)
  176. })
  177. ```
  178. #### Par service exécutant
  179. ```{r ext_par_service}
  180. renderDataTable(
  181. {
  182. endoscopies_ext() %>%
  183. group_by(Service) %>%
  184. summarise(Venues = n_distinct(Venue),
  185. Valorisation = sum(Tarif)) %>%
  186. ungroup %>%
  187. arrange(desc(Valorisation)) %>%
  188. datatable(rownames = F,
  189. extensions = "Buttons") %>%
  190. formatCurrency(3, currency = "€", dec.mark = ",", mark = " ", before = F)
  191. })
  192. ```
  193. #### Par service exécutant et par acte
  194. ```{r ext_par_acte_et_service}
  195. renderDataTable(
  196. {
  197. endoscopies_ext() %>%
  198. group_by(Service, Acte, Acte_libelle) %>%
  199. summarise(Venues = n_distinct(Venue),
  200. Valorisation = sum(Tarif)) %>%
  201. arrange(Service, desc(Valorisation)) %>%
  202. ungroup %>%
  203. datatable(options = list(paging = T, searching = T),
  204. colnames = c("Libelle" = "Acte_libelle"),
  205. rownames = F,
  206. extensions = "Buttons",
  207. filter = "top") %>%
  208. formatCurrency(5, currency = "€", dec.mark = ",", mark = " ", before = F)
  209. })
  210. ```
  211. ### Hospitalisation
  212. #### Total
  213. ```{r total_hos}
  214. renderDataTable(
  215. {
  216. endoscopies_hos() %>%
  217. summarise(RSS = n(),
  218. Valorisation = sum(Valorisation)) %>%
  219. datatable(rownames = F,
  220. extensions = "Buttons") %>%
  221. formatCurrency(2, currency = "€", dec.mark = ",", mark = " ", before = F)
  222. })
  223. ```
  224. #### Par durée d'hospitalisation
  225. ```{r hos_par_durée}
  226. renderDataTable(
  227. {
  228. endoscopies_hos() %>%
  229. group_by(Type_duree) %>%
  230. summarise(RSS = n(),
  231. Valorisation = sum(Valorisation)) %>%
  232. datatable(rownames = F,
  233. colnames = c("Durée" = "Type_duree"),
  234. extensions = "Buttons") %>%
  235. formatCurrency(3, currency = "€", dec.mark = ",", mark = " ", before = F)
  236. })
  237. ```
  238. #### Par GHM {.tabset}
  239. ##### 0 ou 1j
  240. ```{r ghm_hos_0j}
  241. renderDataTable(
  242. {
  243. endoscopies_hos() %>%
  244. filter(Type_duree == "0 ou 1 j") %>%
  245. group_by(GHM, GHM_libelle) %>%
  246. summarise(RSS = n(),
  247. Valorisation = sum(Valorisation)) %>%
  248. ungroup %>%
  249. arrange(desc(RSS)) %>%
  250. datatable(rownames = F,
  251. colnames = c("Libelle GHM" = "GHM_libelle"),
  252. options = list(paging = T),
  253. extensions = "Buttons") %>%
  254. formatCurrency(4, currency = "€", dec.mark = ",", mark = " ", before = F) %>%
  255. formatRound(5)
  256. })
  257. ```
  258. ##### 1+ j
  259. ```{r ghm_hos_1j}
  260. renderDataTable(
  261. {
  262. endoscopies_hos() %>%
  263. filter(Type_duree == "1+ j") %>%
  264. group_by(GHM, GHM_libelle) %>%
  265. summarise(RSS = n(),
  266. Valorisation = sum(Valorisation)) %>%
  267. ungroup %>%
  268. arrange(desc(RSS)) %>%
  269. datatable(rownames = F,
  270. colnames = c("Libelle GHM" = "GHM_libelle"),
  271. options = list(paging = T),
  272. extensions = "Buttons") %>%
  273. formatCurrency(4, currency = "€", dec.mark = ",", mark = " ", before = F) %>%
  274. formatRound(5)
  275. })
  276. ```