# {{page-title}}
## Introduction
The EncounterLite profile is created from the FHIR resource [Encounter](https://www.hl7.org/fhir/encounter.html). 

## Intended Use
EncounterLite profile is created to fetch inpatient encounters at a given location.

The intended use for reading data with this API is in first hand that the API is applied for direct access and should not be used to transfer data between caregivers. If it should be used for "data copying" between care providers, patient consent must be handled outside the API.

Note that the security information (i.e. PDL block) has been bypassed in the API.

### **Specific Rules and Limitations**
|Type|Description|
|----|----|
|Limitation|Encounter status: It is only possible to request encounters that are in status "In-progress" and "Onleave".|
|Limitation|Encounter class: It is only possible to request encounters that belong to inpatient class (IMP).|
|Rule|The consumer of the API is responsible for making sure data retrieved is filtered in compliance with laws and regulations prior to presenting it to any end-users.|
|Rule|For reading encounters, the external system needs to be able to evaluate PDL. This means whether the information can be displayed for a healthcare professional with a specific assignment. PDL data needed (HSA care unit and HSA care provider) is retrieved by including the organization referenced from Encounter.serviceProvider.OrganizationSEVendorLite.|


## Profile Overview
{{link:https://fhir.cambio.se/StructureDefinition/EncounterLite/v1 }}
{{tree:https://fhir.cambio.se/StructureDefinition/EncounterLite/v1 }}

## Statuses
|FHIR status|Status in COSMIC|
|----|----|
|Planned|New, Planned (Applicable for all contact types in COSMIC).|
|Arrived|Arrived (Applicable only for outpatient contact types in COSMIC).|
|In-progress|Ongoing (Applicable for all outpatient contact types. Applicable for inpatient contacts which do not have absence in status "Ongoing"). |
|Onleave|Ongoing (Applicable for inpatient contacts with absence that are in status "Ongoing").|
|Finished|Dishcarged (Applicable for all contact types in COSMIC).|
|Canceled|Missed (Applicable for all contact types in COSMIC).|
|Entered in error|Canceled (Applicable for all contact types in COSMIC).|


## Versions
|COS version|Profile version|Required COSMIC version|Date|Description|
|------|------|------|------|------|
|4.3.0|1.0.0|COSMIC 3.12.0|July 2024|Initial version, support for GET and search.|

## Supported Operations

### HTTP Methods
|Method|Description|
|------|------|
|GET|Fetch inpatient encounters that are in statuses "In-progress" and "Onleave" from COSMIC.|

### Query Operations
#### Search Parameters 
|Query parameter|Format|Mandatory/Optional|Description|
|------|------|------|------|
|Location|Identifier|Mandatory|The identifier of the location which encounters should be fetched.|
|Statuses|Code|Mandatory|The encounter statuses to be considered when fetching. Supported statuses: "In-progress" and "Onleave".|
|Classes|Code|Mandatory|The encounter classes to be considered when fetching. Supported classes: IMP|
|_profile|String|Mandatory|Supported profile: https://fhir.cambio.se/StructureDefinition/EncounterLite/v1|
|_include|String|Optional|Supported SearchInclude operations: Encounter:subject, Encounter:location, Encounter:serviceProvider|


#### Supported Queries
`Search [baseURL]/Encounter`

#### Supported SearchInclude Operations
1. Encounter:subject
2. Encounter:location
3. Encounter.serviceProvider

#### Supported RevInclude Operations
N/A

## Error Codes
|Error code|Description|
|----|----|
|400 Bad request|Invalid search parameter:Status is mandatory: Supported status are ( In Progress, On Leave )|
|400 Bad request|Invalid search parameter:Class is mandatory: Supported classes are (IMP)|
|400 Bad request|Invalid search parameter:location is mandatory|
|403 Forbidden|Restricted access for the user to view the encounter information|

For common codes, refer to [Error handling](https://simplifier.net/guide/CambioImplementationGuide2/Error-Handling?version=current) section.




