• Stars
    star
    159
  • Rank 234,531 (Top 5 %)
  • Language
    Swift
  • License
    Other
  • Created about 10 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

These are Swift classes for data models of FHIR elements and resources

FHIR Swift Classes

These are Swift classes representing data models of ๐Ÿ”ฅ FHIR elements and resources, compatible with iOS 11 and OS X 10.13 and later.

This work is Apache licensed. FHIRยฎ is the registered trademark of HL7 and is used with the permission of HL7.

Versioning

Due to the complications of combining two volatile technologies, here's an overview of which version numbers use which Swift and FHIR versions.

  • The master branch should always compile and is on (point releases of) these main versions.
  • The develop branch should be on versions corresponding to the latest freezes.
  • The feature/latest-ci branch is updated from time to time with the latest and greatest.

See tags/releases.

Version Swift FHIR ย 
4.2 5.0 Packages 4.0.0-a53ec6ee1b R4
4.1 5.0 4.0.0-a53ec6ee1b R4
4.0 4.2 4.0.0-a53ec6ee1b R4
3.1 3.2 3.0.0.11832 STU 3
3.0 3.0 3.0.0.11832 STU 3
2.10 3.0 1.8.0.10521 STU 3 Freeze, Jan 2017
2.9 3.0 1.6.0.9663 STU 3 Ballot, Sep 2016
2.8 3.0 1.0.2.7202 DSTU 2 (+ technical errata)
2.4 2.2 1.6.0.9663 STU 3 Ballot, Sept 2016
2.3 2.3 1.0.2.7202 DSTU 2 (+ technical errata)
2.2.3 2.2 1.0.2.7202 DSTU 2 (+ technical errata)
2.2 2.0-2.2 1.0.2.7202 DSTU 2 (+ technical errata)
2.1 2.0-2.2 1.0.1.7108 DSTU 2
2.0 2.0-2.2 0.5.0.5149 DSTU 2 Ballot, May 2015
1.0 1.2 0.5.0.5149 DSTU 2 Ballot, May 2015
0.2 1.1 0.5.0.5149 DSTU 2 Ballot, May 2015
0.1 1.0 0.0.81.2382 DSTU 1

SMART on FHIR

The Swift-SMART framework utilizes these classes.

Progress

Here's a rough list of what still needs to be done.

[ ] Remove _isSummaryResource workaround to STU-3's nMin/isSummary errors
[ ] More convenience methods to working with resources in code
[ ] Nice support for simple PATCH operations
[ ] Separate resource models from base models; needs untangling of
    _owningResource, _owningBundle (easy), _resolved etc.
[ ] Handle resource versions nicely
[ ] Create a default behavior when a modifierExtension is detected
[ ] Update/modernize FHIRSearch
[ ] Search: report search parameters that the server ignored

Working, at least to some extent:

  • Classes generated for FHIR's base resources
    • Use custom structs for primitive types
    • Use custom Date/Time/DateTime/Instant structs
    • Generate enums for many closed ValueSets
  • Create elements and resources programmatically
  • Use a FHIR server protocol for REST interactions with a server
  • Deserialize from JSON
    • Tells you which mandatory properties were missing,
    • which properties were not expected or
    • which were of a wrong type
  • Serialize to JSON
    • Refuses to serialize incomplete elements
  • Resolve contained/bundled/relative/absolute resource references
  • Contain resources
  • Create enums for code type properties
  • Construct searches with NoSQL-like statements (cf. fhir.js)
  • Perform operations
  • Use example resources for auto-created class unit tests
    • Tests deserialization from file
    • Tests serialization from deserialized instances

Naming Convention

Standard Swift naming conventions apply. Tabs are used for indentation and spaces for alignment โ€“ย the best of both worlds. Classes representing FHIR resources do not have a prefix. Custom classes and protocols start with FHIR to not make them clash with element or resource classes and make them easily distinguishable.

FHIR Data Models

Classes are generated from FHIR resource definitions with our Python FHIR parser.

