/// <summary> /// Find Direct <see cref="Context"/> /// </summary> /// <returns>A <see cref="Context"/> object if found. Null if not found. </returns> public static Context DirectContext(this MimeMessage message) { foreach (var mimeEntity in message.Attachments.Where(a => a is MimePart)) { if (mimeEntity.ContentId == message.DirectContextId()) { return(ContextParser.Parse(mimeEntity as MimePart, "1.0")); } } return(null); }
/// <summary> /// Parse Patient from patient-attributes. /// </summary> /// <param name="headerValue"></param> public Patient(string headerValue) { var patientAttributes = ContextParser.GetPatientAttributes(headerValue, ContextError.InvalidPatient); GivenName = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientGivenName)).Value; SurName = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientSurName)).Value; MiddleName = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientMiddleName)).Value; DateOfBirth = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientDateOfBirth)).Value; Gender = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientGender)).Value; SocialSecurityNumber = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientSocialSecurityNumber)).Value; TelephoneNumber = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientTelephoneNumber)).Value; StreetAddress = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientStreetAddress)).Value; PostalCode = patientAttributes.SingleOrDefault(p => p.Key.Equals(ContextStandard.Patient.PatientPostalCode)).Value; }
/// <summary> /// Find Direct <see cref="Context"/> by version. /// </summary> /// <param name="message"></param> /// <param name="version"></param> /// <returns></returns> public static MimePart DirectContext(this MimeMessage message, string version) { foreach (var mimeEntity in message.Attachments.Where(a => a is MimePart)) { if (mimeEntity.ContentId == message.DirectContextId()) { if (version == ContextParser.Version) { return(ContextParser.Parse(mimeEntity as MimePart, version)); } // // Future versions // } } return(null); }
internal static Dictionary <string, string> GetPatientAttributes(string value, ContextError error) { try { var parts = ContextParser.SplitField(value, error); var patientAttributes = new Dictionary <string, string>(); foreach (var part in parts) { var attribute = Split(part, new[] { '=' }, error); attribute[0].AssertEnum <ContextStandard.Patient.PatientParameter>(ContextError.InvalidPatient); patientAttributes.Add(attribute[0].Trim(), attribute[1].Trim()); } return(patientAttributes); } catch { throw new ContextException(error); } }