public void TestORMParse() { HL7_ORM _order = null; List <string> lMsg = InitializeORM; // we need to get the HL7 field separator and encoding characters _processHL7 = ProcessHL7Message.Instance; // HL7_ORM _order = (HL7_ORM)_processHL7.ParseHL7(slMsg: lMsg); object obj = _processHL7.ParseHL7(slMsg: lMsg); if (obj is HL7_ORM) { _order = (HL7_ORM)obj; } else { Assert.Fail("HL7 Message is not an ORM message type"); } if (IsHeaderValid(_order.HL7Header)) { Assert.Fail("MHS Header validation failed"); } // validate Patients if (IsPatientValid(_order.HL7Patient)) { Assert.Fail("Patient segment failed validation"); } // validate insurance segments if (IsPatientInsuranceValid(_order.HL7Patient)) { Assert.Fail("Insurance segment failed validation"); } if (_order.HL7Patient.NTESegments.Count > 0) { Assert.Fail("NTE segment failed validation"); } if (_order.HL7Orders == null) { Assert.Fail("Orders object is NULL"); } else { if (IsOrderValid(_order.HL7Orders)) { Assert.Fail("Order segments failee"); } } }
/// <summary> /// parseORM - parse the list into an HL7_ORM object /// <param name="slMsg">List<string>-List of HL7 Message</param> /// <returns>HL7_ORM</returns> /// </summary> public HL7_ORM ParseORM(List <string> slMsg) { HL7_ORM HL7ORM = new HL7_ORM(); List <ErrorMsg> lErrorMsg = new List <ErrorMsg>(); string sPrevSegment = GetEnumDescription(Segments.MSH); BuildHeader bldMsh = new BuildHeader(); try { HL7ORM.HL7Header = new BuildHeader().GetHeader(slMsg); HL7ORM.HL7Patient = new BuildPatient().GetPatient(HL7ORM.HL7Header.HL7Encoding, slMsg, HL7ORM.HL7Header.MSHSegment.MessageType); HL7ORM.HL7Orders = new BuildOrders().GetOrders(HL7ORM.HL7Header.HL7Encoding, slMsg); } catch (Exception ex) { lErrorMsg.Add(new ErrorMsg(1, slMsg.ToString() + " Exception: " + ex)); } //do we have errors ? if (lErrorMsg.Count > 0) { foreach (ErrorMsg err in lErrorMsg) { Console.WriteLine(string.Format("Error {0}: {1}", err.Code, err.Message)); } } if (HL7ORM.HL7Header.MSHSegment.Errors.Count > 0) { // display errors for the MSH segment foreach (var err in HL7ORM.HL7Header.MSHSegment.Errors) { Console.WriteLine("MSH segment processing errors"); Console.WriteLine(" Error: " + err); } } if (HL7ORM.HL7Header.NTESegments != null) { if (HL7ORM.HL7Header.MSHSegment.Errors.Count > 0) { // display errors for the MSH segment foreach (var err in HL7ORM.HL7Header.NTESegments) { Console.WriteLine("NTE segment processing errors"); Console.WriteLine(" Error: " + err); } } } return(HL7ORM); }