Пример #1
0
        public HttpResponseMessage Upsert(string type, string id, ResourceEntry entry)
        {
            entry.Tags = Request.GetFhirTags(); // todo: move to model binder?

            if (service.Exists(type, id))
            {
                ResourceEntry newEntry = service.Update(entry, type, id);
                return(Request.StatusResponse(newEntry, HttpStatusCode.OK));
            }
            else
            {
                ResourceEntry newEntry = service.Create(entry, type, id);
                return(Request.StatusResponse(newEntry, HttpStatusCode.Created));
            }
        }
Пример #2
0
        public FhirResponse Create(string type, Resource resource)
        {
            //entry.Tags = Request.GetFhirTags(); // todo: move to model binder?
            Key key = Key.Create(type);

            return(service.Create(key, resource));
        }
Пример #3
0
        public void LoadData()
        {
            var messages = new StringBuilder();

            messages.AppendLine("Import completed!");
            try
            {
                //cleans store and index
                Progress("Clearing the database...", 0);
                fhirStore.Clean();
                fhirIndex.Clean();

                Progress("Loading examples data...", 5);
                this.resources = GetExampleData();

                var resarray = resources.ToArray();
                ResourceCount = resarray.Count();

                for (int x = 0; x <= ResourceCount - 1; x++)
                {
                    var res = resarray[x];
                    // Sending message:
                    var msg = Message("Importing " + res.ResourceType.ToString() + " " + res.Id + "...", x);
                    Clients.Caller.sendMessage(msg);

                    try
                    {
                        //Thread.Sleep(1000);
                        Key key = res.ExtractKey();

                        if (res.Id != null && res.Id != "")
                        {
                            fhirService.Put(key, res);
                        }
                        else
                        {
                            fhirService.Create(key, res);
                        }
                    }
                    catch (Exception e)
                    {
                        // Sending message:
                        var msgError = Message("ERROR Importing " + res.ResourceType.ToString() + " " + res.Id + "... ", x);
                        Clients.Caller.sendMessage(msg);
                        messages.AppendLine(msgError.Message + ": " + e.Message);
                    }
                }

                Progress(messages.ToString(), 100);
            }
            catch (Exception e)
            {
                Progress("Error: " + e.Message);
            }
        }
Пример #4
0
        public void LoadData()
        {
            try
            {
                //cleans store and index
                Progress("Cleaning", 0);
                store.Clean();
                index.Clean();

                Progress("Loading data...");
                this.resources = GetExampleData();

                var resarray = resources.ToArray();
                var rescount = resarray.Count();

                for (int x = 0; x <= rescount - 1; x++)
                {
                    //Thread.Sleep(1000);
                    var res = resarray[x];
                    Key key = res.ExtractKey();

                    if (res.Id != null && res.Id != "")
                    {
                        service.Put(key, res);
                    }
                    else
                    {
                        service.Create(key, res);
                    }


                    // Sending message:

                    var msg = new ImportProgressMessage
                    {
                        Message  = "Importing " + res.ResourceType.ToString() + " " + res.Id + "...",
                        Progress = (int)(x + 1) * 100 / rescount
                    };

                    Clients.Caller.sendMessage(msg);
                }

                Progress("Import completed!", 100);
            }
            catch (Exception e)
            {
                Progress("Error: " + e.Message);
            }
        }