Verbousness

Swift is statically typed and introspection is very limited at the time. Therefore the generator needs to be a bit more verbose and create class-level serializers/deserializers, rather than looking at class properties at runtime and figure out how to serialize/deserialize.

Cardinality

Some data models have properties with a cardinality of a minimum of 1. While these can be enforced to never be nil in Swift by not making them Optionals, they are still optional to enable uniform initializers that only take a JSON dictionary. For classes representing models with non-optional properties, a convenience initializer is supplied to reflect the need to set those properties without enforcing it.

Contained Resources

FHIR makes use of contained resources. An extension on the Reference class is included that adds method to handle reference resolving.

To resolve resource references, call resolve(ModelClass) { resource in } on a reference property, which will return an instance of the referenced type in the callback if resolved successfully. To contain a resource and receive a Reference instance, call parent.containResource(contained)

// create a prescription with a contained medication
let order = MedicationRequest()
let medication = Medication()
medication.id = "med"
do {
    order.medicationReference = try order.containResource(medication)
}
catch let error {
    // failed to contain, either because no id or containing itself
}

// resolve the contained medication
order.medication?.resolve(Medication.self) { medication in
	if let medication = medication {
		// successfully resolved
	}
}

Search

The client supports the NoSQL-like approach proposed and used by fhir.js.

Compartments

Search can be restricted to compartments, these however are not yet supported in the SMART server nor in these classes.

[ ] Patient/23/procedure?date=>2010-01-01&date=<2011-12-31

Referenced (not yet implemented)

If search is restricted to a reference property, this applies:

  • If the search token is merely an id, i.e. it does not contain a forward slash, a type restricted search is constructed based on which instance method is called: GET {base-url}/Thing?referenced:InstanceType={id}
  • If the search token does contain a forward slash it is assumed to be an absolute reference and no :InstanceType will be appended:
    GET {base-url}/Thing?referenced={uri}

Packaging

The full build of the framework will include all FHIR resources, which will result in a rather large binary. Take a look at the package.py script: provide one or more resource names when invoking the script from command line and it will output all the elements and resources that are needed for the desired resources. You may then be able to remove unnecessary resources, which unfortunately is a tedious task and requires fumbling with the factory.

There is an experimental SwiftFHIRMin-iOS build target which only includes a minimal set of resources. The problem here is that the factory is excluded and hence dereferencing, bundles and contained resources won't be properly instantiated.

More Repositories

1

client-py

Python SMART on FHIR client
Python
572
star
2

health-cards

Health Cards Framework: implementation guide and supporting material
TypeScript
259
star
3

fhir-parser

A Python FHIR specification parser and class generator
Python
149
star
4

Swift-SMART

Swift SMART on FHIR framework for iOS and OS X
Swift
125
star
5

smart-dev-sandbox

Docker based sandbox for smart apps
Smarty
116
star
6

api-server

Open-source FHIR Server to support patient- and clinician-facing apps
Groovy
104
star
7

patient-browser

JavaScript
83
star
8

smart-on-fhir.github.io

SMART on FHIR Docs
Jupyter Notebook
77
star
9

fhir-bulk-data-docs

Documentation and issue tracking for the emerging FHIR bulk data implementation guide
Jupyter Notebook
74
star
10

health-cards-dev-tools

Developer tools for validating SMART Health Cards
TypeScript
71
star
11

growth-chart-app

JavaScript
66
star
12

sample-apps-stu3

Collection of simple sample apps
JavaScript
46
star
13

fred

FRED - FHIR Resource Editor
JavaScript
44
star
14

health-cards-tests

Demo for health wallet with Verifiable Credentials and Decentralized Identifiers
TypeScript
43
star
15

bulk-data-server

JavaScript
42
star
16

fhir-server-dashboard

Presents a human-readable representation of the data in a FHIR server.
JavaScript
41
star
17

fhir-viewer

In-browser viewer for FHIR resources
JavaScript
39
star
18

installer

Shell
39
star
19

