SlideShare una empresa de Scribd logo
1 de 28
FHIR® is the registered trademark of HL7 and is used with the permission of HL7. The Flame Design mark is the registered trademark of HL7 and is used with the permission of HL7.
Amsterdam, 15-17 November | @fhir_furore | #fhirdevdays17 | www.fhirdevdays.com
FHIR API for .Net programmers - an introduction
Mirjam Baltus, Furore Health Informatics
Who am I?
• Name: Mirjam Baltus
• Background:
• Furore FHIR team
• FHIR trainer & Support
• Contact: m.baltus@furore.com
Using the Reference Implementation
Hl7.Fhir API
blue stars indicate example code
First step
• Adding the Hl7.Fhir package to your solution
• NuGet Package manager, Hl7.Fhir.STU3 package
Hl7.Fhir.STU3
• Core contents
• Model – classes generated from the spec
• REST functionality – FhirClient
• Parsers and Serializers
• Helper functions
• Source on GitHub: http://github.com/ewoutkramer/fhir-net-api
The model
using Hl7.Fhir.Model;
A FHIR Resource
A FHIR Resource in C# - classes and enums
public partial class Observation : Hl7.Fhir.Model.DomainResource
/// <summary>
/// Codes providing the status of an observation.
/// (url: http://hl7.org/fhir/ValueSet/observation-status)
/// </summary>
public enum ObservationStatus {Registered, Preliminary, Final, …}
var obs = new Observation();
obs.Status = ObservationStatus.Preliminary;
A FHIR Resource in C# - datatypes and lists
public CodeableConcept Code { get; set; }
obs.Code = new CodeableConcept("http://example.org", "EX123",
"Example code 123");
public List<Identifier> Identifier { get; set; }
obs.Identifier.Add(new Identifier("http://example.org", "123456"));
A FHIR Resource in C# - choice properties
public CodeableConcept Code { get; set; }
public Element Value { get; set; }
var qty = new Quantity {
Value = 25,
Unit = "sec",
System = "http://unitsofmeasure.org",
Code = "s" };
obs.Value = qty;
A FHIR Resource in C# - components
public partial class ReferenceRangeComponent : BackboneElement { … }
var refRange = new Observation.ReferenceRangeComponent();
// fill the values
obs.ReferenceRange.Add(refRange);
A FHIR Resource in C# - (non) primitives
/// <summary>
/// Whether this patient's record is
/// in active use
/// </summary>
public bool? Active { … }
public Hl7.Fhir.Model.FhirBoolean ActiveElement { … }
var pat = new Patient();
pat.Active = true;
pat.ActiveElement = new FhirBoolean(true);
// or
Why would you use the non-primitive version?
var name = new HumanName();
name.Given = new string[] { "Mirjam" }; // or
name.GivenElement.Add(new FhirString("Mirjam"));
name.Family = "Baltus-Bakker";
• Adding extensions cannot be done on primitives!
Extensions
<Patient xmlns="http://hl7.org/fhir">
<!-- some metadata and narrative -->
<extension url="http://hl7.org/fhir/StructureDefinition/patient-
mothersMaidenName">
<valueString value="Williams"/>
</extension>
<!-- more patient data -->
</Patient>
Key = location of formal definition
Value = type of value according to definition
Why would you use the non-primitive version?
var name = new HumanName();
name.Given = new string[] { "Mirjam" }; // or
name.GivenElement.Add(new FhirString("Mirjam"));
name.Family = "Baltus-Bakker";
• Adding extensions cannot be done on primitives!
name.FamilyElement.AddExtension(
"http://hl7.org/fhir/StructureDefinition/humanname-partner-name",
new FhirString("Baltus"));
REST interactions
using Hl7.Fhir.Rest;
Using the FHIR Client
• For a list of test servers, see Publicly Available FHIR Servers
var client = new FhirClient("http://vonk.furore.com");
// client options
client.PreferredFormat = ResourceFormat.Xml;
client.PreferredReturn = Prefer.ReturnRepresentation;
C(RUD)
var obs = new Observation();
obs.Status = ObservationStatus.Preliminary;
obs.Code = new CodeableConcept("http://example.org", "EX123",
"Example code 123");
// fill in mandatory fields, plus other fields you have data for
// send the observation to the server to be created
var result = client.Create<Observation>(obs);
// note that this could generate an error,
// so setup error handling to catch exceptions
(C)RUD
// read a resource from the server
var pat = client.Read<Patient>("Patient/1");
// update a resource on the server
pat.Name.Add(HumanName.ForFamily("Kramer").WithGiven("Ewout"));
client.Update<Patient>(pat);
// delete a resource from the server
client.Delete(pat); // or
client.Delete("Patient/12345");
Adding headers to the request, inspecting raw response
client.OnBeforeRequest +=
(object sender, BeforeRequestEventArgs e) =>
{
e.RawRequest.Headers.Add("some_key", "some_value");
};
client.OnAfterResponse +=
(object sender, AfterResponseEventArgs e) =>
{
Console.WriteLine(e.RawResponse.StatusCode);
};
Bundles and searches
using Hl7.Fhir.Rest;
Making queries
var q = new SearchParams()
.Where("name=Ewout")
.Include("Patient:organization")
.LimitTo(10)
.SummaryOnly()
.OrderBy("birthdate", SortOrder.Descending);
q.Add("gender", "male");
Bundle result = client.Search<Patient>(q);
Paging through a Bundle
while (result != null)
{
foreach (var e in result.Entry)
{
Patient p = (Patient)e.Resource;
// do something with the resource
}
result = client.Continue(result, PageDirection.Next);
}
Helper functionality
using Hl7.Fhir.Rest;
Resource Identity
pat.ResourceIdentity().HasBaseUri;
pat.ResourceIdentity().HasVersion;
pat.ResourceIdentity().BaseUri;
pat.ResourceIdentity().ResourceType;
var id = new ResourceIdentity("Patient/3")
.WithBase("http://example.org/fhir");
var id2 = ResourceIdentity.Build(UrnType.OID, "1.2.3.4.5.6");
Transaction builder
var trb = new TransactionBuilder("http://vonk.furore.com")
.Create(pat)
.ResourceHistory("Patient", "1")
.Delete("Patient", "2")
.Read("Patient", "pat2");
var q = new SearchParams().Where("name=Steve");
trb = trb.Search(q, "Patient");
var t_result = client.Transaction(trb.ToBundle());
Questions?
What’s next?
• Join me at the table for the hands-
on session
• Look at the schedule for other
tutorials in the developers track
• Code, have fun, and
ASK QUESTIONS!

