Skip to content

Instantly share code, notes, and snippets.

@EBNull
Created January 28, 2024 23:57
Show Gist options
  • Save EBNull/a743398ff0bee04b4d7232d33a076e2b to your computer and use it in GitHub Desktop.
Save EBNull/a743398ff0bee04b4d7232d33a076e2b to your computer and use it in GitHub Desktop.
Get a CSV of all medication orders from Capsule pharmacy
#!/bin/bash
token() {
echo -n 'Authorization: Bearer YOUR_TOKEN_HERE'
}
acurl() {
curl \
-H 'tz: America/New_York' \
-H "$(token)" \
"$@"
}
order_detail() {
acurl 'https://consumer-client-api.capsule.com/api/v2/orders/'"${1}"
}
orders() {
acurl 'https://consumer-client-api.capsule.com/api/v2/orders'
}
medfmt() {
jq -r '.past[] | select(.status="delivered") | . as $f | {statusText, statusLastUpdated} as $d | .items[] | {name, dosage, completed:$f.completedAt, cf:$f.completedAtFlavorText} + $d | select(.completed) | [.completed, .name, .dosage] | @csv' | sort
}
orders | medfmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment