public Bed(Transfer transfer, Patient patient, Visit visit) { FromDate = transfer.FromDate; Pending = transfer.Pending; CampusId = transfer.CampusId; WardId = transfer.WardId; RoomId = transfer.RoomId; BedId = transfer.BedId; PriorCampusId = transfer.PriorCampusId; PriorWardId = transfer.PriorWardId; PriorRoomId = transfer.PriorRoomId; PriorBedId = transfer.PriorBedId; TemporaryLocation = transfer.TemporaryLocation; LocationStatus = transfer.LocationStatus; PriorLocationStatus = transfer.PriorLocationStatus; ConsultingDoctor = transfer.ConsultingDoctor; DepartmentId = transfer.DepartmentId; DepartmentType = transfer.DepartmentType; FinancialClass = transfer.FinancialClass; FinancialClassFromDate = transfer.FinancialClassFromDate; RoomAsked = transfer.RoomAsked; RoomAssigned = transfer.RoomAssigned; PatientId = patient.Id; PatientLastName = patient.LastName; PatientFirstName = patient.FirstName; PatientBirthDate = patient.BirthDate; PatientSex = patient.Sex; VisitId = visit.Id; PendingAdmission = visit.Pending; PatientClass = visit.PatientClass; AdmissionType = visit.AdmissionType; AdmissionDate = visit.AdmissionDate; DischargeDate = visit.DischargeDate; PendingDischarge = visit.PendingDischarge; }
async Task ProcessPID(string segment) { var fields = segment.Split(fieldSep); var patientId = GetValueFromField(fields.ElementAtOrDefault(3)); //A99 P01 P05 patient = await httpClient.GetAsync<Patient>(string.Format(patientUri, patientId)).ConfigureAwait(false); if (patient == null) patient = new Patient() { Id = patientId }; patient.ExternalId = GetValueFromField(fields.ElementAtOrDefault(2)); patient.LastName = GetValueFromField(fields.ElementAtOrDefault(5)); //A99 P01 P05 patient.FirstName = GetValueFromField(fields.ElementAtOrDefault(5), componentIndex: 1); ////A99 P01 P05 patient.Title = GetValueFromField(fields.ElementAtOrDefault(5), componentIndex: 4); ////A99 P01 P05 patient.PartnerLastName = GetValueFromField(fields.ElementAtOrDefault(6)); //A99 P01 P05 patient.PartnerFirstName = GetValueFromField(fields.ElementAtOrDefault(6), componentIndex: 1); //A99 P01 P05 patient.BirthDate = GetValueFromField(fields.ElementAtOrDefault(7)).ToNullableDatetime("yyyyMMdd", "yyyyMMddHHmmss", "dd/MM/yyyy"); //A99 P01 P05 if ((new string[] { "A01", "A04", "A05", "A08", "A14" }).Contains(eventType)) patient.Sex = GetValueFromField(fields.ElementAtOrDefault(8)); if ((new string[] { "A01", "A04", "A05", "A08", "A14", "A28", "A31", "A14" }).Contains(eventType)) { var street = GetValueFromField(fields.ElementAtOrDefault(11)); var city = GetValueFromField(fields.ElementAtOrDefault(11), componentIndex: 2); var postalCode = GetValueFromField(fields.ElementAtOrDefault(11), componentIndex: 4); var countryCode = GetValueFromField(fields.ElementAtOrDefault(11), componentIndex: 5); if (!string.IsNullOrEmpty(street) || !string.IsNullOrEmpty(city) || !string.IsNullOrEmpty(postalCode) || !string.IsNullOrEmpty(countryCode)) patient.Address = new Address() { Street = street, City = city, PostalCode = postalCode, CountryCode = countryCode }; } if ((new string[] { "A01", "A04", "A05", "A08", "A14", "A28", "A31" }).Contains(eventType)) { patient.Phones = null; patient.MobilePhones = null; patient.Faxes = null; patient.Emails = null; foreach (var repetition in fields.ElementAtOrDefault(13).Split(repetitionSep)) { switch (GetValueFromField(repetition, componentIndex: 2)) { case "PH": if (patient.Phones == null) patient.Phones = new List<string>(); patient.Phones.Add(GetValueFromField(repetition)); break; case "CP": if (patient.MobilePhones == null) patient.MobilePhones = new List<string>(); patient.MobilePhones.Add(GetValueFromField(repetition)); break; case "FX": if (patient.Faxes == null) patient.Faxes = new List<string>(); patient.Faxes.Add(GetValueFromField(repetition)); break; } var email = GetValueFromField(repetition, componentIndex: 3); if (!string.IsNullOrEmpty(email)) { if (patient.Emails == null) patient.Emails = new List<string>(); patient.Emails.Add(email); } } } patient.Language = GetValueFromField(fields.ElementAtOrDefault(15)); //A99 if ((new string[] { "A28", "A31" }).Contains(eventType)) patient.SpokenLanguage = GetValueFromField(fields.ElementAtOrDefault(15), componentIndex: 4); if ((new string[] { "A01", "A04", "A05", "A08" }).Contains(eventType)) patient.MaritalStatus = GetValueFromField(fields.ElementAtOrDefault(16)); if ((new string[] { "A01", "A04", "A05", "A08" }).Contains(eventType)) patient.SSNNumber = GetValueFromField(fields.ElementAtOrDefault(20)); if ((new string[] { "A01", "A04", "A05", "A08" }).Contains(eventType)) patient.MotherId = GetValueFromField(fields.ElementAtOrDefault(21)); if ((new string[] { "A01", "A04", "A05", "A08" }).Contains(eventType)) patient.Nationality = GetValueFromField(fields.ElementAtOrDefault(26)); patient.DeathDate = GetValueFromField(fields.ElementAtOrDefault(29)).ToNullableDatetime("yyyyMMdd", "yyyyMMddHHmmss", "dd/MM/yyyy"); //A99 }
async Task ProcessMRG(string segment) { var fields = segment.Split(fieldSep); var priorPatientId = GetValueFromField(fields.ElementAtOrDefault(1)); var priorPatient = new Patient() { Id = priorPatientId, MergedWithId = patient.Id }; await httpClient.PutAsync<Patient>(string.Format(patientUri, priorPatientId), priorPatient).ConfigureAwait(false); //await httpClient.DeleteAsync(string.Format(patientUri, priorPatientId)).ConfigureAwait(false); //update all visits var result = await httpClient.GetAsync<Adt.CouchDb.Result<Visit>>(string.Format(visitsByPatientIdUri, priorPatientId)).ConfigureAwait(false); if (result != null) { var visits = (from row in result.rows select row.doc); foreach (var visit in visits) { visit.PatientId = patient.Id; await StoreVisit(visit).ConfigureAwait(false); } } //do not store the patient patient = null; }