The data4life JavaScript SDK

The data4life JavaScript SDK lets you store and access user health data on the data4life Personal Health Data Platform (PHDP). You can share PHDP data between users and applications.

For more information about the data4life platform, visit d4l.io.

Before you get started

To use the SDK, you must have a data4life partner ID. To obtain a partner ID, get in touch with us at we@data4life.care.

Using the SDK

Once you have a partner ID, follow these steps to start working with the SDK:

  1. You can either build the SDK hosted by yourself or you import it from the provided URL. It inserts a GC object into the global namespace. Read more about building the SDK in the README.md file.

 <script src="${url}/healthcloud_sdk.js"></script>
  1. To log in a user, implement the OAuth 2.0 code grant flow which redirects the user to the data4life web app for login. Thereby, you must also create an asymmetric key pair by calling GC.SDK.createCAP. The public key of the user must be sent to our backend, while the private key needs to be stored in your OAuth backend. As an alternative, we provide an data4life AuthSDK which, combined with the corresponding AuthService, has the code grant flow already implemented. When using the AuthSDK, call GC.AUTH.login({ clientId, clientURL, environment }) To revoke the received refresh token, post to '/oauth/revoke' with the refresh token as a parameter.

  2. When you use the AuthSDK, this step is included in the login method. To initialize the SDK by providing your client ID:

     GC.SDK.setup(
         clientId,               // clientId of the application that uses the SDK
         environment,            // The environment the SDK should run in. The options are 'development' and 'production'
         privateKey,             // Private key of the logged-in user
         requestAccessToken);    // Callback for requesting a valid access token
  3. The following methods are available:

SDK methods for document management

The following section describes the methods provided by the SDK.

getCurrentUserId

To return the ID of the logged-in user, synchronously call the getCurrentUserId method.

Parameters

This method has no parameters.

Returns

Property Type Description

id

String

The ID of the logged-in user

Sample call

const userId = GC.SDK.getCurrentUserId();

Sample response

'1cf5ee52-88dc-406a-bf7b-bc5e26a17b47'

grantPermission

To allow other users to access data of the logged-in user, use the grantPermission method.

Parameters

Name Type Description

appId

String

ID of the application the data should be shared with

annotations

[String]

Only records with those annotations are shared

Resolves

This method has no resolves.

Sample call

GC.SDK.grantPermission('1cf5ee52-88dc-406a-bf7b-bc5e26a17b47', ['annotation']).then(...)

getReceivedPermissions

To get you information about all permissions you received, use the getReceivedPermissions method.

Parameters

This method has no parameters.

Resolves

Property Type Description

appId

String

App installation ID

commonKey

String

Encrypted common key

grantee

String

Reference to the grantee user ID (recipient) of this permission

granteePublicKey

String

Public key of the grantee

id

String

Unique identifier of type UUID of this permission

owner

String

Reference to the owning user ID of this permission

scope

[String]

Contains the granted tokens

Sample call

GC.SDK.getReceivedPermissions().then(...)

Sample response

