Application Programming Interface (API)
Covered by this topic
Introduction
With Enterprise Health , you can augment the system and layer in configuration to support almost any workflow or process–migrate meaningful data from legacy applications; interface intelligently with HR systems, email applications, labs, and medical devices; experience no concerns about sharing data across the solution, and no barriers aggregating data from multiple sources.
This document provides an overview of the framework that drives these accomplishments.
Explore the Enterprise Health API, below.
Though any coding language may be used, the following example is written in python:
https://github.com/mieweb/wcexport/blob/master/wcjson.py
Interactive, dynamic documentation of the Enterprise Health API can be found inside the product. Navigate to the API tab of the Control Panel for full visibility of the various objects and their APIs.
Session Establishment
Command-line
curl WEBCHARTURL?login_user=USERNAME&login_passwd=PASSWORD
Python example
out = urllib2.urlopen(URL, urllib.urlencode({
'login_user': USERNAME,
'login_passwd': PASSWORD
}))
COOKIE = out.headers.get('Set-Cookie').split('=')[1].split(';')[0]
**_
Enterprise Health _** API 2015 Edition
Overall, this document is intended to comply with the established criteria laid out for 2015 Edition ONC Certification–Patient Selection 170.315(g)(7), Data Category Request 170.315(g)(8), and All Data Request 170.315(g)(9). The following table provides access to the ONC specifications regarding these standards and requirements:
§ 170.315(g)(7) | Application Access – Patient Selection | (g)(7) Guide | Test Procedure (PDF - 172 KB) |
§ 170.315(g)(8) | Application Access – Data Category Request | (g)(8) Guide CCDS Guide | Test Procedure (PDF - 181 KB) CCDS Reference (PDF - 360 KB) |
§ 170.315(g)(9) | Application Access – All Data Request | (g)(9) Guide CCDS Guide | Test Procedure (PDF - 236 KB) |
§ 170.315(g)(7) Application access – Patient Selection
http://system/?f=layout&module=JS&name=API_DOC&tabmodule=admin&tabselect=API
requests = {
'Last Name LIKE "Hart"': 'GET/db/patients/LIKE_last_name=Hart',
'Last Name LIKE "Pregnant"': 'GET/db/patients/LIKE_last_name=Pregnan',
}
for title, url in requests.iteritems():
print('\\nQuerying for patients: {0}'.format(title))
js = json.load(
urllib2.urlopen(URL, urllib.urlencode({
'f': 'json',
'session_id': COOKIE,
'apistring': base64.b64encode(url)
})))
print(json.dumps(js))
Requests are URLs. urllib2.urlopen does the work of calling each request and outputting the response on the screen.
§ 170.315(g)(8) Application access – Data Category Request
URL-specific sections are returned in XML CCDA format.
Patient Name | ?f=layout&module=StructDocAPI&name=Patient%20Name&XML&pat_id=XX |
Sex | ?f=layout&module=StructDocAPI&name=Gender%20Code&XML&pat_id=XX |
Date of Birth | ?f=layout&module=StructDocAPI&name=Birth%20Date&XML&pat_id=XX |
Race | ?f=layout&module=StructDocAPI&name=Patient%20Race&XML&pat_id=XX |
Ethnicity | ?f=layout&module=StructDocAPI&name=Patient%20Ethnicity&XML&pat_id=XX |
Preferred Language | ?f=layout&module=StructDocAPI&name=Patient%20Language&XML&pat_id=XX |
Smoking Status | ?f=layout&module=StructDocAPI&name=Smoking%20Status&XML&pat_id=XX |
Problems | ?f=layout&module=StructDocAPI&name=Problems&XML&pat_id=XX |
Medications | ?f=layout&module=StructDocAPI&name=Medications&XML&pat_id=XX |
Medication Allergies | ?f=layout&module=StructDocAPI&name=Allergies&XML&pat_id=XX |
Laboratory Tests (Orders?) | |
Laboratory Values(s)/Result(s) | ?f=layout&module=StructDocAPI&name=Results&XML&pat_id=XX |
Vital Signs | ?f=layout&module=StructDocAPI&name=Vital Signs&XML&pat_id=XX |
Procedures | ?f=layout&module=StructDocAPI&name=Procedures&XML&pat_id=XX |
Care Team Member(s) | ?f=layout&module=StructDocAPI&name=Care Team Members&XML&encounter_id=XX |
Immunizations | ?f=layout&module=StructDocAPI&name=Immunizations&XML&pat_id=XX |
Unique Device Identifier(s) for a Patient's Implantable Device(s) | ?f=layout&module=StructDocAPI&name=Medical_Equipment&XML&pat_id=XX |
Assessment and Plan of Treatment | ?f=layout&module=StructDocAPI&name=Assessments&XML&encounter_id=XX |
Goals | ?f=layout&module=StructDocAPI&name=Goals&XML&encounter_id=XX |
Health Concerns | ?f=layout&module=StructDocAPI&name=Health Concerns&XML&encounter_id=XX |
&sdate=YYYY-MM-DD | |
&edate=YYYY-MM-DD |
#!/usr/bin/env python
import sys
import os
import urllib2
import urllib
import base64
import json
import re
USERNAME = 'dave'
PASSWORD = 'dave'
COOKIE = None
DTREG = '\\d{4}-\\d{2}-\\d{2}'
OUTPUT = 'output'
APIS = {
'Patient Name': 'Patient Name',
'Sex': 'Gender Code',
'Date of Birth': 'Birth Date',
'Race': 'Patient Race',
'Ethnicity': 'Patient Ethnicity',
'Preferred Language': 'Patient Language',
'Smoking Status': 'Smoking Status',
'Problems': 'Problems',
'Medications': 'Medications',
'Medication Allergies': 'Allergies',
'Lab Values_Result': 'Results',
'Vital Signs': 'Vital Signs',
'Procedures': 'Procedures',
'Immunizations': 'Immunizations',
}
def usage():
print('Usage: {0} URL [startDate [endDate]] PatientLastName1 PatientLastName2 ...'.format(__file__))
exit()
if __name__ == '__main__':
if len(sys.argv) < 3:
usage()
URL = sys.argv[1]
sdate = ''
edate = ''
names = sys.argv[2:]
dtmatches = [x for x in names if re.match(DTREG, x)]
if dtmatches:
if len(dtmatches) == 1:
sdate = dtmatches[0]
else:
sdate = dtmatches[0]
edate = dtmatches[1]
charts = {}
print('Initializing session at {0}'.format(URL))
try:
out = urllib2.urlopen(URL, urllib.urlencode({
'login_user': USERNAME,
'login_passwd': PASSWORD
}))
COOKIE = out.headers.get('Set-Cookie').split('=')[1].split(';')[0]
except Exception as e:
print('Session failed to initialize {0}'.format(e))
if COOKIE:
for name in names:
js = json.load(urllib2.urlopen(URL, urllib.urlencode({
'f': 'json',
'session_id': COOKIE,
'apistring': base64.b64encode('GET/db/patients/LIKE_last_name={0}'.format(name))
})))
if js and js['db']:
for rec in js['db']:
charts[rec['pat_id']] = rec
for cid, chart in charts.iteritems():
patname = '{0},{1},{2}_{3}'.format(chart['last_name'], chart['first_name'],
chart['middle_name'], cid)
if not os.path.exists(os.path.join(OUTPUT, patname)):
os.makedirs(os.path.join(OUTPUT, patname))
print('Retrieving data for {0} {1} {2}'.format(patname,
'after' if not edate and sdate else 'between' if edate and sdate else '',
sdate if not edate else '{0} and {1}'.format(sdate, edate)))
for k, v in APIS.iteritems():
res = urllib2.urlopen(URL, urllib.urlencode({
'session_id': COOKIE,
'f': 'layout',
'module': 'StructDocAPI',
'XML': '1',
'name': v,
'pat_id': cid,
'sdate': sdate,
'edate': edate,
}))
with open (os.path.join(OUTPUT, patname, '{0}.xml'.format(k)), 'w') as fp:
fp.write(res.read())
§ 170.315(g)(9) Application access – All Data Request
Receive documents stored in charts:
#!/usr/bin/env python
import urllib2
import urllib
import base64
import json
import os
URL = 'https://server/webchart.cgi'
USERNAME = 'dave'
PASSWORD = 'dave'
COOKIE = None
# Download a document
def downloadDocument(doc_id, filename):
if not os.path.exists(filename):
out = urllib2.urlopen(URL, urllib.urlencode({
'f': 'stream',
'doc_id': doc_id,
'session_id': COOKIE,
'rawdata': '1'
}))
with open(filename, 'wb') as fp:
fp.write(out.read())
def downloadDocumentMeta(pat_id):
try:
api = "GET/db/documents/storage_type=19&LIKE_service_date=2017-05-02%25&pat_id=" + pat_id
print('\\nQuerying for patients: {0}'.format(pat_id))
docs = json.load(
urllib2.urlopen(URL, urllib.urlencode({
'f': 'json',
'session_id': COOKIE,
'apistring': base64.b64encode(api)
})))
return docs["db"][0]["doc_id"];
except:
return ""
if __name__ == '__main__':
print('Initializing session')
try:
out = urllib2.urlopen(URL, urllib.urlencode({
'login_user': USERNAME,
'login_passwd': PASSWORD
}))
COOKIE = out.headers.get('Set-Cookie').split('=')[1].split(';')[0]
except Exception as e:
print('Session failed to initialize {0}'.format(e))
print('Getting Patients')
if COOKIE:
requests = {
'Last Name LIKE "Newman"': 'GET/db/patients/LIKE_last_name=Newman',
'Last Name LIKE "Larson"': 'GET/db/patients/LIKE_last_name=Larson',
'Last Name LIKE "Bates"': 'GET/db/patients/LIKE_last_name=Bates',
'Last Name LIKE "Wright"': 'GET/db/patients/LIKE_last_name=Wright',
}
for title, url in requests.iteritems():
print('\\nQuerying for patients: {0}'.format(title))
js = json.load(
urllib2.urlopen(URL, urllib.urlencode({
'f': 'json',
'session_id': COOKIE,
'apistring': base64.b64encode(url)
})))
pat_id = js["db"][0]["pat_id"]
name = js["db"][0]["last_name"]
print("Getting Documents for Patient:" + pat_id)
doc_id = downloadDocumentMeta(pat_id);
if doc_id != "":
print("Downloading Document:" + doc_id)
downloadDocument(doc_id, name + "_" + doc_id + ".xml")
else:
print("No documents exist for that patient that meet the criteria.")
# print(json.dumps(js))
Document Export Tool
Enterprise Health has functional tools for importing and exporting documents to the system. The Export Tool is written in Python and can be run on Windows, Mac, or Linux. Conversely, importing documents is done with the MIE File Import utility.
Requirements
- Windows: compiled exe are provided so Windows 7+ is sufficient.
- Mac 10.8+: Python 2.7 is shipped with Mountain Lion and greater.
- Linux: Python 2.7 or Python 3.1 is required and python-tk. The user interface requires a GUI / window manager.
Installing
- Download the project from GitHub at https://github.com/mieweb/wcexport
- Windows-compiled EXE files are provided so python does not have to be installed.
- Instructions for use are in the README.md file within the git project.
Enterprise Health Documentation
Page Created:
Last Updated:
Last Build:
Sat, 21 Jan 2023 16:08:43 UTC
WikiGDrive Version: 75ce6caac9758dd5c192aa0655418de357318c8a