### FHIR Patient Resource Search Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example of how to construct a GET request to search for a Patient resource by name. ```text https://healthlake.us-east-1.amazonaws.com/.healthlake.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/Patient?name=John ``` -------------------------------- ### FHIR Observation Resource Response Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example of a JSON response for a GET /Observation request, conforming to FHIR R4 schema. ```json { "resourceType": "Observation", "id": "obs001", "status": "final", "code": { "text": "Heart rate" }, "valueQuantity": { "value": 72, "unit": "beats/minute" } } ``` -------------------------------- ### Authorization Header Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example of how to include the OAuth 2.0 Bearer token in the Authorization header for API requests. ```text Authorization: Bearer ``` -------------------------------- ### Export Manifest Example Source: https://legendehr.com/docs/electronic-health-information-ehi-export An example of an export manifest file, detailing the transaction time, request URL, and output file locations for exported EHI data. ```json { "transactionTime": "2024-01-15T10:00:00Z", "request": "https://healthlake.us-east-1.amazonaws.com/...", "requiresAccessToken": false, "output": [ { "type": "Patient", "url": "https://export-bucket.s3.amazonaws.com/Patient-1.ndjson.gz" }, { "type": "Observation", "url": "https://export-bucket.s3.amazonaws.com/Observation-1.ndjson.gz" } ], "error": [] } ``` -------------------------------- ### FHIR Patient Resource Response Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example of a JSON response for a GET /Patient/{id} request, conforming to FHIR R4 schema. ```json { "resourceType": "Patient", "id": "12345", "name": [{ "given": ["John"], "family": "Doe" }], "gender": "male", "birthDate": "1980-05-15" } ``` -------------------------------- ### Example FHIR Search Response Body Source: https://legendehr.com/docs/aws-healthlake-fhir-api-documentation This is an example of a successful search response from the HealthLake FHIR API, formatted as a FHIR Bundle resource. ```json { "resourceType": "Bundle", "type": "searchset", "total": 2, "entry": [ { "resource": { "resourceType": "Observation", "id": "obs-1", "code": { "coding": [ { "system": "http://loinc.org", "code": "8310-5", "display": "Body temperature" } ] }, "valueQuantity": { "value": 38.1, "unit": "C", "system": "http://unitsofmeasure.org" } } } ] } ``` -------------------------------- ### Example 400 OperationOutcome Response Source: https://legendehr.com/docs/aws-healthlake-fhir-api-documentation This is an example of a FHIR OperationOutcome resource returned for a 400 Bad Request error, detailing an invalid search parameter. ```json { "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "invalid", "details": { "text": "Invalid search parameter ‘birthdate’. Did you mean ‘birthdate’?" } } ] } ``` -------------------------------- ### FHIR OperationOutcome Error Response Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example of a JSON error response using the FHIR OperationOutcome resource. ```json { "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "invalid", "diagnostics": "Invalid query parameter value." } ] } ``` -------------------------------- ### Patient Resource Access Examples Source: https://legendehr.com/docs/application-access-patient-selection Demonstrates how to retrieve or search for patients using standard FHIR RESTful operations via the Legend EHR FHIR API. ```APIDOC ## Retrieve a specific patient GET [base]/Patient/{id} ### Description Retrieves a specific patient's record using their unique ID. ### Method GET ### Endpoint /Patient/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the patient. ### Response #### Success Response (200) - **Patient resource** (object) - A FHIR Patient resource conformant with US Core Patient Profile. ## Search for a patient by name or identifier GET [base]/Patient?name=Robert GET [base]/Patient?identifier=12345 ### Description Searches for patients based on demographic information like name or identifier. ### Method GET ### Endpoint /Patient ### Parameters #### Query Parameters - **name** (string) - Optional - The name of the patient to search for. - **identifier** (string) - Optional - The identifier of the patient to search for. ### Response #### Success Response (200) - **Bundle resource** (object) - A FHIR Bundle resource containing matching Patient resources. ``` -------------------------------- ### Example CCD (C-CDA R2.1) Export Source: https://legendehr.com/docs/electronic-health-information-export-format This XML structure represents a Continuity of Care Document (CCD) export, adhering to the HL7 CDA namespace and schema definitions. It includes key sections like patient demographics, problems, allergies, and medications. ```xml Continuity of Care Document (CCD) ... ``` -------------------------------- ### Example Patient Resource Response Source: https://legendehr.com/docs/application-access-patient-selection This is an example of a FHIR Patient resource returned by the API, conforming to US Core Patient Profile. It includes basic demographic information. ```json { "resourceType": "Patient", "id": "fd05852e1f0c147dcf212e91372aee1d", "name": [ { "given": ["Robert"], "family": "Smith" } ], "gender": "male", "birthDate": "1946-11-04" } ``` -------------------------------- ### FHIR API Base URL Example Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services This is the base URL for accessing FHIR resources. It includes the AWS HealthLake endpoint and the specific datastore ID. ```text https://healthlake.us-east-1.amazonaws.com/.healthlake.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4 ``` -------------------------------- ### Sample FHIR Patient Resource Source: https://legendehr.com/docs/electronic-health-information-ehi-export Example of a FHIR Patient resource in NDJSON format. This resource contains demographic and identifying information for a patient. ```json { "resourceType": "Patient", "id": "patient-123", "meta": { "versionId": "1", "lastUpdated": "2024-01-15T10:30:00Z" }, "identifier": [ { "system": "http://hospital.org/patient", "value": "12345" } ], "name": [ { "use": "official", "family": "Smith", "given": [ "John" ] } ], "gender": "male", "birthDate": "1980-05-15" } ``` ```json { "resourceType": "Patient", "id": "patient-124", "meta": { "versionId": "1", "lastUpdated": "2024-01-15T10:31:00Z" }, "identifier": [ { "system": "http://hospital.org/patient", "value": "12346" } ], "name": [ { "use": "official", "family": "Doe", "given": [ "Jane" ] } ], "gender": "female", "birthDate": "1975-08-22" } ``` -------------------------------- ### FHIR Bulk Data Export Request Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Example request for exporting population-level data using the FHIR Bulk Data Access specification. Ensure to replace placeholders with actual values. ```http POST https:///$export Authorization: Bearer Accept: application/fhir+json ``` -------------------------------- ### Authorization and Discovery Endpoints Source: https://legendehr.com/docs/fhir-service-urls-for-patient-ehi-access Endpoints for OAuth 2.0 authorization, SMART on FHIR discovery, and FHIR CapabilityStatement. ```APIDOC ## Authorization and Discovery Endpoints **OAuth 2.0 Authorization Server:** https://healthlakeoauth.auth.us-east-1.amazoncognito.com **SMART on FHIR Discovery Endpoint (.well-known):** https://healthlake.us-east-1.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/.well-known/smart-configuration **FHIR CapabilityStatement:** https://healthlake.us-east-1.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/metadata ``` -------------------------------- ### Error Handling & Resilience Source: https://legendehr.com/docs/aws-healthlake-fhir-api-documentation Client-side requirements for handling errors and implementing resilience mechanisms. ```APIDOC ## Error Handling & Resilience ### Requirements - **Error Handling Logic**: Application logic. Must handle standard HTTP errors (401, 403, 404, 422). - **OperationOutcome Parsing**: Application logic. Must parse the OperationOutcome FHIR resource in 4xx error responses to provide meaningful diagnostic information. - **Retry Logic**: Configuration/Algorithm. Must implement retry logic with exponential backoff for 5xx server errors and throttling responses (429 Too Many Requests). ``` -------------------------------- ### Initiate Population-Level Export Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Initiates a population-level data export using the FHIR Bulk Data Access specification. ```APIDOC ## POST /$export ### Description Initiate population-level export (FHIR Bulk Data Access). ### Method POST ### Endpoint https://healthlake.us-east-1.amazonaws.com/.healthlake.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/$export ### Parameters #### Query Parameters - **_type** (String) - Optional - Comma-separated list of resource types to export. - **_since** (DateTime) - Optional - Retrieve data updated since a given date. ### Request Body This endpoint typically does not require a request body for initiating an export, but may accept parameters in the body depending on specific implementation details not fully detailed here. ### Response #### Success Response (202 Accepted) - **Content-Location** (Header) - URL to poll for export status and results. #### Response Example (Headers) Content-Location: https://healthlake.us-east-1.amazonaws.com/.healthlake.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/Operations/export/abc123xyz (Body - typically empty for 202 Accepted, status is polled via Content-Location) ``` -------------------------------- ### Condition Resource Endpoint Source: https://legendehr.com/docs/standardized-api-for-patient-and-population-services Endpoint for retrieving problem/diagnosis lists. ```APIDOC ## GET /Condition ### Description Retrieve problem/diagnosis lists. ### Method GET ### Endpoint https://healthlake.us-east-1.amazonaws.com/.healthlake.amazonaws.com/datastore/8d8ae0ebc52744d8d9c6af8009bef7e6/r4/Condition ### Parameters #### Query Parameters - **patient** (String) - Optional - Filter conditions for a specific patient. - **status** (String) - Optional - Filter conditions by status. - **_count** (Integer) - Optional - Limit the number of results per page. - **_since** (DateTime) - Optional - Retrieve data updated since a given date. ### Response #### Success Response (200) - **resourceType** (String) - Indicates the resource type, e.g., "Condition". - **id** (String) - Unique identifier for the condition resource. - **clinicalStatus** (Object) - The clinical status of the condition. - **verificationStatus** (Object) - The verification status of the condition. #### Response Example { "resourceType": "Bundle", "entry": [ { "resourceType": "Condition", "id": "cond001", "clinicalStatus": { "coding": [{ "code": "active" }] }, "verificationStatus": { "coding": [{ "code": "confirmed" }] } } ] } ``` -------------------------------- ### Authenticate public API user Source: https://legendehr.com/docs/documentation-for-standardized-api-for-patient-and-population-services-170-315g10 Validates user credentials and authorizes the user for API access. ```APIDOC ## Authenticate public API user ### Description Validates user credentials (and authorize the user to use the specified client application for API access). ### Parameters - **sessionInfo** (SessionInfo): public API session information - **authInfo** (AuthInfo): authentication and authorization information (credentials, grant type, client attributes) ### Return - Boolean true if authenticated and authorized; false if not authenticated; or throw PhiQueryException for error conditions. ### Node.js Signature `authenticateAPIUser(sessionInfo, authInfo) → {boolean}` ``` -------------------------------- ### Search for Observations Source: https://legendehr.com/docs/aws-healthlake-fhir-api-documentation Searches for Observation resources based on specified criteria. ```APIDOC ## GET /Observation ### Description Searches for Observation resources based on specified criteria. ### Method GET ### Endpoint /Observation ### Parameters #### Query Parameters - **patient** (String) - Required - Logical ID of a patient resource. e.g., patient=12345 - **category** (Token) - Optional - Classification of the observation. e.g., category=vital-signs - **code** (Token) - Optional - The type of observation (LOINC Code). e.g., `code=http://loinc.org | 8310-5` - **date** (Date) - Optional - Date range search. e.g., date=ge2023-01-01&date=le2023-12-31 ### Response #### Success Response (200 OK) - **resourceType** (String) - "Bundle" (if multiple results) or "Observation" (if single result). - **entry** (Array) - An array of Observation resources matching the search criteria. - **total** (Number) - The total number of resources found. #### Response Example (Bundle) ```json { "resourceType": "Bundle", "total": 2, "entry": [ { "resourceType": "Observation", "id": "obs1", "status": "final", "code": { "coding": [ { "system": "http://loinc.org", "code": "8310-5" } ] }, "subject": { "reference": "Patient/12345" }, "effectiveDateTime": "2023-01-15T10:30:00Z" }, { "resourceType": "Observation", "id": "obs2", "status": "final", "code": { "coding": [ { "system": "http://loinc.org", "code": "8480-6" } ] }, "subject": { "reference": "Patient/12345" }, "effectiveDateTime": "2023-01-15T10:30:00Z" } ] } ``` ```