{
    appId: '227ca002-db96-4175-9f10-d5ff6745259d',
    commonKey: 'CmqrvHd/Dmi8/b+m4MmjH19vlqfkIAz65Yr4UFZhwtLSGUBQQN2KaFcbRAf/jE/7lsywMqGz3H8dPnezLBnlHuA6D04+tvZupPKGe2YPD7tph8P2S3ujjpG/pq9s8qBRMj9jPZp6642dR7P8vlQcgah4mSNIjh2bMkbzmMTL1+79obUcVvxPUeTXMT1B0Ah65NxzqWrbevC83LgBUjk9+8fwwYXryIPXE7OUG7uj54t6xMIk6UiZfRRCXO4xEDbvTTyOF9mdrXDTgd8o6YYtcGyfKXC9IGv2ZB6tFPChp4wxbnzDkGWDOx5utzYb6rCR+y/YlYXwmjYeRrh0nr1pHw==',
    grantee: 'cf06c003-5f3f-499c-a14f-4868fba3487a',
    granteePublicKey: 'eyJ0IjoiYXB1YiIsInYiOjEsInB1YiI6Ik1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBdkNRTGQ3NjNjL3VPTFl4WHFaWkQ5eVcvOFZDTEFQZ29oRFpsNjUvNUpmUzZMeWdBeU5qSDBIUE85MlRNcHl3SmZ5dGVDbGJaQmo0SUJoTlNkL3pUS3NuREY0RmNhY3plQzgxRVZlWUx3SFpGTnJUL2tQUUZuTERNNWYrWUxUVVZHM1JaRUpsblgwSXM2VS82VGdTS1dnYlhnWG9yYW9KT0tjY0pyZG1YemNpbmY4ZGxwc2hEandPV3c1cDM4d1ZqL0E5UXNwUTFZV1MyOXUvc1EyNElmZFh0WXIwcCsxT3JtS0l5TFhJVTBxTEdUNGtBbWprYlZFdUl0YmxlcXJlS25paFhOVTVMSDdXeFJNUEdRQlZKMHNMRGY4M0RVVHFwT3ZUQ0hKVy9JVklUMG5QeSs0WEJtcnVRVEhOQ3g2OFdkclRnb0c1bGQ4U2NNczkwYnBUdDR3SURBUUFCIn0=',
    id: '177cca07-95ce-47e4-968c-2e36d70c87b6',
    owner: 'cf06c003-5f3f-499c-a14f-4868fba3487a',
    scope: ["exc", "perm:r", "perm:w", "rec:r", "rec:w", "attachment:r", "attachment:w", "user:r", "user:w", "user:q"]
}

createCAP

To create an asymmetric key pair that contains a data4life-specific version tag, use the createCAP method. The result is an object that contains the properties privateKey and publicKey. The values are cryptographic keys which are stringified, base-64 encoded, and data4life-versioned.

IMPORTANT: Use the string properties to store the keys in your backend. Don’t store those strings in the browser.

To make the strings storable in the browser, use the sealCAP method. You can initialize the SDK with the result of the sealCAP method.

sealCAP

The sealCAP method imports the custom data4life cryptographic key into the crypto key standard in an unexportable way. You can store the object in the IndexedDB and use it to initialize the SDK. This is a safer format than storing exportable cryptographic keys or using the data4life cryptographic key format.

Parameters

This method has no parameters.

Resolves

Property Type Description

publicKey

String

Base 64-encoded public key

privateKey

String

Base 64-encoded private key

Sample call

GC.SDK.createCAP()

Sample response

{
    publicKey: "eyJ0IjoiYXB1YiIsInYiOjEsInB1YiI6Ik1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBcnF0aGl6YkJVQVQ5ZHpWZm1sczUvd2RCdnZXc1lNTHNsVXVCalNlVlhFaVNBWEVmdXRzNDN4Ty82S0ZlTnoxV0krUVRhTUFLbTRBdWtxemwxMDEvNExBaFk0RzdIQTBuWnlDLzZidXlpb2w2c2xSZTVyVERBZS9tMEljb0xnVFZzczZsU3lBdFhPcDZOOS9rUUd1dG5JN0FpT2x5YWw0b0g0cVhHRWJjMVh2Kyt4aUJyeUZXM2NDTHcxU1RmWjhTYzFYa2Fmb3UyRVBVc3dXK3ZYZ28waHZQUU91c1JZWWo2UG83aFZPOHFIZk01TUptWE9vWDhPUlNzQTF2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VqOENnWUVBaU4rMlIrbWlYcmNOTUpLVXlpNDF6QkV4aVBvbjQrVmhxVDgwR1hQRWxsZUpWeUcyYjBJOVZtZzVBRXVaTkZQZmR4UG1mN05LaTJJaTFGZk1ST0JyeEo0TlB5TVVZY2svbGlhT3o4RzNXNFhBVWtHQ2RSK2VJeTlsRGtrNFhHN2E3L21sUkYzR1ZkOGtHcXpUWkVRS2lwV0V1OHUxNzN4WEE4ak1LbURGdmQwPSJ9"
}

sealCAP

Imports the custom data4life crypto key into the crypto key standard in an unexportable fashion. The object within the output Promise can be stored in the indexedDB and used to initialize the SDK. It is considered to be a safer format than storing the data4life crypto key itself, which is only meant for storing purposes.

