Skip to content

Get property names that have no data while parsing to XML. #478

Open
@alirizaadiyahsi

Description

@alirizaadiyahsi

I am trying to create a tree by parsing hl7 message to XML.

But XmlParser is checking if the component has DATA, if not then it is not adding that prop to XML tree.

Here is the nhapi code that checks if component has data:

image

Here is the example HL7 message.

MSH|^~\&|FDHL7|JOHNSON LABS||P1055|201007231634||ORU^R01|P1055–0000047907|P|2.3|1||NE|NE PID|1|JQ4988|108512373||SAMPLES^JUNIOR||01/10/1948^53 Y|M|||^******^^|||||||| NTE|1|P|**************************************************************************** ADD|NON FASTING

and here is the output (XML)

<ORU_R01 xmlns="urn:hl7-org:v2xml">
    <MSH>
        <MSH.1>|</MSH.1>
        <MSH.2>^~\&amp;</MSH.2>
        <MSH.3>
            <HD.1>FDHL7</HD.1>
        </MSH.3>
        <MSH.4>
            <HD.1>JOHNSON LABS</HD.1>
        </MSH.4>
        <MSH.6>
            <HD.1>P1055</HD.1>
        </MSH.6>
        <MSH.7>
            <TS.1>201007231634</TS.1>
        </MSH.7>
        <MSH.9>
            <CM_MSG.1>ORU</CM_MSG.1>
            <CM_MSG.2>R01</CM_MSG.2>
        </MSH.9>
        <MSH.10>P1055–0000047907</MSH.10>
        <MSH.11>
            <PT.1>P</PT.1>
        </MSH.11>
        <MSH.12>2.3</MSH.12>
        <MSH.13>1</MSH.13>
        <MSH.15>NE</MSH.15>
        <MSH.16>NE</MSH.16>
    </MSH>

For example, as you see MSH.5, MSH.8, MSH.14 are missing.

Here is the output (tree)

image

And here is my code:

  public IEnumerable<Dictionary<string, object>> Deserialize(string text)
  {
      var parser = new PipeParser();
      var iMessage = parser.Parse(text);

      var xmlParser = new DefaultXMLParser();
      var xmlMessage = xmlParser.Encode(iMessage);

      .....       

      return nodes;
  }

What about adding a parser option to add properties that have no data?
Or is there a way/workaround to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting more informationIssue does not contain enough information to support a resolution.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions