user5843610
user5843610

Reputation:

fhir-net-api (STU3) - Hl7.Fhir.Model.PlanDefinition parsing error

Using HL7.FHIR.STU3.Core, I am getting an invalid cast exception when I try and parse an PlanDefinition FHIR file.

Do I need to set the Schema for PlanDefinition file?

        string HL7FilePath = string.Format("{0}\\{1}", System.IO.Directory.GetCurrentDirectory(), "ANA3.xml");
        string HL7FileData = File.ReadAllText(HL7FilePath)

        var b = new FhirXmlParser().Parse<Bundle>(HL7FileData);

Error

InValidCastException {"Unable to cast object of type 'Hl7.Fhir.Model.PlanDefinition' to type 'Hl7.Fhir.Model.Bundle'."}

Upvotes: 0

Views: 308

Answers (1)

Mirjam Baltus
Mirjam Baltus

Reputation: 2299

You are trying to parse a PlanDefinition resource into a Bundle object, as the InvalidCastException tells you. If you change the Parse<Bundle> into Parse<PlanDefinition> your code should work fine.

Upvotes: 0

Related Questions