Skip to content

Instantly share code, notes, and snippets.

@MattCordell
Created April 10, 2018 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattCordell/828f46a31b6921dfef8e6a13d4c1a23b to your computer and use it in GitHub Desktop.
Save MattCordell/828f46a31b6921dfef8e6a13d4c1a23b to your computer and use it in GitHub Desktop.
Adding a patient then searching for by DOB in FHIR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hl7.Fhir.Rest;
using Hl7.Fhir.Model;
namespace PatientLogger
{
class Program
{
static void Main(string[] args)
{
string endpoint = "http://test.fhir.org/r3";
var server = new FhirClient(endpoint);
// Adding a patient
// Anthony Edward "Tony" Stark
var p = new Patient();
var n = new HumanName();
var _givens = new List<string>();
_givens.Add("Anthony");
_givens.Add("Edward");
n.Family = "Stark";
n.Text = "Anthony Edward \"Tony\" Stark";
n.Given = _givens;
p.Name.Add(n);
p.BirthDate = "1963-03";
p.Gender = AdministrativeGender.Male;
var i = new Attachment();
i.Url = "https://pre00.deviantart.net/63c6/th/pre/i/2016/098/4/f/tony_stark_01_by_merrogers-d9y8ni1.png";
p.Photo.Add(i);
p.Active = true;
p.Id = "iamironman";
server.Create<Patient>(p);
//Searching for a patient
var x = new SearchParams();
x.Add("birthDate", "1963");
var found = server.Search<Patient>(x);
foreach (var item in found.Entry)
{
var pat = (Patient)item.Resource;
Console.WriteLine(pat.Name.FirstOrDefault().Family);
}
Console.WriteLine();
Console.WriteLine("Done");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment