public static Bundle FetchPatientRecord(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 = client.TypeOperation <Patient>(Operation.FETCH_PATIENT_RECORD, par);
            }
            else
            {
                var location = new ResourceIdentity(patient);
                result = client.InstanceOperation(location.WithoutVersion().MakeRelative(), Operation.FETCH_PATIENT_RECORD, par);
            }

            return(expect <Bundle>(result));
        }
        public static Parameters TranslateConcept(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(expect <Parameters>(client.InstanceOperation(loc, Operation.TRANSLATE, par)));
        }
        //[base]/Resource/id/$meta/[_history/vid]
        public static Meta Meta(this FhirClient client, Uri location)
        {
            Resource result;

            result = client.InstanceOperation(location, Operation.META, useGet: true);

            return(extractMeta(expect <Parameters>(result)));
        }
        //[base]/Resource/id/$meta/[_history/vid]
        public static Parameters Meta(this FhirClient client, Uri location)
        {
            Resource result;

            result = client.InstanceOperation(location, META);

            return(expect <Parameters>(result));
        }
        public static OperationOutcome ValidateDelete(this FhirClient client, ResourceIdentity location)
        {
            if (location == null)
            {
                throw Error.ArgumentNull("location");
            }

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

            return(expect <OperationOutcome>(client.InstanceOperation(location.WithoutVersion().MakeRelative(), Operation.VALIDATE_RESOURCE, par)));
        }
        public static OperationOutcome ValidateUpdate(this FhirClient client, DomainResource resource, string id, FhirUri profile = null)
        {
            if (id == null)
            {
                throw Error.ArgumentNull("id");
            }
            if (resource == null)
            {
                throw Error.ArgumentNull("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(expect <OperationOutcome>(client.InstanceOperation(loc, Operation.VALIDATE_RESOURCE, par)));
        }
        public static ValueSet ExpandValueSet(this FhirClient client, Uri valueset, FhirString filter = null, FhirDateTime date = null)
        {
            if (valueset == null)
            {
                throw Error.ArgumentNull("valuesetLocation");
            }

            var par = new Parameters();

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

            ResourceIdentity id = new ResourceIdentity(valueset);

            return(expect <ValueSet>(client.InstanceOperation(id.WithoutVersion().MakeRelative(), Operation.EXPAND_VALUESET, par)));
        }
        private static Parameters validateCodeForValueSetId(FhirClient client, string valueSetId, Parameters par)
        {
            ResourceIdentity location = new ResourceIdentity("ValueSet/" + valueSetId);

            return(expect <Parameters>(client.InstanceOperation(location.WithoutVersion().MakeRelative(), Operation.VALIDATE_CODE, par)));
        }
        public static Meta DeleteMeta(this FhirClient client, Uri location, Meta meta)
        {
            var par = new Parameters().Add("meta", meta);

            return(extractMeta(expect <Parameters>(client.InstanceOperation(location, Operation.META_DELETE, par))));
        }
        public static Parameters AddMeta(this FhirClient client, Uri location, Meta meta)
        {
            var par = new Parameters().Add("meta", meta);

            return(expect <Parameters>(client.InstanceOperation(location, META_ADD, par)));
        }