public FhirResponse ServerOperation(string operation) { switch (operation.ToLower()) { case "error": throw new Exception("This error is for testing purposes"); default: return(Respond.WithError(HttpStatusCode.NotFound, "Unknown operation")); } }
public Task <FhirResponse> InstanceOperation(string type, string id, string operation, Parameters parameters) { var key = Key.Create(type, id); return(operation.ToLower() switch { "meta" => _fhirService.ReadMeta(key), "meta-add" => _fhirService.AddMeta(key, parameters), _ => System.Threading.Tasks.Task.FromResult( Respond.WithError(HttpStatusCode.NotFound, "Unknown operation")) });
public FhirResponse ServerOperation(string operation, Parameters parameters) { switch (operation.ToLower()) { case "guidance": return(Respond.WithResource(engine.Guidance(parameters))); case "error": throw new Exception("This error is for testing purposes"); default: return(Respond.WithError(HttpStatusCode.NotFound, "Unknown operation")); } }
public FhirResponse InstanceOperation(string type, string id, string operation, Parameters parameters) { Key key = Key.Create(type, id); switch (operation.ToLower()) { case "meta": return(_fhirService.ReadMeta(key)); case "meta-add": return(_fhirService.AddMeta(key, parameters)); case "meta-delete": default: return(Respond.WithError(HttpStatusCode.NotFound, "Unknown operation")); } }
public async Task <FhirResponse> InstanceOperation(string type, string id, string operation, Parameters parameters) { Key key = Key.Create(type, id); switch (operation.ToLower()) { case "meta": return(await _fhirService.ReadMetaAsync(key).ConfigureAwait(false)); case "meta-add": return(await _fhirService.AddMetaAsync(key, parameters).ConfigureAwait(false)); case "meta-delete": default: return(Respond.WithError(HttpStatusCode.NotFound, "Unknown operation")); } }
public FhirResponse Mailbox(Bundle bundle, Binary body) { // DSTU2: mailbox /* * if(bundle == null || body == null) throw new SparkException("Mailbox requires a Bundle body payload"); * // For the connectathon, this *must* be a document bundle * if (bundle.GetBundleType() != BundleType.Document) * throw new SparkException("Mailbox endpoint currently only accepts Document feeds"); * * Bundle result = new Bundle("Transaction result from posting of Document " + bundle.Id, DateTimeOffset.Now); * * // Build a binary with the original body content (=the unparsed Document) * var binaryEntry = new ResourceEntry<Binary>(KeyHelper.NewCID(), DateTimeOffset.Now, body); * binaryEntry.SelfLink = KeyHelper.NewCID(); * * // Build a new DocumentReference based on the 1 composition in the bundle, referring to the binary * var compositions = bundle.Entries.OfType<ResourceEntry<Composition>>(); * if (compositions.Count() != 1) throw new SparkException("Document feed should contain exactly 1 Composition resource"); * * var composition = compositions.First().Resource; * var reference = ConnectathonDocumentScenario.DocumentToDocumentReference(composition, bundle, body, binaryEntry.SelfLink); * * // Start by copying the original entries to the transaction, minus the Composition * List<BundleEntry> entriesToInclude = new List<BundleEntry>(); * * //if(reference.Subject != null) entriesToInclude.AddRange(bundle.Entries.ById(new Uri(reference.Subject.Reference))); * //if (reference.Author != null) entriesToInclude.AddRange( * // reference.Author.Select(auth => bundle.Entries.ById(auth.Id)).Where(be => be != null)); * //reference.Subject = composition.Subject; * //reference.Author = new List<ResourceReference>(composition.Author); * //reference.Custodian = composition.Custodian; * * foreach (var entry in bundle.Entries.Where(be => !(be is ResourceEntry<Composition>))) * { * result.Entries.Add(entry); * } * * // Now add the newly constructed DocumentReference and the Binary * result.Entries.Add(new ResourceEntry<DocumentReference>(KeyHelper.NewCID(), DateTimeOffset.Now, reference)); * result.Entries.Add(binaryEntry); * * // Process the constructed bundle as a Transaction and return the result * return Transaction(result); */ return(Respond.WithError(HttpStatusCode.NotImplemented)); }