Más contenido relacionado

La actualidad más candente

A simple web-based interface for advanced SNOMED CT queries
A simple web-based interface for advanced SNOMED CT queriesA simple web-based interface for advanced SNOMED CT queries
A simple web-based interface for advanced SNOMED CT queries
Snow Owl
 
The Logical Model Designer - Binding Information Models to Terminology
The Logical Model Designer - Binding Information Models to TerminologyThe Logical Model Designer - Binding Information Models to Terminology
The Logical Model Designer - Binding Information Models to Terminology
Snow Owl
 

La actualidad más candente (20)

20171116 rene spronk_profiling_governance
20171116 rene spronk_profiling_governance20171116 rene spronk_profiling_governance
20171116 rene spronk_profiling_governance
 
Furore devdays2017 tdd-1-intro
Furore devdays2017 tdd-1-introFurore devdays2017 tdd-1-intro
Furore devdays2017 tdd-1-intro
 
Fhir foundation (grahame)
Fhir foundation (grahame)Fhir foundation (grahame)
Fhir foundation (grahame)
 
Furore devdays 2017 - workflow
Furore devdays 2017 - workflowFurore devdays 2017 - workflow
Furore devdays 2017 - workflow
 
Building bridges devdays 2017- powerpoint template
Building bridges devdays 2017- powerpoint templateBuilding bridges devdays 2017- powerpoint template
Building bridges devdays 2017- powerpoint template
 
Devdays 2017 implementation guide authoring - ardon toonstra
Devdays 2017  implementation guide authoring - ardon toonstraDevdays 2017  implementation guide authoring - ardon toonstra
Devdays 2017 implementation guide authoring - ardon toonstra
 
Furore devdays2017 tdd-2-advanced
Furore devdays2017 tdd-2-advancedFurore devdays2017 tdd-2-advanced
Furore devdays2017 tdd-2-advanced
 
Profiling with clin fhir
Profiling with clin fhirProfiling with clin fhir
Profiling with clin fhir
 
