Ejemplo n.º 1
0
 public HL7Message(string message, HL7Template template)
 {
     this.RawMessage = message;
     this.CurrentTemplate = template;
     this.SegmentIndices = new Dictionary<string, List<int>>();
     this.ParseMessage();
 }
Ejemplo n.º 2
0
        // segment: "MSH|^~\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4"
        // field:   "ORU^R01"
        // field components: "ORU" and "R01"
        static void Main(string[] args)
        {
            HL7Template template = new HL7Template("ORU Template", "Quest", "ORU", false, new List<string> { "OBR", "OBX" });
            HL7Message msg = new HL7Message(exMsg, template);
            HL7Template template2 = new HL7Template("ORU Template", "Quest", "ORU", false, new List<string> { "OBR", "OBX" });
            HL7Message msg2 = new HL7Message(exMsg2, template2);
            HL7Template template3 = new HL7Template("ORU Template", "Quest", "ORU", true, new List<string> { "OBR", "OBX" });
            HL7Message msg3 = new HL7Message(exMsg3, template3);

            HL7Template template4 = new HL7Template("ORU Template", "Quest", "ORU", true, new List<string> { "OBR", "OBX" });

            // doing this by hand like this is pretty error prone. A basic editor would be useful for making these
            var someMappedSegments = new Dictionary<string, Dictionary<string, int[]>>()
            {
                { "MSH", new Dictionary<string, int[]>()
                    {
                        { "SEGMENT_TYPE", new int[] { 0 } },
                        { "ENCODING_CHARS", new int[] { 1 } },
                        { "SENDING_APPLICATION", new int[] { 2 } },
                        { "SENDING_FACILITY", new int[] { 3 } },
                        { "RECEIVING_APPLICATION", new int[] { 4 } },
                        { "RECEIVING_FACILITY", new int[] { 5 } },
                        { "MSG_DATETIME", new int[] { 6 } },
                        { "SECURITY", new int[] { 7 } },
                        { "MESSAGE_TYPE", new int[] { 8, 0 } },
                        { "MESSAGE_TYPE_2", new int[] { 8, 1 } },
                        { "MESSAGE_CONTROL_ID", new int[] { 9 } },
                        { "PROCESSING_ID", new int[] { 10 } },
                        { "VERSION_ID", new int[] { 11 } }
                    }
                }
            };

            if (!template4.AddSegmentMap(someMappedSegments))
                throw new Exception("Segments were not mapped successfully");

            HL7Message msg4 = new HL7Message(exMsg4, template4);

            List<int> indices = msg4.GetSegmentIndices("MSH");

            var mappedItems = msg4.GetMappedItems("MSH", "MSG_DATETIME", new List<int>() { 1, 2 });

            Console.ReadLine();
        }