Exemplo n.º 1
0
 public static void Append(this Bundle bundle, Bundle.HTTPVerb method, IEnumerable <Resource> resources)
 {
     foreach (Resource resource in resources)
     {
         bundle.Append(method, resource);
     }
 }
Exemplo n.º 2
0
        private Bundle.EntryComponent newEntry(Bundle.HTTPVerb method)
        {
            var newEntry = new Bundle.EntryComponent();

            newEntry.Request        = new Bundle.RequestComponent();
            newEntry.Request.Method = method;

            return(newEntry);
        }
Exemplo n.º 3
0
        public static ResourceManipulationOperation GetManipulationOperation(Bundle.EntryComponent entryComponent, ILocalhost localhost, ISearchService service = null)
        {
            searchService = service;
            Bundle.HTTPVerb method    = localhost.ExtrapolateMethod(entryComponent, null); //CCR: is key needed? Isn't method required?
            Key             key       = localhost.ExtractKey(entryComponent);
            var             searchUri = GetSearchUri(entryComponent, method);

            return(builders[method](entryComponent.Resource, key, service, searchUri != null? ParseQueryString(localhost, searchUri): null));
        }
Exemplo n.º 4
0
        private Bundle.BundleEntryComponent newEntry(Bundle.HTTPVerb method)
        {
            var newEntry = new Bundle.BundleEntryComponent();

            newEntry.Transaction        = new Bundle.BundleEntryTransactionComponent();
            newEntry.Transaction.Method = method;

            return(newEntry);
        }
Exemplo n.º 5
0
        public static void Append(this Bundle bundle, Bundle.HTTPVerb method, Resource resource)
        {
            var entry = CreateEntryForResource(resource);

            entry.Request ??= new Bundle.RequestComponent();

            entry.Request.Method = method;
            bundle.Entry.Add(entry);
        }
Exemplo n.º 6
0
        private Bundle.EntryComponent newEntry(Bundle.HTTPVerb method, InteractionType interactionType)
        {
            var newEntry = new Bundle.EntryComponent();

            newEntry.Request        = new Bundle.RequestComponent();
            newEntry.Request.Method = method;
            newEntry.AddAnnotation(interactionType);

            return(newEntry);
        }
Exemplo n.º 7
0
        public static Entry ExtractMetadata(BsonDocument document)
        {
            DateTime when = GetVersionDate(document);
            IKey     key  = GetKey(document);

            Bundle.HTTPVerb method = (Bundle.HTTPVerb)(int) document[Field.METHOD];

            RemoveMetadata(document);
            return(Entry.Create(method, key, when));
        }
Exemplo n.º 8
0
        public static void Append(this Bundle bundle, Bundle.HTTPVerb method, Resource resource)
        {
            Bundle.EntryComponent entry = CreateEntryForResource(resource);

            if (entry.Request == null)
            {
                entry.Request = new Bundle.RequestComponent();
            }
            entry.Request.Method = method;
            bundle.Entry.Add(entry);
        }
Exemplo n.º 9
0
        private static Uri GetSearchUri(Bundle.EntryComponent entryComponent, Bundle.HTTPVerb method)
        {
            var searchUri = method switch
            {
                Bundle.HTTPVerb.POST => PostManipulationOperation.ReadSearchUri(entryComponent),
                Bundle.HTTPVerb.PUT => PutManipulationOperation.ReadSearchUri(entryComponent),
                Bundle.HTTPVerb.DELETE => DeleteManipulationOperation.ReadSearchUri(entryComponent),
                _ => null
            };

            return(searchUri);
        }
Exemplo n.º 10
0
        public static void Append(this Bundle bundle, Bundle.HTTPVerb method, Resource resource)
        {
            var entry = new Bundle.BundleEntryComponent();

            entry.Resource = resource;
            entry.Base     = bundle.Base;
            if (entry.Transaction == null)
            {
                entry.Transaction = new Bundle.BundleEntryTransactionComponent();
            }
            entry.Transaction.Method = method;
            bundle.Entry.Add(entry);
        }
Exemplo n.º 11
0
        public static Interaction ToInteraction(this ILocalhost localhost, Bundle.BundleEntryComponent bundleEntry)
        {
            Key key = localhost.ExtractKey(bundleEntry);

            Bundle.HTTPVerb method = localhost.ExtrapolateMethod(bundleEntry, key);

            if (key != null)
            {
                return(Interaction.Create(method, key, bundleEntry.Resource));
            }
            else
            {
                return(Interaction.Create(method, bundleEntry.Resource));
            }
        }
Exemplo n.º 12
0
 protected Entry(Bundle.HTTPVerb method, IKey key, DateTimeOffset?when, Resource resource)
 {
     if (resource != null)
     {
         key.ApplyTo(resource);
     }
     else
     {
         this.Key = key;
     }
     this.Resource = resource;
     this.Method   = method;
     this.When     = when ?? DateTimeOffset.Now;
     this.State    = EntryState.Undefined;
 }
