/// <summary> /// Returns true when the settings of the other study will produce the same output. /// This function assumes the other settings refer to the same clinical study /// </summary> /// <param name="other"></param> /// <returns></returns> internal bool IsCompatible(StudySettings other) { if (other == null) { return(false); } return(this.Cumulative == other.Cumulative && this.SubjectCTCorrelation == other.SubjectCTCorrelation && this.ScatterPlot == other.ScatterPlot && this.Demographictable == other.ScatterPlot && this.UseEx == other.UseEx && this.UseExRef == other.UseExRef && this.UseSuppdm == other.UseSuppdm && this.DisablePcCleanup == other.DisablePcCleanup && this.UseCustomArms == other.UseCustomArms && this.UseCustomPcPctptnum == other.UseCustomPcPctptnum && this.UseCustomPcVisit == other.UseCustomPcVisit && this.UseCustomPpVisit == other.UseCustomPpVisit && this.ArmsCompatible(this.ArmMappings, other.ArmMappings) && this.ValuesCompatible(this.PcVisitMappings, other.PcVisitMappings) && this.ValuesCompatible(this.PpVisitMappings, other.PpVisitMappings) && this.ValuesCompatible(this.PcPctptnumMappings, other.PcPctptnumMappings) && this.DomainsCompatible(this.StudyMappings, other.StudyMappings) && this.CohortsCompatible(this.Cohorts, other.Cohorts)); }
/// <summary> /// Start initialization of a study in the backend and return the job id /// </summary> /// <param name="submissionId"></param> /// <param name="supplementNumber"></param> /// <param name="studyCode"></param> /// <returns></returns> public string Initialize(string submissionId, string supplementNumber, string studyCode) { string studyFolder = getStudyFolder(submissionId, supplementNumber, studyCode).FullName; int hash = StudySettings.GetFilesHash(studyFolder); // Run the 'RunMappings' stored procedure in the SAS server. This procedure will extract // The variables and make the initial mappings for the user to review. return(SasClientObject.NewJob("RunStudyMappings", new { StudyFolder = studyFolder, NdaHash = hash }).ToString()); }
/// <summary> /// Poll the server for the results of a study initialization /// </summary> /// <param name="submissionId"></param> /// <param name="supplementNumber"></param> /// <param name="studyCode"></param> /// <param name="jobId"></param> /// <returns></returns> public JobResponse <StudySettings> GetInitializationResult(string submissionId, string supplementNumber, string studyCode, string jobId) { var response = SasClientObject.Getjob(new Guid(jobId)); // If no data was received the process is still running, return an empty list if (response.Status != SasJobs.Messages.StatusCode.Done) { var noDataResponse = new JobResponse <StudySettings>(response, null); // Give a better response when the process is stuck at 1% if (response.PercentComplete == 1) { noDataResponse.FeedbackMessage = String.Format(@"Determining file structure and study design for study {0}", studyCode); } return(noDataResponse); } // If no data was returned if (response.Data.Tables.Count == 0) { return(new JobResponse <StudySettings>(response, null)); } // Check if an error code was received var errorTable = response.Data.Tables["errorstudy"]; int errorCode = (errorTable != null && errorTable.Rows.Count > 0) ? Convert.ToInt32(errorTable.Rows[0]["error_code"]) : 0; // Retrieve datasets var rawStudies = response.Data.Tables["design"].AsEnumerable(); var mappings = response.Data.Tables["mapping"].AsEnumerable(); var arms = response.Data.Tables["arms"].AsEnumerable(); var ppvisit = response.Data.Tables["ppvisit"].AsEnumerable(); var pcvisit = response.Data.Tables["pcvisit"].AsEnumerable(); var fileVariables = response.Data.Tables["out"].AsEnumerable(); // Initialize study profile var study = new StudySettings { NDAName = submissionId, SupplementNumber = supplementNumber, StudyCode = studyCode, StudyError = errorCode }; // Retrieve study mapping information (FIXME simplify sas-C# interface) var studyRow = rawStudies.FirstOrDefault(); if (studyRow != null) { // study type study.StudyType = Convert.ToInt32(studyRow["Study_Type"]); // Arms study.Arms = arms.Where(arow => arow["Study_Code"].ToString().Equals(study.StudyCode)) .Select(arow => arow["arm"].ToString()).ToList(); // PP:Visit study.PpVisit = ppvisit.Where(pprow => pprow["Study_Code"].ToString().Equals(study.StudyCode)) .Select(pprow => pprow["visit"].ToString()).ToList(); // PC:Visit study.PcVisit = pcvisit.Where(pcrow => pcrow["Study_Code"].ToString().Equals(study.StudyCode)) .Select(pcrow => pcrow["visit"].ToString()).ToList(); // Mappings study.StudyMappings = mappings .Where(mrow => mrow["Study_Code"].ToString().Equals(study.StudyCode)) .GroupBy(mrow => mrow["Source"]).Select(mrows => new Domain { Type = mrows.First()["Source"].ToString(), DomainMappings = mrows.Select(mrow => new Mapping { FileVariable = mrow["File_Variable"].ToString(), SdtmVariable = mrow["SDTM_Variable"].ToString(), MappingQuality = Convert.ToInt32(mrow["Mapping_Quality"]) }).Where(m => m.MappingQuality >= 0).ToList(), // Filter out mappings with quality -1 (dummy mappings) // The way sas returns the data, the variables will be listed in the first table of the dataset. FileVariables = fileVariables.Where(frow => frow["study"].ToString().Equals(study.StudyCode) && frow["source"].Equals(mrows.First()["Source"])) .Select(frow => new FileVariable { Name = frow["variable"].ToString(), Description = frow["variableDescription"].ToString(), Label = String.Format("{0} - {1}", frow["variable"].ToString(), frow["variableDescription"].ToString()) }).ToList(), FileId = mrows.First()["Path"].ToString() }).ToList(); } // If no studies have been retrieved return null return(new JobResponse <StudySettings>(response, study)); }