---
name: Andreas
surname: Gammelgaard Damsbo
position: "MD, PhD student"
# profilepic: portraitsq.jpg
pronouns: he/him
address: "Danish Stroke Centre, Neurology, Aarhus University Hospital"
phone: +45 2490 3612
www: andreas.gdamsbo.dk
email: andrlr@rm.dk
orcid: 0000-0002-7559-1154
github: agdamsbo
date: "`r format(Sys.time(), '%B %Y')`"
docname: publications
knit: (function(inputFile, encoding) {
      out_dir <- "docs";
      rmarkdown::render(inputFile,
                        encoding=encoding,
                        output_dir=file.path(dirname(inputFile), out_dir))})
output:
  vitae::awesomecv: 
    page_total: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(vitae)
library(dplyr)
library(tibble)
library(rorcid)

orc_id <- "0000-0002-7559-1154"
scholar_id <- "Y80Xqc4AAAAJ"

get_new_pub_list = TRUE
```

```{r}
# Getting references
if (get_new_pub_list | !file.exists("bib-files/publications.bib")) {
  source("orcid_pubs.R")
  orcid_pubs(orc_id)
}
```

```{r}
# Splitting in seperate files
refs <- read.bib("bib-files/publications.bib", encoding = "unknown", srcfile)

names <- do.call(c,lapply(seq_along(refs),function(i){
  names(refs[[i]][[1]][1])
}))

main <- grepl("^[Dd]amsbo*.",names)
other <- grepl("^[Hh]ttps*.",names)
coauth <- !main&!other


library(bibtex)
library(RefManageR)
WriteBib(bib = as.BibEntry(refs[[main]]), file = "bib-files/agd-main.bib")
WriteBib(bib = as.BibEntry(refs[[other]]), file = "bib-files/agd-other.bib")
WriteBib(bib = as.BibEntry(refs[[coauth]]), file = "bib-files/agd-coauth.bib")
```

# Publications

```{r}
# library(scholar)
# l <- get_profile(scholar_id)
# scholar::get_publications(scholar_id)
# bibliography_entries() %>%
#   arrange(desc(author$family), issued)
```

## Main author

```{r Publications}
articles <- bibliography_entries("bib-files/publications.bib") %>% filter(type == "article-journal")

main_author <- do.call(c,lapply(articles$author,function(i,j){
  do.call(c,i)[[1]]=="Damsbo"
}))

mains <- articles |> filter(main_author) |> arrange(desc(issued))
mains
```

## Co-author

```{r Coauthor}
articles |> filter(!main_author) |> arrange(desc(issued))
```

<!-- \newpage -->

## Other publications

```{r Others}
bibliography_entries("bib-files/publications.bib") %>% filter(type != "article-journal") |> arrange(desc(issued))
```
