fhir search for client developers by mirjam baltus

25
© 2014 HL7 ® International. Licensed under Creative Commons. HL7 & Health Level Seven are registered trademarks of Health Level Seven International. Reg. U.S. TM Office. FHIR Search for client developers Mirjam Baltus FHIR Developer Days November 24, 2014

Upload: fhir-developer-days-2014

Post on 12-Jul-2015

247 views

Category:

Healthcare


2 download

TRANSCRIPT

Page 1: FHIR Search for client developers by Mirjam Baltus

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

FHIR Searchfor client developers

Mirjam Baltus

FHIR Developer Days

November 24, 2014

Page 2: FHIR Search for client developers by Mirjam Baltus

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

Who am I?

Name: Mirjam Baltus-Bakker

Company: Furore, Amsterdam

Background:

ICT trainer

Furore FHIR team

Contact:

[email protected]

2

Page 3: FHIR Search for client developers by Mirjam Baltus

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

Searching FHIR

Understanding search

Basic search

Search parameters

Parameter types

More complex searches

Search using the API

Page 4: FHIR Search for client developers by Mirjam Baltus

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

Basic search

Syntax

GET [base-url]/[resourcetype](?parameters)

Getting all patients

GET http://acme.org/fhir/Patient

Always returns a paged feed

Use _count for number of results per page

4

Page 5: FHIR Search for client developers by Mirjam Baltus

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

Basic search

Special case of the “real” search operation:

http://acme.org/fhir/Patient?_id=23

http://acme.org/fhir/Patient/23

http://acme.org/fhir/Patient?name=eve

OperationOutcome resource

5

Page 6: FHIR Search for client developers by Mirjam Baltus

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

Searching FHIR

Understanding search

Basic search

Search parameters

Parameter types

More complex searches

Search using the API

Page 7: FHIR Search for client developers by Mirjam Baltus

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

Search (patient)

Each resource has a set of “standard” search parameters,

so not every element can be searched!:

Our last search

used this one

7

Page 8: FHIR Search for client developers by Mirjam Baltus

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

Conformance

8

Page 9: FHIR Search for client developers by Mirjam Baltus

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

Searching FHIR

Understanding search

Basic search

Search parameters

Parameter types

More complex searches

Search using the API

Page 10: FHIR Search for client developers by Mirjam Baltus

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

Search (patient)

Each search parameter has a ‘type’

Parameter

Type

10

Page 11: FHIR Search for client developers by Mirjam Baltus

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

Parameter types

11

number: =, =<, =<=, =>, =>=

Significant digits matter

date: =, =<, =<=, =>, =>=

Matches calculated using interval operations

Precision turns all dates into intervals

string: =

“contains” search, ignoring case, accents

Can use :exact to be case and accent-sensitive

Search for [param]=2013-01-14 returns

resources where [param] is between

2013-01-14T00:00 and 2013-01-14T23:59

Search for [param]=>2013-01-14T10:00

includes resources where [param] has

a value of 2013-01-14

http://acme.org/fhir/Patient?name:exact=Eve

Page 12: FHIR Search for client developers by Mirjam Baltus

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

Parameter types (cont’d)

12

token: =

[code] matches codes/identifier values

independent of system

[system]|[code/value] matches a specified code or

identifier within the specified system

|[code/value] matches the specified code or

identifier in instances where no system is declared

:text performs a string search on

CodeableConcept.text, Coding.display and

Identifier.label

http://acme.org/fhir/Patient?gender=M

http://acme.org/fhir/Patient?

gender=v3/AdministrativeGender|M

Page 13: FHIR Search for client developers by Mirjam Baltus

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

Parameter types (cont’d)

13

quantity: =, =<, =>, =<=, =>=

[comparator][number]|[system]|[code]

Follows rules for number + token together for

value + units of quantity

reference: =

Either the local or absolute id

:type filters resource type

http://acme.org/fhir/Observation?

value=5.4|http://unitsofmeasure.org|mg

http://acme.org/fhir/DiagnosticReport?

subject=Patient/23

Page 14: FHIR Search for client developers by Mirjam Baltus

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

Ok I get it…or not?

http://acme.org/fhir/Patient/ 406 hits

http://acme.org/fhir/Patient?gender=M 234 hits

http://acme.org/fhir/Patient?gender=F 167 hits

Total: 234 + 167 = 401

http://acme.org/fhir/Patient/ 406 hits

http://acme.org/fhir/Patient?gender=M 234 hits

http://acme.org/fhir/Patient?gender=F 167 hits

http://acme.org/fhir/Patient?gender:missing=true 5 hits

Total: 234 + 167 + 5 = 406

14

Page 15: FHIR Search for client developers by Mirjam Baltus

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

Searching FHIR

Understanding search

Basic search

Search parameters

Parameter types

More complex searches

Search using the API

Page 16: FHIR Search for client developers by Mirjam Baltus

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

Combining parameters

Specifying multiple parameters finds

resources matching all params “AND”

Parameters may list multiple values “OR”

Try:

http://acme.org/fhir/Patient?

birthdate=1972-11-30&language=nl,fr

16

Page 17: FHIR Search for client developers by Mirjam Baltus

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

Chained searches

Patient has a search for “name”.

Observation has a search for “subject” (the

id of the Patient, Group or Device)

How do I find Observations for a patient,

searching using his name?

17

Page 18: FHIR Search for client developers by Mirjam Baltus

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

2 queries in 1

You (as a client) don’t need to do separate

operations, just one:

http://acme.org/fhir/Observation?

But note: this still only works on the predefined

search parameters. You cannot just use any

property of the resource.

18

subject:Patient.name=jimsubject.name=jim

Page 19: FHIR Search for client developers by Mirjam Baltus

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

More optimalizations

Say we do:http://acme.org/fhir/DiagnosticReport?

date=2013-03-11

We get back: a Bundle with 0..* “DiagnosticReports”

Now, usually, wouldn’t we want the Patient

information too? => Need to do “N” queries

for the DiagnosticReport’s “subject”

Quicker: _include=DiagnosticReport.subject

Returns both DiagnosticReports + Patients19

Page 20: FHIR Search for client developers by Mirjam Baltus

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

Summary

Some resources can be “big”

e.g. Patient with pictures & lots of contacts

10MB JSON result set is bad when you’re an

Android app presenting a list of 100 patients for a

clinician to scroll through

Solution: _summary=true strips a

resource’s elements down to those most

likely to be useful in a “list” view.

22

Page 21: FHIR Search for client developers by Mirjam Baltus

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

Sorting

Use _sort:asc or _sort:desc to control sort

E.g. Observation?_sort:asc=name&_sort:desc

=date

Sorts observations of the same type together,

newest first

23

Page 22: FHIR Search for client developers by Mirjam Baltus

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

Searching FHIR

Understanding search

Basic search

Search parameters

Parameter types

More complex searches

Search using the API

Page 23: FHIR Search for client developers by Mirjam Baltus

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

Search using the API

Demo in .Net

Page 24: FHIR Search for client developers by Mirjam Baltus

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

Final words

FHIR has a lot of query capability

However . . .

Almost all of it is optional

So how do you design a client when you have no

clue what the server will support?

The more generic you want your client to be, the less

you should rely on sophisticated server capabilities

Always check the response to see what parameters

were actually used26

Page 25: FHIR Search for client developers by Mirjam Baltus

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

Questions?

http://hl7.org/fhir [email protected]

27