Created
January 28, 2024 23:57
-
-
Save EBNull/a743398ff0bee04b4d7232d33a076e2b to your computer and use it in GitHub Desktop.
Get a CSV of all medication orders from Capsule pharmacy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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