hapi

HAPI FHIR Server With Sample Patients
Dockerfile
37
star
20

SoF-Demo

Simple SMART on FHIR / Argonaut iOS sample app that fetches a couple of resources
Swift
36
star
21

smart-launcher

Launcher for SMART apps
JavaScript
33
star
22

smart-scheduling-links

Clinical Appointment Slot Discovery
TypeScript
28
star
23

sample-apps

HTML
25
star
24

cardiac-risk-app

JavaScript
25
star
25

generated-sample-data

Contains all the bundles that are loaded into the FHIR server
24
star
26

bulk-data-tools

HTML
23
star
27

smart-examples

Collection of public apps
JavaScript
14
star
28

client-node

SMART client for NodeJS
HTML
13
star
29

bulk-import

12
star
30

bulk-data-implementations

listing of bulk FHIR client implementations
12
star
31

bulk-data-client

JavaScript
11
star
32

tag-uploader

Adds tags to FHIR bundles and resources and uploads them to specified servers
JavaScript
9
star
33

sample-patients-stu3

Python
9
star
34

client-ts

FHIR Client Library
HTML
9
star
35

bp-centiles-app

JavaScript
8
star
36

cumulus-etl

Extract FHIR data, Transform with NLP and DEID tools, and then Load FHIR data into a SQL Database for analysis
Python
8
star
37

diabetes-monograph-app

JavaScript
7
star
38

fhir-starter

HTML
7
star
39

smart-launcher-v2

SMART Launcher
TypeScript
6
star
40

smart-local-sandbox

Docker based sandbox for smart apps
JavaScript
6
star
41

health-cards-designs

5
star
42

smart-hapi-stack

Experimental HAPI stack to support SMART on FHIR
Java
5
star
43

sample-bulk-fhir-datasets

Sample bulk export results of various sizes, for testing tools and workflows
Shell
5
star
44

bdt

Bulk Data Test Suite and Test Runner
TypeScript
5
star
45

sample-patients-prom

Provisional Quarterly Patient Reported Outcome Measures (PROMs) in England - April 2015 to March 2016, November 2016 release
JavaScript
5
star
46

smart-stub

Node / Express server to stub SMART Auth
JavaScript
4
star
47

mpr-monitor-app

JavaScript
4
star
48

dstu2-examples

Copy of official FHIR examples with an index page
HTML
4
star
49

synthea

Static build of Synthea with http interface
JavaScript
4
star
50

hca-fhir-importer

Import synthetic breast cancer sample data, courtesy of HCA/Bill Gregg
Python
4
star
51

fhir-demo-app

ApacheConf
3
star
52

smart-health-card-decoder

Sample code for a SMART Health Card validator
JavaScript
3
star
53

smart-health-links

Static documentation site for SMART Health Links
JavaScript
3
star
54

ehi-app

EHI Export API Client Reference Implementation
TypeScript
3
star
55

ehi-server

An EHI export server reference implementation of Argonaut's EHI Export API IG
TypeScript
3
star
56

bulk-import-client

CLI Client app for Bulk Data Import
JavaScript
2
star
57

confidential-client-example

JavaScript
2
star
58

fiery-sublime

Sublime Text 3 Plugin for FHIR data models
Python
2
star
59

disease-monograph-app

JavaScript
2
star
60

fhir-crawler

Utility to download resources from a FHIR server
TypeScript
1
star
61

fhir-server-tasks

Maintenance web-hooks for FHIR servers
JavaScript
1
star
62

timeshift

Shift dates in FHIR datasets
JavaScript
1
star
63

client-js-examples

Contains examples of how to use the client-js library
HTML
1
star
64

registry

Registry of FHIR Profiles for SMART Platforms
HTML
1
star
65

bulk-import-consumer

Bulk Data Import Server (Data Consumer)
JavaScript
1
star
66

reachnet

JavaScript
1
star
67

cumulus-library-hypertension

Hypertension case definition to support CDC chronic disease management and CMS measures
Python
1
star