0

How can I get value of Hl7 field specifying just name of structure and filed of Hl7 message? This line of code message.GetStructure("MSH") works well, while this does not: message.GetStructure("MSH.SendingFacility"). The name of field is known in a runtime only, so I can not use strongly type methods like message.GetStructure("MSH").SendingFacility().

YMC
  • 4,925
  • 7
  • 53
  • 83
  • I took a look at Hl7 spec and I guess there is no 'get by field name' method as there is no such field names defined in Hl7 spec, instead order is defined only. There is a method in NHapi letting access field value by its order which meets the spec. Correct me if I'm wrong please – YMC Sep 17 '13 at 15:43

1 Answers1

0

Why don't you know the field name?

NHAPI is based around the HL7 specifications. Within the specifications all of the fields in all segments are named.

If you are adding a new field, then you should be creating a custom message definition and naming the field.

As @YMC mentioned, you can select a field using the index. Another option, although possibly not as efficient, is to traverse through all segments and fields. Which I have done in my NHAPI HL7 tree view application

davidlg
  • 86
  • 3
  • Field name is only known in run time in my case as it is something user enters in the form. Do I understand you correctly that field names are defined in so called message definition that is part of hl7 message and may be any string value, whatever 2 communicating organizations agreed upon, i.e. hl7 standard does not fix specific names of fields, but only orders? – YMC Sep 18 '13 at 14:55