public static async Task <Bundle> FetchPatientRecordAsync(this FhirClient client, Uri patient = null, FhirDateTime start = null, FhirDateTime end = null)
        {
            var par = new Parameters();

            if (start != null)
            {
                par.Add("start", start);
            }
            if (end != null)
            {
                par.Add("end", end);
            }

            Resource result;

            if (patient == null)
            {
                result = await client.TypeOperationAsync <Patient>(RestOperation.FETCH_PATIENT_RECORD, par).ConfigureAwait(false);
            }
            else
            {
                var location = new ResourceIdentity(patient);
                result = await client.InstanceOperationAsync(location.WithoutVersion().MakeRelative(), RestOperation.FETCH_PATIENT_RECORD, par).ConfigureAwait(false);
            }

            return(OperationResult <Bundle>(result));
        }
        public static async Task <Parameters> TranslateConceptAsync(this FhirClient client, string id, Code code, FhirUri system, FhirString version,
                                                                    FhirUri valueSet, Coding coding, CodeableConcept codeableConcept, FhirUri target, IEnumerable <TranslateConceptDependency> dependencies)
        {
            Parameters par = createTranslateConceptParams(code, system, version, valueSet, coding, codeableConcept, target, dependencies);
            var        loc = ResourceIdentity.Build("ConceptMap", id);

            return(OperationResult <Parameters>(await client.InstanceOperationAsync(loc, RestOperation.TRANSLATE, par).ConfigureAwait(false)));
        }
        //[base]/Resource/id/$meta/[_history/vid]
        public static async Task <Meta> MetaAsync(this FhirClient client, Uri location)
        {
            Resource result;

            result = await client.InstanceOperationAsync(location, RestOperation.META, useGet : true).ConfigureAwait(false);

            return(extractMeta(OperationResult <Parameters>(result)));
        }
        public static async Task <OperationOutcome> ValidateDeleteAsync(this FhirClient client, ResourceIdentity location)
        {
            if (location == null)
            {
                throw Error.ArgumentNull(nameof(location));
            }

            var par = new Parameters().Add("mode", new Code("delete"));

            return(OperationResult <OperationOutcome>(await client.InstanceOperationAsync(location.WithoutVersion().MakeRelative(), RestOperation.VALIDATE_RESOURCE, par).ConfigureAwait(false)));
        }
        public static async Task <OperationOutcome> ValidateUpdateAsync(this FhirClient client, DomainResource resource, string id, FhirUri profile = null)
        {
            if (id == null)
            {
                throw Error.ArgumentNull(nameof(id));
            }
            if (resource == null)
            {
                throw Error.ArgumentNull(nameof(resource));
            }

            var par = new Parameters().Add("resource", resource).Add("mode", new Code("update"));

            if (profile != null)
            {
                par.Add("profile", profile);
            }

            var loc = ResourceIdentity.Build(resource.TypeName, id);

            return(OperationResult <OperationOutcome>(await client.InstanceOperationAsync(loc, RestOperation.VALIDATE_RESOURCE, par).ConfigureAwait(false)));
        }
        public static async Task <ValueSet> ExpandValueSetAsync(this FhirClient client, Uri valueset, FhirString filter = null, FhirDateTime date = null)
        {
            if (valueset == null)
            {
                throw Error.ArgumentNull(nameof(valueset));
            }

            var par = new Parameters();

            if (filter != null)
            {
                par.Add("filter", filter);
            }
            if (date != null)
            {
                par.Add("date", date);
            }

            ResourceIdentity id = new ResourceIdentity(valueset);

            return((await client.InstanceOperationAsync(id.WithoutVersion().MakeRelative(), RestOperation.EXPAND_VALUESET, par).ConfigureAwait(false))
                   .OperationResult <ValueSet>());
        }
        public static async Task <Meta> DeleteMetaAsync(this FhirClient client, Uri location, Meta meta)
        {
            var par = new Parameters().Add("meta", meta);

            return(extractMeta(OperationResult <Parameters>(await client.InstanceOperationAsync(location, RestOperation.META_DELETE, par).ConfigureAwait(false))));
        }