Difference between revisions of "Internal GCAPI"

From GrandCare Systems
Jump to navigation Jump to search
m
 
(32 intermediate revisions by 2 users not shown)
Line 1: Line 1:
GCAPI gives developers access to the core tools provided by a GCManage server and como systems. A variety of tasks can be performed by making simple web service calls.
= Calling GCAPI =
= Calling GCAPI =
A basic call to GCAPI looks like this:
A basic call to GCAPI looks like this:
  http://[como-URL]/api/[api-subsystem].php?passcode=[my-passcode]&op=[operation]&encoding=[json|xml]
  http://[como-URL]/api/[api-subsystem].php?passcode=[my-passcode]&op=[operation]&encoding=[json|xml]


The como URL and passcode are from the results of a [[GCManage API]] remote login call. The como URL is what GCManage determines is the path to the como system. This can either be proxied or the direct IP of the system. passcode is the authentication mechanism used by GCAPI -- it is a code generated every 24 hours by a system and reported to GCManage. subsystem names the subsystem you want to work on and operation defines the actual operation to perform. Each operation can have a number of other parameters that will be passed via other parameters in the URL.
The como URL and passcode are from the results of a [[Internal GCManage API]] remote login call. The como URL is what GCManage determines is the path to the como system. This can either be proxied or the direct IP of the system. passcode is the authentication mechanism used by GCAPI -- it is a code generated every 24 hours by a system and reported to GCManage. subsystem names the subsystem you want to work on and operation defines the actual operation to perform. Each operation can have a number of other parameters that will be passed via other parameters in the URL.


= Local Application Authentication =
= Local Application Authentication =
Line 49: Line 51:


= API Subsystems =
= API Subsystems =
== History API ==
The [[InternalHistory API Subsystem|History subsystem]] allows you to fetch ADL and wellness data from a system. Most of the operations take the same parameters and return different data.


