#!/bin/bash

# Public domain notice for all NCBI EDirect scripts is located at:
# https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice

xtract -set IdxDocumentSet -rec IdxDocument -pattern PubmedArticle \
  -wrp IdxUid -element MedlineCitation/PMID -clr -rst -tab "" \
  -group PubmedArticle -pkg IdxSearchFields \
    -block Article/AuthorList/Author/Identifier \
      -if "Identifier@Source" -equals ORCID \
        -subset Identifier -if Identifier -starts-with "http" \
            -wrp AUID -element "Identifier[orcid.org/|]" \
          -else -wrp AUID -element "Identifier" |
transmute -format