Exemplo n.º 13
0
        private static Uri GetSearchUri(Bundle.EntryComponent entryComponent, Bundle.HTTPVerb method)
        {
            Uri searchUri = null;

            if (method == Bundle.HTTPVerb.POST)
            {
                searchUri = PostManipulationOperation.ReadSearchUri(entryComponent);
            }
            else if (method == Bundle.HTTPVerb.PUT)
            {
                searchUri = PutManipulationOperation.ReadSearchUri(entryComponent);
            }
            else if (method == Bundle.HTTPVerb.DELETE)
            {
                searchUri = DeleteManipulationOperation.ReadSearchUri(entryComponent);
            }
            return(searchUri);
        }
Exemplo n.º 14
0
        public static void SetResourceBaseAddOrUpdate <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>(Resource Resource, ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> ResourceCurrentBase, string Version, bool IsDeleted, Bundle.HTTPVerb Method, int FhirReleaseId)
            where ResCurrentType : ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexStringType : ResourceIndexString <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexTokenType : ResourceIndexToken <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexUriType : ResourceIndexUri <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexReferenceType : ResourceIndexReference <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexQuantityType : ResourceIndexQuantity <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexDateTimeType : ResourceIndexDateTime <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>

        {
            SetResourceBase(Resource, ResourceCurrentBase, null, Version, false, Method, FhirReleaseId);
        }
Exemplo n.º 15
0
        private static void SetResourceBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>(Resource Resource, ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> ResourceCurrentBase, string FhirResourceId, string Version, bool IsDeleted, Bundle.HTTPVerb Method, int FhirReleaseId)
            where ResCurrentType : ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexStringType : ResourceIndexString <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexTokenType : ResourceIndexToken <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexUriType : ResourceIndexUri <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexReferenceType : ResourceIndexReference <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexQuantityType : ResourceIndexQuantity <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexDateTimeType : ResourceIndexDateTime <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>

        {
            ResourceCurrentBase.FhirReleaseId = FhirReleaseId;
            ResourceCurrentBase.IsDeleted     = IsDeleted;
            ResourceCurrentBase.VersionId     = Version;
            ResourceCurrentBase.Method        = Method;
            if (!IsDeleted)
            {
                ResourceCurrentBase.FhirId = Resource.Id;
                Hl7.Fhir.Serialization.FhirXmlSerializer FhirXmlSerializer = new Hl7.Fhir.Serialization.FhirXmlSerializer();
                ResourceCurrentBase.Resource    = Common.Tools.GZip.GZipper.Compress(FhirXmlSerializer.SerializeToBytes(Resource));
                ResourceCurrentBase.LastUpdated = (DateTimeOffset)Resource.Meta.LastUpdated;

                // Zip to byte[]
                //byte[] CompressedBytes = Common.Tools.GZip.GZipper.Compress(FhirXmlSerializer.SerializeToBytes(Resource));

                //string ResourceString = Common.Tools.GZip.GZipper.Decompress(CompressedBytes);
            }
            else
            {
                ResourceCurrentBase.FhirId      = FhirResourceId;
                ResourceCurrentBase.Resource    = null;
                ResourceCurrentBase.LastUpdated = DateTimeOffset.Now;
            }
        }
Exemplo n.º 16
0
 public static Interaction Create(Bundle.HTTPVerb method, IKey key, DateTimeOffset when)
 {
     return(new Interaction(method, key, when, null));
 }
Exemplo n.º 17
0
 public static Entry Create(Bundle.HTTPVerb method, IKey key, DateTimeOffset when)
 {
     return(new Entry(method, key, when, null));
 }
Exemplo n.º 18
0
 public static Interaction Create(Bundle.HTTPVerb method, IKey key, Resource resource)
 {
     return(new Interaction(method, key, null, resource));
 }
Exemplo n.º 19
0
 public static Entry Create(Bundle.HTTPVerb method, Resource resource)
 {
     return(new Entry(method, null, null, resource));
 }
Exemplo n.º 20
0
        private static void SetResourceBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>(Resource Resource, ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> ResourceCurrentBase, string FhirResourceId, string Version, bool IsDeleted, Bundle.HTTPVerb Method, int FhirReleaseId)
            where ResCurrentType : ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexStringType : ResourceIndexString <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexTokenType : ResourceIndexToken <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexUriType : ResourceIndexUri <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexReferenceType : ResourceIndexReference <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexQuantityType : ResourceIndexQuantity <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexDateTimeType : ResourceIndexDateTime <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>

        {
            ResourceCurrentBase.FhirReleaseId = FhirReleaseId;
            ResourceCurrentBase.IsDeleted     = IsDeleted;
            ResourceCurrentBase.VersionId     = Version;
            ResourceCurrentBase.Method        = Method;
            if (!IsDeleted)
            {
                ResourceCurrentBase.FhirId = Resource.Id;
                Hl7.Fhir.Serialization.FhirXmlSerializer FhirXmlSerializer = new Hl7.Fhir.Serialization.FhirXmlSerializer();
                ResourceCurrentBase.XmlBlob = FhirXmlSerializer.SerializeToString(Resource);

                //Now obsolete in FHIR .NET API
                //ResourceCurrentBase.XmlBlob = Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(Resource);

                ResourceCurrentBase.LastUpdated = (DateTimeOffset)Resource.Meta.LastUpdated;
            }
            else
            {
                ResourceCurrentBase.FhirId      = FhirResourceId;
                ResourceCurrentBase.XmlBlob     = "";
                ResourceCurrentBase.LastUpdated = DateTimeOffset.Now;
            }
        }