private PatientDemoCondensed ConvertFileStringToPatientInfoSegments(string fileContent) { var message = Message.Parse(fileContent); try { _pV1 = message.Segments.FirstOrDefault(x => x.Type == "PV1"); _pId = message.Segments.FirstOrDefault(x => x.Type == "PID"); _oBr = message.Segments.FirstOrDefault(x => x.Type == "OBR"); _iN1 = message.Segments.FirstOrDefault(x => x.Type == "IN1"); var patientInfo = new PatientDemoCondensed { AccessionId = _pV1.Field(19)?.Value, FullName = _pId.Field(5).Value.Replace('^', ' '), Address1 = _pId.Field(11).Value?.Split('^')[0], Address2 = _pId.Field(11).Value?.Split('^')[1], City = _pId.Field(11).Value?.Split('^')[2], WorkZip = _pId.Field(11).Value?.Split('^').Last(), BirthDate = _pId.Field(7)?.Value, Gender = _pId.Field(8)?.Value[0], PhoneHome = _pId.Field(13)?.Value?.Split('^')[0], Ssn = _pId.Field(19)?.Value, ZipCode = _pId.Field(11).Value?.Split('^').Last(), LocationCode = ReArrangeLocationCode(_pV1.Field(3)?.Value), MedicalRecord = _pId.Field(2)?.Value, ProviderCode = _pV1.Field(7)?.Value.Split('^')[0], ReferringPhys = _oBr?.Field(16).Value .Split('^').LastOrDefault(), InsuranceCode = _iN1.Field(3)?.Value, InsPolicy = _iN1.Field(36)?.Value, InsPolicyStatus = "P", InsRelationShip = _iN1.Field(17)?.Value }; return(patientInfo); } catch (Exception e) { Console.WriteLine(e); throw; } }