fhir api for dotnet (mirjam)

Preview:

Citation preview

© 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 APIfor .Net programmers

Mirjam BaltusFHIR Developer DaysNovember 18, 2015

© 2012 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 Company: Furore, Amsterdam Background:

Furore FHIR team IT trainer & Software developer

Contact: m.baltus@furore.com

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

HL7.FHIR SUPPORT APIUsing the Reference Implementations

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

Hl7.Fhir

- Core contents- Model – classes generated from the spec- Parsers and Serializers- REST functionality – FhirClient- Validation

- Specification

NuGet “FHIR”, look for DSTU2 packages fhirapi@furore.com or GitHub for support/issues

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

A FHIR 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.

A FHIR Resource in C#public partial class Observation : Hl7.Fhir.Model.DomainResource{ // Codes specifying how two observations are related. public enum ObservationRelationshipType {HasMember, DerivedFrom, SequelTo, …} // Codes providing the status of an observation. public enum ObservationStatus {Registered, Preliminary, Final, …}

public partial class ObservationReferenceRangeComponent : BackboneElement { … }

public CodeableConcept Code { get; set; } public Element Value { get; set;}

public List<ResourceReference> Performer { get; set; }}

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

Primitives are not really primitive…

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

Using the FHIR Client

var client =new FhirClient("http://acme.org/fhir");

var pat = client.Read<Patient>("Patient/1");var id = pat.Id;

pat.Name.Add(HumanName.ForFamily("Kramer").WithGiven("Ewout"));

client.Update<Patient>(pat);

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

Bundles

var criteria = new string[] { "family=Eve" };Bundle result = client.Search<Patient>(criteria);

while (result != null){ foreach (var e in result.Entry) { Patient p = (Patient)e.Resource; // Do something with the resource } result = client.Continue(result);}

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

Parsing/Serializing

// Create a file-based reader for XmlXmlReader xr = XmlReader.Create(

new StreamReader(@"observation-example.xml"));

// Parse the Observation from the streamvar obs = (Observation)FhirParser.ParseResource(xr);

// Serialize the in-memory observation to Jsonvar jsonText = FhirSerializer.SerializeResourceToJson(obs);

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

Validation example

var pat = new Patient() { /* set up data */ };

// Will throw a ValidationException upon errorsDotNetAttributeValidation.Validate(pat);

// Alternatively, use the TryXXXX patternvar errors = new List<ValidationResult>();var success = DotNetAttributeValidation.TryValidate(pat, errors);

if (!success) { /* handle errors */ }

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

WHAT’S NEXT?

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

Next Steps for you

Come to the round table with guidance session after this presentation

Try the Beginners Track orthe Patient Track at the Hackathon

See github for FhirStarters

Implementer’s Skype Channel StackOverflow: hl7 fhir tag FHIR DOTNET group on Google Groups

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

The End – Questions?

Recommended