hl7-fhirdstu2-fhir

How do I add Immunization to an FHIR Transaction Bundle?


I have downloaded some DSTU2 patient bundles from https://syntheticmass.mitre.org/download.html. I am trying to upload the data to an FHIR test server. My code (using fhir-net-api) loops through several files and compils them into a single transaction bundle. I've included the segment of code below that builds the transaction bundle below.

The problem is that the immunization entries do not have fullUrl element. I thought I was missing a step in in my loop, but according to https://www.hl7.org/fhir/immunization.html, the immunization entry doesn't even support a fullUrl element.

If I build a custom patient with just a few demographic details the process works, so I am guessing that I need to make some alteration to the Immunization entries but I cannot find an example transaction bundle that includes immunization data.

public Bundle ParseTestData(List<string> list) //File data as string in list
    {
        var parser = new FhirJsonParser();
        var parsedBundles = new List<Bundle>();
        var transactionBundle = new Bundle()
        {
            Id = "test-data-bundle",
            Type = Bundle.BundleType.Transaction
        };
        foreach (var str in list)
        {
            try
            {
                Bundle bundle = parser.Parse<Bundle>(str);
                parsedBundles.Add(bundle);
            }
            catch (Exception e){/*cut for brevity*/}
        }
        foreach (var bundle in parsedBundles)
        {
            foreach (var entry in bundle.Entry)
            {
                entry.Request = new Bundle.RequestComponent
                {
                    Method = Bundle.HTTPVerb.POST,
                    Url = "urn:uuid:" + Guid.NewGuid().ToString()
                };
                transactionBundle.Entry.Add(entry);
            }
        }
        return transactionBundle;
    }

My struggle here isn't the c# code. I simply don't know how to structure this data in the bundle properly.

Here is a bit of JSON from the source file.

{
  "fullUrl": "urn:uuid:05374078-2d51-4c7e-a562-273b030ba019",
  "resource": {
    "id": "05374078-2d51-4c7e-a562-273b030ba019",
    "status": "finished",
    "class": "outpatient",
    "type": [
      {
        "coding": [
          {
            "system": "http://snomed.info/sct",
            "code": "170258001"
          }
        ],
        "text": "Outpatient Encounter"
      }
    ],
    "patient": {
      "reference": "urn:uuid:0d88250d-63c6-4ce5-aedb-91d64fa09838"
    },
    "period": {
      "start": "2011-09-25T02:18:02-04:00",
      "end": "2011-09-25T03:18:02-04:00"
    },
    "serviceProvider": {
      "reference": "urn:uuid:a602f5c0-26a5-4288-b83d-39abc341757d"
    },
    "resourceType": "Encounter"
  }
},
{
  "resource": {
    "status": "completed",
    "date": "2011-09-25T02:18:02-04:00",
    "vaccineCode": {
      "coding": [
        {
          "system": "http://hl7.org/fhir/sid/cvx",
          "code": "08",
          "display": "Hep B, adolescent or pediatric"
        }
      ],
      "text": "Hep B, adolescent or pediatric"
    },
    "patient": {
      "reference": "urn:uuid:0d88250d-63c6-4ce5-aedb-91d64fa09838"
    },
    "wasNotGiven": false,
    "reported": false,
    "encounter": {
      "reference": "urn:uuid:05374078-2d51-4c7e-a562-273b030ba019"
    },
    "resourceType": "Immunization"
  }
},

Solution

  • fullUrl lives in the Bundle resource, not in Immunization. Bundles have an array of "entry" elements. Each "entry" (for a transaction request) then contains a "fullUrl", a "resource" and a "request" element. The content for the Immunization goes inside the "resource" element. You can see an example here: http://build.fhir.org/bundle-transaction.json.html. (Just stick your immunization content where the Patient content is.)