public void CanInsertNewPatientRecord() { var name = new PersonName(); name.FirstName = "Thomas"; name.LastName = "Chapman"; name.MiddleName = "C"; var newDiagnosis1 = new Diagnosis(); newDiagnosis1.SetId = 9998; newDiagnosis1.DiagnosisDateTime = DateTime.Now; newDiagnosis1.Description = "Test Diagnosis 1"; newDiagnosis1.Clinician = "Dr. Test"; var newDiagnosis2 = new Diagnosis(); newDiagnosis2.SetId = 9998; newDiagnosis2.DiagnosisDateTime = DateTime.Now; newDiagnosis2.Description = "Test Diagnosis 2"; newDiagnosis2.Clinician = "Dr. Assert"; var newPatientVisit = new PatientVisit(); newPatientVisit.SetId = 9998; newPatientVisit.Location.Bed = "1"; newPatientVisit.Location.Building = "5"; newPatientVisit.Location.Facility = "UMC"; newPatientVisit.Location.Floor = "2"; newPatientVisit.Location.LocationDescription = "General"; newPatientVisit.Location.LocationStatus = "Active"; newPatientVisit.Location.Room = "2112"; var newPatient = new Patient(); newPatient.ExternalPatientId = "123456789"; newPatient.InternalPatientId = "987654321"; newPatient.Address.Address1 = "1917 Churchill Downs"; newPatient.Address.Address2 = ""; newPatient.Address.City = "Lebanon"; newPatient.Address.State = "TN"; newPatient.Address.PostalCode = "37087"; newPatient.Gender = "M"; newPatient.DateOfBirth = Convert.ToDateTime("11/23/1976"); newPatient.PrimaryPhoneNumber.AreaCode = "615"; newPatient.PrimaryPhoneNumber.CountryCode = "1"; newPatient.PrimaryPhoneNumber.LineNumber = "496-4071"; newPatient.Names.Add(name); newPatient.Diagnosis.Add(newDiagnosis1); newPatient.Diagnosis.Add(newDiagnosis2); newPatient.PatientVisit.Add(newPatientVisit); IHL7UnitOfWork uow = new HL7UnitOfWork(); uow.Patients.Add(newPatient); uow.Commit(); Assert.IsTrue(true); }
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); }