Esempio n. 1
0
        public void UpdateRequestedProcedure(string accessionNumber, string requestedProcedureID, WCFRequestedProcedure procedure)
        {
            ImagingServiceRequest imgRequest = new ImagingServiceRequest()
            {
                AccessionNumber = accessionNumber
            };
            WCFRequestedProcedure reqProcedure = new WCFRequestedProcedure()
            {
                RequestedProcedureID = requestedProcedureID
            };

            Guard.ArgumentNotNullOrEmpty(accessionNumber, "accessionNumber");
            Guard.ArgumentNotNullOrEmpty(requestedProcedureID, "RequestedProcedureID");
            Guard.ArgumentNotNullOrEmpty(procedure.RequestedProcedureID, "RequestedProcedureID");
            //Guard.ArgumentNotNullOrEmpty(procedure.StudyInstanceUID, "StudyInstanceUID");
            //Guard.ArgumentNotNullOrEmpty(procedure.RequestedProcedureDescription, "RequestedProcedureDescription");
            using (MWLDataset ds = DB.DataAccess.Find(imgRequest, reqProcedure))
            {
                if (ds != null && ds.RequestedProcedure.Rows.Count > 0)
                {
                    MWLDataset.RequestedProcedureRow row = ds.RequestedProcedure.Rows[0] as MWLDataset.RequestedProcedureRow;

                    row.Update(procedure);
                    DB.DataAccess.UpdateMWL(ds);
                }
                else
                {
                    throw new Exception("Requested procedure not found");
                }
            }
        }
Esempio n. 2
0
        public static void AddRequestedProcedure(this MWLDataset ds, ImagingServiceRequest request, WorklistRequestedProcedure procedure)
        {
            MWLDataset.RequestedProcedureRow rpr = ds.RequestedProcedure.NewRequestedProcedureRow();

            ds.EnforceConstraints = false;
            procedure.CopyTo <MWLDataset.RequestedProcedureRow>(rpr);
            rpr.AccessionNumber = request.AccessionNumber;
            ds.RequestedProcedure.AddRequestedProcedureRow(rpr);
            if (procedure.RequestedProcedureCodeSequence != null)
            {
                MWLDataset.RequestedProcedureCodeSequenceRow row = ds.RequestedProcedureCodeSequence.NewRequestedProcedureCodeSequenceRow();

                procedure.RequestedProcedureCodeSequence.CopyTo <MWLDataset.RequestedProcedureCodeSequenceRow>(row);
                row.AccessionNumber      = request.AccessionNumber;
                row.RequestedProcedureID = procedure.RequestedProcedureID;
                ds.RequestedProcedureCodeSequence.AddRequestedProcedureCodeSequenceRow(row);
            }

            if (procedure.ReferencedStudySequence != null)
            {
                foreach (ReferencedStudySequence rs in procedure.ReferencedStudySequence)
                {
                    MWLDataset.ReferencedStudySequenceRow row = ds.ReferencedStudySequence.NewReferencedStudySequenceRow();

                    row.SetOrderNumberNull();
                    row.ReferencedSOPClassUID    = rs.ReferencedSOPClassUID;
                    row.ReferencedSOPInstanceUID = rs.ReferencedSOPInstanceUID;
                    row.RequestedProcedureID     = procedure.RequestedProcedureID;
                    row.AccessionNumber          = request.AccessionNumber;
                    ds.ReferencedStudySequence.AddReferencedStudySequenceRow(row);
                }
            }
        }
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");
                }
            }
        }