Search code examples
hl7-fhiroperation

Use of $docref operation in C#


I'm currently trying to get a CCD from Cerner's CODE using the FHIR DocumentReference resource. In order to get a CCD the $docref operation has to be passed in the URL (example below) but the FHIR library we are using doesn't allow to use this operation.

http://fhir.cerner.com/millennium/dstu2/infrastructure/document-reference/#operation-docref

Any ideas? Anyone has been able to do this in C#?


Solution

  • You can use the official FHIR library for .Net, see https://github.com/FirelyTeam/fhir-net-api for the source, or add the Hl7.Fhir.Dstu2 library it to your project through NuGet.

    This library has a FhirClient, that you can point to your endpoint and use to call the operation.

    Here's how that could be achieved - values taken from the documentation you linked to:

      var c = new FhirClient("https://fhir-open.cerner.com/dstu2/ec2458f2-1e24-41c8-b71b-0e701af7583d/");
             
      var p = new Parameters();
      p.Parameter.Add(new Parameters.ParameterComponent() { Name = "patient", Value = new FhirString("12724066") });
      p.Parameter.Add(new Parameters.ParameterComponent() { Name = "type", Value = new CodeableConcept("http://loinc.org", "34133-9") });
    
      var result = c.TypeOperation<DocumentReference>("docref", p, useGet: true);