Sample Call

GC.SDK.sealCAP(privateKey)

Parameter

Name Type Description

privateKey

Object

A base64 encoded privateKey

Resolves

Property Type Description

privateKeyPromise

Promise<Object>

Unexportable CryptoKey within a Promise.

Sample Response

Promise<WebCrypto{}>

reset

To reset the SDK, use the reset method. Resetting sets all user information, including user ID and userLanguage, to null and removes all access tokens, including the masterAccessToken. Resetting also removes any available private keys, common keys, and app IDs.

Sample call

    GC.SDK.reset()

isAllowedFileType

To check the file format of files uploaded to the data4life platform, use the isAllowedFileType method. The SDK allows the upload of the following file formats to the data4life platform:

  • JPEG,including JPEG/JFIF

  • PNG — Portable Network Graphics

  • TIFF — Tagged Image File Format

  • DCM — Digital Imaging and Communications in Medicine

  • PDF — Portable Document Format

Trying to create resources with another file format fails.

The file format check looks at a byte sequence in the file at a specific offset. It doesn’t rely on the filename extension.
For a good user experience, check the file format as early as possible.

Parameters

Name Type Description

(unnamed parameter)

File

File for which to check the validity

Resolves

Property Type Description

(unnamed single return value)

Boolean

True if the file is allowed, otherwise false

Sample call

    GC.SDK.isAllowedFileType(file).then(...)

createResource

To upload any type of FHIR resource, use the createResource method.

Parameters

Name Type Description

ownerId

string

Owner of the resource

fhirResource

fhir.DomainResource

FHIR resource to upload

annotations

string[]

Custom annotations for the uploaded resource which you can later use for searches

Resolves

Property Type Description

Record

Record

The record with the contained FHIR resource

Sample call

GC.SDK.createResource(ownerId, fhirResource, new Date(), ["blood test report", "dr john doe"]).then(...)

fhirResource can be any kind of FHIR resource. For example, for a medication, the resource is https://www.hl7.org/fhir/careplan-example.json.html.

Sample response

{
    id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
    fhirResource: {
        id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
        resourceType: "CarePlan",
        status: "active",
        intent: "plan",
        category: [
            {
                text: "Weight management plan"
            }
        ],
    },
    annotations: ["blood test report", "dr john doe"],
    customCreationDate: "2018-05-07T10:09:09.394Z",
    updatedDate: "2018-05-07",
    partner: "partner_id" // Partner ID from that the record is uploaded. Refers to the apps using the SDK.
}

updateResource

To update any type of FHIR resource, use the updateResource method.

Parameters

Name Type Description

ownerId

string

Owner ID of the resource

fhirResource

fhir.DomainResource

FHIR resource to update

annotations

string[]

Custom annotations for the resource uploaded which you can later use for searches

Resolves

Property Type Description

Record

Record

Record with contained FHIR resource

Sample call

GC.SDK.updateResource(ownerId, fhirResource, ["blood test report", "dr john miller"]).then(...)

fhirResource is the FHIR resource that was already created on the platform.

Every created FHIR resource has an id parameter.

Sample response

{
    id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
    fhirResource: {
        id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
        resourceType: "CarePlan",
        status: "active",
        intent: "plan",
        category: [
            {
                text: "Weight management plan"
            }
        ],
    },
    annotations: ["blood test report", "dr john miller"],
    customCreationDate: "2018-05-07T10:09:09.394Z",
    updatedDate: "2018-05-07",
    partner: "partner_id" // Partner ID from which the record is uploaded. Refers to the apps using the SDK.

}

fetchResource

To download FHIR resources you uploaded, use the fetchResource method.

Parameters

Name Type Description

ownerId

String

Owner ID of the resource to fetch

resourceId

String

ID of the resource to fetch

Returns

Property Type Description

Record

Record

Requested record with contained FHIR resource

Sample call

GC.SDK.fetchResource('1cf5ee52-88dc-406a-bf7b-bc5e26a17b47', '500b2aa5-2728-48f1-b77b-2cdac113917a').then(...)

Sample response