Furore devdays 2017- profiling academy - profiling guidelines v1
Furore devdays 2017- profiling academy - profiling guidelines v1Furore devdays 2017- profiling academy - profiling guidelines v1
Furore devdays 2017- profiling academy - profiling guidelines v1
 
fhir-documents
fhir-documentsfhir-documents
fhir-documents
 
Fhir path (ewout)
Fhir path (ewout)Fhir path (ewout)
Fhir path (ewout)
 
Whats new (grahame)
Whats new (grahame)Whats new (grahame)
Whats new (grahame)
 
Security overview (grahame)
Security overview (grahame)Security overview (grahame)
Security overview (grahame)
 
Mohannad hussain dicom and imaging tools
Mohannad hussain   dicom and imaging toolsMohannad hussain   dicom and imaging tools
Mohannad hussain dicom and imaging tools
 
Fhir dev days_advanced_fhir_terminology_services
Fhir dev days_advanced_fhir_terminology_servicesFhir dev days_advanced_fhir_terminology_services
Fhir dev days_advanced_fhir_terminology_services
 
final Keynote (grahame)
final Keynote (grahame)final Keynote (grahame)
final Keynote (grahame)
 
Building a Scenario using clinFHIR
Building a Scenario using clinFHIRBuilding a Scenario using clinFHIR
Building a Scenario using clinFHIR
 
A simple web-based interface for advanced SNOMED CT queries
A simple web-based interface for advanced SNOMED CT queriesA simple web-based interface for advanced SNOMED CT queries
A simple web-based interface for advanced SNOMED CT queries
 
Furore devdays 2017- fhir and devices - cooper thc2
Furore devdays 2017- fhir and devices - cooper thc2Furore devdays 2017- fhir and devices - cooper thc2
Furore devdays 2017- fhir and devices - cooper thc2
 
The Logical Model Designer - Binding Information Models to Terminology
The Logical Model Designer - Binding Information Models to TerminologyThe Logical Model Designer - Binding Information Models to Terminology
The Logical Model Designer - Binding Information Models to Terminology
 

Similar a Beginners .net api dev days2017

Similar a Beginners .net api dev days2017 (20)

FHIR API for .Net programmers by Mirjam Baltus
FHIR API for .Net programmers by Mirjam BaltusFHIR API for .Net programmers by Mirjam Baltus
FHIR API for .Net programmers by Mirjam Baltus
 
FHIR API for Java programmers by James Agnew
FHIR API for Java programmers by James AgnewFHIR API for Java programmers by James Agnew
FHIR API for Java programmers by James Agnew
 
OpenCMIS Part 1
OpenCMIS Part 1OpenCMIS Part 1
OpenCMIS Part 1
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
FHIR Client Development with .NET
FHIR Client Development with .NETFHIR Client Development with .NET
FHIR Client Development with .NET
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 
08 -functions
08  -functions08  -functions
08 -functions
 
John's Top PECL Picks
John's Top PECL PicksJohn's Top PECL Picks
John's Top PECL Picks
 
Php client libray
Php client librayPhp client libray
Php client libray
 
Secure PHP environment
Secure PHP environmentSecure PHP environment
Secure PHP environment
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
Ingesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScriptIngesting and Manipulating Data with JavaScript
Ingesting and Manipulating Data with JavaScript
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Apache Eagle in Action
Apache Eagle in ActionApache Eagle in Action
Apache Eagle in Action
 
FHIR for Hackers
FHIR for HackersFHIR for Hackers
FHIR for Hackers
 
Google Cloud healthcare data platform and FHIR APIs by Kalyan Pamarthy
Google Cloud healthcare data platform and FHIR APIs by Kalyan PamarthyGoogle Cloud healthcare data platform and FHIR APIs by Kalyan Pamarthy
Google Cloud healthcare data platform and FHIR APIs by Kalyan Pamarthy
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 

Más de DevDays

Más de DevDays (16)

Consent dev days
Consent dev daysConsent dev days
Consent dev days
 
Integrating with the epic platform fhir dev days 17
Integrating with the epic platform fhir dev days 17Integrating with the epic platform fhir dev days 17
Integrating with the epic platform fhir dev days 17
 
