public void UpdatePatient(string origPatientId, string origIssuerOfPatientId, WCFPatient patient) { WCFPatient srchPatient = new WCFPatient() { PatientID = origPatientId, IssuerOfPatientID = origIssuerOfPatientId }; Guard.ArgumentNotNullOrEmpty(patient.PatientID, "PatientID"); Guard.ArgumentNotNullOrEmpty(patient.IssuerOfPatientID, "IssuerOfPatientID"); Guard.ArgumentNotNullOrEmpty(patient.PatientNameFamilyName + patient.PatientNameGivenName + patient.PatientNameMiddleName, "Patient Name"); using (MWLDataset ds = DB.DataAccess.Find(srchPatient)) { if (ds != null && ds.Patient.Rows.Count > 0) { MWLDataset.PatientRow row = ds.Patient.Rows[0] as MWLDataset.PatientRow; row.Update(patient); DB.DataAccess.UpdateMWL(ds); } else { throw new Exception("Patient id not found"); } } }
/// <summary> /// Adds the patient. /// </summary> /// <param name="ds">The ds.</param> /// <param name="patient">The patient.</param> public static void AddPatient(this MWLDataset ds, WCFPatient patient) { MWLDataset.PatientRow pr = ds.Patient.NewPatientRow(); MWLDataset.VisitRow vr = ds.Visit.NewVisitRow(); MWLDataset.ImagingServiceRequestRow isrr = ds.ImagingServiceRequest.NewImagingServiceRequestRow(); MWLDataset.RequestedProcedureRow rpr = ds.RequestedProcedure.NewRequestedProcedureRow(); MWLDataset.ScheduledProcedureStepRow spsr = ds.ScheduledProcedureStep.NewScheduledProcedureStepRow(); MWLDataset.ScheduledStationAETitlesRow ssaetr = ds.ScheduledStationAETitles.NewScheduledStationAETitlesRow(); Random rnd = new Random(); string AccessionNumber = rnd.Next(100000000, 999999999).ToString() + "." + DateTime.Now.ToString("ssfff"); string ReferDrLastName = "N/A"; string ReferDrFirstName = "N/A"; string modality = "IO"; string[] Accessions = DB.DataAccess.GetAccessionNumbers(patient.PatientID, patient.IssuerOfPatientID); if (Accessions.Length < 1) { patient.CopyTo <MWLDataset.PatientRow>(pr); if (patient.LastMenstrualDate.HasValue) { pr.LastMenstrualDate = patient.LastMenstrualDate.Value.Date1.ToDateTime(); } if (patient.PatientBirthDate.HasValue) { pr.PatientBirthDate = patient.PatientBirthDate.Value.Date1.ToDateTime(); } if (!patient.PregnancyStatus.IsNullOrEmpty()) { switch (patient.PregnancyStatus.ToLower()) { case "not pregnant": pr.PregnancyStatus = 1; break; case "possibly pregnant": pr.PregnancyStatus = 2; break; case "definitely pregnant": pr.PregnancyStatus = 3; break; case "unknown": pr.PregnancyStatus = 4; break; default: pr.PregnancyStatus = 0; break; } } pr.IssuerOfPatientID = patient.IssuerOfPatientID; ds.Patient.AddPatientRow(pr); } else { LogMessage(Logger.Global, LogType.Information, "Patient <" + patient.PatientID + "> already exists."); } if (patient.MedicalAlerts != null) { foreach (string ma in patient.MedicalAlerts) { MWLDataset.MedicalAlertsRow mar = ds.MedicalAlerts.NewMedicalAlertsRow(); mar.MedicalAlert = ma; mar.PatientID = patient.PatientID; mar.IssuerOfPatientID = patient.IssuerOfPatientID; ds.MedicalAlerts.AddMedicalAlertsRow(mar); } } if (patient.ContrastAllergies != null) { foreach (string ca in patient.ContrastAllergies) { MWLDataset.ContrastAllergiesRow car = ds.ContrastAllergies.NewContrastAllergiesRow(); car.ContrastAllergy = ca; car.PatientID = patient.PatientID; car.IssuerOfPatientID = patient.IssuerOfPatientID; ds.ContrastAllergies.AddContrastAllergiesRow(car); } } if (patient.OtherPatientIDs != null) { foreach (string id in patient.OtherPatientIDs) { MWLDataset.OtherPatientIDsRow oir = ds.OtherPatientIDs.NewOtherPatientIDsRow(); oir.OtherPatientID = id; oir.PatientID = patient.PatientID; oir.IssuerOfPatientID = patient.IssuerOfPatientID; ds.OtherPatientIDs.AddOtherPatientIDsRow(oir); } } //Start Insert of Remaining Tables needed for MWL if (AccessionNumber != null) { if (Accessions.Length < 1) { //Insert Visit vr.AdmissionID = AccessionNumber; vr.CurrentPatientLocation = "MEDICAL"; ds.Visit.AddVisitRow(vr); //Insert ImagingServiceRequest isrr.AccessionNumber = AccessionNumber; isrr.PatientID = patient.PatientID; isrr.IssuerOfPatientID = patient.IssuerOfPatientID; isrr.RequestingPhysicianFamilyName = ReferDrLastName; isrr.RequestingPhysicianGivenName = ReferDrFirstName; isrr.ReferringPhysicianFamilyName = ReferDrLastName; isrr.ReferringPhysicianGivenName = ReferDrFirstName; ds.ImagingServiceRequest.AddImagingServiceRequestRow(isrr); //Insert RequestedProcedure rpr.AccessionNumber = AccessionNumber; rpr.RequestedProcedureID = AccessionNumber; rpr.StudyInstanceUID = "1.2.840.114257.15.400000.2." + DateTime.Now.ToString("hhmmss") + patient.PatientID + DateTime.Now.ToString("yyyyMMdd"); rpr.RequestedProcedureDescription = "MEDICAL"; rpr.RequestedProcedurePriority = "MED"; rpr.AdmissionID = AccessionNumber; ds.RequestedProcedure.AddRequestedProcedureRow(rpr); //Insert ScheduledProcedureStep spsr.ScheduledProcedureStepID = AccessionNumber; spsr.AccessionNumber = AccessionNumber; spsr.RequestedProcedureID = AccessionNumber; spsr.ScheduledProcedureStepLocation = "MEDICAL"; spsr.ScheduledProcedureStepStartDate_Time = DateTime.Now; spsr.ScheduledPerformingPhysicianNameFamilyName = ReferDrLastName; spsr.ScheduledPerformingPhysicianNameGivenName = ReferDrFirstName; spsr.Modality = modality; spsr.ScheduledProcedureStepDescription = "MEDICAL"; ds.ScheduledProcedureStep.AddScheduledProcedureStepRow(spsr); //Insert ScheduledStationAETitles ssaetr.ScheduledProcedureStepID = AccessionNumber; ssaetr.ScheduledStationAETitle = patient.ScheduledStationAE; ds.ScheduledStationAETitles.AddScheduledStationAETitlesRow(ssaetr); LogMessage(Logger.Global, LogType.Information, "Patient <" + patient.PatientID + "> was added"); } } }
public static void AddPatient(this MWLDataset ds, WorklistPatient patient) { MWLDataset.PatientRow pr = ds.Patient.NewPatientRow(); patient.CopyTo <MWLDataset.PatientRow>(pr); if (patient.LastMenstrualDate.HasValue) { pr.LastMenstrualDate = patient.LastMenstrualDate.Value.Date1.ToDateTime(); } if (patient.PatientBirthDate.HasValue) { pr.PatientBirthDate = patient.PatientBirthDate.Value.Date1.ToDateTime(); } if (!string.IsNullOrEmpty(patient.PregnancyStatus)) { switch (patient.PregnancyStatus.ToLower()) { case "not pregnant": pr.PregnancyStatus = 1; break; case "possibly pregnant": pr.PregnancyStatus = 2; break; case "definitely pregnant": pr.PregnancyStatus = 3; break; case "unknown": pr.PregnancyStatus = 4; break; default: pr.PregnancyStatus = 0; break; } } ds.Patient.AddPatientRow(pr); /*if (patient.MedicalAlerts != null) * { * foreach (string ma in patient.MedicalAlerts) * { * MWLDataset.MedicalAlertsRow mar = ds.MedicalAlerts.NewMedicalAlertsRow(); * * mar.MedicalAlert = ma; * mar.PatientID = patient.PatientID; * mar.IssuerOfPatientID = patient.IssuerOfPatientID; * ds.MedicalAlerts.AddMedicalAlertsRow(mar); * } * } * * if (patient.ContrastAllergies != null) * { * foreach (string ca in patient.ContrastAllergies) * { * MWLDataset.ContrastAllergiesRow car = ds.ContrastAllergies.NewContrastAllergiesRow(); * * car.ContrastAllergy = ca; * car.PatientID = patient.PatientID; * car.IssuerOfPatientID = patient.IssuerOfPatientID; * ds.ContrastAllergies.AddContrastAllergiesRow(car); * } * } * * if (patient.OtherPatientIDs != null) * { * foreach (string id in patient.OtherPatientIDs) * { * MWLDataset.OtherPatientIDsRow oir = ds.OtherPatientIDs.NewOtherPatientIDsRow(); * * oir.OtherPatientID = id; * oir.PatientID = patient.PatientID; * oir.IssuerOfPatientID = patient.IssuerOfPatientID; * ds.OtherPatientIDs.AddOtherPatientIDsRow(oir); * } * }*/ }