{
    id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
    fhirResource: {
        resourceType: "CarePlan",
        status: "active",
        intent: "plan",
        category: [
            {
                text: "Weight management plan"
            }
        ],
    },
    annotations: ["blood test report", "dr john doe"],
    customCreationDate: "2018-05-07T10:09:09.394Z",
    updatedDate: "2018-05-07",
    partner: "partner_id"
}

downloadResource

To download documents you uploaded, or other documents that you have access permission for, use the downloadResource method.

Parameters

Name Type Description

ownerId

String

Owner ID of the resource to download

documentId

String

ID of the resource to download

options

Object

(optional) Download options for image sizes (see below)

Options

Lets you specify options for the downloadResource method about the size of image resources.

  • imageSize Fetch the specified version of your resource if it’s an image. Supported values are full (default), preview, and thumbnail. The default value is also returned when no image with the requested size is found.

Returns

Property Type Description

fhirResource

fhirResource

The requested document

Sample call

GC.SDK.downloadRessource('1cf5ee52-88dc-406a-bf7b-bc5e26a17b47', 'f843456a-81c2-471d-9f55-ae3317171547').then(...)

Sample response

{
    attachments: [{
        file: {},
        title: "Screen Shot 2018-05-03 at 15.40.15.png",
        contentType: "image/png",
        creation: "2018-05-03T13:40:18.190Z",
        id: "219d6639-af8c-4a7c-9df4-15adddd82aa2"
    }],
    type: "Document",
    creationDate: "2018-05-07T10:09:09.394Z",
    title: "title",
    author: { firstName: "Max" },
    id: "f843456a-81c2-471d-9f55-ae3317171547"
}
{
    annotations: [],
    customCreationDate: "2019-02-14T00:00:00.000Z",
    fhirResource:
    {
        resourceType: "DocumentReference",
        status: "current",
        type:
        {
            coding: [
                {
                    display: "",
                    code: "ECG"
                }
            ]
        },
        author: [
            {
            reference: "#contained-author-id"
            }
        ],
        description: "ECG",
        subject:
        {
            reference: "ECG"
        },
        contained: [
            {
                resourceType: "Practitioner",
                id: "contained-author-id",
                identifier: [],
                name: [
                {
                    family: "Doe",
                    given: ["Jane"],
                    prefix: [],
                    suffix: []
                }
            ],
            address: [
                {
                    city: "",
                    line: [],
                    postalCode: ""
                }
            ],
            telecom: []
            }
        ],
        content: [
            {
                attachment:
                {
                    contentType: "image/png",
                    creation: "2019-02-14T14:09:11.155Z",
                    title: "ECG 2019-02-13 at 13.53.21.png",
                    id:"b51904e8-6556-4ca5-ab68-4db386917576",
                    file:
                        {
                            name: "ECG 2019-02-13 at 13.53.21.png",
                            lastModifiedDate: null
                        }
                    }
                }
            ],
        context:
            {
                practiceSetting: {
                    coding: [
                        {
                            display: "",
                            code: "394612005"
                        }
                    ]
                }
            },
            id: "a50cf592-1b10-4784-9686-4b399513efc3"
        },
        id: "a50cf592-1b10-4784-9686-4b399513efc3",
        partner: "31be119e-3782-4db8-a24a-1490eea27ed3",
        updatedDate: "2019-02-14T13:09:51.492Z"
    }
}

deleteResource

To delete FHIR resources, use the deleteResource method.

Parameters

Name Type Description

ownerId

String

Owner ID of the resource to delete

recordId

String

Record ID of the resource to delete

Sample call

GC.SDK.deleteResource('196e897f-c60f-44db-8507-d5f67022a11f', 'f843456a-81c2-471d-9f55-ae3317171547').then(...)

fetchResources

To fetch all FHIR resources you uploaded, use the fetchResources method.

Parameters

Name Type Description

ownerId

String

Owner ID of the resource to fetch

options

Object

(optional) Fetching options for resources

Options

Lets you specify options for the fetchResource method.

Name Type Description

limit

String

(optional, default: 20, maximum 1000) Maximum number of documents to retrieve

offset

String

(optional, default: 0) Number of records to skip when retrieving

start_date

Date

(optional) Earliest date for which to return records

end_date

Date

(optional) Latest date for which to return records

resourceType

