Patient360 (Record Retrieval)

Overview

Patient360 enables developers to retrieve medical records for clinical purposes from data exchange networks such as CommonWell, CareQuality and eHealth Exchange. This guide provides detailed instructions on how to use our API to search for patient records and retrieve clinical records from various data sources.

The Patient360 API is part of Health Gorilla's RESTful API suite and is based on HL7 FHIR STU3 and R4.

References

HL7 FHIR

Health Gorilla RESTful API is based on FHIR protocol version 3 and 4. Some custom resource profiles are defined and extension mechanism is used to introduce new attributes and operations that are absent in the original protocol.

Access Control

Health Gorilla implements SMART-on-FHIR profile and uses OAuth 2.0 framework for authentication and authorization. You need to obtain an access token and include it into the request to access the desired API endpoint.

user/*.* patient360

High level workflow

Patient360 flow diagram for querying records.Patient360 flow diagram for querying records.

Patient360 flow diagram for querying records.

Select patient

To query records in the Patient360 network, the patient record must first exist in Health Gorilla.

See the FHIR Patient APIs section on how to create or search for a patient to determine the Patient Resource ID.

The more information provided for patient can dramatically increase the number of documents returned.

Field

Required / Recommended

Notes

given

Required

Patient given name

family

Required

Patient family name

birthdate

Required

gender

Required

address

Required

  • Postal code OR city/state required, but full address recommended
  • Including multiple addresses can increase number of documents retrieved

phone number

Recommended

  • telecom in FHIR Patient

email

Recommended

  • telecom in FHIR Patient

Bulk querying

The Patient360 workflow describes how to query, retrieve and import records for a single patient. If you have multiple patients that meet the query trigger criteria, you can do the following to set up a bulk query:

  1. Load a patient roster
  2. Implement async requests

To load and queue up your patient roster, convert your patients from a text delimited roster or database table into json files. Using your programming platform of choice, POST or UPDATE patients using the Health Gorilla FHIR Patient Resource API.

Implement async requests to speed up the process and get through the queue more quickly. Using async requests, you can query up to 20 patients in parallel.

Retrieve documents

You have the option to retrieve all available documents for the specified patient or to customize your settings, e.g. if you are interested in retrieving documents from a specific organization.

Retrieve all documents

You can retrieve all available documents for the specified patient from the Health Gorilla Clinical Network with a single endpoint ($p360-search).

  1. First, if your organization will be connected with CommonWell, enroll your patient into CommonWell. Once the specified patient is enrolled into CommonWell, then all documents linked to the patient are returned by this $p360 endpoint. Follow these directions to enroll patient into CommonWell. If you will not be retrieving documents from CW, then you can skip this step.
  2. All documents from all CareQuality and eHealth Exchange provider institutions within the 50 miles radius (200 miles for eHealth Exchange) near the patient's address are included in $p360-search.
https://api.healthgorilla.com/fhir/DocumentReference/$p360-search
?patient=PATIENT_RESOURCE_ID

Parameters

Name

Value

Description

patient

PATIENT_RESOURCE_ID

The patient resourced ID. Mandatory.

🚧

This operation can take a long time to complete, therefore it must be performed asynchronously.

If you want to import all documents to your HealthGorilla account. Then you need convert the searchset to a 'batch' and send it to the Bundle endpoint.

Query from a specific network

Health Gorilla connects to multiple clinical networks and the $p360 endpoint queries all networks from a single call based on some pre-defined settings.

Depending on your specific use cases, you may want to further customize your solution, e.g. retrieve documents from a specific network or organization, retrieve a subset of documents, or adjusting the search radius.

CareQuality and eHealth Exchange Flow

While CQ and eHEX are two different consortiums, the workflow steps for querying and retrieving records is the same.

The common workflow for CQ and eHEX is as follows:

  • Query records by:
    • Directly searching Organizations in the directory
    • Geolocation based on Patient demographics or the provided search area
  • Query Patient documents' metadata
  • Retrieve Documents based on metadata
  • Add Documents to patient chart
CareQuality and eHEX flowCareQuality and eHEX flow

CareQuality and eHEX flow

1. Find Organization in CareQuality Directory

API method that allows to search for CareQuality connections by name near the specified location.

All CareQuality connections are represented by Organization resource of the following type:

https://www.healthgorilla.com/fhir/organization-type|CQ

eHEX connections are represented by Organization resource of type:

https://www.healthgorilla.com/fhir/organization-type|EHEX

Request

This is a common SEARCH operation that retrieves only Organization resources of a certain type.

https://api.healthgorilla.com/fhir/Organization?[parameter={value}]

Parameters

Name

Value

Description

type

https://www.healthgorilla.com/fhir/organization-type|CQ

https://www.healthgorilla.com/fhir/organization-type|EHEX

Required.
CQ or eHEX providers

name

string

Portion of the organization's name

address-city

string

City of organization's address.

address-state

string

US state in organization's address.

address-postalcode

string

Postal code of organization's address.

near-distance

Quantity

Radius in miles. Optional.
If specified then either address-postalcode or address-city and address-state should be not empty.

_offset

number

Positive integer. Specifies the position to return search results from.

_count

number

Positive integer. If specified then the server will not return more than _count results. Default: 20 entries.

We allow a maximum of 100 entries to be read at once. If the maximum available limit is exceeded, use paging to iterate in batches.

Example

Search for CareQuality connections within 20 miles radius from San Francisco,CA and name ‘athena’.

https://api.healthgorilla.com/fhir/Organization
 ?type=https://www.healthgorilla.com/fhir/organization-type|CQ
 &name=athena
 &address-city=San Francisco
 &address-state=CA
 &near-distance=20

Response

The operation returns a bundle of resources matching the specified search criteria. This is a stateless bundle, pagination available.

Example

{
    "resourceType": "Bundle",
    "id": "82c1d057-7447-42cf-b614-f3dad6c66367",
    "meta": {
        "lastUpdated": "2019-07-29T09:10:34.213+00:00",
        "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
        ]
    },
    "type": "searchset",
    "link": [
        {
            "relation": "self",
            "url": "https://api.healthgorilla.com/fhir/Organization?type=https://www.healthgorilla.com/fhir/organization-type%7CCQ&_format=json"
        },
        {
            "relation": "first",
            "url": "https://api.healthgorilla.com/fhir/Organization?type=https://www.healthgorilla.com/fhir/organization-type%7CCQ&_format=json&_offset=0&_count=20"
        },
        {
            "relation": "next",
            "url": "https://api.healthgorilla.com/fhir/Organization?type=https://www.healthgorilla.com/fhir/organization-type%7CCQ&_format=json&_offset=20&_count=20"
        }
    ],
    "entry": [
        {
            "fullUrl": "https://api.healthgorilla.com/fhir/Organization/cq-2.16.840.1.113883.3.564.1",
            "resource": {
                "resourceType": "Organization",
                "id": "cq-2.16.840.1.113883.3.564.1",
                "meta": {
                    "profile": [
                        "https://healthgorilla.com/fhir/StructureDefinition/hg-cq-provider"
                    ]
                },
                "text": {
                    "status": "generated",
                    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">athenahealth, Inc.</div>"
                },
                "identifier": [
                    {
                        "type": {
                            "coding": [
                                {
                                    "code": "hcid",
                                    "display": "Home Community ID"
                                }
                            ],
                            "text": "Home Community ID"
                        },
                        "value": "2.16.840.1.113883.3.564.1"
                    }
                ],
                "active": true,
                "type": [
                    {
                        "coding": [
                            {
                                "system": "https://www.healthgorilla.com/fhir/organization-type",
                                "code": "CQ",
                                "display": "Carequality Provider"
                            }
                        ]
                    }
                ],
                "name": "athenahealth, Inc.",
                "address": [
                    {
                        "extension": [
                            {
                                "url": "http://hl7.org/fhir/StructureDefinition/geolocation",
                                "extension": [
                                    {
                                        "url": "latitude",
                                        "valueDecimal": 42.3633557
                                    },
                                    {
                                        "url": "longitude",
                                        "valueDecimal": -71.16703869999999
                                    }
                                ]
                            }
                        ],
                        "text": "311 Arsenal St., Watertown, MA 2472",
                        "line": [
                            "311 Arsenal St."
                        ],
                        "city": "Watertown",
                        "state": "MA",
                        "postalCode": "2472",
                        "country": "USA"
                    }
                ]
            },
            "search": {
                "mode": "match"
            }
        },
...

2. Find patient details information

2.1. Explicitly find patient details information in a given connection

API method that allows to search for matching patient records within the specified CareQuality connection.

Request

‘search’ request should be sent to Patient endpoint.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cq-search?organization=CAREQUALITY_PROVIDER_RESOURCE_ID
https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$ehex-search?organization=EHEX_PROVIDER_RESOURCE_ID
Parameters

Name

Value

Description

organization

RESOURCE_ID

CareQuality connection resource ID. Mandatory.

Example

Search patient details matching the given patient in the specified CQ connection.

https://api.healthgorilla.com/fhir/Patient/96afb95c241be840030d7072/$cq-search?organization=cq-1.3.6.1.4.1.52618.2.4270&_format=json
Response

The operation returns a bundle of matching patients. The whole set in one place, pagination is not available.

Each Patient entry has ‘identifier’ of the system:

https://www.healthgorilla.com/cq

It should be read and used for further requests.

Example
{
    "resourceType": "Bundle",
    "meta": {
        "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
        ]
    },
    "type": "searchset",
    "total": 1,
    "link": [
        {
            "relation": "self",
            "url": "https://api.healthgorilla.com/fhir/Patient/96afb95c241be840030d7072/$cq-search?organization=cq-1.3.6.1.4.1.52618.2.4270&_format=json"
        }
    ],
    "entry": [
        {
            "resource": {
                "resourceType": "Patient",
                "identifier": [
                    {
                        "system": "https://www.healthgorilla.com/cq",
                        "value": "ctUDA_Y4EmqH1tBjCyzdgLUIeQXUlnUMkFkzgBvY2-Q9ZooFGX0mWdc6WJmKggPf2FdGPd9hYp5jaueLGbqgp4HxaUsKP-xBxLQgITqXWVzD0FqX0UB8QRCIRHcIrWYfd5gcYZs3-VG8OwFbNkkBRBdngSNxHbYKfvFKrS9vtv9Q12WSQP8fREUghKNImb_wunGuOgkc6RmXzUkp5FmCXIWcpW_XrCH3NWr1MTvpEkE3RzxaGSoO1XeNcRc7BgxF_gPbsDEYrJUi0xz1RoahL7LYmmWQlsYLMBq4rGqB4f5vT0dCT9JfeJ7qlTiXO9td"
                    }
                ],
                "active": true,
                "name": [
                    {
                        "family": "Test",
                        "given": [
                            "Joe"
                        ]
                    }
                ]
            },
            "search": {
                "mode": "match"
            }
        }
    ]
}
Errors

There are several common error responses.

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "not-supported",
            "expression": [
                "http.organization"
            ]
        }
    ]
}
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "not-found",
            "expression": [
                "http.organization"
            ]
        }
    ]
}

2.2. Find patient details information within patient’s address radius

If the certain institution where patient has medical records is unknown then there is a way to look up matching patients in all CareQuality connections within the 50 miles radius around the patient’s addresses.

To do that make the same request as in section 2.1 but skip the organization parameter.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cq-search
https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$ehex-search

3. Retrieve document metadata

🚧

This operations can take a long time to complete, therefore it must be performed asynchronously.

3.1 Find patient's medical documents for the specified patient.

3.1.1 Find patient's medical documents for the specified CQ patient.

You can read medical documents for the specified CareQuality patient.

Request

‘cq-search’ request should be made to DocumentReference endpoint.

https://api.healthgorilla.com/fhir/DocumentReference/$cq-search
?patient.identifier=https://www.healthgorilla.com/cq|CQ_PATIENT_IDENTIFIER
Parameters

Name

Value

Description

patient.identifier

IDENTIFIER

CareQuality patient identifier.
System: https://www.healthgorilla.com/cq
Mandatory.

Example

Retrieve medical documents for the given CareQuality patient.

https://api.healthgorilla.com/fhir/DocumentReference/$cq-search?patient.identifier=https://www.healthgorilla.com/cq|ctUDA_Y4EmqH1tBjCyzdgLUIeQXUlnUMkFkzgBvY2-Q9ZooFGX0mWdc6WJmKggPf2FdGPd9hYp5jaueLGbqgp4HxaUsKP-xBxLQgITqXWVzD0FqX0UB8QRCIRHcIrWYfd5gcYZs3-VG8OwFbNkkBRBdngSNxHbYKfvFKrS9vtv9Q12WSQP8fREUghKNImb_wunGuOgkc6RmXzUkp5FmCXIWcpW_XrCH3NWr1MTvpEkE3RzxaGSoO1XeNcRc7BgxF_gPbsDEYrJUi0xz1RoahL7LYmmWQlsYLMBq4rGqB4f5vT0dCT9JfeJ7qlTiXO9td
Response

The operation returns bundle of DocumentReference resources representing medical documents that belong to specified patient. The whole set in one place, pagination is not available.

Example
{
    "resourceType": "Bundle",
    "meta": {
        "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
        ]
    },
    "type": "searchset",
    "total": 1,
    "link": [
        {
            "relation": "self",
            "url": "https://api.healthgorilla.com/fhir/DocumentReference/$cq-search?patient.identifier=https://www.healthgorilla.com/cq%7CctUDA_Y4EmqH1tBjCyzdgLUIeQXUlnUMkFkzgBvY2-Q9ZooFGX0mWdc6WJmKggPf2FdGPd9hYp5jaueLGbqgp4HxaUsKP-xBxLQgITqXWVzD0FqX0UB8QRCIRHcIrWYfd5gcYZs3-VG8OwFbNkkBRBdngSNxHbYKfvFKrS9vtv9Q12WSQP8fREUghKNImb_wunGuOgkc6RmXzUkp5FmCXIWcpW_XrCH3NWr1MTvpEkE3RzxaGSoO1XeNcRc7BgxF_gPbsDEYrJUi0xz1RoahL7LYmmWQlsYLMBq4rGqB4f7IuQIq68o-XjGO16RvUO_LC9XG572iHF8kfwx6Nn2diX8ElxcWMiV3RYJgb7azfwuE0m6WXrqEhUtHz8br7K5p&_format=json"
        }
    ],
    "entry": [
        {
            "resource": {
                "resourceType": "DocumentReference",
                "contained": [
                    {
                        "resourceType": "Organization",
                        "id": "1",
                        "identifier": [
                            {
                                "type": {
                                    "coding": [
                                        {
                                            "code": "hcid",
                                            "display": "Home Community ID"
                                        }
                                    ],
                                    "text": "Home Community ID"
                                },
                                "value": "1.3.6.1.4.1.52618.2.4270"
                            }
                        ],
                        "name": "Secret Health Hospital"
                    }
                ],
                "created": "2019-07-31T08:32:40+00:00",
                "custodian": {
                    "reference": "#1",
                    "display": "Secret Health Hospital"
                },
                "description": "Continuity of Care Document",
                "content": [
                    {
                        "attachment": {
                            "contentType": "text/xml",
                            "url": "https://api.healthgorilla.com/api/Binary/cq-6NPeUyZWgSxfJzdc0XqJJdLLwGn3sMAAxlC4D_BhEe2kxhhK1KLDVB4e4Hy0inFyUKfhey9HJt9KChIpsxXmz-BPakWzSN5po1wLCah5U3230ndfLdjIIDHAdC_Th5NpIFOwQQ1aMJIfLnqmiOafJzmML99ugWJv6VKwU1H57lTrnsyf0YSJ4h89AqhOz9xdnKq-hBDKQT5R35IeRX5qNBiAxEkHLeILwIZ7C-_hcKuMHHkAVV7lLRJydRAtqMjvluBQzd1kdUesi99POexK22E1qVdI1ev_tUqL9atQpFg2LsZrkQ8-cflqejeJmwi5fqET18Mt94hbV4hUuEPoDOU1dHSM6W23Qg8rWHzhF6znfR10fzw0RLO4ig9UUPuM"
                        }
                    }
                ]
            },
            "search": {
                "mode": "match"
            }
        }
    ]
}
3.1.2 Find patient's medical documents for the specified eHEX patient.

You can read medical documents for the specified eHEX patient.

Request

‘ehex-search’ request should be made to DocumentReference endpoint.

https://api.healthgorilla.com/fhir/DocumentReference/$ehex-search
?patient.identifier=https://www.healthgorilla.com/ehex|EHEX_PATIENT_IDENTIFIER
Parameters

Name

Value

Description

patient.identifier

IDENTIFIER

eHEX patient identifier.
System: https://www.healthgorilla.com/ehex
Mandatory.

Response

The operation returns bundle of DocumentReference resources representing medical documents that belong to specified patient. The whole set in one place, pagination is not available.

3.2 Find patient's medical records within certain geo location

You can pull available medical records of the patient within a radius of the specified zip code or address that are not stored in the patient's chart, so that you do not have to identify every institution that a patient has been treated at. You may not know all the institutions where the patient has been treated, and patient may have been treated at an institution not close to their home (e.g. on vacation).

3.2.1 Find patient's medical records within certain geo location in CQ catalog
Request

‘search’ request should be sent to DocumentReference endpoint. Either State and City or Postal (ZIP) Code should be specified as geographic location.

https://api.healthgorilla.com/fhir/DocumentReference/$cq-search?
&patient=PATIENT_RESOURCE_ID
&[parameter={value}]
Parameters

Name

Value

Description

address-state

String

State. E.g. CA. Required if address-city parameter is specified

address-city

String

City. Required if address-state is specified.

address-postalcode

String

Postal (ZIP) code

near-distance

Quantity

Miles. Default is 50 miles

Example
https://api.healthgorilla.com/fhir/DocumentReference/$cq-search?
patient=PATIENT_RESOURCE_ID
&address-state=CA
&address-city=San Francisco
&near-distance=25
https://api.healthgorilla.com/fhir/DocumentReference/$cq-search?patient=PATIENT_RESOURCE_ID
&address-postalcode=94087
3.2.2 Find patient's medical records within certain geo location in eHEX catalog
Request

‘search’ request should be sent to DocumentReference endpoint. Either State and City or Postal (ZIP) Code should be specified as geographic location.

https://api.healthgorilla.com/fhir/DocumentReference/$ehex-search?
&patient=PATIENT_RESOURCE_ID
&[parameter={value}]
Parameters

Name

Value

Description

address-state

String

State. E.g. CA. Required if address-city parameter is specified

address-city

String

City. Required if address-state is specified.

address-postalcode

String

Postal (ZIP) code

near-distance

Quantity

Miles. Default is 50 miles

CommonWell Flow

The general flow diagram for retrieving person's medical history from CommonWell network is as follows

CommonWell flowCommonWell flow

CommonWell flow

You will need to execute the following steps:

  • Create Patient record in your Health Gorilla instance or search for the Patient previously created
  • Having patient's identifier search this Patient information in CommonWell's Master Patient Index of Persons.
  • If CommonWell doesn't have information about your patient then you will Enroll your Patient as a new Person
  • If CommonWell finds existing persons matching your Patient search then you can link your Patient (called Local Patient in this case as it is isolated in your Health Gorilla account) to it. This link is called Patient Link. That Person in CommonWell's Master Patient Index may have links to other Local Patients from different organizations (called Remote Patients). A transitive relationship between Local Patient and Remote Patients which reference the same Person is called Network Links. Every Network Link has its level of confidence, called "Level of Link Assurance" (LOLA) and may have values of 0, 1, 2, 3 or 4. By enrolling your local patient into CommonWell Health Gorilla will establish link of LOLA 2.
  • Once you enroll your Local Patient into CommonWell either as existing or new Person then you can query for set of documents metadata.
  • Retrieve content of documents using their URLs from metadata.

1. Search for matching persons

This API method lets you search for matching Persons in CommonWell. If the given patient is already enrolled in CommonWell (see Enroll patient in CommonWell) - search results will always come back empty as the Person was already determined.

Request

‘search’ request should be sent to Patient endpoint.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cw-search
Example

Search persons in CommonWell matching the given patient. The operation returns a bundle of matching persons. The whole search result in one response, pagination is not available.

https://api.healthgorilla.com/fhir/Patient/fa6a2e5dc18ac1d18b64f618/$cw-search
{
    "resourceType": "Bundle",
    "meta": {
        "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
        ]
    },
    "type": "searchset",
    "total": 1,
    "link": [
        {
            "relation": "self",
            "url": "https://qa.healthgorilla.com/fhir/Patient/43a23b60c6d4e720b3a61cef/%24cw-lookup"
        }
    ],
    "entry": [
        {
            "fullUrl": "https://qa.healthgorilla.com/fhir/Person/cw-222229e9-c079-481d-8957-3de6434729cf",
            "resource": {
                "resourceType": "Person",
                "id": "cw-7cee0de0-09b5-43a6-9336-92c7deb8f313",
                "name": [
                    {
                        "use": "usual",
                        "family": "Simpson",
                        "given": [
                            "Homer"
                        ]
                    }
                ],
                "birthDate": "1770-12-03",
                "address": [
                    {
                        "postalCode": "62702"
                    }
                ],
                "link": [
                        {
                            "target": {
                            "reference": "Patient/03db4352ee0190ad5e9e6748",
                            "display": "Homer Simpson"
                        }
                    }
                ]
            },
            "search": {
                "mode": "match"
            }
        }
    ]
}

You can capture id of the desired Person and then you can use it to enroll the patient into CommonWell linking with the given Person.

2. Identify whether the patient is enrolled in CommonWell

This API method allows to check whether the given patient is enrolled in CommonWell. If the patient is enrolled, then there is a Person in CommonWell linked to the given Patient resource.

Request

‘cw-lookup’ operation request should be sent to Patient endpoint.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cw-lookup
Example

Check that the given patient is enrolled in CommonWell.

https://api.healthgorilla.com/fhir/Patient/96afb95c241be840030d7072/$cw-lookup

Response

Enrolled

If the specified patient is enrolled in CommonWell then the operation result is a Bundle of Person resources linked to the given patient.

{  
   "resourceType":"Bundle",
   "meta":{  
      "profile":[  
         "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
      ]
   },
   "type":"searchset",
   "total":1,
   "link":[  
      {  
         "relation":"self",
         "url":"https://api.healthgorilla.com/fhir/Patient/fa6a2e5dc18ac1d18b64f618/$cw-search?_format=json"
      }
   ],
   "entry":[  
      {  
         "fullUrl":"https://api.healthgorilla.com/fhir/urn:uuid:455a3ae7-0438-4337-9539-08aae04a68aa",
         "resource":{  
            "resourceType":"Person",
            "id":"cw-7cee0de0-09b5-43a6-9336-92c7deb8f313",
            "name":[  
               {  
                  "use":"usual",
                  "family":"Simpson",
                  "given":[  
                     "Homer"
                  ]
               }
            ],
            "birthDate":"1770-12-03",
            "address":[  
               {  
                  "postalCode":"62702"
               }
            ]
         },
         "search":{  
            "mode":"match"
         }
      },
   ]
}
Not Enrolled

If the specified patient is not enrolled in CommonWell, then the result of the operation will be HTTP 404 Not Found response, which you can see below:

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "information",
            "code": "not-found",
            "details": {
                "coding": [
                    {
                        "code": "NOT_ENROLLED"
                    }
                ],
                "text": "The supplied patient is not enrolled in CommonWell."
            },
            "diagnostics": "Linked Person can't be found in CommonWell."
        }
    ]
}

3. Enroll patient in CommonWell

This API method can be used to enroll patient in CommonWell either as a new Person or with the link to Person record that already exists in CommonWell.
You may link several existing Persons to a single patient, for example when you believe that CommonWell's Master Patient Index has duplicate entries for the same person. It is not permitted to enroll as a new person if your local patient already has link to existing person in CommonWell.

Request

‘enroll’ request should be sent to Patient endpoint.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cw-enroll?person=COMMONWELL_PERSON_RESOURCE_ID

Parameters

Name

Value

Description

person

PERSON_ID

CommonWell person resource ID. Optional.

Example

Enroll the given patient as a new person in CommonWell.

https://api.healthgorilla.com/fhir/Patient/96afb95c241be840030d7072/$cw-enroll

Link the given patient to the specified person.

https://api.healthgorilla.com/fhir/Patient/96afb95c241be840030d7072/$cw-enroll?person=cw-7cee0de0-09b5-43a6-9336-92c7deb8f313

Response

The operation result is a Parameters bundle that contains the following two values:

Parameter Name

Details

enrolled

true

targetPerson

COMMONWELL_PERSON_RESORCE_ID

You can use an ID part from the targetPerson parameter (starting with "cw-") to reference CommonWell's person your local patient was linked to during the enrollment.

Examples of response

{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "enrolled",
            "valueBoolean": true
        },
        {
            "name": "targetPerson",
            "valueId": "Person/cw-7cee0de0-09b5-43a6-9336-92c7deb8f313"
        }
    ]
}
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "business-rule",
            "details": {
                "coding": [
                    {
                        "code": "NOT_PERMITTED"
                    }
                ],
                "text": "Operation not permitted"
            },
            "diagnostics": "Creation of a new Person while there are links to existing Person(s) is restricted"
        }
    ]
}

In the above response you can find the Person ID in CommonWell

cw-7cee0de0-09b5-43a6-9336-92c7deb8f313

Errors

There are several common error responses that the given operation may return.

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "not-supported",
            "expression": [
                "http.person"
            ]
        }
    ]
}

4. Unenroll patient from CommonWell

API method that can be used to unenroll patient from CommonWell by removing the links from Patient to the Person.

Request

‘un-enroll’ request should be sent to Patient endpoint.

https://api.healthgorilla.com/fhir/Patient/PATIENT_RESOURCE_ID/$cw-unenroll?
&person=COMMONWELL_PERSON_RESOURCE_ID
&purposeOfUse=NHIN_PURPOSE_OF_USE

Parameters

Name

Type

Value

person

Reference

CommonWell person resource ID. Optional.
If not specified then all persons will be un-enrolled.

purposeOfUse

Token

The NHIN purpose-of-use code.
https://www.hl7.org/fhir/codesystem-nhin-purposeofuse.html

Example

POST /fhir/Patient/fa6a2e5dc18ac1d18b64f618 HTTP/1.1 
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
Content-Type: application/x-www-form-urlencoded
Content-Length: 69

person=cw-7cee0de0-09b5-43a6-9336-92c7deb8f313&purposeOfUse=treatment
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Hg-Request-Id: 15e2305e94845d4d2f3f7796
Content-Length: 0
Date: Tue, 6 Feb 2020 14:33:16 GMT

5. Query documents metadata

API method that allows to query medical documents metadata for the given CommonWell patient.

🚧

This operations can take a long time to complete, therefore it must be performed asynchronously.

Request

‘cw-search’ request should be sent to DocumentReference endpoint.

https://api.healthgorilla.com/fhir/DocumentReference/$cw-search
?patient=PATIENT_RESOURCE_ID

Parameters

Name

Value

Description

patient

PATIENT_RESOURCE_ID

The patient resource ID.
Mandatory.

The operation returns a Bundle of matching documents's metadata.

Example

Query medical documents' metadata for the given CommonWell patient.

https://api.healthgorilla.com/fhir/DocumentReference/$cw-search?patient=fa6a2e5dc18ac1d18b64f618
{
    "resourceType": "Bundle",
    "meta": {
        "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-stateless-bundle"
        ]
    },
    "type": "searchset",
    "total": 3,
    "link": [
        {
            "relation": "self",
            "url": "https://api.healthgorilla.com/fhir/DocumentReference/$cw-search?patient=fa6a2e5dc18ac1d18b64f618&_format=json"
        }
    ],
    "entry": [
        {
            "fullUrl": "https://api.healthgorilla.com/fhir/urn:uuid:455a3ae7-0438-4337-9539-08aae04a68aa",
            "resource": {
                "resourceType": "DocumentReference",
                "contained": [
                    {
                        "resourceType": "Organization",
                        "id": "1",
                        "name": "Health Gorilla-OrgA-1370"
                    }
                ],
                "masterIdentifier": {
                    "system": "urn:ietf:rfc:3986",
                    "value": "2.16.840.1.113883.3.3330.8889429.1370.1^91540..1"
                },
                "custodian": {
                    "reference": "#1",
                    "display": "Health Gorilla-OrgA-1370"
                },
                "description": "Health Gorilla-OrgA-1370 Summarization Of Episode Note",
                "content": [
                    {
                        "attachment": {
                            "contentType": "application/octet-stream",
                            "url": "https://api.healthgorilla.com/api/Binary/cw-a-cHN8UdWyGRxV3RtW5Hk9vFXZxD3Cy1NMRwiUqUN0IiWvmp_Z37TeLisex8Ti5g_yL90xqO0knTm3SJSfvIFUdF7X0u4cJspw12ZK022CyokP3d_254qrzRN3T-TTQBBK_FSW5txZVaMbv74wRbZEHJ-A4PXapxarTZ7m7TP3RdLOQscfz21_TrMhRHluymlDxFU9agllcNTb_-N7BT14JRmWRRvbHxW_Xrpm1xlpnEFSzmp-YgRmZAZMqm-Qa2TW1EX_JRkehbUkluoVlu_C_sDh3lxdfj64OOgOsMQJpM9JcW5LZe6em26WaW0xF-Trqq0g7ltwKoMAZWPPOQuI9zVR6rMAykowTXbcq7JDvM5i8LXFCmhNGJ7L8OVg9Y1jn65wIwy3UHKZzuSAyBGmy8Y6u6c7tUfyBi1wwy9ZLbXn_ZEhJipZpDJAImv9Z4NfBVCMJTc6mmIlptlSvwXe3S1O8fjMbu9z5g6FmR6tY"
                        }
                    }
                ]
            },
            "search": {
                "mode": "match"
            }
        },
...
}

Errors

There are several common error responses.

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "processing",
            "details": {
                "coding": [
                    {
                        "code": "NOT_ENROLLED"
                    }
                ],
                "text": "The supplied patient is not enrolled in CommonWell."
            },
            "diagnostics": "Linked Person can't be found in CommonWell."
        }
    ]
}

CommonWell Errors

There are several error responses common for CommonWell operations.

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "processing",
            "details": {
                "coding": [
                    {
                        "code": "INSUFFICIENT_PATIENT_DATA"
                    }
                ],
                "text": "The patient does not contain enough data to be processed by CommonWell."
            },
            "diagnostics": "Insufficient data to create CommonWell Local Patient"
        }
    ]
}
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "fatal",
            "code": "processing",
            "details": {
                "coding": [
                    {
                        "code": "BAD_PATIENT_ZIP"
                    }
                ],
                "text": "The patient's zip code is not valid and rejected."
            },
            "diagnostics": "The Zip code does not match the required specifications."
        }
    ]
}

Retrieve and add documents

You have the option to retrieve a subset of selected documents or to import all documents.

Retrieve selected document

Once you got a DocumentReference using retrieve operation, the next step is to retrieve the document itself by downloading it's content.

DocumentReference.content.attachment contains URL to the document.

Attribute

Description

Attachment.url

Link that should be used to download the given document. This is a link to a Binary resource.

Attachment.hash

The calculated hash of the document. Optional.

Attachment.contentType

MIME type of the document. Optional.

Health Gorilla provides an endpoint that is used to download binary content. This endpoint represents FHIR Binary resource. See https://www.hl7.org/fhir/binary.html for details.

GET /api/Binary/BINARY_RESOURCE_ID HTTP/1.1 
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
Accept: text/html

An ‘Accept’ header is required to be set. You can pass either / Accept Any or pass the MIME type specified for the given document in Attachment.

The result of this call is HTTP 200 OK.

Example:

https://api.healthgorilla.com/api/Binary/cw-a-cHN8UdWyGRxV3RtW5Hk9vFXZxD3Cy1NMRwiUqUN0IiWvmp_Z37TeLisex8Ti5g_yL90xqO0knTm3SJSfvIFUdF7X0u4cJspw12ZK022CyokP3d_254qrzRN3T-TTQBBK_FSW5txZVaMbv74wRbZEHJ-A4PXapxarTZ7m7TP3RdLOQscfz21_TrMhRHluymlDxFU9agllcNTb_-N7BT14JRmWRRvbHxW_Xrpm1xlpnEFSzmp-YgRmZAZMqm-Qa2TW1EX_JRkehbUkluoVlu_C_sDh3lxdfj64OOgOsMQJpM9JcW5LZe6em26WaW0xF-Trqq0g7ltwKoMAZWPPOQuI9zVR6rMAykowTXbcq7JDvM5i8LXFCmhNGJ7L8OVg9Y1jn65wIwy3UHKZzuSAyBGmy8Y6u6c7tUfyBi1wwy9ZLbXn_ZEhJipZpDJAImv9Z4NfBVCMJTc6mmIlptlSvwXe3S1O8fjMbu9z5g6FmR6tY

Retrieve all available documents

You can retrieve all available documents for the specified patient from CommonWell and Carequality within one request.

  • If the specified patient is enrolled into CommonWell then all appropriate documents are returned.
  • All documents from all Carequality provider institutions within the 50 miles radius near the patient's address are included into the response.
  • All documents from all eHEX provider institutions within the 50 miles radius near the patient's address are included into the response.
https://api.healthgorilla.com/fhir/DocumentReference/$p360-search
?patient=PATIENT_RESOURCE_ID

Parameters

Name

Value

Description

patient

PATIENT_RESOURCE_ID

The patient resource ID.
Mandatory.

🚧

This operations can take a long time to complete, therefore it must be performed asynchronously.

If you want to import all documents to your HealthGorilla account. Then you need convert the searchset to a 'batch' and send it to the Bundle endpoint.

Import Document

HealthGorilla provides two different ways to import selected Carequality and CommonWell documents:

  • import a single document
  • import a batch of documents

📘

Note

If you import a CDA document (clinical note, transfer note etc.) then all embedded medical history records will be attached to the corresponding patient chart.

🚧

Regardless of the method you choose be aware that the import process could take a significant amount of time due to communication delays while we fetching the original document from its source. So you must request in an asynchronous manner.

Import a single document

In order to import a single document you should send HTTP POST request to the DocumentReference endpoint and supply the selected DocumentReference resource as a payload.

You can find the detailed operation description in FHIR Restful API Guide.

The synchronous version of this operation is below:

POST /fhir/DocumentReference HTTP/1.1 
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
HG-Idempotency-Key: 15e72676-48c3-11ea-b77f-2e728ce88125
Content-Type: application/json 
[...omitted for brevity...]
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
X-Hg-Request-Id: 15e2305e94845d4d2f3f7796
Location: https://api.healthgorilla.com/fhir/DocumentReference/a690435f1528380fc5d18479
Content-Length: 0
Date: Tue, 25 aug 2020 12:15:01 GMT
{ 
   "resourceType":"DocumentReference",
   "meta":{ 
      "profile":[ 
         "https://healthgorilla.com/fhir/StructureDefinition/hg-cw-document"
      ]
   },
   "masterIdentifier":{ 
      "system":"urn:ietf:rfc:3986",
      "value":"5fb4315db0e647bd6e38c1a6"
   },
   "identifier":[ 
      { 
         "use":"official",
         "system":"urn:ietf:rfc:3986",
         "value":"urn:uuid:b558f5eb-4276-4597-bbe8-c8fb456ead60"
      }
   ],
   "status":"current",
   "type":{ 
      "coding":[ 
         { 
            "system":"http://loinc.org/",
            "code":"34133-9",
            "display":"Summarization of episode note"
         }
      ]
   },
   "class":{ 
      "coding":[ 
         { 
            "system":"http://loinc.org/",
            "code":"34133-9",
            "display":"Summarization of episode note"
         }
      ]
   },
   "subject":{ 
      "reference":"Patient/fa6a2e5dc18ac1d18b64f618",
      "display":"Tom Sower"
   },
   "created":"2020-02-13T06:55:35+00:00",
   "indexed":"2020-02-13T06:55:35.000+00:00",
   "description":"Continuity of Care Document",
   "securityLabel":[ 
      { 
         "text":"Normal"
      }
   ],
   "content":[ 
      { 
         "attachment":{ 
            "contentType":"text/xml",
            "language":"en-us",
            "url":"https://api.healthgorilla.com/fhir/Binary/sample"
         },
         "format":{ 
            "code":"urn:ihe:pcc:xphr:2007"
         }
      }
   ],
   "context":{ 
      "facilityType":{ 
         "coding":[ 
            { 
               "system":"http://snomed.info/sct",
               "code":"83891005",
               "display":"Solo practice private office"
            }
         ]
      }
   }
}

Import a batch of documents

In order to import a batch of documents into your HealthGorilla account, you should send HTTP POST request to the Bundle endpoint and supply selected DocumentsReference resources packaged in a Bundle of type “batch” as a payload.

This is a two-step operation in which first you need to submit a batch of documents and then send a second request to read the operation outcome.

You can find the detailed description in FHIR Restful API Guide.

The synchronous version of this operation is below:

POST /fhir/Bundle HTTP/1.1 
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
HG-Idempotency-Key: 15e72676-48c3-11ea-b77f-2e728ce88125
Content-Type: application/json 
[...omitted for brevity...]
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
X-Hg-Request-Id: 15e2305e94845d4d2f3f7796
Location: https://api.healthgorilla.com/fhir/Bundle/9146293b-a1e4-446b-b692-faa929ea8725
Content-Length: 0
Date: Tue, 25 Aug 2020 09:09:55 GMT
{
  "resourceType": "Bundle",
  "id": "batch",
  "type": "batch",
  "entry": [
    {
      "fullUrl": "urn:uuid:7f9724ed-ef8d-4434-aacb-41869db83233",
      "resource": {
        "resourceType": "DocumentReference",
        "meta": {
          "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-cq-document"
          ]
        },
        "contained": [
          {
            "resourceType": "Organization",
            "id": "1",
            "identifier": [
              {
                "type": {
                  "coding": [
                    {
                      "code": "hcid",
                      "display": "Home Community ID"
                    }
                  ],
                  "text": "Home Community ID"
                },
                "value": "1.3.6.1.4.1.52618.2.3120"
              }
            ],
            "name": "Test Practice 360-2"
          }
        ],
        "extension": [
          {
            "url": "https://www.healthgorilla.com/fhir/StructureDefinition/documentreference-ondemand",
            "valueBoolean": true
          }
        ],
        "status": "current",
        "type": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "class": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "subject": {
          "reference": "Patient/96afb95c241be840030d7072",
          "display": "Joe Test"
        },
        "created": "2020-08-20T08:11:15+00:00",
        "indexed": "2020-08-20T08:11:15.000+00:00",
        "custodian": {
          "reference": "#1",
          "display": "Sacred health Hospital"
        },
        "description": "Continuity of Care Document",
        "content": [
          {
            "attachment": {
              "contentType": "text/xml",
              "url": "https://api.healthgorilla.com/fhir/Binary/cq-6NPeUyZWgSxfJzdc0XqJJdLLwGn3sMAAxlC4D_BhEe1ZcwF-ahhG4LrU0q-luDzpUKfhey9HJt9KChIpsxXmz-BPakWzSN5po1wLCah5U3230ndfLdjIIDHAdC_Th5NphXURzt-qGyyE-GUmqowRTjmML99ugWJv6VKwU1H57lTrnsyf0YSJ4h89AqhOz9xdnKq-hBDKQT5R35IeRX5qNBiAxEkHLeILwIZ7C-_hcKuMHHkAVV7lLRJydRAtqMjvluBQzd1kdUesi99POexK28VLa5vHhmZoVOmS0s9X3t42LsZrkQ8-cflqejeJmwi5fqET18Mt94hbV4hUuEPoDOU1dHSM6W23Qg8rWHzhF6znfR10fzw0RLO4ig9UUPuM"
            }
          }
        ]
      }
    },
    {
      "fullUrl": "urn:uuid:d5d0848a-6610-4053-8663-42a8c9423a13",
      "resource": {
        "resourceType": "DocumentReference",
        "meta": {
          "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-cq-document"
          ]
        },
        "contained": [
          {
            "resourceType": "Organization",
            "id": "1",
            "identifier": [
              {
                "type": {
                  "coding": [
                    {
                      "code": "hcid",
                      "display": "Home Community ID"
                    }
                  ],
                  "text": "Home Community ID"
                },
                "value": "1.3.6.1.4.1.52618.2.6572"
              }
            ],
            "name": "Dr. John M Doe, MD Practice"
          }
        ],
        "extension": [
          {
            "url": "https://www.healthgorilla.com/fhir/StructureDefinition/documentreference-ondemand",
            "valueBoolean": true
          }
        ],
        "status": "current",
        "type": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "class": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "subject": {
          "reference": "Patient/96afb95c241be840030d7072",
          "display": "Joe Test"
        },
        "created": "2020-08-20T08:11:23+00:00",
        "indexed": "2020-08-20T08:11:23.000+00:00",
        "custodian": {
          "reference": "#1",
          "display": "Dr. John M Doe, MD Practice"
        },
        "description": "Continuity of Care Document",
        "content": [
          {
            "attachment": {
              "contentType": "text/xml",
              "url": "https://api.healthgorilla.com/fhir/Binary/cq-6NPeUyZWgSxfJzdc0XqJJdLLwGn3sMAAxlC4D_BhEe2iYsFGdA0MMMrVf0i0d2c_uMPOZfOiE7L5gHXPnlAtTeBPakWzSN5po1wLCah5U3230ndfLdjIIDHAdC_Th5NphfZ4cI-lTNkSK8qdz27_2zmML99ugWJv6VKwU1H57lTrnsyf0YSJ4h89AqhOz9xdnKq-hBDKQT5R35IeRX5qNBiAxEkHLeILwIZ7C-_hcKuMHHkAVV7lLRJydRAtqMjvluBQzd1kdUesi99POexK26vcnNsWQFV01bJm2bMyggc2LsZrkQ8-cflqejeJmwi5fqET18Mt94hbV4hUuEPoDOU1dHSM6W23Qg8rWHzhF6znfR10fzw0RLO4ig9UUPuM"
            }
          }
        ]
      }
    },
    {
      "fullUrl" : "urn:uuid:046751b9-210c-4bbf-a914-ec742fd71fc5",
      "resource": {
        "resourceType": "DocumentReference",
        "meta": {
          "profile": [
            "https://healthgorilla.com/fhir/StructureDefinition/hg-cq-document"
          ]
        },
        "contained": [
          {
            "resourceType": "Organization",
            "id": "1",
            "identifier": [
              {
                "type": {
                  "coding": [
                    {
                      "code": "hcid",
                      "display": "Home Community ID"
                    }
                  ],
                  "text": "Home Community ID"
                },
                "value": "1.3.6.1.4.1.52618.2.2634"
              }
            ],
            "name": "Test Practice"
          }
        ],
        "extension": [
          {
            "url": "https://www.healthgorilla.com/fhir/StructureDefinition/documentreference-ondemand",
            "valueBoolean": true
          }
        ],
        "status": "current",
        "type": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "class": {
          "coding": [
            {
              "system": "http://loinc.org",
              "code": "34133-9",
              "display": "Summarization of episode note"
            }
          ]
        },
        "subject": {
          "reference": "Patient/96afb95c241be840030d7072",
          "display": "Joe Test"
        },
        "created": "2020-08-20T08:11:26+00:00",
        "indexed": "2020-08-20T08:11:26.000+00:00",
        "custodian": {
          "reference": "#1",
          "display": "Test Practice 360-5"
        },
        "description": "Continuity of Care Document",
        "content": [
          {
            "attachment": {
              "contentType": "text/xml",
              "url": "https://api.healthgorilla.com/fhir/Binary/cq-6NPeUyZWgSxfJzdc0XqJJdLLwGn3sMAAxlC4D_BhEe0D2VnjtdjjcP_6P63ieJahnMTyDdPu14CmHMV0h2a-nOBPakWzSN5po1wLCah5U3230ndfLdjIIDHAdC_Th5Np1Hu8jsc7ffgh5m7hewkg9DmML99ugWJv6VKwU1H57lTrnsyf0YSJ4h89AqhOz9xdnKq-hBDKQT5R35IeRX5qNBiAxEkHLeILwIZ7C-_hcKuMHHkAVV7lLRJydRAtqMjvluBQzd1kdUesi99POexK2yVRNJAnzssJayeYaDH2OUA2LsZrkQ8-cflqejeJmwi5fqET18Mt94hbV4hUuEPoDOU1dHSM6W23Qg8rWHzhF6znfR10fzw0RLO4ig9UUPuM"
            }
          }
        ]
      }
    }
  ]
}
{
    "resourceType": "Bundle",
    "type": "batch-response",
    "total": 3,
    "entry": [
        {
            "fullUrl": "urn:uuid:7f9724ed-ef8d-4434-aacb-41869db83233",
            "response": {
                "status": "201 Created",
                "location": "/fhir/DocumentReference/40333e5f892edf9999e78973"
            }
        },
        {
            "fullUrl": "urn:uuid:d5d0848a-6610-4053-8663-42a8c9423a13",
            "response": {
                "status": "201 Created",
                "location": "/fhir/DocumentReference/42333e5fca0f80adf9ca0042"
            }
        },
        {
            "fullUrl": "urn:uuid:046751b9-210c-4bbf-a914-ec742fd71fc5",
            "response": {
                "status": "201 Created",
                "location": "/fhir/DocumentReference/44333e5f9fe634e0740e455a"
            }
        }
    ]
}

Converting a search set to a batch:

The search operation outcome is a Bundle of type ‘searchset’. And if you want to import all of these documents then you need to convert it to a Bundle of type ‘batch’.
a) Change the Bundle.type to ‘batch’
b) Remove the following attributes

  • Bundle.meta
  • Bundle.total
  • Bundle.link

c) Add the Bundle.entry.fullUrl parameter to an each entry

"fullUrl":"urn:uuid:UUIDV4"

Then you can import this Bundle to your HealthGorilla account.

Patient360 Subscriptions

You can register FHIR Subscription and be notified when new information is stored in the patient's chart as part of Patient360 Record Retrieval service. See Patient360 Subscription chapter for more details.

Enable/disable patient's records sharing

You can control on a per patient basis if medical information will be shared back to requesting provider organization for Treatment purpose. In order to enable/disable sharing of patient's records you should send HTTP request (POST or GET) to the Patient endpoint and supply the selected patient identifier as a part of URL and enabled as a payload or URL parameter.

GET /fhir/R4/Patient/d36f565d066c1914e32b7e15/$enabledForSharing?enabled=true
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
POST /fhir/Patient/d36f565d066c1914e32b7e15/$enabledForSharing
Host: api.healthgorilla.com 
Authorization: Bearer sldfksgkkG78dsdff787
Content-Type: application/json
Payload:
{
    "resourceType": "Parameters",
    "parameter": [
        {
            "name": "enabled",
            "valueBoolean": true
        }
    ]
}
{
    "resourceType": "Parameters",
    "id": "d36f565d066c1914e32b7e15",
    "parameter": [
        {
            "name": "enabled",
            "valueBoolean": true
        }
    ]
}

Method returns value of changed 'enabled' value for Patient if state was changed (passed value was not the same as stored).