Demonstrates two methods for submitting FHIR questionnaire responses to Welshare user profiles.
User connects their existing Welshare wallet. The wallet handles signing and submission.
When to use: Users who already have Welshare wallets.
Key files:
src/components/ExternalWalletSubmission.tsxsrc/hooks/use-external-wallet-submission.ts
App creates an embedded wallet for the user via Privy. App manages wallet and uses SDK for direct API submission.
When to use: Onboarding users who don't have Welshare wallets yet.
Key files:
src/components/EmbeddedWalletSubmission.tsxsrc/hooks/use-seattle-angina-submission.tssrc/hooks/use-storage-key.ts
-
Install dependencies:
pnpm install
-
Copy
.env.exampleto.envand configure:NEXT_PUBLIC_PRIVY_APP_ID=your-privy-app-id NEXT_PUBLIC_WELSHARE_APP_ID=your-welshare-app-id NEXT_PUBLIC_WELSHARE_QUESTIONNAIRE_ID=your-questionnaire-id NEXT_PUBLIC_WELSHARE_ENVIRONMENT=staging -
Run the development server:
pnpm dev
QuestionnaireRenderer.tsx takes a FHIR Questionnaire JSON and renders form fields:
choicetype →<select>dropdowngrouptype → nested container- Response codes from
answerOptionbecome option values
build-questionnaire-response.ts converts form state into a FHIR QuestionnaireResponse:
- Maps user selections back to FHIR
valueCodingformat - Includes calculated scores as
valueDecimalitems
use-seattle-angina-scores.ts shows how to include computed values in submissions. This is questionnaire-specific logic—adapt for your use case.
- Use your own questionnaire: Replace
seattle_angina.jsonwith your FHIR Questionnaire - Customize form rendering: Modify
QuestionnaireRenderer.tsxfor your question types - Add/remove scores: Adjust
use-seattle-angina-scores.tsor remove if not needed - Choose one method: If you only need one submission method, remove the other
@welshare/react- External wallet connection@welshare/sdk- Direct API submission@privy-io/react-auth- Embedded wallet authentication