Mohannad hussain community track - siim dataset & dico mweb proxy
Mohannad hussain   community track - siim dataset & dico mweb proxyMohannad hussain   community track - siim dataset & dico mweb proxy
Mohannad hussain community track - siim dataset & dico mweb proxy
 
Validation in net and java (ewout james)
Validation in net and java (ewout james)Validation in net and java (ewout james)
Validation in net and java (ewout james)
 
Transforming other content (grahame)
Transforming other content (grahame)Transforming other content (grahame)
Transforming other content (grahame)
 
Structure definition 101 (ewout)
Structure definition 101 (ewout)Structure definition 101 (ewout)
Structure definition 101 (ewout)
 
Quality improvement dev days-2017
Quality improvement dev days-2017Quality improvement dev days-2017
Quality improvement dev days-2017
 
Furore devdays 2017- oai
Furore devdays 2017- oaiFurore devdays 2017- oai
Furore devdays 2017- oai
 
Furore devdays 2017 - implementation guides (lloyd)
Furore devdays 2017 - implementation guides (lloyd)Furore devdays 2017 - implementation guides (lloyd)
Furore devdays 2017 - implementation guides (lloyd)
 
Dev days 2017 advanced directories (brian postlethwaite)
Dev days 2017 advanced directories (brian postlethwaite)Dev days 2017 advanced directories (brian postlethwaite)
Dev days 2017 advanced directories (brian postlethwaite)
 
Connectathon opening 2017
Connectathon opening 2017Connectathon opening 2017
Connectathon opening 2017
 
20171127 rene spronk_messaging_the_unloved_paradigm
20171127 rene spronk_messaging_the_unloved_paradigm20171127 rene spronk_messaging_the_unloved_paradigm
20171127 rene spronk_messaging_the_unloved_paradigm
 
Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)Vonk fhir facade (christiaan)
Vonk fhir facade (christiaan)
 
Opening student track
Opening student trackOpening student track
Opening student track
 
Furore devdays 2017- continua implementing fhir
Furore devdays 2017- continua implementing fhirFurore devdays 2017- continua implementing fhir
Furore devdays 2017- continua implementing fhir
 
