Edit: /opt/mawid/scripts/demo-reset.sh (1200B)
#!/usr/bin/env bash
# Reset a demo patient between pitches: GDPR-deletes the patient (and all
# their appointments/conversations/waitlist entries) via the API.
# Usage: ./scripts/demo-reset.sh +905321234567 [api-url] [owner-email] [owner-password]
set -euo pipefail
PHONE=${1:?usage: demo-reset.sh +9055XXXXXXXX [api-url] [email] [password]}
API=${2:-http://localhost:3001}
EMAIL=${3:-owner@demo.clinic}
PASSWORD=${4:-demo-owner-password}
TOKEN=$(curl -sf -X POST "$API/auth/login" -H 'Content-Type: application/json' \
-d "{\"email\":\"$EMAIL\",\"password\":\"$PASSWORD\"}" | python3 -c 'import sys,json;print(json.load(sys.stdin)["accessToken"])')
PATIENT_ID=$(curl -sf "$API/patients?search=$(python3 -c "import urllib.parse,sys;print(urllib.parse.quote(sys.argv[1]))" "$PHONE")" \
-H "Authorization: Bearer $TOKEN" |
python3 -c 'import sys,json;rows=json.load(sys.stdin);print(rows[0]["id"] if rows else "")')
if [ -z "$PATIENT_ID" ]; then
echo "no patient found for $PHONE — nothing to reset"
exit 0
fi
curl -sf -X DELETE "$API/patients/$PATIENT_ID" -H "Authorization: Bearer $TOKEN" > /dev/null
echo "demo patient $PHONE wiped (patient, appointments, conversations, waitlist)"