public object GetValueFor(ItemsChoiceType choice) { var idx = GetIndexFor(choice); if (idx == -1) return null; return Items[idx]; }
private int GetIndexFor(ItemsChoiceType choice) { for (int i = 0; i != ItemsElementName.Length; ++i) if (ItemsElementName[i] == choice) return i; return -1; }
protected virtual CodeExpression BuildConditionalExpression( conditionalContainer container, ItemsChoiceType choiceType) { //grab the children List<CodeExpression> children = new List<CodeExpression>(); for (int i = 0; i < container.Items.Length; i++) { if (container.Items[i] is conditionalContainer) { children.Add(BuildConditionalExpression((conditionalContainer)container.Items[i], container.ItemsElementName[i])); } else if (container.Items[i] is actionEquals) { children.Add(BuildConditionalExpression((actionEquals)container.Items[i])); } else if (container.Items[i] is valueEquals) { children.Add(BuildConditionalExpression((valueEquals)container.Items[i], container.ItemsElementName[i])); } else { throw new GatException("Unrecognized conditional item type: " + container.Items[i].GetType()); } } //get the full expression CodeExpression expr = null; if (choiceType == ItemsChoiceType.none) { expr = new CodeBinaryOperatorExpression(children[0], CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(false)); for (int i = 1; i < children.Count; i++) { expr = new CodeBinaryOperatorExpression(expr, CodeBinaryOperatorType.BooleanAnd, new CodeBinaryOperatorExpression(children[i], CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(false))); } } else if (choiceType == ItemsChoiceType.all || choiceType == ItemsChoiceType.any) { CodeBinaryOperatorType opType = choiceType == ItemsChoiceType.all ? CodeBinaryOperatorType.BooleanAnd : CodeBinaryOperatorType.BooleanOr; expr = children[0]; for (int i = 1; i < children.Count; i++) { expr = new CodeBinaryOperatorExpression(expr, CodeBinaryOperatorType.BooleanOr, children[i]); } } else { throw new GatException("Unrecognized choice type: " + choiceType); } return expr; }
public static QueryRequestCqlQuery createQueryRequestCqlQuery(string name, string[] queryModifierItems, ItemsChoiceType[] queryModifierItemsChoiceType1, Association targetAssociation, Group targetGroup) { QueryRequestCqlQuery arg = new QueryRequestCqlQuery(); arg.CQLQuery = new CQLQuery(); arg.CQLQuery.Target = new Object(); arg.CQLQuery.Target.name = name; if ((queryModifierItems != null) && (queryModifierItemsChoiceType1 != null)) { arg.CQLQuery.QueryModifier = new QueryModifier(); arg.CQLQuery.QueryModifier.countOnly = false; arg.CQLQuery.QueryModifier.Items = queryModifierItems; arg.CQLQuery.QueryModifier.ItemsElementName = queryModifierItemsChoiceType1; } if (targetAssociation != null) arg.CQLQuery.Target.Item = targetAssociation; else if (targetGroup != null) arg.CQLQuery.Target.Item = targetGroup; return arg; }
public static CQLQueryResults getAnnotationOfAnnotationInfo() { object[] obj; AIMTCGADataServicePortTypeClient proxy = new AIMTCGADataServicePortTypeClient(); string[] items = new string[] { "codeValue", "codeMeaning", "codingSchemeDesignator", "codingSchemeVersion", "annotatorConfidence" }; ItemsChoiceType[] itemsChoiceType1 = new ItemsChoiceType[] { ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames }; // Anatomic Entity obj = null; Attribute attrCodeValue = null; Attribute attrCodeMeaning = null; Attribute attrCodingSchemeDesignator = null; Attribute attrCodingSchemeVersion = null; Attribute attrAnnotatorConfidence = null; return null; }
public bool HasValueFor(ItemsChoiceType choice) { return GetValueFor(choice) != null; }
private int GetIndexOf(ItemsChoiceType type) { var index = ItemsElementName.Select((x, i) => Tuple.Create(x, i)).Where(x => x.Item1 == type).Select(x => x.Item2 + 1).SingleOrDefault() - 1; return index; }
protected virtual CodeExpression BuildConditionalExpression( valueEquals valEquals, ItemsChoiceType choiceType) { int regexIndex = -1; if (valEquals.regex) { regexIndex = _regexes.Count; _regexes.Add(valEquals.value); } if (choiceType == ItemsChoiceType.columnEquals) { if (!valEquals.regex) { //context.Columns.Contains(VALUE_LITERAL) return new CodeMethodInvokeExpression(new CodePropertyReferenceExpression( new CodeVariableReferenceExpression("context"), "Columns"), "Contains", new CodePrimitiveExpression(valEquals.value)); } else { //context.IsRegexColumnPresent(_regexes[REGEX_INDEX]) return new CodeMethodInvokeExpression(new CodeMethodReferenceExpression( new CodeVariableReferenceExpression("context"), "IsRegexColumnPresent"), new CodeArrayIndexerExpression(new CodeFieldReferenceExpression( null, "_regexes"), new CodePrimitiveExpression(regexIndex))); } } else if (choiceType == ItemsChoiceType.schemaEquals || choiceType == ItemsChoiceType.tableEquals) { CodePropertyReferenceExpression propRef; if (choiceType == ItemsChoiceType.schemaEquals) { propRef = new CodePropertyReferenceExpression( new CodeVariableReferenceExpression("context"), "Schema"); } else { propRef = new CodePropertyReferenceExpression( new CodeVariableReferenceExpression("context"), "Table"); } if (!valEquals.regex) { //VALUE_LITERAL.Equals(context.Schema/Table) return new CodeMethodInvokeExpression(new CodeMethodReferenceExpression( new CodePrimitiveExpression(valEquals.value), "Equals"), propRef); } else { //_regexes[REGEX_INDEX].IsMatch(context.Schema/Table) return new CodeMethodInvokeExpression(new CodeMethodReferenceExpression( new CodeArrayIndexerExpression(new CodeFieldReferenceExpression(null, "_regexes"), new CodePrimitiveExpression(regexIndex)), "IsMatch"), propRef); } } else { throw new GatException("Unrecognized choice type: " + choiceType); } }
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; ArrayList results = new ArrayList(); NCIACoreServicePortTypeClient proxy = new NCIACoreServicePortTypeClient(); proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(endPointUrl); string[] items = new string[] { "protocolId", "protocolName" }; ItemsChoiceType[] itemsChoiceType1 = new ItemsChoiceType[] { 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 results = new ArrayList(); assoSeries = null; obj = null; if (assoImage != null) results.Add(assoImage); if (!_queryParameters.Modality.IsEmpty) results.Add(this.CreateAttribute("modality", _queryParameters.Modality)); if (results.Count > 0) obj = (object[])results.ToArray(typeof(object)); if (obj != null) { Group grpSeries = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoSeries = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Series", "seriesCollection", grpSeries); } // Study obj = null; assoStudy = null; results = new ArrayList(); if (assoSeries != null) results.Add(assoSeries); if (!_queryParameters.StudyInstanceUID.IsEmpty) results.Add(this.CreateAttribute("studyInstanceUID", _queryParameters.StudyInstanceUID)); assoStudy = null; if (results.Count > 0) obj = (object[])results.ToArray(typeof(object)); if (obj != null) { Group groupStudy = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoStudy = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Study", "studyCollection", groupStudy); } // 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); } // Patient obj = null; results = new ArrayList(); if (assoStudy != null) results.Add(assoStudy); 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) { Group patientGroup = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoPatient = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Patient", "patient", patientGroup); } // Clinical Trial Site 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)); Group grpClinicalTrialSite = null; if (obj != null) { grpClinicalTrialSite = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSite = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSite", "site", grpClinicalTrialSite); } // Clinical Trial Subject 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)); Group grpClinicalTrialSubject = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSubject = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSubject", "subjectCollection", grpClinicalTrialSubject); } // Clinical Trial Protocol (Root) obj = null; results = new ArrayList(); if (assoClinicalTrialSubject != null) results.Add(assoClinicalTrialSubject); 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)); Group grpClinicalTrialProtocol = null; if (obj != null) { grpClinicalTrialProtocol = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); } QueryRequestCqlQuery arg = CreateQRAttrAssoGroup.createQueryRequestCqlQuery("gov.nih.nci.ncia.domain.ClinicalTrialProtocol", items, itemsChoiceType1, null, grpClinicalTrialProtocol); 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; }
private static string GetStringItemFromPosition(Position position, ItemsChoiceType itemsChoice) { var indItemChoice = position.ItemsElementName.ToList().FindIndex(x => x == itemsChoice); return indItemChoice >= 0 ? position.Items[indItemChoice] : null; }
private string Write3_ItemsChoiceType(ItemsChoiceType v) { switch (v) { case ItemsChoiceType.ExcludeQuery: return "ExcludeQuery"; case ItemsChoiceType.MaxValueQuery: return "MaxValueQuery"; case ItemsChoiceType.MinValueQuery: return "MinValueQuery"; case ItemsChoiceType.RegularQuery: return "RegularQuery"; } long num = (long) v; throw base.CreateInvalidEnumValueException(num.ToString(CultureInfo.InvariantCulture), "Microsoft.PowerShell.Cmdletization.Xml.ItemsChoiceType"); }
private MessageRefType FindMessage(InterfaceOperationType op2, ItemsChoiceType type) { for (int i = 0; i < op2.ItemsElementName.Length; i++) { if (op2.ItemsElementName[i] == type) return op2.Items[i] as MessageRefType; } return null; }
public void Init() { Items = new object[] { 1, 2 }; ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.In, ItemsChoiceType.Es }; }
public RightNowFieldAttribute(string name, ItemsChoiceType type) { CanUpdate = true; FieldType = type; Name = name; }
private CQLQueryResults getPatientCQLInfo(string endPointUrl) { object[] obj; CQLQueryResults result = null; Association assoClinicalTrialSite = null; Association assoClinicalTrialProtocol = null; Association assoClinicalTrialSubject = null; Association assoImage = null; Association assoTrialDataProvenance = null; Association assoSeries = null; Association assoStudy = null; ArrayList results = new ArrayList(); NCIACoreServicePortTypeClient proxy = new NCIACoreServicePortTypeClient(); proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(endPointUrl); string[] items = new string[] { "ethnicGroup", "patientBirthDate", "patientId", "patientName", "patientSex" }; ItemsChoiceType[] itemsChoiceType1 = new ItemsChoiceType[] { ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames, ItemsChoiceType.AttributeNames }; // 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) { 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) { 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) { Group grpClinicalTrialSubject = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoClinicalTrialSubject = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.ClinicalTrialSubject", "subjectCollection", grpClinicalTrialSubject); } // 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(); Attribute attrSeries = null; if (assoImage != null) { results.Add(assoImage); } if (!_queryParameters.Modality.IsEmpty) { attrSeries = this.CreateAttribute("modality", _queryParameters.Modality); } if (attrSeries != null) { results.Add(attrSeries); } if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null) { Group grpSeries = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoSeries = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Series", "seriesCollection", grpSeries); } // Study obj = null; assoStudy = null; results = new ArrayList(); if (assoSeries != null) { results.Add(assoSeries); } if (!_queryParameters.StudyInstanceUID.IsEmpty) { results.Add(this.CreateAttribute("studyInstanceUID", _queryParameters.StudyInstanceUID)); } assoStudy = null; if (results.Count > 0) { obj = (object[])results.ToArray(typeof(object)); } if (obj != null) { Group groupStudy = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); assoStudy = CreateQRAttrAssoGroup.createAssociation("gov.nih.nci.ncia.domain.Study", "studyCollection", groupStudy); } // Patient obj = null; results = new ArrayList(); if (assoClinicalTrialSubject != null) { results.Add(assoClinicalTrialSubject); } if (assoTrialDataProvenance != null) { results.Add(assoTrialDataProvenance); } if (assoStudy != null) { results.Add(assoStudy); } 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)); } Group groupPatient = CreateQRAttrAssoGroup.createGroup(obj, LogicalOperator.AND); QueryRequestCqlQuery arg = CreateQRAttrAssoGroup.createQueryRequestCqlQuery("gov.nih.nci.ncia.domain.Patient", items, itemsChoiceType1, null, groupPatient); XmlDocument doc = XMLSerializingDeserializing.Serialize(arg); 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); }
public object GetSingleItemByEnum(ItemsChoiceType choiceType) { if (itemList == null) itemList = new List<ItemsChoiceType>(this.ItemsElementName); var returnvalue = itemList.FindIndex(x => x == choiceType); if (returnvalue > -1) return this.Items[returnvalue]; return null; }