--- title: "Developer Access" slug: "developer-access" updated: 2024-05-29T21:27:27Z published: 2024-05-29T21:27:27Z canonical: "docs.doc-know.com/developer-access" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.doc-know.com/llms.txt > Use this file to discover all available pages before exploring further. # Developer Access ## API Access Typical product integrations occur via an **HL7** or **FHIR** interface. Dr. Know has tools and trained staff to assist with these types of integrations. Learn more [here](http://docs.doc-know.com/cost-comparison). For trusted partnership scenarios or if your project requires a deeper integration, you can [request direct access to the Dr. Know platform](https://dk-api-management.developer.azure-api.net/) via our API and SDK. Our team will review your request and you should receive a response within 48 hours. ## Getting Started Upon approval, you will be provided with an **App ID**, which is required when making **API** and **SDK** calls. Additionally, you will gain access to the Dr. Know API [documentation portal](https://dk-api-management.developer.azure-api.net). ## Software Development Kit (SDK) The Dr. Know API is extensive. As such, using our SDK can make development much easier and is strongly recommended. The SDK is made available to all approved developers. Supported Platforms Currently, Dr. Know offers an SDK based on the **.NET Standard**. Future SDKs are planned to support additional platforms (i.e. **JavaScript**). There are only two files included with the SDK, which are required to exist alongside your executable when deployed: ``` 1. DK.Models.dll -- Main SDK (contains all clinical types) 2. Symmetry.dll -- Generic API wrapper ``` ## SDK Initialization You must initialize the SDK during your project's startup before any other code executes: ``` // specify your App ID and the appropriate threading mode for your project Platform.Initialize(MyAppID, ThreadingMode.AsyncLocal); ``` At initialization time, you must specify the appropriate **threading mode** for your project, which instructs the SDK how it should manage its in-memory state. This setting is critical because the SDK heavily utilizes the **async/await** pattern and different project types behave differently with this pattern. For example, **UI-based** projects typically return from an **await** on the same thread, while **non-UI-based** projects typically return from an **await** on a different thread. Use the table below to determine the appropriate threading mode for your project. | Threading Mode | Description | | --- | --- | | **Singleton** | Use with **UI-based** project types (e.g. WinUI, UWP, WinForms). | | **AsyncLocal** | Use within an **async/await** call chain (e.g. Azure Functions). | | **ThreadLocal** | Use for manually-managed, multi-threaded scenarios. | ## Connecting Users Next, you must **connect** a valid Dr. Know **user** to establish a **session**. This is equivalent to a user logging in to the Dr. Know product. Internally, the SDK will cache a **session token** for this user's session. All subsequent SDK calls will be scoped to this user's session, until the session ends or another call to Connect() is made with a different username. ``` // connect an active subscribing user to the platform await Platform.Connect("user@mydomain.com"); ``` Once connected, you can use the various SDK types to perform the desired actions. All SDK types have convenient names and are self-documented via IntelliSense. ## Error Handling For scenarios when an item may or may not exist (e.g. finding a patient), a **null reference** is returned when the item does not exist. **Null-checking** is recommended for this scenario. ``` // attempt to find patient with MR# 123 // null-check to determine if patient was found var patient = await Patient.Create(123); if (patient == null) return; // continue work var fullName = patient.FullName; ``` For scenarios when an error occurs during a function call that is expected to succeed, a descriptive **exception** will be thrown. Inspecting the **error code** and **message** will provide further details. Normal **try-catch blocks** are recommended for this scenario. ``` try { // call a function that is expected to succeed ... } catch (Exception error) { System.Console.Writeline(error.Message); } ``` ## Usage Patterns The API and SDK support two common usage patterns: | Pattern | Description | | --- | --- | | **CRUD** | Used for **Create**, **Read**, **Update**, and **Delete** operations. | | **Functions** | Used for calling static functions. | Below are examples demonstrating each pattern's usage. ``` // CREATE // create a NEW object using new(), populating its properties, and then calling // CreateNew(item) on the same type, passing in your instance. // note: CreateNew() methods within the SDK represent CREATE operations. // note: the ID property will be -1 prior to this call, but will be a valid new ID afterwards. var patient = new Patient(); patient.FirstName = "Jane"; patient.LastName = "Doe"; patient.DOB = DateTime.Now; patient = await Patient.CreateNew(patient); ``` ``` // READ // find an existing object by calling the appropriate Create() method on the type. // note: Create() and CreateAll() methods within the SDK represent READ operations. // use null-checking to see if the object was found. var patient = await Patient.Create(123); if (patient == null) return; ``` ``` // UPDATE // update an object's properties and then call Save() to save your changes. patient.FirstName = "John"; await patient.Save(); ``` ``` // DELETE // call Delete() on a valid object to delete it from the database. await patient.Delete(); ``` ``` // FUNCTION CALLING // call a supported static function on the desired type. // note: most SDK types support static factory or other useful functions. // fetch the first 10 patients who were born on May 16, 1975. var patients = await Patient.CreateAll("05/16/1975", 10); ```