Extending FHIR by Ewout Kramer

Post on 25-Jan-2017

699 views 0 download

Transcript of Extending FHIR by Ewout Kramer

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

EXTENDING FHIRINTERNATIONAL DEVDAYS 2015 – Advanced Track

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

FHIR extension points

Start with an empty Basic Resource Extend an existing resource or datatype

(StructureDefinition) Add additional operations or search

parameters (OperationDefinition, SearchParameter)

Publish your extensions Make your server indicate support using the

Conformance resource

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

3

Basic Resource

As close as you can get to a “new” resource Use Basic if you need a resource and it

clearly doesn't fit one of the ones currently defined, use Basic.

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

4

An example instance…

01. Referral Basic.xml

Note how the nested extensions are <extension> elements with “simple” urls

Yes, you could nest “real” extensions -> extensions on an extension

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

5

Let’s define a referral

This is a complex extension on Basic

Define a complex “referral” extension (that’s a StructureDefinition)

Define a “basic-referral” profile on Basic to constrain it to use the extension (and this extension only)

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

6

Schematic

Resource “Basic” (instance)

code: referralsubject: “Patient/f201”author: “Practitioner/example”

Extension “referral” (instance)

Requestor: “Practitioner/f101”Service:ConsultationTarget Date:April 1 - April 31Status: COMPLETED

StructureDefinition “basic-referral” (constraint)

“Must have code, subject, author”“Must have one extension “referral””

StructureDefinition “referral”(extension)

Requestor: ReferenceType: CodeableConceptTargetDate: PeriodStatus: Code

defines defines

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

7

A simple extension

Let’s first define a simple extension with a single value “Boolean”

Note how this is a StructureDefinition = a constraint on the Extension datatype!

Fix this URL to the extension’s url

Limit to just “Boolean” [1..1]

Don’t allow nested extensions

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

8

The simple extension

02. Referral Extension - step 1.xml

Note the contextType/context Means it can be used on Basic (no one says

it should -> we’ll handle this later) Note the root has cardinality 1..1 ->

extension cannot repeat in an instance

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

9

The complex extension

02. Referral Extension - step 2.xml

Since these are nested <extension> elements (see the instance)…. You need to “slice” the <extension> element of Extension

(read that again) And make sure value[x] does not appear

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

10

Schematic

Resource “Basic” (instance)

code: referralsubject: “Patient/f201”author: “Practitioner/example”

Extension “referral” (instance)

Requestor: “Practitioner/f101”Service:ConsultationTarget Date:April 1 - April 31Status: COMPLETED

StructureDefinition “basic-referral” (constraint)

“Must have code, subject, author”“Must have one extension “referral””

StructureDefinition “referral”(extension)

Requestor: ReferenceType: CodeableConceptTargetDate: PeriodStatus: Code

defines defines

√ √

TODO

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

11

Constrain Basic…

Must have one extension “referral”

Fix to “referral”

Constrain to 1 Patient

No “created”

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

12

Now mark the instance

http://hl7.org/fhir/StructureDefinition/basic-referral"

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

13

Now, tell the world

Register extension in http://simplifier.net

Update the conformance statement of your server FHIR “metadata” operation, remember? http://spark-dstu2.furore.com/fhir/metadata

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

14

ConformanceConformance.profile

A list of profiles that represent different use cases supported by the system.

For a server, "supported by the system" means the system hosts/produces a set of resources that are conformant to a particular profile, and allows clients that use its services to search using this profile and to find appropriate data.

GET [base]/Basic?_profile=http://hl7.org/fhir/StructureDefinition/basic-referral

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

15

Extensions: where?

Most resources derivce from DomainResource:

Notable exceptions: Bundle, Binary

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

16

modifierExtensions

There are some cases where the information provided in extensions modifies the meaning of the element that contains it.

If modifier extensions are present, an application cannot safely process the resource unless it knows what the extension means for its own use of the data.

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

17

Extensions: where?

All datatypes derive from Element:

There are no modifierExtensions allowed on the basic datatypes.

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

18

Defining search params

Now…how to search on “service” in our complex extension?

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

19

Predefined params

For Basic:

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

20

A “normal” param: code

05. Search Param Basic.xml

Name on the url: code (Basic?code=xxxx) Type of param: token (code is a coded type) <xpath value="f:Basic/f:code"/>

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

21

Now for our extension

Works on “Basic”, and let’s call it “service” It’s a coded type too But it works on an extension…

06. Search Param Service.xml

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

22

Let’s declare it in our conformance!

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

23

Add a new param

07. Conformance with Search Param Service.xml

Uri points to the definition But that’s 0..1, you can inline some of the

definitional parts (you don’t strictly need the SearchParam resource)

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

24

Operations…

FHIR offers the possibility to add operations on top of the standard CRUD REST interactions

Work on system/type/instance level, operations start with $<operationname>

http://fhir2.healthintersections.com.au/open/Patient/1/$everything

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

25

Our own definition

08. OperationDefinition for trigger.xml

No parameters (nice and simple) Not idempotent Not a named query

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

26

Let’s declare it in our conformance!

© 2012 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office.

27

Questions?