This document provides an overview of using Azure DocumentDB as a HL7 document repository for healthcare integration. It discusses DocumentDB features like JSON documents, indexing, CRUD operations, and querying. Example use cases for a HL7 document repository using DocumentDB are presented, including personal health records, document sharing, decision support, and patient demographics. The document concludes by previewing the design of an Azure API connector app for DocumentDB and a Logic App for HL7 FHIR.
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Azure DocumentDB for Healthcare Integration Overview
1. Sponsored & Brought to you by
Azure DocumentDB for
Healthcare Integration
Howard Edidin
https://twitter.com/hsedidin
http://www.linkedin.com/in/hedidin
2. Azure DocumentDB for Healthcare Integration
Howard S. Edidin
Microsoft Partner Technical Specialist (BizTalk, Azure) for Healthcare
Gold Member
3. About the series
• Currently there is no direct support for HL7 in Azure
• Using DocumentDB as the foundation, we will overcome this issue
3
7. DocumentDB
• DocumentDB is unique among NoSQL stores
– It was developed and delivered as a service
– It’s truly schema-free, queryable and JSON aware
– Offers transactional processing through language integrated JavaScript
– Predictable performance and tunable consistency
7
9. Access Model
• RESTful interaction over HTTP
• Standard HTTP verbs & semantics
• Can utilize BizTalk as a client
• Built-in support for TCP for smart clients
• Designed for Gateway as well as Direct Connectivity options
POST
Item
resource TenantFeed
URI
PUT
Item
resource
Item
URI
DELETE
Item
URI
GET
PATCH
TenantFeed Or Item
URI
Item URI
Create a new resource
/Execute a sprocs/trigger/query
Replace an existing resource
Delete an existing resource
Read/Query an existing
resource
*Selectively Edit an existing resource
Item
resource
POST http://myaccount.documents.azure.net/dbs
{ "name":"My Company Db"}
...
[201 Created]
{
"name": "My Company Db",
"id": "UoEi5w==",
"self": "dbs/UoEi5w==/",
"colls": "colls/",
"users": "users/"
}
9
10. JSON Documents
JavaScript Object Literals
JSON serializable
values (aka JSON
Infoset)
Why JSON?
Ubiquitous
Schema-free and yet queryable
Minimal impedance mismatch
Committed to JSON & JavaScript
Automatic indexing of documents without requiring schema or secondary indices
SQL query dialect rooted in JSON; extensible via JavaScript
Efficient execution of application logic with (JavaScript) language integrated database transactions
Minimal impedance mismatch between the programming languages and the database type systems
10
11. Data partitioned into collections
10GB
zz
RU/s
$z per
hour
10GB
yy
RU/s
$y per
hour
10GB
xx
RU/s
$x per hour
• Collections can be added and removed from
databases
• Each collection has reserved storage (10 GB)
and throughput
• Scale horizontally across multiple collections
• Collections can be configured with different
throughput levels
POST
Item
resource TenantFeed
URI
Create a new resource
/Execute a sprocs/trigger/query
11
12. Indexing
How it works
• Automatic indexing of documents
• JSON documents are represented as
trees
• Structural information and instance
values are normalized into a JSON-
Path
• Fixed upper bound on index size
(typically 5-10% in real production
data)
Example
{"headquarters": "Belgium"} /"headquarters"/"Belgium"
{"exports": [{"city": “Moscow"}, {"city": Athens"}]} /"exports"/0/"city"/"Moscow"
and /"exports"/1/"city"/"Athens".
12
13. CREATING A DOCUMENTDB DATABASE
Azure DocumentDB for Healthcare Integration – Part 1
13
14. DocumentDB app
• We are NOT designing a DocumentDB application
– We won’t need to Model data as JSON
– List common access patterns – top 5-10 queries, sprocs, and CRUD
– Review indexing policy and query
– Decide partitioning scheme
14
15. DEMO - CREATING A DOCUMENTDB DATABASE
Azure DocumentDB for Healthcare Integration – Part 1
15
16. DocumentDB Database
A DocumentDB database is a logical container of one or more
collections and users, as shown in the following diagram. You can
create any number of databases under a DocumentDB database
account subject to offer limits.
16
17. REST
• The DocumentDB REST API supports the following:
– Access control to resources.
– Query functionality for resources.
– Basic CRUD operations for resources.
17
18. Access control on resources
• Access to DocumentDB resources is governed by a master key token
or a resource token. To access a resource, the selected token is
included in the REST authorization header, as part of the
authorization string.
18
19. Query functionality for resources
• All DocumentDB resources except account resources, can be queried
using DocumentDB SQL language.
• To perform a SQL query on a resource, do the following:
– Execute a POST method against a resource path using JSON with the "query"
property set to the SQL query string, and the "parameters" property set to the
array of optional parameter values.
– Set the x-ms-documentdb-isquery header to true.
– Set the Content-Type header to application/query+json.
POST https://contosomarketing.documents.azure.com/dbs/XP0mAA==/colls/XP0mAJ3H-AA=/docs HTTP/1.1
x-ms-documentdb-isquery: True
x-ms-date: Mon, 18 Apr 2015 13:05:49 GMT
authorization:
type%3dmaster%26ver%3d1.0%26sig%3dkOU%2bBn2vkvIlHypfE8AA5fulpn8zKjLwdrxBqyg0YGQ%3d
x-ms-version: 2015-04-08
Accept: application/json
Content-Type: application/query+json
Host: contosomarketing.documents.azure.com
Content-Length: 50
{
query: "SELECT * FROM root WHERE (root.Author.id = 'Don')",
parameters: []
}
19
21. CRUD Operations
• The DocumentDB API supports basic CRUD operations on the
resources under a database account
– The document resource is represented by docs in the DocumentDB resource
model
• A document consists of user-defined content in JSON format
• Aside from the required id property, users can define any arbitrary elements, structures,
and hierarchies for the content. The id element is a unique string that is user-settable and
must not exceed 255 characters
• By default, documents are automatically indexed, thus making a document queryable as
soon as it is created
• Attachments can also be linked to a document
21
22. Create a document
• A new document can be created by executing an HTTPS POST
request against the docs URI resource path.
Request Syntax:
Method Request URI HTTP Version
POST https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-col}/docs HTTP/1.1
Note that the {databaseaccount} is the name of the DocumentDB account created under your
subscription. The {_rid-db} value is the resource ID of the database. The {_rid-col} value is the resource
ID of the collection that contains the document.
22
23. Get a document
• Performing a GET operation on a specific document resource
retrieves the user defined JSON elements and system properties of
the document.
Request Syntax:
Method Request URI HTTP
Version
GET https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-col}/docs/{_rid-doc} HTTP/1.1
Note that the {databaseaccount} is the name of the DocumentDB account created under your
subscription. The {_rid-db} value is the resource ID of the database. The {_rid-col} value is the resource
ID of the collection that contains the document.
23
24. Replace a document
• Performing a PUT operation on a specific document resource replaces the entire
document resource. All user settable properties, including the id, and the user
defined JSON elements must be submitted in the body to perform the
replacement. Any element omissions result in unintended data loss as this
operation is a full replace operation. The x-ms-indexing-directive header can be
set and submitted for the operation to include or exclude the document from being
indexed.
Request Syntax:
Method Request URI HTTP
Version
PUT https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-col}/docs/{_rid-doc} HTTP/1.1
24
25. Delete a document
• Performing a DELETE operation on a specific document resource deletes the
document resource from the collection.
Method Request URI HTTP
Version
DELETE https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-col}/docs/{_rid-doc} HTTP/1.1
Request Syntax:
25
27. Other operations
• Operations on DocumentDB Document Collections
– Create a collection
– List collections
– Get a collection
– Delete a collection
• Operations on DocumentDB Attachments
– Create an Attachment
– Replace an attachment
– List attachments
– Delete attachments
27
28. Other operations
• Operations on Stored Procedures
– Create a stored procedure
– Replace a stored procedure
– List stored procedures
– Delete a stored procedure
– Query stored procedures
– Execute a stored procedure
28
29. Other operations
• Operations on User Defined Functions
– Create a UDF
– Replace a UDF
– List UDFs
– Delete a UDF
– Query UDFs
• Operations on Triggers
– Create a trigger
– Replace a trigger
– List triggers
– Delete a trigger
– Query triggers
29
30. Other operations
• Operations on DocumentDB Databases
– Create a Database
– List Databases
– Get a Database
– Delete a Database
• Querying DocumentDB Resources
– All DocumentDB resources except account resources can be queried using
DocumentDB SQL language.
30
31. DocumentDB Resource URI Syntax
for REST
Resources Base URI
Database https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}
User https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/users/{_rid-user}
Permission https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/users/{_rid-user}/permissions/{_rid-perm}
Collection https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}
Stored Procedure https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}/sprocs/{_rid-sproc}
Trigger https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}/triggers/{_rid-trigger}
UDF https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}/udfs/{_rid-udf}
Document https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}/docs/{_rid-doc}
Attachment https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-coll}/docs/{_rid-
doc/attachments/{_rid-attch}
31
32. DOCUMENTDB SQL QUERY LANGUAGE
Azure DocumentDB for Healthcare Integration – Part 1
32
33. SQL Query
• Azure DocumentDB supports querying of documents using a familiar
SQL (Structured Query Language) like grammar over hierarchical
JSON documents without requiring explicit schema or creation of
secondary indexes
33
38. HL7 Document Repository
– Decision Support
• One common use of healthcare information systems is to integrate some
form of decision support software into clinical systems.
– Common uses of clinical decision support are:
» Drug-drug interaction checking, and more generally, prescription safety checks
» Suggesting commonly missed diagnostic data interpretations (including delta
checking)
» Patient surveillance for early warning of deteriorating patient health (both acute and
ambulatory care)
» Identifying candidates for alternative treatment plans for improved efficacy
38
39. HL7 Document Repository
– Patient Demographics Query for Mobile (PDQm)
• The Patient Demographics Query for Mobile (PDQm) Profile defines a lightweight RESTful
interface to a patient demographics supplier leveraging technologies readily available to
mobile applications and lightweight browser based applications.
• The functionality is identical to the PDQ Profile
• The differences are transport and messaging format of messages and queries. The profile
leverages HTTP transport, and the JavaScript Object Notation (JSON), Simple-XML, and
Representational State Transfer (REST). The payload format is defined by the HL7 Fast
Health Interoperable Resources (FHIR) draft standard.
– Web based EHR/EMR applications which wish to provide dynamic updates of patient
demographic information such as a non-postback search, additional demographic detail, etc.
– A health portal securely exposing demographics data to browser based plugins
39
40. PREVIEWING API AND LOGIC APPS
Azure DocumentDB for Healthcare Integration – Part 1
40
42. Azure DocumentDB for Healthcare Integration
42
Howard S. Edidin MCTS, MCP, Author, Trainer, TechNet Wiki Ninja
Microsoft Partner Application Integration
|HL7|HIPAA
Microsoft Virtual Technical Specialist (BizTalk, Azure) for Healthcare
hedidin@edidingroup.net
Editor's Notes
Database account: A database account is associated with a set of databases and a fixed amount of blob storage for attachments (preview feature). You can create one or more database accounts using your Azure subscription. Every Standard database account is allocated a minimum capacity of one S1 collection.
Database: A database is a logical container of document storage partitioned across collections. It is also a users container.
User: The logical namespace for scoping/partitioning permissions.
Permission: An authorization token associated with a user for authorized access to a specific resource.
Collection: A collection is a container of JSON documents and the associated JavaScript application logic. A collection is a billable entity, where the cost is determined by the performance level associated with the collection. The performance levels (S1, S2 and S3) provide 10GB of storage and a fixed amount of throughput.
Stored Procedure: Application logic written in JavaScript which is registered with a collection and transactionally executed within the database engine.
Trigger; Application logic written in JavaScript modeling side effects associated with insert, replace or delete operations.
UDFA: side effect free, application logic written in JavaScript. UDFs enable you to model a custom query operator and thereby extend the core DocumentDB query language.
Document: User defined (arbitrary) JSON content. By default, no schema needs to be defined nor do secondary indices need to be provided for all the documents added to a collection.(Preview)
Attachment: An attachment is a special document containing references and associated metadata for external blob/media. You can choose to have the blob managed by DocumentDB or store it with an external blob service provider such as OneDrive, Dropbox, etc.
https://portal.azure.com
Support for parameterized SQL request with a string parameter
A collection is a container of JSON documents and associated JavaScript application logic, i.e. stored procedures, triggers and user-defined functions.
A stored procedure is a piece of application logic written in JavaScript that is registered and executed against a collection as a single transaction.
In DocumentDB, JavaScript is hosted in the same memory space as the database. Hence, requests made within stored procedures execute in the same scope of a database session. This enables DocumentDB to guarantee ACID for all operations that are part of a single stored procedure.
The stored procedure resource has a fixed schema. The body property contains the application logic.
---------------------------------------
A user defined function (UFD) is a side effect free piece of application logic written in JavaScript. It allows developers to construct a query operator, thus extending the core of the DocumentDB query language. Like stored procedures, UDFs live in the confines of a collection, thus confining the application logic to the collection.
Similar to stored procedures, the UDFs resource has a fixed schema. The body property contains the application logic.
-------------
Triggers are pieces of application logic that can executed before (pre-triggers) and after (post-triggers) creation, deletion, and replacement of a document. Triggers are written in JavaScript. Both pre and post triggers do no take parameters. Like stored procedures, triggers live within the confines of a collection, thus confining the application logic to the collection.
A collection is a container of JSON documents and associated JavaScript application logic, i.e. stored procedures, triggers and user-defined functions.
A stored procedure is a piece of application logic written in JavaScript that is registered and executed against a collection as a single transaction.
In DocumentDB, JavaScript is hosted in the same memory space as the database. Hence, requests made within stored procedures execute in the same scope of a database session. This enables DocumentDB to guarantee ACID for all operations that are part of a single stored procedure.
The stored procedure resource has a fixed schema. The body property contains the application logic.
---------------------------------------
A user defined function (UFD) is a side effect free piece of application logic written in JavaScript. It allows developers to construct a query operator, thus extending the core of the DocumentDB query language. Like stored procedures, UDFs live in the confines of a collection, thus confining the application logic to the collection.
Similar to stored procedures, the UDFs resource has a fixed schema. The body property contains the application logic.
-------------
Triggers are pieces of application logic that can executed before (pre-triggers) and after (post-triggers) creation, deletion, and replacement of a document. Triggers are written in JavaScript. Both pre and post triggers do no take parameters. Like stored procedures, triggers live within the confines of a collection, thus confining the application logic to the collection.
A stored procedure is a piece of application logic written in JavaScript that is registered and executed against a collection as a single transaction.
In DocumentDB, JavaScript is hosted in the same memory space as the database. Hence, requests made within stored procedures execute in the same scope of a database session. This enables DocumentDB to guarantee ACID for all operations that are part of a single stored procedure.
The stored procedure resource has a fixed schema. The body property contains the application logic.
---------------------------------------
A user defined function (UFD) is a side effect free piece of application logic written in JavaScript. It allows developers to construct a query operator, thus extending the core of the DocumentDB query language. Like stored procedures, UDFs live in the confines of a collection, thus confining the application logic to the collection.
Similar to stored procedures, the UDFs resource has a fixed schema. The body property contains the application logic.
-------------
Triggers are pieces of application logic that can executed before (pre-triggers) and after (post-triggers) creation, deletion, and replacement of a document. Triggers are written in JavaScript. Both pre and post triggers do no take parameters. Like stored procedures, triggers live within the confines of a collection, thus confining the application logic to the collection.
A stored procedure is a piece of application logic written in JavaScript that is registered and executed against a collection as a single transaction.
In DocumentDB, JavaScript is hosted in the same memory space as the database. Hence, requests made within stored procedures execute in the same scope of a database session. This enables DocumentDB to guarantee ACID for all operations that are part of a single stored procedure.
The stored procedure resource has a fixed schema. The body property contains the application logic.
---------------------------------------
A user defined function (UFD) is a side effect free piece of application logic written in JavaScript. It allows developers to construct a query operator, thus extending the core of the DocumentDB query language. Like stored procedures, UDFs live in the confines of a collection, thus confining the application logic to the collection.
Similar to stored procedures, the UDFs resource has a fixed schema. The body property contains the application logic.
-------------
Triggers are pieces of application logic that can executed before (pre-triggers) and after (post-triggers) creation, deletion, and replacement of a document. Triggers are written in JavaScript. Both pre and post triggers do no take parameters. Like stored procedures, triggers live within the confines of a collection, thus confining the application logic to the collection.