public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields() { IType hl7Type = new ExtendedPersonName { FamilyName = new FamilyName { Surname = "1" }, GivenName = "2", SecondAndFurtherGivenNamesOrInitialsThereof = "3", Suffix = "4", Prefix = "5", Degree = "6", NameTypeCode = "7", NameRepresentationCode = "8", NameContext = new CodedWithExceptions { Identifier = "9" }, NameValidityRange = new DateTimeRange { RangeStartDateTime = new DateTime(2020, 10, 10, 0, 0, 10) }, NameAssemblyOrder = "11", EffectiveDate = new DateTime(2020, 12, 12, 0, 0, 12), ExpirationDate = new DateTime(2020, 1, 13, 0, 0, 13), ProfessionalSuffix = "14", CalledBy = "15" }; string expected = "1^2^3^4^5^6^7^8^9^20201010000010^11^20201212000012^20200113000013^14^15"; string actual = hl7Type.ToDelimitedString(); Assert.Equal(expected, actual); }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } ExtendedPersonName x = (ExtendedPersonName)obj; return(base.Equals(obj) && (this.NameTypeCode == x.NameTypeCode) && (this.NameRepresentationCode == x.NameRepresentationCode)); }
public override ExtendedPersonName GetPatientName() { // Tennessee Health care only sends the first name, middle initial, and last name, in that order. // Since it is not the standard v2.3 format... ExtendedPersonName xpn = new ExtendedPersonName(); string fieldValue = GetField(5); xpn.GivenName = GetComponent(fieldValue, 0); xpn.MiddleNameOrInitial = GetComponent(fieldValue, 1); xpn.FamilyName = GetComponent(fieldValue, 2); return(xpn); }
public void GenericV23AdtA01MessagePatientIsDonaldDDuck() { MessageFactory messageFactory = new MessageFactory(); ExtendedPersonName expectedExtendedPersonName = new ExtendedPersonName() { GivenName = "DONALD", MiddleNameOrInitial = "D", FamilyName = "DUCK" }; Message newMessage = messageFactory.MakeMessage(TestMessages.GenericV23_ADT_A01); PID pidSegment = (PID)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PID); ExtendedPersonName actualExtendedPersonName = pidSegment.GetPatientName(); Assert.AreEqual(expectedExtendedPersonName, actualExtendedPersonName); }
public void USAHealthCareAdtA01MessagePatientIsBobaBountyhunterFett() { MessageFactory messageFactory = new MessageFactory(); ExtendedPersonName expectedExtendedPersonName = new ExtendedPersonName() { GivenName = "BOBA", MiddleNameOrInitial = "BOUNTYHUNTER", FamilyName = "FETT" }; Message newMessage = messageFactory.MakeMessage(TestMessages.USAHealthCare_ADT_A01); PID pidSegment = (PID)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PID); ExtendedPersonName actualExtendedPersonName = pidSegment.GetPatientName(); Assert.AreEqual(expectedExtendedPersonName, actualExtendedPersonName); }
public void TennesseeHealthSystemsAdtA01MessagePatientIsDarthAVader() { MessageFactory messageFactory = new MessageFactory(); ExtendedPersonName expectedExtendedPersonName = new ExtendedPersonName() { GivenName = "DARTH", MiddleNameOrInitial = "A", FamilyName = "VADER" }; Message newMessage = messageFactory.MakeMessage(TestMessages.TennesseeHealthSystems_ADT_A01); PID pidSegment = (PID)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PID); ExtendedPersonName actualExtendedPersonName = pidSegment.GetPatientName(); Assert.AreEqual(expectedExtendedPersonName, actualExtendedPersonName); }
public void TennesseeHealthCareAdtA01MessagePatientIsThomasCChapman() { MessageFactory messageFactory = new MessageFactory(); ExtendedPersonName expectedExtendedPersonName = new ExtendedPersonName() { GivenName = "THOMAS", MiddleNameOrInitial = "C", FamilyName = "CHAPMAN" }; Message newMessage = messageFactory.MakeMessage(TestMessages.TennesseeHealthCare_ADT_A01); PID pidSegment = (PID)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PID); ExtendedPersonName actualExtendedPersonName = pidSegment.GetPatientName(); Assert.AreEqual(expectedExtendedPersonName, actualExtendedPersonName); }
internal ExtendedPersonName GetExtendedPersonName(int fieldIndex) { ExtendedPersonName xpn = new ExtendedPersonName(); string fieldValue = GetField(fieldIndex); xpn.FamilyName = GetComponent(fieldValue, 0); xpn.GivenName = GetComponent(fieldValue, 1); xpn.MiddleNameOrInitial = GetComponent(fieldValue, 2); xpn.Suffix = GetComponent(fieldValue, 3); xpn.Prefix = GetComponent(fieldValue, 4); xpn.Degree = GetComponent(fieldValue, 5); xpn.NameTypeCode = GetComponent(fieldValue, 6); return(xpn); }
public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields() { IType expected = new ExtendedPersonName { FamilyName = new FamilyName { IsSubcomponent = true, Surname = "1" }, GivenName = "2", SecondAndFurtherGivenNamesOrInitialsThereof = "3", Suffix = "4", Prefix = "5", Degree = "6", NameTypeCode = "7", NameRepresentationCode = "8", NameContext = new CodedWithExceptions { IsSubcomponent = true, Identifier = "9" }, NameValidityRange = new DateTimeRange { IsSubcomponent = true, RangeStartDateTime = new DateTime(2020, 10, 10, 0, 0, 10) }, NameAssemblyOrder = "11", EffectiveDate = new DateTime(2020, 12, 12, 0, 0, 12), ExpirationDate = new DateTime(2020, 1, 13, 0, 0, 13), ProfessionalSuffix = "14", CalledBy = "15" }; IType actual = new ExtendedPersonName(); actual.FromDelimitedString("1^2^3^4^5^6^7^8^9^20201010000010^11^20201212000012^20200113000013^14^15"); expected.Should().BeEquivalentTo(actual); }
/// <inheritdoc/> public void FromDelimitedString(string delimitedString, Separators separators) { Separators seps = separators ?? new Separators().UsingConfigurationValues(); string[] segments = delimitedString == null ? Array.Empty <string>() : delimitedString.Split(seps.FieldSeparator, StringSplitOptions.None); if (segments.Length > 0) { if (string.Compare(Id, segments[0], true, CultureInfo.CurrentCulture) != 0) { throw new ArgumentException($"{ nameof(delimitedString) } does not begin with the proper segment Id: '{ Id }{ seps.FieldSeparator }'.", nameof(delimitedString)); } } PriorPatientIdentifierList = segments.Length > 1 && segments[1].Length > 0 ? segments[1].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(x, false, seps)) : null; PriorAlternatePatientId = segments.Length > 2 && segments[2].Length > 0 ? segments[2].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(x, false, seps)) : null; PriorPatientAccountNumber = segments.Length > 3 && segments[3].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(segments[3], false, seps) : null; PriorPatientId = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(segments[4], false, seps) : null; PriorVisitNumber = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(segments[5], false, seps) : null; PriorAlternateVisitId = segments.Length > 6 && segments[6].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeIdWithCheckDigit>(segments[6], false, seps) : null; PriorPatientName = segments.Length > 7 && segments[7].Length > 0 ? TypeSerializer.Deserialize <ExtendedPersonName>(segments[7], false, seps) : null; }
public static TSRDSO13 BuildDispense(string senderId = "LAB1", string senderFacility = "LAB", string receiverId = "DEST2", string receiverFacility = "DEST", string controlNr = "123456") { var result = new TSRDSO13(); // MSH segment result.MSH = new MSH(); result.MSH.SendingApplication_03 = new SendingApplication(); result.MSH.SendingApplication_03.NamespaceID_01 = senderId; result.MSH.SendingFacility_04 = new SendingFacility(); result.MSH.SendingFacility_04.NamespaceID_01 = senderFacility; result.MSH.ReceivingApplication_05 = new ReceivingApplication(); result.MSH.ReceivingApplication_05.NamespaceID_01 = receiverId; result.MSH.ReceivingFacility_06 = new ReceivingFacility(); result.MSH.ReceivingFacility_06.NamespaceID_01 = receiverFacility; result.MSH.DateTimeOfMessage_07 = DateTime.Now.Date.ToString("yyyyMMdd") + DateTime.Now.TimeOfDay.ToString("hhmm"); result.MSH.MessageType_09 = new MessageType(); result.MSH.MessageType_09.MessageCode_01 = "RDS"; result.MSH.MessageType_09.TriggerEvent_02 = "O13"; result.MSH.MessageType_09.MessageStructure_03 = "RDS_O13"; result.MSH.MessageControlID_10 = controlNr; result.MSH.ProcessingID_11 = new ProcessingID(); result.MSH.ProcessingID_11.ProcessingID_01 = "P"; result.MSH.VersionID_12 = new VersionID(); result.MSH.VersionID_12.VersionID_01 = "2.6"; // PID LOOP result.LoopPID = new Loop_PID_TSRDSO13(); // BEGIN PID LOOP // PID segment result.LoopPID.PID = new PID(); // Patient ID result.LoopPID.PID.PatientID_02 = new ExtendedCompositeIDWithCheckDigit(); result.LoopPID.PID.PatientID_02.IDNumber_01 = "0008064993"; result.LoopPID.PID.PatientID_02.AssigningAuthority_04 = new ExtendedAssigningAuthority(); result.LoopPID.PID.PatientID_02.AssigningAuthority_04.ExtendedAssigningAuthority01 = "ENT"; result.LoopPID.PID.PatientID_02.IdentifierTypeCode_05 = "PE"; result.LoopPID.PID.PatientID_02.EffectiveDate_07 = "20030806"; result.LoopPID.PID.PatientID_02.ExpirationDate_08 = "200507"; // Patient Identifier result.LoopPID.PID.PatientIdentifierList_03 = new List <ExtendedCompositeIDWithCheckDigit>(); var patientIdentifier1 = new ExtendedCompositeIDWithCheckDigit(); patientIdentifier1.IDNumber_01 = "0008064993"; patientIdentifier1.AssigningAuthority_04 = new ExtendedAssigningAuthority(); patientIdentifier1.AssigningAuthority_04.ExtendedAssigningAuthority01 = "PAT"; patientIdentifier1.IdentifierTypeCode_05 = "MR"; patientIdentifier1.AssigningFacility_06 = new AssigningFacility(); patientIdentifier1.AssigningFacility_06.NamespaceID_01 = "20030806"; patientIdentifier1.EffectiveDate_07 = "2005"; result.LoopPID.PID.PatientIdentifierList_03.Add(patientIdentifier1); // Patient Name result.LoopPID.PID.PatientName_05 = new List <ExtendedPersonName>(); var patientName1 = new ExtendedPersonName(); patientName1.FamilyName_01 = new FamilyName(); patientName1.FamilyName_01.Surname_01 = "SURNAME"; patientName1.Suffix_04 = "PATA"; patientName1.Prefix_05 = "AN"; result.LoopPID.PID.PatientName_05.Add(patientName1); // Patient Mothers Name result.LoopPID.PID.MothersMaidenName_06 = new List <ExtendedPersonName>(); var mothersMaidenName1 = new ExtendedPersonName(); mothersMaidenName1.FamilyName_01 = new FamilyName(); mothersMaidenName1.FamilyName_01.Surname_01 = "EVERYWOMEN"; mothersMaidenName1.GivenName_02 = "EVE"; mothersMaidenName1.SecondAndFurtherGivenNamesOrInitialsThereof_03 = "J"; result.LoopPID.PID.MothersMaidenName_06.Add(mothersMaidenName1); // DOB result.LoopPID.PID.DateTimeOfBirth_07 = "19471007"; // Sex result.LoopPID.PID.AdministrativeSex_08 = "F"; // Race result.LoopPID.PID.Race_10 = new List <GuarantorRace>(); var race1 = new GuarantorRace(); race1.GuarantorRace01 = "1016-5"; result.LoopPID.PID.Race_10.Add(race1); // Patient Address result.LoopPID.PID.PatientAddress_11 = new List <ExtendedAddress>(); var patientAddress1 = new ExtendedAddress(); patientAddress1.StreetAddress_01 = new StreetAddress(); patientAddress1.StreetAddress_01.StreetOrMailingAddress_01 = "2222HOMESTREET"; patientAddress1.City_03 = "HOUSTON"; patientAddress1.StateOrProvince_04 = "TX"; patientAddress1.ZipOrPostalCode_05 = "77030"; patientAddress1.Country_06 = "USA"; result.LoopPID.PID.PatientAddress_11.Add(patientAddress1); // Marital Status result.LoopPID.PID.MaritalStatus_16 = new GuarantorMaritalStatusCode(); result.LoopPID.PID.MaritalStatus_16.GuarantorMaritalStatusCode01 = "S"; // Patient Account Number result.LoopPID.PID.PatientAccountNumber_18 = new ExtendedCompositeIDWithCheckDigit(); result.LoopPID.PID.PatientAccountNumber_18.IDNumber_01 = "6045681"; result.LoopPID.PID.PatientAccountNumber_18.AssigningAuthority_04 = new ExtendedAssigningAuthority(); result.LoopPID.PID.PatientAccountNumber_18.AssigningAuthority_04.ExtendedAssigningAuthority01 = "PATA"; result.LoopPID.PID.PatientAccountNumber_18.IdentifierTypeCode_05 = "AN"; // END PID LOOP // Repeating ORC LOOP result.LoopORC = new List <Loop_ORC_TSRDSO13>(); // BEGIN ORC LOOP var orcLoop = new Loop_ORC_TSRDSO13(); // ORC Segment orcLoop.ORC = new ORC(); orcLoop.ORC.OrderControl_01 = "CH"; orcLoop.ORC.PlacerOrderNumber_02 = new ComprehensiveLocationIdentifier(); orcLoop.ORC.PlacerOrderNumber_02.EntityIdentifier_01 = "177A"; orcLoop.ORC.PlacerOrderNumber_02.NamespaceID_02 = "SMS"; orcLoop.ORC.OrderStatus_05 = "ER"; orcLoop.ORC.ResponseFlag_06 = "N"; orcLoop.ORC.QuantityTiming_07 = new List <Timingquantity>(); // Quantity Timing var quantityTiming1 = new Timingquantity(); // Quantity quantityTiming1.Quantity_01 = new Quantity(); quantityTiming1.Quantity_01.Quantity_01 = "1"; quantityTiming1.Quantity_01.Units_02 = new InternationalVersionID(); quantityTiming1.Quantity_01.Units_02.Identifier_01 = "1_2_1"; quantityTiming1.Quantity_01.Units_02.Text_02 = "1_2_2"; quantityTiming1.Quantity_01.Units_02.NameOfCodingSystem_03 = "ATC"; quantityTiming1.Quantity_01.Units_02.AlternateIdentifier_04 = "1_2_4"; quantityTiming1.Quantity_01.Units_02.AlternateText_05 = "1_2_5"; quantityTiming1.Quantity_01.Units_02.NameOfAlternate_06 = "C4"; // Interval quantityTiming1.Interval_02 = new Interval(); quantityTiming1.Interval_02.RepeatPattern_01 = "C"; quantityTiming1.Interval_02.ExplicitTimeInterval_02 = "2_2"; // Duration quantityTiming1.Duration_03 = "3"; // Start Date quantityTiming1.StartDateTime_04 = new ExpirationDate(); quantityTiming1.StartDateTime_04.Time_01 = "20160827"; quantityTiming1.StartDateTime_04.DegreeOfPrecision_02 = "4"; // End Date quantityTiming1.EndDateTime_05 = new ExpirationDate(); quantityTiming1.EndDateTime_05.Time_01 = "20160927"; quantityTiming1.EndDateTime_05.DegreeOfPrecision_02 = "5"; // Priority quantityTiming1.Priority_06 = "6"; // Condition quantityTiming1.Condition_07 = "7"; // Notes quantityTiming1.Text_08 = "D"; // Conjunction quantityTiming1.Conjunction_09 = "S"; // Order Sequence quantityTiming1.OrderSequencing_10 = new OrderSequencing(); quantityTiming1.OrderSequencing_10.SequenceResultsFlag_01 = "C"; quantityTiming1.OrderSequencing_10.PlacerOrderNumberEntityIdentifier_02 = "177C"; quantityTiming1.OrderSequencing_10.PlacerOrderNumberNamespaceID_03 = "SMS"; quantityTiming1.OrderSequencing_10.FillerOrderNumberEntityIdentifier_04 = "M"; quantityTiming1.OrderSequencing_10.FillerOrderNumberNamespaceID_05 = "P"; quantityTiming1.OrderSequencing_10.SequenceConditionValue_06 = "*ES+0M"; quantityTiming1.OrderSequencing_10.MaximumNumberOfRepeats_07 = "7"; quantityTiming1.OrderSequencing_10.PlacerOrderNumberUniversalID_08 = "T"; quantityTiming1.OrderSequencing_10.PlacerOrderNumberUniversalIDType_09 = "DNS"; quantityTiming1.OrderSequencing_10.FillerOrderNumberUniversalID_10 = "Y"; quantityTiming1.OrderSequencing_10.FillerOrderNumberUniversalIDType_11 = "DNS"; // Occurrence duration quantityTiming1.OccurrenceDuration_11 = new InternationalVersionID(); quantityTiming1.OccurrenceDuration_11.Identifier_01 = "C"; quantityTiming1.OccurrenceDuration_11.Text_02 = "11_2"; quantityTiming1.OccurrenceDuration_11.NameOfCodingSystem_03 = "CCC"; quantityTiming1.OccurrenceDuration_11.AlternateIdentifier_04 = "11_4"; quantityTiming1.OccurrenceDuration_11.AlternateText_05 = "11_5"; quantityTiming1.OccurrenceDuration_11.NameOfAlternate_06 = "CCC"; quantityTiming1.TotalOccurrences_12 = "12"; orcLoop.ORC.QuantityTiming_07.Add(quantityTiming1); orcLoop.ORC.Parent_08 = new EntityIdentifierPair(); orcLoop.ORC.Parent_08.PlacerAssignedIdentifier_01 = new ComprehensiveLocationIdentifier(); orcLoop.ORC.Parent_08.PlacerAssignedIdentifier_01.EntityIdentifier_01 = "177"; // BEGIN RXO LOOP orcLoop.LoopRXO = new Loop_RXO_TSRDSO13(); orcLoop.LoopRXO.RXO = new RXO(); orcLoop.LoopRXO.RXO.RequestedGiveCode_01 = new AssigningAgencyOrDepartment(); orcLoop.LoopRXO.RXO.RequestedGiveCode_01.Identifier_01 = "Requested"; orcLoop.LoopRXO.RXO.RequestedGiveAmountMinimum_02 = "125"; orcLoop.LoopRXO.RXO.RequestedGiveUnits_04 = new AssigningAgencyOrDepartment(); orcLoop.LoopRXO.RXO.RequestedGiveUnits_04.Identifier_01 = "ML"; orcLoop.LoopRXO.RXO.RequestedDosageForm_05 = new AssigningAgencyOrDepartment(); orcLoop.LoopRXO.RXO.RequestedDosageForm_05.Identifier_01 = "Requested Give Per"; orcLoop.LoopRXO.RXO.ProvidersPharmacyTreatmentInstructions_06 = new List <AssigningAgencyOrDepartment>(); var providerInstructions1 = new AssigningAgencyOrDepartment(); providerInstructions1.Identifier_01 = "H1"; orcLoop.LoopRXO.RXO.ProvidersPharmacyTreatmentInstructions_06.Add(providerInstructions1); // END RXO LOOP // RXD Segment orcLoop.RXD = new RXD(); orcLoop.RXD.DispenseSubIDCounter_01 = "4"; orcLoop.RXD.DispenseGiveCode_02 = new AdministeredCode(); orcLoop.RXD.DispenseGiveCode_02.AdministeredCode01 = "01"; orcLoop.RXD.DateTimeDispensed_03 = "20160927"; orcLoop.RXD.ActualDispenseAmount_04 = "5"; orcLoop.RXD.ActualDispenseUnits_05 = new AssigningAgencyOrDepartment(); orcLoop.RXD.ActualDispenseUnits_05.Identifier_01 = "D"; orcLoop.RXD.PrescriptionNumber_07 = "E"; // Repeating RXR Segments orcLoop.RXR = new List <RXR>(); // RXR Segment var rxr1 = new RXR(); rxr1.Route_01 = new Route(); rxr1.Route_01.Route01 = "PO"; orcLoop.RXR.Add(rxr1); result.LoopORC.Add(orcLoop); // END ORC LOOP return(result); }
public void ConsumeMessage_PersistPatientInfoToDatabase_RetrievePatientInfo_IsSuccess() { // Consume a message MessageFactory messageFactory = new MessageFactory(); Message newMessage = messageFactory.MakeMessage(TestMessages.TennesseeHealthCare_ADT_A01); // Parse some segments PID pidSegment = (PID)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PID); DG1 dg1Segment = (DG1)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.DG1); PV1 pv1Segment = (PV1)newMessage.Segments.Find(s => s.SegmentType == SegmentTypes.PV1); // Populate some models with the parsed data ExtendedPersonName patientExtendedPersonName = pidSegment.GetPatientName(); var name = new HL7Model.PersonName(); name.FirstName = patientExtendedPersonName.GivenName; name.LastName = patientExtendedPersonName.FamilyName; name.MiddleName = patientExtendedPersonName.MiddleNameOrInitial; var newDiagnosis1 = new HL7Model.Diagnosis(); newDiagnosis1.SetId = dg1Segment.GetSetId(); newDiagnosis1.DiagnosisDateTime = dg1Segment.GetDiagnosisDateTime(); newDiagnosis1.Description = dg1Segment.GetDiagnosisDescription(); newDiagnosis1.Clinician = dg1Segment.GetDiagnosingClinician(); PersonLocation patientLocation = pv1Segment.GetAssignedPatientLocation(); var newPatientVisit = new HL7Model.PatientVisit(); newPatientVisit.SetId = pv1Segment.GetSetID(); newPatientVisit.Location.Bed = patientLocation.Bed; newPatientVisit.Location.Building = patientLocation.Building; newPatientVisit.Location.Facility = patientLocation.Facility; newPatientVisit.Location.Floor = patientLocation.Floor; newPatientVisit.Location.LocationDescription = patientLocation.LocationDescription; newPatientVisit.Location.LocationStatus = patientLocation.LocationStatus; newPatientVisit.Location.Room = patientLocation.Room; Address patientAddress = pidSegment.GetPatientAddress(); PhoneNumber patientPhoneNumber = pidSegment.GetHomePhoneNumber(); var newPatient = new HL7Model.Patient(); newPatient.ExternalPatientId = pidSegment.GetExternalPatientId(); newPatient.InternalPatientId = pidSegment.GetInternalPatientId(); newPatient.Address.Address1 = patientAddress.Address1; newPatient.Address.Address2 = patientAddress.Address2; newPatient.Address.City = patientAddress.City; newPatient.Address.State = patientAddress.State; newPatient.Address.PostalCode = patientAddress.ZipCode; newPatient.Gender = pidSegment.GetGender(); newPatient.DateOfBirth = pidSegment.GetDateOfBirth(); newPatient.PrimaryPhoneNumber.AreaCode = patientPhoneNumber.AreaCode; newPatient.PrimaryPhoneNumber.CountryCode = patientPhoneNumber.CountryCode; newPatient.PrimaryPhoneNumber.LineNumber = patientPhoneNumber.LineNumber; newPatient.Names.Add(name); newPatient.Diagnosis.Add(newDiagnosis1); newPatient.PatientVisit.Add(newPatientVisit); // Commit the patient to the database IHL7UnitOfWork uow = new HL7UnitOfWork(); uow.Patients.Add(newPatient); uow.Commit(); // Retrieve the patient back from the database Patient patient = uow.Patients.GetPatientByExternalId(pidSegment.GetExternalPatientId()); // Assert that the data retrieved from the database is the same as what went in. Assert.AreEqual(pidSegment.GetInternalPatientId(), patient.InternalPatientId); Assert.AreEqual(patientExtendedPersonName.GivenName, patient.Names[0].FirstName); Assert.AreEqual(dg1Segment.GetDiagnosisDescription(), patient.Diagnosis[0].Description); Assert.AreEqual(patientLocation.Room, patient.PatientVisit[0].Location.Room); }