Esempio n. 1
0
        public static void AddImagingServiceRequest(this MWLDataset ds, Patient patient, ImagingServiceRequest request)
        {
            MWLDataset.ImagingServiceRequestRow ir = ds.ImagingServiceRequest.NewImagingServiceRequestRow();

            request.CopyTo <MWLDataset.ImagingServiceRequestRow>(ir);
            ir.PatientID         = patient.PatientID;
            ir.IssuerOfPatientID = patient.IssuerOfPatientID;
            ds.ImagingServiceRequest.AddImagingServiceRequestRow(ir);
        }
Esempio n. 2
0
        public void UpdateImagingServiceRequest(string accessionNumber, string patientID, string issuerOfPatientID, ImagingServiceRequest request)
        {
            ImagingServiceRequest srcRequest = new ImagingServiceRequest()
            {
                AccessionNumber = accessionNumber
            };
            Patient patient = new Patient()
            {
                PatientID = patientID, IssuerOfPatientID = issuerOfPatientID
            };

            Guard.ArgumentNotNullOrEmpty(request.AccessionNumber, "AccessionNumber");
            Guard.ArgumentNotNullOrEmpty(patientID, "patientID");
            Guard.ArgumentNotNullOrEmpty(issuerOfPatientID, "issuerOfPatientID");

            //
            // Check to see if the accesion number exists
            //
            if (accessionNumber.ToLower() != request.AccessionNumber.ToLower())
            {
                using (MWLDataset ds = DB.DataAccess.Find(new ImagingServiceRequest()
                {
                    AccessionNumber = request.AccessionNumber
                }))
                {
                    if (ds != null && ds.ImagingServiceRequest.Rows.Count > 0)
                    {
                        throw new Exception("Primary key violation. Accession number already exist.");
                    }
                }
            }

            using (MWLDataset ds = DB.DataAccess.Find(patient, srcRequest))
            {
                if (ds != null && ds.ImagingServiceRequest.Rows.Count > 0)
                {
                    MWLDataset.ImagingServiceRequestRow row = ds.ImagingServiceRequest.Rows[0] as MWLDataset.ImagingServiceRequestRow;

                    row.Update(request);
                    DB.DataAccess.UpdateMWL(ds);
                }
                else
                {
                    throw new Exception("Imaging service request not found");
                }
            }
        }
Esempio n. 3
0
        /// <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");
                }
            }
        }