# Golang Source: https://developer.eka.care/SDKs/backend/go-sdk A Go SDK for integrating with Eka Care’s healthcare APIs, including ABDM (Ayushman Bharat Digital Mission) services. ## Overview Use this SDK to authenticate with Eka Care, call ABDM services, and build backend integrations in Go with minimal boilerplate. ## Prerequisites * Go 1.24+ (matches the SDK’s go.mod) * Eka Care developer account and credentials (client\_id and client\_secret) ## Installation ```bash theme={null} go get github.com/eka-care/eka-sdk-go ``` Install a specific version (recommended for reproducible builds): ```bash theme={null} go get github.com/eka-care/eka-sdk-go@latest # or pin to a specific release go get github.com/eka-care/eka-sdk-go@vX.Y.Z ``` ## Authentication and Setup The SDK supports configuration via environment variables (recommended) or explicit options in code. ### Recommended: Environment variables Set the following variables in your environment or a .env file: ```bash theme={null} # Required export EKA_ENVIRONMENT=production # or development export EKA_CLIENT_ID=your-client-id export EKA_CLIENT_SECRET=your-client-secret ``` Then initialize the client from environment variables: ```go theme={null} client := ekasdk.NewFromEnv() ``` ### Alternative: Explicit configuration (not recommended for production) ```go theme={null} client := ekasdk.New( ekasdk.WithEnvironment(ekasdk.EnvironmentProduction), ekasdk.WithClientID("your-client-id"), ekasdk.WithClientSecret("your-client-secret"), ) ``` ## Quickstart Authenticate and call an ABDM API (login init via PHR address): ```go theme={null} package main import ( "context" "log" ekasdk "github.com/eka-care/eka-sdk-go" "github.com/eka-care/eka-sdk-go/internal/interfaces" "github.com/eka-care/eka-sdk-go/services/abdm/abha/login" ) func main() { ctx := context.Background() // Create SDK client from environment variables client := ekasdk.NewFromEnv() // Authenticate with Eka platform if err := client.Login(ctx); err != nil { log.Fatalf("Authentication failed: %v", err) } // Common headers used by ABDM services headers := interfaces.Headers{ PatientID: "eka-user-oid", PartnerUserID: "your-user-id", HipID: "your-hip-id", } // Example: ABDM login (init via PHR address) otpReq := &login.InitLoginRequest{ Identifier: "demo@abdm", Method: login.LoginMethodPhrAddress, } otpResp, err := client.ABDM.Login().LoginInit(ctx, headers, otpReq) if err != nil { log.Printf("ABDM login failed: %v", err) return } log.Printf("Success! Transaction ID: %s", otpResp.TxnID) } ``` ## Configuration reference * EKA\_CLIENT\_ID: Client ID from the developer portal (required) * EKA\_CLIENT\_SECRET: Client secret from the developer portal (required) * EKA\_ENVIRONMENT: production or development (required) Configuration priority (highest to lowest): * Environment variables * Explicit options via WithXxx() functions * Built-in defaults ## Available services Once authenticated, you can access: * ABDM services: `client.ABDM.Login()`, `client.ABDM.Registration()`, `client.ABDM.Profile()` * More services will be added as they become available ## Troubleshooting Typical auth/config errors when calling `client.Login(ctx)`: ```text theme={null} "client ID is required for authentication. Set EKA_CLIENT_ID environment variable or use WithClientID() option" "client secret is required for authentication. Set EKA_CLIENT_SECRET environment variable or use WithClientSecret() option" "failed to authenticate with provided credentials: invalid client credentials" ``` ## Examples and resources * GitHub repository: [https://github.com/eka-care/eka-sdk-go](https://github.com/eka-care/eka-sdk-go) * Examples: [https://github.com/eka-care/eka-sdk-go/tree/main/examples/quickstart](https://github.com/eka-care/eka-sdk-go/tree/main/examples/quickstart) * Issues & support: [https://github.com/eka-care/eka-sdk-go/issues](https://github.com/eka-care/eka-sdk-go/issues) # Python Source: https://developer.eka.care/SDKs/backend/report-parsing-sdk A Python SDK for parsing medical documents using Eka Care APIs # Overview [Report Parsing SDK on GitHub](https://github.com/eka-care/reports-parsing-sdk/tree/main/python) A comprehensive Python SDK for interacting with the Eka Care Medical Records API. This SDK enables you to upload and process medical documents with support for smart report parsing and PII detection. ## Installation Install from source: ```bash theme={null} git clone https://github.com/eka-care/reports-parsing-sdk.git cd reports-parsing-sdk/python pip install -e . ``` *** ## Quick Start Basic initialization and document processing: ```python theme={null} from ekacare_sdk import EkaCareSDK # Initialize the SDK with your credentials sdk = EkaCareSDK( client_id="your_client_id", client_secret="your_client_secret" ) # Process a document result = sdk.process_document( "/path/to/lab_report.jpg", task="smart" ) # Get the document ID from the result print(f"Document ID: {result['document_id']}") # Retrieve the processing results response = sdk.get_document_result(result['document_id']) print(response['data']) # Clean up sdk.close() ``` *** ## Configuration ### Environment Variables Create a `.env` file with your credentials: ```bash theme={null} EKACARE_CLIENT_ID=your_client_id EKACARE_CLIENT_SECRET=your_client_secret EKACARE_BASE_URL=https://api.eka.care ``` ### Using Configuration Class Load settings from environment variables or configure manually: ```python theme={null} from ekacare_sdk.config import EkaCareConfig # Load from environment config = EkaCareConfig.from_env() sdk = EkaCareSDK(config.client_id, config.client_secret) ``` *** ## Features The SDK provides the following capabilities: * **Automatic Authentication**: Handles token management automatically * **Document Processing**: Upload and process medical documents * **Polling Support**: Built-in polling for asynchronous results * **Environment Configuration**: Easy setup via environment variables *** ## Task Options When processing documents, you can specify different task types: | Task | Description | | ------- | --------------------------------------------------- | | `smart` | Default option - Smart report parsing | | `pii` | PII (Personally Identifiable Information) detection | | `both` | Combined smart parsing and PII detection | Example: ```python theme={null} # Smart report parsing (default) result = sdk.process_document("/path/to/report.pdf", task="smart") # PII detection result = sdk.process_document("/path/to/report.pdf", task="pii") # Both smart parsing and PII detection result = sdk.process_document("/path/to/report.pdf", task="both") ``` *** ## API Reference ### Primary Methods | Method | Description | | ---------------------------------------------------------- | ------------------------------------------ | | `process_document(file_path, doc_type="lr", task="smart")` | Upload and process a document | | `get_document_result(document_id)` | Retrieve processing results for a document | # Java Source: https://developer.eka.care/SDKs/backend/report-parsing-sdk-java A Java Spring Boot SDK for parsing medical documents using Eka Care APIs # Overview [Report Parsing SDK on GitHub](https://github.com/eka-care/reports-parsing-sdk/tree/main/java) A Java Spring Boot SDK for processing medical documents through the Eka Care API. This SDK supports document submission, result polling, and FHIR data extraction. ## Prerequisites * **JDK 17+** (verify with `java -version`) * **Maven** (verify with `mvn -version`) * **IDE**: IntelliJ IDEA, Eclipse, or VS Code with Java extensions * **Eka Care API Credentials**: Valid client ID and secret *** ## Project Structure ``` ekacare-sdk/ ├── src/main/java/com/example/ekacare/ │ ├── sdk/EkaCareSDK.java │ ├── service/EkaCareService.java │ └── controller/DocumentController.java ├── src/main/resources/application.properties └── pom.xml ``` *** ## Setup Instructions ### Step 1: Create Spring Boot Project **Via Spring Initializr:** * Visit [start.spring.io](https://start.spring.io) * Select Maven, Java 17, Spring Boot 3.2.0 * Add "Spring Web" dependency * Generate and extract **Via IntelliJ IDEA:** File → New → Project → Spring Initializr → Configure with Java 17 and Spring Boot 3.2.0 ### Step 2: Add SDK Files Copy files from the repository to respective directories: * `EkaCareSDK.java` → `src/main/java/com/example/ekacare/sdk/` * `EkaCareService.java` → `src/main/java/com/example/ekacare/service/` * `application.properties` → `src/main/resources/` * `pom.xml` → project root ### Step 3: Configure Credentials Update `application.properties`: ```properties theme={null} ekacare.client.id=YOUR_CLIENT_ID_HERE ekacare.client.secret=YOUR_CLIENT_SECRET_HERE ``` ### Step 4: Build ```bash theme={null} mvn clean install ``` *** ## Quick Start ### Direct SDK Usage ```java theme={null} try (EkaCareSDK sdk = new EkaCareSDK("CLIENT_ID", "CLIENT_SECRET")) { Map result = sdk.processAndWait( "/path/to/document.jpg", "smart", 10, // poll interval (seconds) 300 // timeout (seconds) ); Map data = (Map) result.get("data"); System.out.println("FHIR: " + data.get("fhir")); } ``` ### Spring Boot Service ```java theme={null} @Component public class MyDocumentProcessor { @Autowired private EkaCareService ekaCareService; public void process() throws InterruptedException { Map result = ekaCareService .processDocumentAndWait("/path/to/document.jpg", "smart"); System.out.println("Result: " + result); } } ``` *** ## REST API Endpoints The SDK provides REST endpoints for document processing: | Method | Endpoint | Purpose | | ------ | ---------------------------------------- | -------------------------------------- | | POST | `/api/documents/process?task=smart` | Async document submission | | GET | `/api/documents/{id}/result` | Retrieve processing result | | POST | `/api/documents/process-sync?task=smart` | Sync processing (waits for completion) | *** ## Task Options When processing documents, you can specify different task types: | Task | Description | | ------- | --------------------------------------------------- | | `smart` | Smart report parsing | | `pii` | PII (Personally Identifiable Information) detection | | `both` | Combined smart parsing and PII detection | *** ## Example cURL Requests ```bash theme={null} # Submit document asynchronously curl -X POST http://localhost:8080/api/documents/process?task=smart \ -F "file=@/path/to/document.jpg" # Get processing result curl http://localhost:8080/api/documents/abc123/result # Synchronous processing (waits for completion) curl -X POST http://localhost:8080/api/documents/process-sync?task=smart \ -F "file=@/path/to/document.jpg" ``` *** ## Troubleshooting | Issue | Solution | | ------------------- | ------------------------------------------------------ | | File Not Found | Use absolute paths or verify relative path correctness | | Authorization (401) | Validate credentials in properties file | | Maven Build Fails | Run `mvn clean install -U` | | Port 8080 In Use | Change in `application.properties`: `server.port=8081` | ### Large File Upload For large files, increase limits in `application.properties`: ```properties theme={null} spring.servlet.multipart.max-file-size=50MB spring.servlet.multipart.max-request-size=50MB ``` # Profile KYC Source: https://developer.eka.care/SDKs/web-sdk/abha-sdk/abha-kyc Complete implementation guide for the ABHA SDK to be used for ABHA KYC Verification Flow. # ABHA SDK - Profile KYC Implementation This guide provides everything you need to integrate the ABHA SDK into your application for ABHA Profile KYC Verification. * **ABHA Profile KYC**: Get your ABHA address KYC verified. ### Implementation Example Add the following HTML and script tags to your webpage: For staging/dev environments, replace the SDK URLs with: * **JS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/js/abha.js` * **CSS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/css/abha.css` ```html theme={null} ABHA SDK Integration for ABHA Profile KYC