Fhir tooling (grahame)
Fhir tooling (grahame)Fhir tooling (grahame)
Fhir tooling (grahame)
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Beginners .net api dev days2017

  • 1. FHIR® is the registered trademark of HL7 and is used with the permission of HL7. The Flame Design mark is the registered trademark of HL7 and is used with the permission of HL7. Amsterdam, 15-17 November | @fhir_furore | #fhirdevdays17 | www.fhirdevdays.com FHIR API for .Net programmers - an introduction Mirjam Baltus, Furore Health Informatics
  • 2. Who am I? • Name: Mirjam Baltus • Background: • Furore FHIR team • FHIR trainer & Support • Contact: m.baltus@furore.com
  • 3. Using the Reference Implementation Hl7.Fhir API blue stars indicate example code
  • 4. First step • Adding the Hl7.Fhir package to your solution • NuGet Package manager, Hl7.Fhir.STU3 package
  • 5. Hl7.Fhir.STU3 • Core contents • Model – classes generated from the spec • REST functionality – FhirClient • Parsers and Serializers • Helper functions • Source on GitHub: http://github.com/ewoutkramer/fhir-net-api
  • 8. A FHIR Resource in C# - classes and enums public partial class Observation : Hl7.Fhir.Model.DomainResource /// <summary> /// Codes providing the status of an observation. /// (url: http://hl7.org/fhir/ValueSet/observation-status) /// </summary> public enum ObservationStatus {Registered, Preliminary, Final, …} var obs = new Observation(); obs.Status = ObservationStatus.Preliminary;
  • 9. A FHIR Resource in C# - datatypes and lists public CodeableConcept Code { get; set; } obs.Code = new CodeableConcept("http://example.org", "EX123", "Example code 123"); public List<Identifier> Identifier { get; set; } obs.Identifier.Add(new Identifier("http://example.org", "123456"));
  • 10. A FHIR Resource in C# - choice properties public CodeableConcept Code { get; set; } public Element Value { get; set; } var qty = new Quantity { Value = 25, Unit = "sec", System = "http://unitsofmeasure.org", Code = "s" }; obs.Value = qty;
  • 11. A FHIR Resource in C# - components public partial class ReferenceRangeComponent : BackboneElement { … } var refRange = new Observation.ReferenceRangeComponent(); // fill the values obs.ReferenceRange.Add(refRange);
  • 12. A FHIR Resource in C# - (non) primitives /// <summary> /// Whether this patient's record is /// in active use /// </summary> public bool? Active { … } public Hl7.Fhir.Model.FhirBoolean ActiveElement { … } var pat = new Patient(); pat.Active = true; pat.ActiveElement = new FhirBoolean(true); // or
  • 13. Why would you use the non-primitive version? var name = new HumanName(); name.Given = new string[] { "Mirjam" }; // or name.GivenElement.Add(new FhirString("Mirjam")); name.Family = "Baltus-Bakker"; • Adding extensions cannot be done on primitives!
  • 14. Extensions <Patient xmlns="http://hl7.org/fhir"> <!-- some metadata and narrative --> <extension url="http://hl7.org/fhir/StructureDefinition/patient- mothersMaidenName"> <valueString value="Williams"/> </extension> <!-- more patient data --> </Patient> Key = location of formal definition Value = type of value according to definition
  • 15. Why would you use the non-primitive version? var name = new HumanName(); name.Given = new string[] { "Mirjam" }; // or name.GivenElement.Add(new FhirString("Mirjam")); name.Family = "Baltus-Bakker"; • Adding extensions cannot be done on primitives! name.FamilyElement.AddExtension( "http://hl7.org/fhir/StructureDefinition/humanname-partner-name", new FhirString("Baltus"));
  • 17. Using the FHIR Client • For a list of test servers, see Publicly Available FHIR Servers var client = new FhirClient("http://vonk.furore.com"); // client options client.PreferredFormat = ResourceFormat.Xml; client.PreferredReturn = Prefer.ReturnRepresentation;
  • 18. C(RUD) var obs = new Observation(); obs.Status = ObservationStatus.Preliminary; obs.Code = new CodeableConcept("http://example.org", "EX123", "Example code 123"); // fill in mandatory fields, plus other fields you have data for // send the observation to the server to be created var result = client.Create<Observation>(obs); // note that this could generate an error, // so setup error handling to catch exceptions
  • 19. (C)RUD // read a resource from the server var pat = client.Read<Patient>("Patient/1"); // update a resource on the server pat.Name.Add(HumanName.ForFamily("Kramer").WithGiven("Ewout")); client.Update<Patient>(pat); // delete a resource from the server client.Delete(pat); // or client.Delete("Patient/12345");
  • 20. Adding headers to the request, inspecting raw response client.OnBeforeRequest += (object sender, BeforeRequestEventArgs e) => { e.RawRequest.Headers.Add("some_key", "some_value"); }; client.OnAfterResponse += (object sender, AfterResponseEventArgs e) => { Console.WriteLine(e.RawResponse.StatusCode); };
  • 21. Bundles and searches using Hl7.Fhir.Rest;
  • 22. Making queries var q = new SearchParams() .Where("name=Ewout") .Include("Patient:organization") .LimitTo(10) .SummaryOnly() .OrderBy("birthdate", SortOrder.Descending); q.Add("gender", "male"); Bundle result = client.Search<Patient>(q);
  • 23. Paging through a Bundle while (result != null) { foreach (var e in result.Entry) { Patient p = (Patient)e.Resource; // do something with the resource } result = client.Continue(result, PageDirection.Next); }
  • 25. Resource Identity pat.ResourceIdentity().HasBaseUri; pat.ResourceIdentity().HasVersion; pat.ResourceIdentity().BaseUri; pat.ResourceIdentity().ResourceType; var id = new ResourceIdentity("Patient/3") .WithBase("http://example.org/fhir"); var id2 = ResourceIdentity.Build(UrnType.OID, "1.2.3.4.5.6");
  • 26. Transaction builder var trb = new TransactionBuilder("http://vonk.furore.com") .Create(pat) .ResourceHistory("Patient", "1") .Delete("Patient", "2") .Read("Patient", "pat2"); var q = new SearchParams().Where("name=Steve"); trb = trb.Search(q, "Patient"); var t_result = client.Transaction(trb.ToBundle());
  • 28. What’s next? • Join me at the table for the hands- on session • Look at the schedule for other tutorials in the developers track • Code, have fun, and ASK QUESTIONS!