== History ==
See [[Internal History API Subsystem|documentation]] for details or click an specific History operation below
The History subsystem allows you to fetch ADL and wellness data from a system. All of the operations take the same parameters and return different data.
=== [[Internal History API Subsystem#bp|Blood Pressure]] ===
 
=== bp ===
Fetches blood pressure sensor history from the system
Fetches blood pressure sensor history from the system
==== Parameters ====
=== [[Internal History API Subsystem#weight|Weight Scale]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
* ''resident'' - [optional] - ID of resident to limit data to
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<bp>
<timestamp>05/12/12 09:35:44</timestamp>
<deviceId>1001</deviceId>
<residentId>cf6ff892-3124-41ef-8c77-e729f0f66fc5</residentId>
<systolic>138</systolic>
<diastolic>88</diastolic>
<pulse>49</pulse>
<mean-ap>108</mean-ap>
</bp>
<bp>
<timestamp>05/11/12 07:11:08</timestamp>
<deviceId>1001</deviceId>
<residentId>cf6ff892-3124-41ef-8c77-e729f0f66fc5</residentId>
<systolic>128</systolic>
<diastolic>84</diastolic>
<pulse>58</pulse>
<mean-ap>98</mean-ap>
</bp>
<totalEntries>2</totalEntries>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "bp": [
            {
                "timestamp": "07/31/12 08:15:57",
                "deviceId": "1001",
                "residentId": "cf6ff892-3124-41ef-8c77-e729f0f66fc5",
                "systolic": "134",
                "diastolic": "95",
                "pulse": "54",
                "mean-ap": "117"
            },
            {
                "timestamp": "07/28/12 07:51:16",
                "deviceId": "1001",
                "residentId": "cf6ff892-3124-41ef-8c77-e729f0f66fc5",
                "systolic": "134",
                "diastolic": "89",
                "pulse": "51",
                "mean-ap": "104"
            }
        ],
        "totalEntries": "2"
    }
}
 
=== weight ===
Fetches scale history from the system
Fetches scale history from the system
==== Parameters ====
=== [[Internal History API Subsystem#temp|Temperature Sensor]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
* ''resident'' - [optional] - ID of resident to limit data to
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<weight>
<timestamp>05/16/12 07:30:26</timestamp>
<deviceId>1000</deviceId>
<residentId>cf6ff892-3124-41ef-8c77-e729f0f66fc5</residentId>
<value>179.6</value>
</weight>
<weight>
<timestamp>05/15/12 08:00:52</timestamp>
<deviceId>1000</deviceId>
<residentId>cf6ff892-3124-41ef-8c77-e729f0f66fc5</residentId>
<value>179.8</value>
</weight>
<totalEntries>1354</totalEntries>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "weight": [
            {
                "timestamp": "07/31/12 08:14:45",
                "deviceId": "1000",
                "residentId": "cf6ff892-3124-41ef-8c77-e729f0f66fc5",
                "value": "176.6"
            },
            {
                "timestamp": "07/28/12 07:49:32",
                "deviceId": "1000",
                "residentId": "cf6ff892-3124-41ef-8c77-e729f0f66fc5",
                "value": "176.2"
            }
        ],
        "totalEntries": "2"
    }
}
 
=== temp ===
Fetches temperature sensor history from the system
Fetches temperature sensor history from the system
==== Parameters ====
=== [[Internal History API Subsystem#bed|Bed Sensor]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<temp>
<timestamp>09/14/10 02:50:29</timestamp>
<deviceId>1070</deviceId>
<value>70</value>
</temp>
<temp>
<timestamp>09/14/10 01:37:27</timestamp>
<deviceId>1070</deviceId>
<value>71</value>
</temp>
<totalEntries>2</totalEntries>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "temp": [
            {
                "timestamp": "07/20/12 12:06:18",
                "deviceId": "103",
                "value": "73"
            },
            {
                "timestamp": "07/20/12 11:53:14",
                "deviceId": "103",
                "value": "74"
            }
        ],
        "totalEntries": "2"
    }
}
 
=== bed ===
Fetches bed sensor history from the system
Fetches bed sensor history from the system
 
=== [[Internal History API Subsystem#oxi|Oximeter]] ===
==== Parameters ====
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<totalEntries>1</totalEntries>
<bed>
<timestamp>...</timestamp>
<device-id>...</device-id>
<value>[Occupied|Unoccupied]</value>
</bed>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "bed": [{
                "timestamp": "...",
                "device-id": "...",
                "value": "[Occupied|Unoccupied]"
        }],
        "totalEntries": "1"
    }
}
 
=== oxi ===
Fetches oximeter history from the system
Fetches oximeter history from the system
==== Parameters ====
=== [[Internal History API Subsystem#motion|Motion]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
* ''resident'' - [optional] - ID of resident to limit data to
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<oxi>
<timestamp>05/06/12 16:55:57</timestamp>
<deviceId>1003</deviceId>
<residentId>b61790c5-0f61-40a7-864b-87b8c62cc750</residentId>
<spo2>97</spo2>
<pulse>72</pulse>
</oxi>
<oxi>
<timestamp>05/05/12 22:34:57</timestamp>
<deviceId>1003</deviceId>
<residentId>b61790c5-0f61-40a7-864b-87b8c62cc750</residentId>
<spo2>99</spo2>
<pulse>83</pulse>
</oxi>
<totalEntries>2</totalEntries>
</gcapi>
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "oxi": [
            {
                "timestamp": "08/01/12 08:11:59",
                "deviceId": "1003",
                "residentId": "b61790c5-0f61-40a7-864b-87b8c62cc750",
                "spo2": "96",
                "pulse": "63"
            },
            {
                "timestamp": "07/31/12 10:19:25",
                "deviceId": "1003",
                "residentId": "b61790c5-0f61-40a7-864b-87b8c62cc750",
                "spo2": "95",
                "pulse": "63"
            }
        ],
        "totalEntries": "2"
    }
}
 
=== motion ===
Fetches motion sensor history from the system
Fetches motion sensor history from the system
==== Parameters ====
=== [[Internal History API Subsystem#gluc|Glucometer]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<motion>
<timestamp>07/20/12 14:07:36</timestamp>
<deviceId>105</deviceId>
<value>Off</value>
</motion>
<motion>
<timestamp>07/20/12 14:05:48</timestamp>
<deviceId>102</deviceId>
<value>Off</value>
</motion>
<totalEntries>55</totalEntries>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "motion": [
            {
                "timestamp": "07/20/12 14:07:36",
                "deviceId": "105",
                "value": "Off"
            },
            {
                "timestamp": "07/20/12 14:05:48",
                "deviceId": "102",
                "value": "Off"
            }
        ],
        "totalEntries": "2"
    }
}
 
=== gluc ===
Fetches glucometer history from the system
Fetches glucometer history from the system
==== Parameters ====
=== [[Internal History API Subsystem#door|Door Sensor]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
* ''resident'' - [optional] - ID of resident to limit data to
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<gluc>
<timestamp>08/01/12 07:24:00</timestamp>
<deviceId>1002</deviceId>
<residentId>b61790c5-0f61-40a7-864b-87b8c62cc750</residentId>
<value>113</value>
<notes></notes>
</gluc>
<gluc>
<timestamp>07/31/12 08:17:00</timestamp>
<deviceId>1002</deviceId>
<residentId>b61790c5-0f61-40a7-864b-87b8c62cc750</residentId>
<value>105</value>
<notes></notes>
</gluc>
<totalEntries>2</totalEntries>
</gcapi>
 
===== json =====
{
    "gcapi": {
        "result": "SUCCESS",
        "gluc": [
            {
                "timestamp": "08/01/12 07:24:00",
                "deviceId": "1002",
                "residentId": "b61790c5-0f61-40a7-864b-87b8c62cc750",
                "value": "113",
                "notes": ""
            },
            {
                "timestamp": "07/31/12 08:17:00",
                "deviceId": "1002",
                "residentId": "b61790c5-0f61-40a7-864b-87b8c62cc750",
                "value": "105",
                "notes": ""
            }
        ],
        "totalEntries": "2"
    }
}
 
=== door ===
Fetches door sensor history from the system
Fetches door sensor history from the system
==== Parameters ====
=== [[Internal History API Subsystem#cid|Caller ID]] ===
* ''limit'' - [optional] - Limits the number of entries returned. Defaults to 50
Fetches caller ID history from the system
* ''offset'' - [optional] - Skip this number of entries. Useful for paging
* ''date'' - [optional] - Returns only entries for this date
* ''days'' - [optional] - Returns entries for the last number of days
* ''devices'' - [optional] - Comma separated list of devices to get data. Can be a single device
==== Results ====
SUCCESS, the total number of readings, and a list readings.
===== xml =====
<gcapi>
<result>SUCCESS</result>
<door>
<timestamp>08/01/12 07:24:00</timestamp>
<deviceId>1002</deviceId>
<value>Open</value>
</door>
<door>
<timestamp>07/31/12 08:17:00</timestamp>
<deviceId>1002</deviceId>
<value>Closed</value>
</door>
<totalEntries>2</totalEntries>
</gcapi>


===== json =====
== Assign API ==
{
The [[Internal Assign API Subsystem|Assign subsystem]] allows you to assign and delete wellness readings from a system.
    "gcapi": {
        "result": "SUCCESS",
        "door": [
            {
                "timestamp": "08/01/12 07:24:00",
                "deviceId": "1002",
                "value": "Open"
            },
            {
                "timestamp": "07/31/12 08:17:00",
                "deviceId": "1002",
                "value": "Closed"
            }
        ],
        "totalEntries": "2"
    }
}


== Assign API ==
See [[Internal Assign API Subsystem|documentation]] for details or click an specific Assign operation below
* URL: $SystemAddress/api/assign.php
=== [[Internal Assign API Subsystem#assign|Assign Reading]] ===
Assigns a wellness reading to a resident
=== [[Internal Assign API Subsystem#delete|Delete Reading]] ===
Marks a wellness reading as deleted


== Caregiver API ==
== Caregiver API ==
* URL: $SystemAddress/api/caregiver.php
The [[Internal Caregiver API Subsystem|Caregiver subsystem]] allows you to create, read, update, and delete caregivers from a system.
 
== Care note API ==
* URL: $SystemAddress/api/carenote.php
 
== Configure API ==
* URL: $SystemAddress/api/configure.php
 
== Device API ==
* URL: $SystemAddress/api/device.php
 
== Log API ==
* URL: $SystemAddress/api/log.php


== Media API ==
See [[Internal Caregiver API Subsystem|documentation]] for details or click an specific Caregiver operation below
* URL: $SystemAddress/api/media.php
=== [[Internal Caregiver API Subsystem#create|Create]] ===
Create a caregiver
=== [[Internal Caregiver API Subsystem#read|Read]] ===
Reads a single caregiver or all caregivers
=== [[Internal Caregiver API Subsystem#update|Update]] ===
Updates an existing caregiver
=== [[Internal Caregiver API Subsystem#delete|Delete]] ===
Deletes an existing caregiver


== Medication API ==
== Medication API ==
* URL: $SystemAddress/api/medication.php
The [[Internal Medication API Subsystem|Medication subsystem]] allows you to manage medication and schedules from a system.
 
== Message API ==
* URL: $SystemAddress/api/message.php


== PIN API ==
See [[Internal Medication API Subsystem|documentation]] for details or click an specific Medication operation below
* URL: $SystemAddress/api/pin.php
=== [[Internal Medication API Subsystem#createPrescription|Create Prescription]] ===
Create a prescription
=== [[Internal Medication API Subsystem#readPrescription|Read Prescription]] ===
Reads a single prescription or all prescriptions
=== [[Internal Medication API Subsystem#updatePrescription|Update]] ===
Updates an existing prescription
=== [[Internal Medication API Subsystem#deletePrescription|Delete]] ===
Deletes an existing prescription
=== [[Internal Medication API Subsystem#storePrescriptionPic|Store Picture]] ===
Stores a picture for a prescription


== Resident API ==
=== [[Internal Medication API Subsystem#createSchedule|Create Prescription Schedule]] ===
* URL: $SystemAddress/api/resident.php
Create a prescription schedule
=== [[Internal Medication API Subsystem#readSchedule|Read Prescription Schedule]] ===
Reads a single prescription schedule or all prescription schedules
=== [[Internal Medication API Subsystem#updateSchedule|Update Prescription Schedule]] ===
Updates an existing prescription schedule
=== [[Internal Medication API Subsystem#deleteSchedule|Delete Prescription Schedule]] ===
Deletes an existing prescription schedule
=== [[Internal Medication API Subsystem#setCompliance|Set Compliance]] ===
Set compliance on an existing prescription schedule
=== [[Internal Medication API Subsystem#checkCompliance|Check Compliance]] ===
Check compliance on an existing prescription schedule
=== [[Internal Medication API Subsystem#backfillCompliance|Backfill Compliance]] ===
Backfill compliance on an existing prescription schedule
=== [[Internal Medication API Subsystem#RxLookup|Lookup Rx]] ===
Finds Rx via FDA NDC Directory


== Rule API ==
== ActivityLog API ==
* URL: $SystemAddress/api/rule.php
The [[Internal ActivityLog API Subsystem|Activity Log subsystem]] allows you to view a log of touchscreen events
=== [[Internal ActivityLog API Subsystem#read|Read]] ===
Read entries out of the log
=== [[Internal ActivityLog API Subsystem#add|Add]] ===
Add entries to the log


== System API ==
== TODO ==
* URL: $SystemAddress/api/system.php
* <strike>assign api</strike>
* <strike>caregiver api</strike>
* carenote api
* configure api
* device api
* <strike>history api</strike>
* log api
* media api
* medication api
* message api
* pin api
* resident api
* rule api
* system api
* activitylog api
* notification api
* calendar api
* letters api


= Other Resources =
= Other Resources =
* [https://github.com/ngharo/gc-javascript-api Experimental JavaScript library]
* [https://github.com/ngharo/gc-javascript-api Experimental JavaScript library]

Latest revision as of 22:00, 19 July 2017

GCAPI gives developers access to the core tools provided by a GCManage server and como systems. A variety of tasks can be performed by making simple web service calls.

Calling GCAPI

A basic call to GCAPI looks like this:

http://[como-URL]/api/[api-subsystem].php?passcode=[my-passcode]&op=[operation]&encoding=[json|xml]

The como URL and passcode are from the results of a Internal GCManage API remote login call. The como URL is what GCManage determines is the path to the como system. This can either be proxied or the direct IP of the system. passcode is the authentication mechanism used by GCAPI -- it is a code generated every 24 hours by a system and reported to GCManage. subsystem names the subsystem you want to work on and operation defines the actual operation to perform. Each operation can have a number of other parameters that will be passed via other parameters in the URL.

Local Application Authentication

Applications may also want to call the API without an associated GCManage account. GrandCare will provide each application an "application key" that allows for a simple way to fetch the required passcodes. To do this, call the API via "localhost" using the following URL:

http://[como-URL]/api/system.php?op=getpasscodes&appkey=[gc-provided-app-key]

This will return the required passcodes for making authenticated calls to the API. See the section on the System API Subsystem for more information about the getpasscodes API call.

Results From GCAPI

The response from GCAPI will either be encoded in JSON or XML, depending on the requested encoding. By default the response will be encoded in XML.

XML Results

By default, GCAPI responds to commands by returning an XML document. Here is the most basic success result:

<gcapi>
   <result>SUCCESS</result>
</gcapi>

The root XML element for all GCAPI results is gcapi. The other always present element is result, which contains either SUCCESS or FAILURE, depending on whether the call succeeded or not. A failure response also contains the fail-message element, which gives the reasons for the failure. For example:

<gcapi>
   <result>FAILURE</result>
   <fail-message>Invalid credentials for API call</fail-message>
</gcapi>

This result would occur if invalid credentials were supplied during the GCAPI call.

JSON Results

GCAPI can also respond by returning a JSON object. Here is the most basic success result:

{
   "gcapi": {
       "result": "SUCCESS"
   }
}

A failure encoded in JSON looks like:

{
   "gcapi": {
       "result": "FAILURE",
       "fail-message": "Invalid credentials for API call"
   }
}

API Subsystems

History API

The History subsystem allows you to fetch ADL and wellness data from a system. Most of the operations take the same parameters and return different data.

See documentation for details or click an specific History operation below

Blood Pressure

Fetches blood pressure sensor history from the system

Weight Scale

Fetches scale history from the system

Temperature Sensor

Fetches temperature sensor history from the system

Bed Sensor

Fetches bed sensor history from the system

Oximeter

Fetches oximeter history from the system

Motion

Fetches motion sensor history from the system

Glucometer

Fetches glucometer history from the system

Door Sensor

Fetches door sensor history from the system

Caller ID

Fetches caller ID history from the system

Assign API

The Assign subsystem allows you to assign and delete wellness readings from a system.

See documentation for details or click an specific Assign operation below

Assign Reading

Assigns a wellness reading to a resident

Delete Reading

Marks a wellness reading as deleted

Caregiver API

The Caregiver subsystem allows you to create, read, update, and delete caregivers from a system.

See documentation for details or click an specific Caregiver operation below

Create

Create a caregiver

Read

Reads a single caregiver or all caregivers

Update

Updates an existing caregiver

Delete

Deletes an existing caregiver

Medication API

The Medication subsystem allows you to manage medication and schedules from a system.

See documentation for details or click an specific Medication operation below

Create Prescription

Create a prescription

Read Prescription

Reads a single prescription or all prescriptions

Update

Updates an existing prescription

Delete

Deletes an existing prescription

Store Picture

Stores a picture for a prescription

Create Prescription Schedule

Create a prescription schedule

Read Prescription Schedule

Reads a single prescription schedule or all prescription schedules

Update Prescription Schedule

Updates an existing prescription schedule

Delete Prescription Schedule

Deletes an existing prescription schedule

Set Compliance

Set compliance on an existing prescription schedule

Check Compliance

Check compliance on an existing prescription schedule

Backfill Compliance

Backfill compliance on an existing prescription schedule

Lookup Rx

Finds Rx via FDA NDC Directory

ActivityLog API

The Activity Log subsystem allows you to view a log of touchscreen events

Read

Read entries out of the log

Add

Add entries to the log

TODO

  • assign api
  • caregiver api
  • carenote api
  • configure api
  • device api
  • history api
  • log api
  • media api
  • medication api
  • message api
  • pin api
  • resident api
  • rule api
  • system api
  • activitylog api
  • notification api
  • calendar api
  • letters api

Other Resources