public async Task <ClinicalTrialResult <ClinicalTrial> > GetClinicalTrials(ClinicalTrialFilter filter)
        {
            GraphQLRequest graphQLRequest = GetGraphQLRequest(GetQueryForClinicalTrial(filter));
            var            result         = await _Client.PostAsync(graphQLRequest);

            ClinicalTrialResult <ClinicalTrial> clinicalTrialResult = GetClinicalTrialResultInstance(result);

            MapResultToClinicalTrialObject(result, clinicalTrialResult);

            return(clinicalTrialResult);
        }
        public async Task <ClinicalTrialResult <ClinicalSponsor> > GetClinicalSponsors(ClinicalFilter filter)
        {
            GraphQLRequest graphQLRequest = GetGraphQLRequest(GetQuery(SponsorObject, DefaultSponsorProperties, false, filter.first, filter.after));
            var            result         = await _Client.PostAsync(graphQLRequest);

            ClinicalTrialResult <ClinicalSponsor> clinicalTrialResult = GetClinicalSponsorResultInstance(result);

            MapResultToClinicalSponsorObject(result, clinicalTrialResult);

            return(clinicalTrialResult);
        }
 private void MapResultToClinicalSponsorObject(GraphQL.Common.Response.GraphQLResponse result, ClinicalTrialResult <ClinicalSponsor> clinicalTrialResult)
 {
     foreach (var edge in result.Data.sponsors.edges)
     {
         clinicalTrialResult.Items.Add(new ClinicalSponsor()
         {
             Name = edge.node.name
         });
     }
 }
        private void MapResultToClinicalTrialObject(GraphQL.Common.Response.GraphQLResponse result, ClinicalTrialResult <ClinicalTrial> clinicalTrialResult)
        {
            var data = result.Data.trials != null ? result.Data.trials : result.Data.baseMatches;

            foreach (var edge in data.edges)
            {
                var clinicalTrial = new ClinicalTrial()
                {
                    Cursor                      = edge.cursor,
                    Title                       = edge.node.title,
                    Phase                       = edge.node.phase,
                    Gender                      = edge.node.gender,
                    MaximumAge                  = edge.node.maximumAge,
                    MinimumAge                  = edge.node.minimumAge,
                    Description                 = edge.node.description,
                    Criteria                    = edge.node.criteria,
                    Conditions                  = GetListFromTextArray(edge.node.conditions.Value),
                    AgencyClass                 = edge.node.agencyClass,
                    DetailedDescription         = edge.node.detailedDescription,
                    HasExpandedAccess           = edge.node.hasExpandedAccess,
                    HealthyVolunteers           = edge.node.healthyVolunteers,
                    IsFdaRegulated              = edge.node.isFdaRegulated,
                    Keywords                    = GetListFromTextArray(edge.node.keywords.Value),
                    LinkDescription             = edge.node.linkDescription,
                    LinkUrl                     = edge.node.linkUrl,
                    NctId                       = edge.node.nctId,
                    OfficialTitle               = edge.node.officialTitle,
                    OverallContactEmail         = edge.node.overallContactEmail,
                    OverallContactName          = edge.node.overallContactName,
                    OverallContactPhone         = edge.node.overallContactPhone,
                    OverallOfficialAffilitation = edge.node.overallOfficialAffilitation,
                    OverallOfficialName         = edge.node.overallOfficialName,
                    OverallOfficialRole         = edge.node.overallOfficialRole,
                    OverallStatus               = edge.node.overallStatus,
                    Sponsor                     = edge.node.sponsor,
                    StudyType                   = edge.node.studyType,
                    Sites                       = new List <ClinicalTrialSite>()
                };

                int i = 0;
                foreach (var site in edge.node.sites)
                {
                    clinicalTrial.Sites.Add(new ClinicalTrialSite()
                    {
                        Key             = i,
                        City            = site.city,
                        ContactEmail    = site.contactEmail,
                        ContactName     = site.contactName,
                        ContactPhone    = site.contactPhone,
                        ContactPhoneExt = site.contactPhoneExt,
                        Country         = site.country,
                        Facility        = site.facility,
                        Latitude        = site.latitude,
                        Longitude       = site.longitude,
                        State           = site.state,
                        Status          = site.status,
                        Url             = site.url,
                        ZipCode         = site.zipCode,
                    });

                    i++;
                }

                clinicalTrialResult.Items.Add(clinicalTrial);
            }
        }