String

(optional) Type of requested FHIR resources

partner

String

(optional) ID of the partner the records where uploaded from

Resolves

Property Type Description

records

[Records]

List of records containing FHIR resources and metadata

Sample call

GC.SDK.fetchResources('1cf5ee52-88dc-406a-bf7b-bc5e26a17b47', {
    limit: 10,
    offset: 10,
}).then(...)

Sample response

[
    {
        id: "500b2aa5-2728-48f1-b77b-2cdac113917a",
        fhirResource: {
            resourceType: "CarePlan",
            status: "active",
            intent: "plan",
            category: [
                {
                    text: "Weight management plan"
                }
            ],
        },
        annotations: ["blood test report", "dr john doe"],
        customCreationDate: "2018-05-07T10:09:09.394Z",
        updatedDate: "2018-05-07",
        partner: "partner_id"
    }
]

countResources

To count the FHIR resources you uploaded, use the countResources method.

Parameters

Name Type Description

ownerId

String

Owner ID of the resource to count

options

Object

Options

Options
Name Type Description

start_date

Date

(optional) Earliest date for which to return records

end_date

Date

(optional) Latest date for which to return records

Resolves

Property Type Description

count

Number

Total number of resources on the server that match the search criteria

Sample call

GC.SDK.countResources('1cf5ee52-88dc-406a-bf7b-bc5e26a17b47', {
    start_date: '2017-08-01',
}).then(...)

Models

The data4life platform supports multiple resource types. The resource types are reflected in the models.

HCAuthor

An Author resource contains information about the author of a document.

Sample construction
let hcAuthor = new GC.SDK.models.HCAuthor({
    firstName: 'Ruslan'
    prefix: 'Dr.'
});
Parameters
Name Type Description

identifier

String

Custom identifier

firstName

String

First name

lastName

String

Last name

prefix

String

e.g., Capt., Mr., Mrs.

suffix

String

e.g., Sr., Late

street

String

Street name

city

String

City name

postalCode

String

Postal code or ZIP code

telephone

String

Phone number

website

String

Website address

specialty

Number

