public RDS_O13(XDocument xdoc) { var __last_significant_item = "NONE"; Orders = new List <Order>(); Header = new Header(); Patient = new hl7Patient(); var currentOrder = new Order(); if (xdoc.Root == null) { return; } foreach (var xe in xdoc.Root.Elements()) { switch (xe.Name.ToString()) { case "AL1": Patient.AL1.Add(new AL1(xe)); break; case "MSH": Header.MSH = new MSH(xe); __last_significant_item = "MSH"; break; case "OBX": currentOrder.OBX.Add(new OBX(xe)); break; case "PID": Patient.PID = new PID(xe); __last_significant_item = "PID"; break; case "PV1": Patient.PV1 = new PV1(xe); __last_significant_item = "PV1"; break; case "PV2": Patient.PV2 = new PV2(xe); __last_significant_item = "PV2"; break; case "PD1": Patient.PD1 = new PD1(xe); break; case "PRT": if (__last_significant_item == "PID" || __last_significant_item.Contains("PV")) { Patient.PRT.Add(new PRT(xe)); } else { currentOrder.PRT.Add(new PRT(xe)); } break; case "IN1": Patient.IN1 = new IN1(xe); break; case "IN2": Patient.IN2 = new IN2(xe); break; case "TQ1": currentOrder.TQ1.Add(new TQ1(xe)); break; case "RXC": currentOrder.RXC.Add(new RXC(xe)); break; case "RXD": currentOrder.RXD = new RXD(xe); break; case "RXE": currentOrder.RXE = new RXE(xe); __last_significant_item = "RXE"; break; case "RXO": currentOrder.RXO = new RXO(xe); break; case "RXR": currentOrder.RXR.Add(new RXR(xe)); break; case "ORC": // Need to parse the order if (!currentOrder.Empty()) // Is this a new order { Orders.Add(currentOrder); // ReSharper disable once RedundantAssignment currentOrder = null; } currentOrder = new Order { ORC = new ORC(xe) }; __last_significant_item = "ORC"; break; case "ZAS": Header.ZAS = new ZAS(xe); break; case "ZLB": Header.ZLB = new ZLB(xe); break; case "ZPI": Header.ZPI = new ZPI(xe); break; case "NTE": if (__last_significant_item == "PID") { Patient.NTE.Add(new NTE(xe)); } else if (__last_significant_item == "MSH") { Header.NTE.Add(new NTE(xe)); } else { currentOrder.NTE.Add(new NTE(xe)); } break; case "DG1": Patient.DG1.Add(new DG1(xe)); break; case "SFT": Header.SFT.Add(new SFT(xe)); break; // ReSharper disable once RedundantEmptySwitchSection default: break; } } Orders.Add(currentOrder); }
/// <summary> /// RDEO11 Message /// </summary> /// <param name="xDocument"></param> public RDE_O11(XDocument xDocument) { string lastSignificantItem = "NONE"; Header = new Header(); Orders = new List <Order>(); Patient = new hl7Patient(); var currentOrder = new Order(); Hl7XmLset = xDocument ?? throw new ArgumentNullException(nameof(xDocument)); if (xDocument.Root != null) { foreach (var xElement in xDocument.Root.Elements()) { switch (xElement.Name.ToString()) { case "AL1": Patient.AL1.Add(new AL1(xElement)); break; case "MSH": Header.MSH = new MSH(xElement); lastSignificantItem = "MSH"; break; case "OBX": currentOrder.OBX.Add(new OBX(xElement)); break; case "PID": Patient.PID = new PID(xElement); lastSignificantItem = "PID"; break; case "PV1": Patient.PV1 = new PV1(xElement); lastSignificantItem = "PV1"; break; case "PV2": Patient.PV2 = new PV2(xElement); lastSignificantItem = "PV2"; break; case "PD1": Patient.PD1 = new PD1(xElement); break; case "PRT": if (lastSignificantItem == "PID" || lastSignificantItem.Contains("PV")) { Patient.PRT.Add(new PRT(xElement)); } else { currentOrder.PRT.Add(new PRT(xElement)); } break; case "IN1": Patient.IN1 = new IN1(xElement); break; case "IN2": Patient.IN2 = new IN2(xElement); break; case "TQ1": currentOrder.TQ1.Add(new TQ1(xElement)); break; case "RXC": currentOrder.RXC.Add(new RXC(xElement)); break; case "RXD": currentOrder.RXD = new RXD(xElement); break; case "RXE": currentOrder.RXE = new RXE(xElement); lastSignificantItem = "RXE"; break; case "RXO": currentOrder.RXO = new RXO(xElement); break; case "RXR": currentOrder.RXR.Add(new RXR(xElement)); break; case "ORC": // Need to parse the order if (!currentOrder.Empty()) // Is this a new order { Orders.Add(currentOrder); // ReSharper disable once RedundantAssignment currentOrder = null; } currentOrder = new Order { ORC = new ORC(xElement) }; lastSignificantItem = "ORC"; break; case "ZAS": Header.ZAS = new ZAS(xElement); break; case "ZLB": Header.ZLB = new ZLB(xElement); break; case "ZPI": Header.ZPI = new ZPI(xElement); break; case "NTE": if (lastSignificantItem == "PID") { Patient.NTE.Add(new NTE(xElement)); } else if (lastSignificantItem == "MSH") { Header.NTE.Add(new NTE(xElement)); } else { currentOrder.NTE.Add(new NTE(xElement)); } break; case "DG1": Patient.DG1.Add(new DG1(xElement)); break; case "SFT": Header.SFT.Add(new SFT(xElement)); break; // ReSharper disable once RedundantEmptySwitchSection default: break; } } } Orders.Add(currentOrder); }