private CQLQueryResults getClinicalTrialProtocolCQLInfo(string endPointUrl) { object[] obj; CQLQueryResults result; Association assoTrialDataProvenance = null; Association assoClinicalTrialSubject = null; Association assoClinicalTrialSite = null; Association assoImage = null; Association assoSeries = null; Association assoStudy = null; Association assoPatient = null; var results = new ArrayList(); var proxy = new NCIACoreServicePortTypeClient(); proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(endPointUrl); var items = new[] { "protocolId", "protocolName" }; var itemsChoiceType1 = new[] { ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames }; assoImage = null; if (!_queryParameters.SliceThickness.IsEmpty) { var attrPatient = CreateAttribute("sliceThickness", _queryParameters.SliceThickness); var grpPatient = CreateQRAttrAssoGroup.createGroup(attrPatient, LogicalOperator.AND); assoImage = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Image", "imageCollection", grpPatient); } results = new ArrayList(); assoSeries = null; obj = null; if (assoImage != null) { results.Add(assoImage); } if (!_queryParameters.Modality.IsEmpty) { results.Add(CreateAttribute("modality", _queryParameters.Modality)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null) { var grpSeries = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoSeries = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Series", "seriesCollection", grpSeries); } obj = null; assoStudy = null; results = new ArrayList(); if (assoSeries != null) { results.Add(assoSeries); } if (!_queryParameters.StudyInstanceUID.IsEmpty) { results.Add(CreateAttribute("studyInstanceUID", _queryParameters.StudyInstanceUID)); } assoStudy = null; if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null) { var groupStudy = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoStudy = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Study", "studyCollection", groupStudy); } assoTrialDataProvenance = null; if (!_queryParameters.ProjectName.IsEmpty) { var attrTrialDataProvenance = CreateAttribute("project", _queryParameters.ProjectName); var grpTrialDataProvenance = CreateQRAttrAssoGroup.createGroup(attrTrialDataProvenance, LogicalOperator.AND); assoTrialDataProvenance = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.TrialDataProvenance", "dataProvenance", grpTrialDataProvenance); } obj = null; results = new ArrayList(); if (assoStudy != null) { results.Add(assoStudy); } if (assoTrialDataProvenance != null) { results.Add(assoTrialDataProvenance); } if (!_queryParameters.PatientBirthDate.IsEmpty) { results.Add(CreateAttribute("patientBirthDate", _queryParameters.PatientBirthDate)); } if (!_queryParameters.PatientId.IsEmpty) { results.Add(CreateAttribute("patientId", _queryParameters.PatientId)); } if (!_queryParameters.PatientName.IsEmpty) { results.Add(CreateAttribute("patientName", _queryParameters.PatientName)); } if (!_queryParameters.PatientSex.IsEmpty) { results.Add(CreateAttribute("patientSex", _queryParameters.PatientSex)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null) { var patientGroup = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoPatient = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Patient", "patient", patientGroup); } obj = null; results = new ArrayList(); if (!_queryParameters.SiteId.IsEmpty) { results.Add(CreateAttribute("siteId", _queryParameters.SiteId)); } if (!_queryParameters.SiteName.IsEmpty) { results.Add(CreateAttribute("siteName", _queryParameters.SiteName)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } Group grpClinicalTrialSite = null; if (obj != null) { grpClinicalTrialSite = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSite = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSite", "site", grpClinicalTrialSite); } results = new ArrayList(); if (assoClinicalTrialSite != null) { results.Add(assoClinicalTrialSite); } if (assoPatient != null) { results.Add(assoPatient); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); var grpClinicalTrialSubject = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSubject = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSubject", "subjectCollection", grpClinicalTrialSubject); } obj = null; results = new ArrayList(); if (assoClinicalTrialSubject != null) { results.Add(assoClinicalTrialSubject); } if (!_queryParameters.ProtocolId.IsEmpty) { results.Add(CreateAttribute("protocolId", _queryParameters.ProtocolId)); } if (!_queryParameters.ProtocolName.IsEmpty) { results.Add(CreateAttribute("protocolName", _queryParameters.ProtocolName)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } Group grpClinicalTrialProtocol = null; if (obj != null) { grpClinicalTrialProtocol = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); } var arg = CreateQRAttrAssoGroup.createQueryRequestCqlQuery("gov.nih.nci.ncia.domain.ClinicalTrialProtocol", items, itemsChoiceType1, null, grpClinicalTrialProtocol); var doc = XMLSerializingDeserializing.Serialize(arg); Console.WriteLine(doc.InnerXml); try { result = proxy.query(arg); } catch (System.Net.WebException ex) { Console.WriteLine(ex.Message); result = null; } catch (Exception e) { Console.WriteLine(e.Message); result = null; throw new GridServicerException("Error querying NCIA Grid", e); } return(result); }
protected Attribute CreateAttribute(string attributeName, QueryData queryData) { return(CreateQRAttrAssoGroup.createAttribute(attributeName, FromQueryPredicate(queryData.Predicate), queryData.SelectedValue)); }
private CQLQueryResults getStudyCQLInfo(string endPointUrl) { object[] obj; CQLQueryResults result; Association assoImage = null; Association assoTrialDataProvenance = null; Association assoSeries = null; Association assoClinicalTrialSite = null; Association assoClinicalTrialProtocol = null; Association assoClinicalTrialSubject = null; Association assoPatient = null; ArrayList results = new ArrayList(); NCIACoreServicePortTypeClient proxy = new NCIACoreServicePortTypeClient(); proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(endPointUrl); string[] items = new string[] { "additionalPatientHistory", "admittingDiagnosesCodeSequence", "occupation", "patientAge", "patientSize", "patientWeight", "studyDate", "studyId", "studyInstanceUID", "studyTime", "timePointDescription", "timePointId" }; ItemsChoiceType[] itemsChoiceType1 = new ItemsChoiceType[] { ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames }; // Image assoImage = null; if (!_queryParameters.SliceThickness.IsEmpty) { Attribute attrPatient = this.CreateAttribute("sliceThickness", _queryParameters.SliceThickness); Group grpPatient = CreateQRAttrAssoGroup.createGroup(attrPatient, LogicalOperator.AND); assoImage = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Image", "imageCollection", grpPatient); } // Series assoSeries = null; obj = null; results = new ArrayList(); if (assoImage != null) { results.Add(assoImage); } if (!_queryParameters.Modality.IsEmpty) { results.Add(this.CreateAttribute("modality", _queryParameters.Modality)); } if (results.Count > 0 || assoImage != null) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { Group grpSeries = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoSeries = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Series", "seriesCollection", grpSeries); } // TrialDataProvenance assoTrialDataProvenance = null; if (!_queryParameters.ProjectName.IsEmpty) { Attribute attrTrialDataProvenance = this.CreateAttribute("project", _queryParameters.ProjectName); Group grpTrialDataProvenance = CreateQRAttrAssoGroup.createGroup(attrTrialDataProvenance, LogicalOperator.AND); assoTrialDataProvenance = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.TrialDataProvenance", "dataProvenance", grpTrialDataProvenance); } // ClinicalTrial Site assoClinicalTrialSite = null; obj = null; results = new ArrayList(); if (!_queryParameters.SiteId.IsEmpty) { results.Add(this.CreateAttribute("siteId", _queryParameters.SiteId)); } if (!_queryParameters.SiteName.IsEmpty) { results.Add(this.CreateAttribute("siteName", _queryParameters.SiteName)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { Group grpClinicalTrialSite = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSite = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSite", "site", grpClinicalTrialSite); } // ClinicalTrial Protocol assoClinicalTrialProtocol = null; obj = null; results = new ArrayList(); if (!_queryParameters.ProtocolId.IsEmpty) { results.Add(this.CreateAttribute("protocolId", _queryParameters.ProtocolId)); } if (!_queryParameters.ProtocolName.IsEmpty) { results.Add(this.CreateAttribute("protocolName", _queryParameters.ProtocolName)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { Group grpClinicalTrialProtocol = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialProtocol = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialProtocol", "protocol", grpClinicalTrialProtocol); } // Clinical Trial Subject obj = null; results = new ArrayList(); assoClinicalTrialSubject = null; if (assoClinicalTrialSite != null) { results.Add(assoClinicalTrialSite); } if (assoClinicalTrialProtocol != null) { results.Add(assoClinicalTrialProtocol); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { Group grpClinicalTrialSubject = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSubject = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSubject", "subjectCollection", grpClinicalTrialSubject); } // Patient obj = null; results = new ArrayList(); if (assoClinicalTrialSubject != null) { results.Add(assoClinicalTrialSubject); } if (assoTrialDataProvenance != null) { results.Add(assoTrialDataProvenance); } if (!_queryParameters.PatientBirthDate.IsEmpty) { results.Add(this.CreateAttribute("patientBirthDate", _queryParameters.PatientBirthDate)); } if (!_queryParameters.PatientId.IsEmpty) { results.Add(this.CreateAttribute("patientId", _queryParameters.PatientId)); } if (!_queryParameters.PatientName.IsEmpty) { results.Add(this.CreateAttribute("patientName", _queryParameters.PatientName)); } if (!_queryParameters.PatientSex.IsEmpty) { results.Add(this.CreateAttribute("patientSex", _queryParameters.PatientSex)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { Group patientGroup = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoPatient = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Patient", "patient", patientGroup); } // Study obj = null; results = new ArrayList(); Group groupStudy = null; if (assoSeries != null) { results.Add(assoSeries); } if (assoPatient != null) { results.Add(assoPatient); } if (!_queryParameters.StudyInstanceUID.IsEmpty) { results.Add(this.CreateAttribute("studyInstanceUID", _queryParameters.StudyInstanceUID)); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null && obj.Length > 0) { groupStudy = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); } QueryRequestCqlQuery arg = CreateQRAttrAssoGroup.createQueryRequestCqlQuery("gov.nih.nci.ncia.domain.Study", items, itemsChoiceType1, null, groupStudy); XmlDocument doc = XMLSerializingDeserializing.Serialize(arg); Console.WriteLine(((System.Xml.XmlDocument)((System.Xml.XmlNode)(doc))).InnerXml); try { result = proxy.query(arg); } catch (System.Net.WebException ex) { System.Console.WriteLine(ex.Message); result = null; } catch (Exception e) { System.Console.WriteLine(e.Message); result = null; throw new GridServicerException("Error querying NCIA Grid", e); } return(result); }