ABHA SDK Demo

``` ## Core Functions ### 1. initAbhaApp Initializes and renders the ABHA SDK in your specified container. **Parameters:** | Name | Type | Required | Description | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `containerId` | `string` | ✅ | The HTML element ID where the SDK will mount. | | `clientId` | `string` | ✅ | Provide clientId as `ext`. | | `data` | `{`
`accessToken: string;`
`oid?: string;`
`hipId?: string;`
`identifier: string;`
`identifier_type: string;`
`flow: string;`
`orgIconUrl?: string;`
`linkToOrgIcon?: string;`
` }` | ⚙️ Optional | Configuration data for initializing the ABHA flow.

- accessToken: Pass the access token you have generated from [Connect Login ](https://developer.eka.care/api-reference/authorization/client-login) API without the word `Bearer`.
- oid: Pass the OID of the patient if available.
- hipId: Pass the HFR ID you have.
- identifier: Pass the identifier value i.e. phr address to get it kyced.
- identifier\_type: Pass the type of identifier which you passed in `identifier` key i.e. "phr\_address".
- flow: Pass the type of flow for which you want to use SDK for i.e. `abha-kyc` for KYC flow.
- orgIconUrl: Public CDN URL of the logo of your organisation url should start with https\://. [Example](https://cdn.eka.care/vagus/cl5jgf0u500070shaetqw0r5l.png)
- linkToOrgIcon: Public CDN URL of the icon representing “Link ABHA to your organisation” url should start with https\://. [Example](https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp)

`keys with ? are optional.` | | `onKYCSuccess` | `(params: TOnAbhaKycSuccessParams) => void` | ✅ | Triggered when the user KYC verified successfully. | | `onError` | `(params: TOnAbhaFailureParams) => void` | ✅ | Triggered when an error occurs during the ABHA flow. | | `onAbhaClose` | `() => void` | ✅ | Triggered when SDK closes. | **Example:** ```javascript theme={null} window.initAbhaApp({ containerId: "sdk_container", data: { accessToken: "your_access_token_here", oid: "patient_oid_here", identifier: "phr_address_of_the_patient_to_be_kyced" identifier_type: "phr_address" flow: "abha-kyc" hipId: "available HFR ID", linkToOrgIcon: "url_of_image_to_link_abha_to_your_org", }, onKYCSuccess: (params) => { console.log("ABHA KYC verification successful!", params); }, onError: (error) => { console.error("ABHA flow failed:", error); }, onAbhaClose: (error) => { console.error("ABHA SDK closed"); }, }); ``` ## Callback Parameters ### onKYCSuccess Callback The onKYCSuccess callback is triggered when the ABHA KYC flow completes successfully. It returns a confirmation message indicating that the KYC has been verified. **Callback Signature:** ```typescript theme={null} onKYCSuccess: (params: TOnAbhaKycSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaKycSuccess = string; ``` **Parameters** | | Type | Description | | ------------------- | -------- | ----------------------------------------------------- | | `TOnAbhaKycSuccess` | `string` | A confirmation message from SDK post KYC verification | **Example:** ```javascript theme={null} const onKYCSuccess = (params) => { console.log("KYC verification Success:", params); alert("KYC was verified successfully!"); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAbhaKYCSuccess(params); } }; ``` ### onError Callback The onError callback is triggered whenever an ABHA flow fails or is interrupted. It provides details about the failure through structured parameters, allowing you to handle or forward the error appropriately (for example, to native apps or monitoring tools). **Callback Signature:** ```typescript theme={null} onError: (params: TOnAbhaFailureParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaFailureParams = { error?: string; response?: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ------------------------ | ---------------------------------------------------------------- | | `error` | `string?` | Short description of the failure or error message. | | `response` | `TAuthVerifyV2Response?` | Partial or full API response object returned from ABHA services. | **Example:** ```javascript theme={null} const onError = (params) => { console.error("ABHA Error:", params); if (params.response?.error?.code === 1001) { alert("Authentication failed. Please try again."); } else if (params.error === "NETWORK_ERROR") { alert("Please check your internet connection."); } else { alert("Something went wrong. Please retry."); } // Forward the error to native handler if available if (window.EkaAbha) { window.EkaAbha.onAbhaFailure(JSON.stringify(params)); } }; ``` ### onAbhaClose Callback The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. **Callback Signature:** ```typescript theme={null} onAbhaClose: () => void; ``` **Example:** ```javascript theme={null} const onAbhaClose = () => { console.log("ABHA SDK Closed"); }; ``` **Suggest Handling** * Always log the full error response (params) for debugging. * Display friendly error messages for known error.code values. * If params.response is present, inspect response.error.message for more detail. * If integrating with native apps, forward the serialized error object: ```javascript theme={null} window.EkaAbha.onAbhaFailure(JSON.stringify(params)); ``` ## Container Styling Ensure your container has sufficient space: ```html theme={null}
``` ## Troubleshooting ### Common Issues #### 1. SDK Not Rendering **Problem**: Nothing appears in the container. **Solution**: * Ensure containerId matches an existing HTML element. * Verify the SDK JS and CSS are correctly loaded. * Check browser console for errors. #### 2. APIs Not Being Called **Problem**: API requests are not triggered after the SDK is mounted. **Solution**: * Ensure that the accessToken is passed correctly (do not include the Bearer prefix) and that the token has not expired. * To prevent CORS-related issues, ensure that your domain is whitelisted. #### 3. Callback Not Triggered **Problem**: onSuccess, onError, onKYCSuccess, onConsentSuccess, onAbhaClose isn’t firing. **Solution**: * Make sure callbacks are passed as valid functions. * Avoid race conditions (e.g., calling before SDK fully loads). #### 4. Styling Issues **Problem**: SDK content appears misaligned or clipped. **Solution**: * Give your container a fixed height (e.g., 600px). * Ensure no parent element uses overflow: hidden. # Registration Source: https://developer.eka.care/SDKs/web-sdk/abha-sdk/abha-login-create Complete implementation guide for the ABHA SDK to be used for ABHA Login or Create. # ABHA SDK - Login or Create This guide provides everything you need to integrate the ABHA SDK into your application for Create ABHA, Login with ABHA flows into your healthcare applications. It provides: * **Create ABHA**: Create a new ABHA using Mobile or Aadhaar. * **Login with ABHA**: Login to your exisiting ABHA using PHR Address, ABHA number, Aadhaar number or Mobile number. ### Implementation Example Add the following HTML and script tags to your webpage: For staging/dev environments, replace the SDK URLs with: * **JS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/js/abha.js` * **CSS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/css/abha.css` ```html theme={null} ABHA SDK Integration

ABHA SDK Demo

``` ## Core Functions ### 1. initAbhaApp Initializes and renders the ABHA SDK in your specified container. **Parameters:** | Name | Type | Required | Description | | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | | `containerId` | `string` | ✅ | The HTML element ID where the SDK will mount. | | | `clientId` | `string` | ✅ | Provide clientId as `ext`. | | | `data` | `{`
`accessToken: string;`
`oid?: string;`
`hipId?: string;`
`orgIconUrl?: string;`
`linkToOrgIcon?: string;`
`skipABHAEnable?: boolean;`
`}` | ⚙️ Optional | Configuration data for initializing the ABHA flow.

- accessToken: Pass the access token you have generated from [Connect Login ](https://developer.eka.care/api-reference/authorization/client-login) API without the word `Bearer`.
- oid: Pass the OID of the patient if available.
- hipId: Pass the HFR ID you have.
- orgIconUrl: Public CDN URL of the logo of your organisation url should start with https\://. [Example](https://cdn.eka.care/vagus/cl5jgf0u500070shaetqw0r5l.png)
- linkToOrgIcon: Public CDN URL of the icon representing “Link ABHA to your organisation” url should start with https\://. [Example](https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp)
- skipABHAEnable: Pass the boolean as true if you want Skip ABHA button to be enabled on login screen.

`keys with ? are optional.` | | | `onSuccess` | `(params: TOnAbhaSuccessParams) => void` | ✅ | Triggered when the user successfully creates or logs in to ABHA. | | | `onError` | `(params: TOnAbhaFailureParams) => void` | ✅ | Triggered when an error occurs during the ABHA flow. | | | `onAbhaClose` | `() => void` | ✅ | Triggered when SDK closes. | | | `onSkipAbha` | `(params: TOnSkipABHA) => void` | ⚙️ Optional | Triggered if the ABHA flow is skipped. | | **Example:** ```javascript theme={null} window.initAbhaApp({ containerId: "sdk_container", data: { accessToken: "your_access_token_here", oid: "patient_oid_here", hipId: "available HFR ID", linkToOrgIcon: "url_of_image_to_link_abha_to_your_org", skipABHAEnable: "boolean_value_here" }, onSuccess: (params) => { console.log("ABHA created successfully!", params); }, onError: (error) => { console.error("ABHA flow failed:", error); }, onAbhaClose: (error) => { console.error("ABHA SDK closed"); }, onSkipAbha: (params) => { console.log("ABHA flow skipped by user:", params); }, }); ``` ## Callback Parameters ### onSuccess Callback The onSuccess callback is triggered when the ABHA flow completes successfully. It returns verified user details and tokens, which can be used to log in or continue the user’s session. **Callback Signature:** ```typescript theme={null} onSuccess: (params: TOnAbhaSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaSuccessParams = { response: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ----------------------- | ---------------------------------------------------------------------------------------------------------- | | `response` | `TAuthVerifyV2Response` | The complete ABHA verification response, containing session tokens, user profile, and transaction details. | **Example:** ```javascript theme={null} const onSuccess = (params) => { console.log("ABHA Success:", params.response); const abhaNumber = params.response.data?.profile?.abha_number; const userName = params.response.data?.profile?.name; alert(`Welcome ${userName}! Your ABHA Number: ${abhaNumber}`); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAbhaSuccess(JSON.stringify(params)); } }; ``` ### onError Callback The onError callback is triggered whenever an ABHA flow fails or is interrupted. It provides details about the failure through structured parameters, allowing you to handle or forward the error appropriately (for example, to native apps or monitoring tools). **Callback Signature:** ```typescript theme={null} onError: (params: TOnAbhaFailureParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaFailureParams = { error?: string; response?: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ------------------------ | ---------------------------------------------------------------- | | `error` | `string?` | Short description of the failure or error message. | | `response` | `TAuthVerifyV2Response?` | Partial or full API response object returned from ABHA services. | **Example:** ```javascript theme={null} const onError = (params) => { console.error("ABHA Error:", params); if (params.response?.error?.code === 1001) { alert("Authentication failed. Please try again."); } else if (params.error === "NETWORK_ERROR") { alert("Please check your internet connection."); } else { alert("Something went wrong. Please retry."); } // Forward the error to native handler if available if (window.EkaAbha) { window.EkaAbha.onAbhaFailure(JSON.stringify(params)); } }; ``` ### onAbhaClose Callback The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. **Callback Signature:** ```typescript theme={null} onAbhaClose: () => void; ``` **Example:** ```javascript theme={null} const onAbhaClose = () => { console.log("ABHA SDK Closed"); }; ``` ### onSkipAbha Callback The onSkipAbha callback is triggered when the ABHA SDK flow is skipped. The callback is functional when skipABHAEnable is set to true in the data parameter while initializing the SDK. **Callback Signature:** ```typescript theme={null} onSkipAbha: (params: TOnSkipABHA) => void; ``` **Example:** ```javascript theme={null} const onSkipAbha = (params) => { console.log("ABHA SDK Skipped:", params); }; ``` **Type Definitions** ```typescript theme={null} type IdentifierType = "mobile" | "aadhaar_number" | "abha_number" | "phr_address"; type TOnSkipABHA = { identifier?: string; identifier_type?: IdentifierType[]; // No default value here }; ``` **Parameters** | Key | Type | Description | | ----------------- | ------------------- | ------------------------------------------------- | | `identifier` | `string?` | It will be login identifier value filled by user. | | `identifier_type` | `IdentifierType[]?` | It will be type of login identifier. | **Suggest Handling** * Always log the full error response (params) for debugging. * Display friendly error messages for known error.code values. * If params.response is present, inspect response.error.message for more detail. * If integrating with native apps, forward the serialized error object: ```javascript theme={null} window.EkaAbha.onAbhaFailure(JSON.stringify(params)); ``` ## Container Styling Ensure your container has sufficient space: ```html theme={null}
``` ## Troubleshooting ### Common Issues #### 1. SDK Not Rendering **Problem**: Nothing appears in the container. **Solution**: * Ensure containerId matches an existing HTML element. * Verify the SDK JS and CSS are correctly loaded. * Check browser console for errors. #### 2. APIs Not Being Called **Problem**: API requests are not triggered after the SDK is mounted. **Solution**: * Ensure that the accessToken is passed correctly (do not include the Bearer prefix) and that the token has not expired. * To prevent CORS-related issues, ensure that your domain is whitelisted. #### 3. Callback Not Triggered **Problem**: onSuccess, onError, onKYCSuccess, onConsentSuccess, onAbhaClose isn’t firing. **Solution**: * Make sure callbacks are passed as valid functions. * Avoid race conditions (e.g., calling before SDK fully loads). #### 4. Styling Issues **Problem**: SDK content appears misaligned or clipped. **Solution**: * Give your container a fixed height (e.g., 600px). * Ensure no parent element uses overflow: hidden. # Scan & Share Source: https://developer.eka.care/SDKs/web-sdk/abha-sdk/abha-s&s Complete implementation guide for the ABHA SDK to be used for ABHA Scan & Share Book Appointment Flow. # ABHA SDK - Scan & Share Implementation This guide provides everything you need to integrate the ABHA SDK into your application for ABHA Scan & Share Book Appointment Flow. * **ABHA Scan & Share**: Get your Appointments Booked through ABHA. ### Implementation Example Add the following HTML and script tags to your webpage: For staging/dev environments, replace the SDK URLs with: * **JS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/js/abha.js` * **CSS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/css/abha.css` ```html theme={null} ABHA SDK Integration for ABHA Scan & Share

ABHA SDK Demo

``` ## Core Functions ### 1. initAbhaApp Initializes and renders the ABHA SDK in your specified container. **Parameters:** | Name | Type | Required | Description | | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `containerId` | `string` | ✅ | The HTML element ID where the SDK will mount. | | `clientId` | `string` | ✅ | Provide clientId as `ext`. | | `data` | `{`
`oid?: string;`
`hipId?: string;`
`counter_id?: string;`
`orgIconUrl?: string;`
`linkToOrgIcon?: string;`
`identifier: string;`
`identifier_type: string;`
`flow: string;`
`orgIconUrl?: string;`
`linkToOrgIcon?: string; `
`}` | ✅ | Configuration data for initializing the ABHA flow.

- oid: Pass the OID of the patient if available.
- hipId: Pass the HFR ID you have.
- counter\_id: Pass the HIP code of the facility you have.
- identifier: Pass the identifier value i.e. phr address of the patient.
- identifier\_type: Pass the type of identifier which you passed in `identifier` key i.e. "phr\_address".
- flow: Pass the type of flow for which you want to use SDK for i.e. `scan-share` for Scan & Share Flow.
- orgIconUrl: Public CDN URL of the logo of your organisation url should start with https\://. [Example](https://cdn.eka.care/vagus/cl5jgf0u500070shaetqw0r5l.png)
- linkToOrgIcon: Public CDN URL of the icon representing “Link ABHA to your organisation” url should start with https\://. [Example](https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp)

`keys with ? are optional.` | | `onAppointmentBookedSuccess` | `(params: TOnAbhaSnSAppointmentSuccessParams) => void` | ✅ | Triggered when the Appointment is booked and token gets generated successfully. | | `onError` | `(params: TOnAbhaFailureParams) => void` | ✅ | Triggered when an error occurs during the ABHA flow. | | `onAbhaClose` | `() => void` | ✅ | Triggered when SDK closes. | **Example:** ```javascript theme={null} window.initAbhaApp({ containerId: "sdk_container", data: { oid: "patient_oid_here", hipId: "available_HFR_ID", counter_id: "available_HIP_code" identifier: "phr_address_of_the_patient" identifier_type: "phr_address" flow:'scan-share', // Pass the flow as scan-share }, onAppointmentBookedSuccess: (params) => { console.log("Appointment Booked successfully!", params); }, onError: (error) => { console.error("ABHA flow failed:", error); }, onAbhaClose: (error) => { console.error("ABHA SDK closed"); }, }); ``` ## Callback Parameters ### onAppointmentBookedSuccess Callback The onAppointmentBookedSuccess callback is triggered when the appointment is booked and token gets generated successfully. It returns a confirmation message indicating that the Appointment is booked. **Callback Signature:** ```typescript theme={null} onAppointmentBookedSuccess: (params: TOnAbhaSnSAppointmentSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaSnSAppointmentSuccess = string; ``` **Parameters** | | Type | Description | | ---------------------------- | -------- | ----------------------------------------------------------------- | | `onAppointmentBookedSuccess` | `string` | A confirmation message from SDK post Appointment Token generation | **Example:** ```javascript theme={null} const onAppointmentBookedSuccess = (params) => { console.log("Appointment Booked successfully!:", params); alert("Appointment Booked successfully!"); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAppointmentBookedSuccess(params); } }; ``` ### onError Callback The onError callback is triggered whenever an ABHA flow fails or is interrupted. It provides details about the failure through structured parameters, allowing you to handle or forward the error appropriately (for example, to native apps or monitoring tools). **Callback Signature:** ```typescript theme={null} onError: (params: TOnAbhaFailureParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaFailureParams = { error?: string; response?: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ------------------------ | ---------------------------------------------------------------- | | `error` | `string?` | Short description of the failure or error message. | | `response` | `TAuthVerifyV2Response?` | Partial or full API response object returned from ABHA services. | **Example:** ```javascript theme={null} const onError = (params) => { console.error("ABHA Error:", params); if (params.response?.error?.code === 1001) { alert("Authentication failed. Please try again."); } else if (params.error === "NETWORK_ERROR") { alert("Please check your internet connection."); } else { alert("Something went wrong. Please retry."); } // Forward the error to native handler if available if (window.EkaAbha) { window.EkaAbha.onAbhaFailure(JSON.stringify(params)); } }; ``` ### onAbhaClose Callback The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. **Callback Signature:** ```typescript theme={null} onAbhaClose: () => void; ``` **Example:** ```javascript theme={null} const onAbhaClose = () => { console.log("ABHA SDK Closed"); }; ``` **Suggest Handling** * Always log the full error response (params) for debugging. * Display friendly error messages for known error.code values. * If params.response is present, inspect response.error.message for more detail. * If integrating with native apps, forward the serialized error object: ```javascript theme={null} window.EkaAbha.onAbhaFailure(JSON.stringify(params)); ``` ## Container Styling Ensure your container has sufficient space: ```html theme={null}
``` ## Troubleshooting ### Common Issues #### 1. SDK Not Rendering **Problem**: Nothing appears in the container. **Solution**: * Ensure containerId matches an existing HTML element. * Verify the SDK JS and CSS are correctly loaded. * Check browser console for errors. #### 2. APIs Not Being Called **Problem**: API requests are not triggered after the SDK is mounted. **Solution**: * Ensure that the accessToken is passed correctly (do not include the Bearer prefix) and that the token has not expired. * To prevent CORS-related issues, ensure that your domain is whitelisted. #### 3. Callback Not Triggered **Problem**: onSuccess, onError, onAppointmentBookedSuccess, onAbhaClose isn’t firing. **Solution**: * Make sure callbacks are passed as valid functions. * Avoid race conditions (e.g., calling before SDK fully loads). #### 4. Styling Issues **Problem**: SDK content appears misaligned or clipped. **Solution**: * Give your container a fixed height (e.g., 600px). * Ensure no parent element uses overflow: hidden. # Custom Theming Source: https://developer.eka.care/SDKs/web-sdk/abha-sdk/abha-sdk-theme Customize the ABHA SDK colors to match your application's branding # ABHA SDK - Customizing the Theme The ABHA SDK supports full color-token overriding. You can pass a `theme` object during initialization to match your application's branding. ## Passing theme to initAbhaApp The `theme` parameter is an optional key in `initAbhaApp`. Pass it alongside your other configuration: | Name | Type | Required | Description | | ------- | -------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `theme` | `object` | ⚙️ Optional | Color token overrides to match your organisation's design system. All keys are optional — only supply the tokens you want to change. | ```javascript theme={null} window.initAbhaApp({ containerId: "sdk_container", clientId: "ext", theme: { // pass only the tokens you want to override }, data: { /* ... */ }, onSuccess: (params) => { /* ... */ }, onError: (params) => { /* ... */ }, }); ``` ## Default Theme Colors If no theme is provided, the SDK uses the following default values: ```typescript theme={null} const defaultAbhaColors = { semantic: { error: '#BD0F0F', warning: '#FCB069', success: '#27B961', }, primary: { brand: '#6B5CE0', // Main buttons, radios, and active states }, surface: { base: '#FFFFFF', // Background of pages subtle: '#F2F4F7', // Card backgrounds muted: '#E4E7EC', // Dividers and borders strong: '#BEC5D0', success: '#D5F6E2', // Success background alerts neutral: '#0000000D', danger: '#DD3F3F', abhaCard: '#232477', // Specific background for the ABHA ID card }, content: { primary: '#111B31', // Heading and main text secondary: '#4B596D', // Subtext muted: '#9EA8B8', // Disabled or placeholder text success: '#1B7E43', // Success text enabled: '#ffffff', // Enabled button text color }, qrCodeColors: { fgColor: '#000000', // Color of the QR code dots bgColor: '#FFFFFF' // Background of the QR code } }; ``` ## Overriding the Theme To customize the look, add the `theme` key to your `initAbhaApp` configuration: ```typescript theme={null} window.initAbhaApp({ containerId: "sdk_container", clientId: "ext", theme: { primary: { brand: '', // Brand color }, semantic: { error: '', warning: '', success: '', }, surface: { base: '', // Background of pages subtle: '', // Card backgrounds muted: '', // Dividers and borders strong: '', success: '', // Success background alerts neutral: '', danger: '', abhaCard: '', // Specific background for the ABHA ID card }, content: { primary: '', // Heading and main text secondary: '', // Subtext muted: '', // Disabled or placeholder text success: '', // Success text enabled: '', // Enabled button text color }, qrCodeColors: { fgColor: '', // Color of the QR code dots bgColor: '' // Background of the QR code } }, data: { orgIconUrl: "https://your-domain.com/logo.png", // ... rest of your data }, onSuccess: (params) => { /* ... */ }, onError: (params) => { /* ... */ }, // ... other methods }); ``` ## Troubleshooting ### Common Theming Issues #### 1. Button Not Visible or Hard to See **Problem**: A button appears invisible, blends into the background, or is difficult to read. **Cause**: This typically happens when `primary.brand` and `content.enabled` are too similar (e.g., both set to white or both dark), making the button label invisible against its background. **Solution**: * Ensure `primary.brand` (button background) and `content.enabled` (button text) have sufficient contrast. * A dark `primary.brand` should pair with a light `content.enabled` (e.g., `#ffffff`), and vice versa. ```typescript theme={null} theme: { primary: { brand: ‘#1A237E’, // Dark button background }, content: { enabled: ‘#FFFFFF’, // Light text on button — must contrast with brand }, } ``` #### 2. Color Discrepancy — Overrides Not Taking Effect **Problem**: You passed a theme but some colors still appear as defaults. **Cause**: Token keys may be misspelled, nested incorrectly, or using the wrong casing. **Solution**: * Double-check that your token keys exactly match the structure in [Default Theme Colors](#default-theme-colors). The SDK performs a shallow merge — missing or misnamed keys fall back to defaults silently. * Verify nesting: tokens like `surface.base` must be passed as `surface: { base: ‘...’ }`, not as a flat key. ```typescript theme={null} // ❌ Wrong — flat key, will be ignored theme: { ‘surface.base’: ‘#F9FAFB’, } // ✅ Correct — nested object theme: { surface: { base: ‘#F9FAFB’, }, } ``` #### 3. Success / Error States Look Off **Problem**: Success alerts, error messages, or validation states are visually inconsistent or unreadable. **Cause**: Overriding only `semantic.success` without also updating `surface.success` and `content.success` (or vice versa) breaks the foreground/background pairing for state banners. **Solution**: Always override semantic state colors as a group — the background surface token, the text content token, and the semantic indicator token together. | State | Tokens to keep in sync | | ------- | -------------------------------------------------------- | | Success | `semantic.success`, `surface.success`, `content.success` | | Error | `semantic.error`, `surface.danger` | | Warning | `semantic.warning` | #### 4. ABHA Card Color Not Changing **Problem**: The ABHA ID card background color is not updating despite passing a theme. **Solution**: The card background is controlled by `surface.abhaCard`, not `surface.base` or `primary.brand`. Pass it explicitly: ```typescript theme={null} theme: { surface: { abhaCard: ‘#1A237E’, // Override the ABHA card background }, } ``` #### 5. QR Code Invisible or Unreadable **Problem**: The QR code is not scannable or appears blank. **Cause**: `qrCodeColors.fgColor` and `qrCodeColors.bgColor` may have been set to the same or similar colors. **Solution**: Maintain high contrast between the QR dot color and background — black on white is the most reliable combination for scanner compatibility. ```typescript theme={null} theme: { qrCodeColors: { fgColor: ‘#000000’, // QR dots — keep dark bgColor: ‘#FFFFFF’, // QR background — keep light }, } ``` # Get Started Source: https://developer.eka.care/SDKs/web-sdk/abha-sdk/get-started Complete implementation guide for the ABHA[Ayushman Bharat Digital Mission] SDK # ABHA SDK - Implementation This guide provides everything you need to integrate the ABHA SDK into your application. ## Overview The ABHA SDK allows you to integrate flows—such as Create ABHA, Login, Profile KYC, Consent Management, and Scan & Share—into your healthcare application, while offering customizable theme options. It provides: * **Create ABHA**: Create a new ABHA using Mobile or Aadhaar. * **Login with ABHA**: Login to your exisiting ABHA using PHR Address, ABHA number, Aadhaar number or Mobile number. * **ABHA Consent Management**: Manage Consent requests raised by healthcare providers to share medical records securely. * **ABHA Profile KYC**: Get your ABHA address KYC verified. * **ABHA Scan & Share**: Get your Appointments Booked through ABHA. * **Customizing the Theme**: Customize the ABHA SDK colors to match your application's branding. ## Installation ### Prerequisites * A modern web browser. * Your domain must be whitelisted with Eka Care to avoid CORS(Cross-Origin Resource Sharing) error. (Contact Eka Care to request API access and domain whitelisting.) * A valid HTML container element where the SDK will mount. ### Setup Add the following HTML and script tags to your webpage: For staging/dev environments, replace the SDK URLs with: * **JS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/js/abha.js` * **CSS:** `https://unpkg.com/@eka-care/abha-stg/dist/sdk/abha/css/abha.css` ```html theme={null} ABHA SDK Integration

ABHA SDK Demo

``` ## Core Functions ### 1. initAbhaApp Initializes and renders the ABHA SDK in your specified container. **Parameters:** | Name | Type | Required | Description | | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `containerId` | `string` | ✅ | The HTML element ID where the SDK will mount. | | `clientId` | `string` | ✅ | Provide clientId as `ext`. | | `data` | `{`
`accessToken: string;`
`hipId: string;`
`oid?: string;`
`identifier?: string;`
`identifier_type?: string;`
`counter_id?: string;`
`consent_id?: string;`
`flow?: string;`
`orgIconUrl?: string;`
`linkToOrgIcon?: string;`
`skipABHAEnable?: boolean;`
`}` | ⚙️ Optional | Configuration data for initializing the ABHA flow.

- accessToken: Pass the access token you have generated from [Connect Login ](https://developer.eka.care/api-reference/authorization/client-login) API without the word `Bearer`.
- hipId: Pass the HFR ID you have.
- oid: Pass oid of patient if available / needed in the flow.
- identifier: Pass the login identifier value i.e. mobile number / aadhaar number / phr address / abha number.
- identifier\_type: Pass the type of identifier which you passed in `identifier` key i.e. "mobile" / "aadhaar\_number" / "phr\_address" / "abha\_number" /. If not known pass undefined.
- counter\_id: Pass the HIP code of the facility you have.
- consent\_id: Pass the consent\_id of the consent request raised.
- flow: Pass the type of flow for which you want to use SDK for i.e. `abha-kyc` for KYC flow / `consent` for Consent flow.
- orgIconUrl: Public CDN URL of the logo of your organisation url should start with https\://. [Example](https://cdn.eka.care/vagus/cl5jgf0u500070shaetqw0r5l.png)
- linkToOrgIcon: Public CDN URL of the icon representing “Link ABHA to your organisation” url should start with https\://. [Example](https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp)
- skipABHAEnable: Pass the boolean as true if you want Skip ABHA button to be enabled on login screen.

`keys with ? are optional and needs to be passed as per flow requirement.` | | `theme` | `object` | ⚙️ Optional | Color token overrides to match your organisation's design system. All keys are optional — only supply the tokens you want to change. [Refer here](https://developer.eka.care/SDKs/web-sdk/abha-sdk/abha-sdk-theme) | | `onSuccess` | `(params: TOnAbhaSuccessParams) => void` | ✅ | Triggered when the user successfully creates or logs in to ABHA. | | `onKYCSuccess` | `(params: TOnAbhaKycSuccessParams) => void` | ⚙️ Optional | Triggered when the user KYC verified successfully. | | `onConsentSuccess` | `(params: TOnAbhaConsentSuccessParams) => void` | ⚙️ Optional | Triggered when the consent flow completes successfully. | | `onAppointmentBookedSuccess` | `(params: TOnAbhaSnSAppointmentSuccessParams) => void` | ✅ | Triggered when the Appointment is booked and token gets generated successfully. | | `onSkipAbha` | `(params: TOnSkipABHA) => void` | ⚙️ Optional | Triggered if the ABHA flow is skipped. | | `onAbhaClose` | `() => void` | ✅ | Triggered when SDK closes. | | `onError` | `(params: TOnAbhaFailureParams) => void` | ✅ | Triggered when an error occurs during the ABHA flow. | ## Callback Parameters ### onSuccess Callback The onSuccess callback is triggered when the ABHA flow completes successfully. It returns verified user details and tokens, which can be used to log in or continue the user’s session. **Callback Signature:** ```typescript theme={null} onSuccess: (params: TOnAbhaSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaSuccessParams = { response: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ----------------------- | ---------------------------------------------------------------------------------------------------------- | | `response` | `TAuthVerifyV2Response` | The complete ABHA verification response, containing session tokens, user profile, and transaction details. | **Example:** ```javascript theme={null} const onSuccess = (params) => { console.log("ABHA Success:", params.response); const abhaNumber = params.response.data?.profile?.abha_number; const userName = params.response.data?.profile?.name; alert(`Welcome ${userName}! Your ABHA Number: ${abhaNumber}`); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAbhaSuccess(JSON.stringify(params)); } }; ``` ### onKYCSuccess Callback The onKYCSuccess callback is triggered when the ABHA KYC flow completes successfully. It returns a confirmation message indicating that the KYC has been verified. **Callback Signature:** ```typescript theme={null} onKYCSuccess: (params: TOnAbhaKycSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaKycSuccess = string; ``` **Parameters** | | Type | Description | | ------------------- | -------- | ----------------------------------------------------- | | `TOnAbhaKycSuccess` | `string` | A confirmation message from SDK post KYC verification | **Example:** ```javascript theme={null} const onKYCSuccess = (params) => { console.log("KYC verification Success:", params); alert("KYC was verified successfully!"); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAbhaKYCSuccess(params); } }; ``` ### onConsentSuccess Callback The onConsentSuccess callback is triggered when the ABHA Consent flow completes successfully. It returns a confirmation message indicating that the Consent flow ended successfully. **Callback Signature:** ```typescript theme={null} onConsentSuccess: (params: TOnAbhaConsentSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaConsentSuccessParams = string; ``` **Parameters** | | Type | Description | | ----------------------------- | -------- | ------------------------------------------------------------ | | `TOnAbhaConsentSuccessParams` | `string` | A confirmation message from SDK post Consent flow completion | **Example:** ```javascript theme={null} const onConsentSuccess = (params) => { console.log("Consent Flow completed:", params); alert("Consent flow completed successfully!"); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAbhaConsentSuccess(params); } }; ``` ### onAppointmentBookedSuccess Callback The onAppointmentBookedSuccess callback is triggered when the appointment is booked and token gets generated successfully. It returns a confirmation message indicating that the Appointment is booked. **Callback Signature:** ```typescript theme={null} onAppointmentBookedSuccess: (params: TOnAbhaSnSAppointmentSuccessParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaSnSAppointmentSuccess = string; ``` **Parameters** | | Type | Description | | ---------------------------- | -------- | ----------------------------------------------------------------- | | `onAppointmentBookedSuccess` | `string` | A confirmation message from SDK post Appointment Token generation | **Example:** ```javascript theme={null} const onAppointmentBookedSuccess = (params) => { console.log("Appointment Booked successfully!:", params); alert("Appointment Booked successfully!"); // Optionally pass data to native bridge if available if (window.EkaAbha) { window.EkaAbha.onAppointmentBookedSuccess(params); } }; ``` ### onSkipAbha Callback The onSkipAbha callback is triggered when the ABHA SDK flow is skipped. The callback is functional when skipABHAEnable is set to true in the data parameter while initializing the SDK. **Callback Signature:** ```typescript theme={null} onSkipAbha: (params: TOnSkipABHA) => void; ``` **Example:** ```javascript theme={null} const onSkipAbha = (params) => { console.log("ABHA SDK Skipped:", params); }; ``` **Type Definitions** ```typescript theme={null} type IdentifierType = | "mobile" | "aadhaar_number" | "abha_number" | "phr_address"; type TOnSkipABHA = { identifier?: string; identifier_type?: IdentifierType[]; // No default value here }; ``` **Parameters** | Key | Type | Description | | ----------------- | ------------------- | ------------------------------------------------- | | `identifier` | `string?` | It will be login identifier value filled by user. | | `identifier_type` | `IdentifierType[]?` | It will be type of login identifier. | ### onAbhaClose Callback The onAbhaClose callback is triggered when the ABHA SDK flow gets closed. **Callback Signature:** ```typescript theme={null} onAbhaClose: () => void; ``` **Example:** ```javascript theme={null} const onAbhaClose = () => { console.log("ABHA SDK Closed"); }; ``` ### onError Callback The onError callback is triggered whenever an ABHA flow fails or is interrupted. It provides details about the failure through structured parameters, allowing you to handle or forward the error appropriately (for example, to native apps or monitoring tools). **Callback Signature:** ```typescript theme={null} onError: (params: TOnAbhaFailureParams) => void; ``` **Type Definitions** ```typescript theme={null} type TOnAbhaFailureParams = { error?: string; response?: TAuthVerifyV2Response; }; type TAuthVerifyV2Response = { skip_state: number; method: AUTH_METHOD; data?: { tokens: { sess: string; refresh: string; }; profile: TProfileRecord; }; txn_id: string; error?: { code: number; message: string; }; }; enum AUTH_METHOD { EMAIL = 1, MOBILE = 2, ABHA = 7, } type TProfileRecord = { fln: string; fn: string; mn?: string; ln?: string; gen?: "M" | "F" | "O" | "U" | undefined; // 'male' | 'female' | 'other' | 'unknown' dob?: string; mobile?: string; email?: string; uuid?: string; bloodgroup?: "" | "A+" | "A-" | "B+" | "B-" | "O+" | "O-" | "AB+" | "AB-"; pic?: string; as?: string; "dob-valid"?: boolean; "is-d"?: boolean; "is-d-s"?: boolean; "is-p"?: boolean; oid: string; at: string; type?: 1 | 2 | 3 | 4 | 5 | 6; "health-ids"?: Array; abha_number?: string; kyc_verified?: boolean; }; ``` **Parameters** | Key | Type | Description | | ---------- | ------------------------ | ---------------------------------------------------------------- | | `error` | `string?` | Short description of the failure or error message. | | `response` | `TAuthVerifyV2Response?` | Partial or full API response object returned from ABHA services. | **Example:** ```javascript theme={null} const onError = (params) => { console.error("ABHA Error:", params); if (params.response?.error?.code === 1001) { alert("Authentication failed. Please try again."); } else if (params.error === "NETWORK_ERROR") { alert("Please check your internet connection."); } else { alert("Something went wrong. Please retry."); } // Forward the error to native handler if available if (window.EkaAbha) { window.EkaAbha.onAbhaFailure(JSON.stringify(params)); } }; ``` **Suggest Handling** * Always log the full error response (params) for debugging. * Display friendly error messages for known error.code values. * If params.response is present, inspect response.error.message for more detail. * If integrating with native apps, forward the serialized error object: ```javascript theme={null} window.EkaAbha.onAbhaFailure(JSON.stringify(params)); ``` ## Container Styling Ensure your container has sufficient space: ```html theme={null}
``` ## Troubleshooting ### Common Issues #### 1. SDK Not Rendering **Problem**: Nothing appears in the container. **Solution**: * Ensure containerId matches an existing HTML element. * Verify the SDK JS and CSS are correctly loaded. * Check browser console for errors. #### 2. APIs Not Being Called **Problem**: API requests are not triggered after the SDK is mounted. **Solution**: * Ensure that the accessToken is passed correctly (do not include the Bearer prefix) and that the token has not expired. * To prevent CORS-related issues, ensure that your domain is whitelisted. #### 3. Callback Not Triggered **Problem**: onSuccess, onError, onKYCSuccess, onConsentSuccess, onAbhaClose isn’t firing. **Solution**: * Make sure callbacks are passed as valid functions. * Avoid race conditions (e.g., calling before SDK fully loads). #### 4. Styling Issues **Problem**: SDK content appears misaligned or clipped. **Solution**: * Give your container a fixed height (e.g., 600px). * Ensure no parent element uses overflow: hidden. # Get Started Source: https://developer.eka.care/SDKs/web-sdk/consent-management/get-started Embed ABDM medical records consent management into your application ## Overview The **ABDM Records** module is a plug-and-play UI widget that enables your application to request, track, and act on ABDM (Ayushman Bharat Digital Mission) health data consents on behalf of your patients. When a patient approves a consent request, the **View** button becomes available — your application is then responsible for fetching and rendering the records by calling Eka's APIs. *** ## How It Works Load the ABDM Records widget inside your application by rendering it in an `