(a standard set of codes is allowed in specialty value, see https://www.hl7.org/fhir/valueset-c80-practice-codes.html. reflected in HCSpeciality)

HCSpecialty

The Specialty resource is an enum (a list of named constants), which has a standard set of codes for an author. The code represents the clinical specialty of the practitioner or provider who interacted with, treated, or provided a service for the patient. For the complete list of specialties and codes, see https://www.hl7.org/fhir/valueset-c80-practice-codes.html.

Sample construction
GC.SDK.models.Specialty.AdultMentalIllness // equals 408467006

CarePlan

The CarePlan resource is one of the request resources in the FHIR workflow specification. It’s used for medication plans for patients. https://www.hl7.org/fhir/careplan.html

To create your own individual CarePlan FHIR resource, use the data4life helper functions.

Sample construction
const patient = GC.SDK.createPatient('firstNamePatient', 'lastNamePatient');
const practitioner =  GC.SDK.createPractitioner('firstName');
const medicationRequest = new GC.SDK.models.MedicationRequest(
    patient.id,
    'ingredient',
    {
        value: 20,
        unit: "gram"
    }
);

const carePlan = new GC.SDK.models.CarePlan(patient, practitioner, medicationRequest)
const extractedPatient = carePlan.getPatient();
const extractedPractitioner = carePlan.getAuthor();
const extractedMedicationRequest = carePlan.getMedicationRequest();
const carePlanFHIRObject = carePlan.asFHIR();
const anotherCarePlanInstance = GC.SDK.models.CarePlan.ofFHIR(carePlanFHIRObject);

As shown above, the CarePlan resource supports these helper functions.

Name Description

getPatient()

Returns the Patient https://www.hl7.org/fhir/patient.html from Careplan

getAuthor()

Returns the author https://www.hl7.org/fhir/practitioner.html from Careplan

getAuthor()

Returns the author https://www.hl7.org/fhir/practitioner.html from Careplan

getMedicationRequest()

Returns the medication request https://www.hl7.org/fhir/medicationrequest.html

asFHIR()

Converts the class instance into a FHIR Object

static ofFHIR(fhirObject)

Converts the fhirObject of type https://www.hl7.org/fhir/careplan.html to a class instance so you can use helper functions

DocumentReference

To describe a document that’s made available to a healthcare system, use the DocumentReference resource. https://www.hl7.org/implement/standards/fhir/documentreference.html

You can generate your own DocumentReference FHIR resource by using our helper functions.

Sample construction
let attachment = new Attachment({
    id: 'attachmentId',
    contentType: 'image/png',
    creation: new Date(),
    title: 'John Doe',
});
// You can also create an attachment by using the JS native File Object.
attachment = new Attachment(file)
Note that the supported file types are .pdf, .jpeg, .jpg, .tiff, .png, .dcm

const type = createCodeableConcept('Radiology Study observation (findings)', '18782-3', 'http://loinc.org');
const practioner = new Practitioner({
    firstName: 'John',
    lastName: 'Miller',
    prefix: 'Dr.',
    suffix: 'Jr.',
    street: 'Liverpool St.',
    city: 'London',
    postalCode: '20439',
    telephone: '915023421456',
    website: 'www.example.com',
});
const practiceSpecialty = createCodeableConcept('RadiologyInterventionalRadiology', '408455009', 'http://loinc.com');
// Note that attachment is the only mandatory parameter for creating a documentreference.
const documentReference = new DocumentReference({
    attachments: [attachment],
    type,
    title: 'John Doe Document',
    customCreationDate: '2018-08-08',
    author: practioner,
    practiceSpecialty,
    id: 'documentId',
});
// You can also set a custom ID for the document uploaded.
documentReference.setAdditionalIdForClient('clientId', 'customId');
customId = documentReference.getAdditionalIdForClient('clientId');

The DocumentReference resource supports the following helper functions.

Name Description

setAdditionalIdForClient(clientId: string, customId: string)

Sets a custom ID corresponding to the document

getAdditionalIdForClient(clientId: string): string

Gets the custom ID corresponding to the client ID

getTitle(): string

Returns the document title

getAuthor(): fhir.Practitioner

Returns the author https://www.hl7.org/fhir/practitioner.html of the DocumentReference resource

getPractioner(): fhir.Practitioner

Returns the practitioner who authored the document https://www.hl7.org/fhir/practitioner.html

getType(): fhir.CodeableConcept

Returns the medication request https://www.hl7.org/fhir/medicationrequest.html

getAttachments(): fhir.Attachment[]

Returns the list of attachments in a document

The Practitioner object, which is contained in the DocumentReference resource, supports the following helper functions:

  • getFirstName(): string

  • getLastName(): string

  • getPrefix(): string

  • getSuffix(): string

  • getStreet(): string

  • getCity(): string

  • getPostalCode(): string

  • getTelephone(): string

  • getWebsite(): string

Attachments

DocumentReference objects can contain attachments which may be image files (see above, also see the isAllowedFileType method).

For all image files, the SDK generates previews and thumbnails during creation:

  • Preview is a JPEG file that’s 1000 pixels in height and is proportionally scaled. When the original image is less than 1001 pixels in height, the preview equals the original image.

  • Thumbnail is a JPEG file that’s 200 pixels in height and is proportionally scaled. When the original image is less than 201 pixels in height, the thumbnail equals the original image.

The versions can be downloaded directly (see downloadResource).

Observation

The Observation resource is referenced by DiagnosticReport to represent lab, imaging, and other clinical and diagnostic data to form a complete report, see https://www.hl7.org/fhir/observation.html. For example observations, see https://www.hl7.org/fhir/observation-examples.html.

You can generate your own Observation FHIR resource by using our helper functions.

Sample construction
    const type = createCodeableConcept('Body Weight');
    const category = createCodeableConcept('Vital Signs');
    const referenceRange = new ObservationReferenceRange(type, 'mg', 200, 400);
    const quantity = createQuantity(300, 'mg');

    const observation = new GC.SDK.models.Observation(type, 'active', '1999-07-02', '1999-07-02', referenceRange, category, quantity, '400 mg');

This website uses cookies - see our privacy policy for more information about cookies and your rights as a user. Click on "accept" to allow the cookie use.
More about this