Skip to content

Commit

Permalink
close #21 not doable at the moment
Browse files Browse the repository at this point in the history
#3 separated the FhirController into 4 files within a partial class
#3 Changed the IFhirBaseService for create, update, patch and delete to return actionresult instead of a fhir base object since those endpoints will onlyl return 201 or 202 (ref https://www.restapitutorial.com/httpstatuscodes.html)
#16 Some config is moved out of Instigator due to dependencies that aren't recommended to have in a class library (ref startup.cs and fhirstarter.config)
  • Loading branch information
hha046 committed Feb 22, 2019
1 parent 3eb27fa commit 0b74bb7
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
using FhirStarter.R4.Detonator.Core.SparkEngine.Core;
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
using Microsoft.AspNetCore.Mvc;

namespace FhirStarter.R4.Detonator.Core.Interface
{
public interface IFhirBaseService
{
// The name of the Resource you can query (earlier called GetAlias)
string GetServiceResourceReference();
HttpResponseMessage Create(IKey key, Resource resource);
Base Create(IKey key, Resource resource);
Base Read(SearchParams searchParams);
Base Read(string id);
HttpResponseMessage Update(IKey key, Resource resource);
HttpResponseMessage Delete(IKey key);
HttpResponseMessage Patch(IKey key, Resource resource);
ActionResult Update(IKey key, Resource resource);
ActionResult Delete(IKey key);
ActionResult Patch(IKey key, Resource resource);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using FhirStarter.R4.Detonator.Core.Formatters;
using FhirStarter.R4.Detonator.Core.Interface;
using FhirStarter.R4.Instigator.Core.Helper;
using FhirStarter.R4.Instigator.Core.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -19,26 +17,18 @@ public static class FhirStarterConfig

public static void SetupFhir(IServiceCollection services, IConfigurationRoot fhirStarterSettings, CompatibilityVersion dotNetCoreVersion)
{
SetupHeadersAndController(services, fhirStarterSettings, dotNetCoreVersion);
// SetupHeadersAndController(services, fhirStarterSettings, dotNetCoreVersion);
AddFhirStarterSettings(services, fhirStarterSettings);
RegisterServices(services, fhirStarterSettings);
}

private static void SetupHeadersAndController(IServiceCollection services, IConfigurationRoot fhirStarterSettings, CompatibilityVersion dotNetCoreVersion)
#region Assembly

private static void AddFhirStarterSettings(IServiceCollection services, IConfigurationRoot fhirStarterSettings)
{
services.Configure<FhirStarterSettings>(fhirStarterSettings.GetSection(nameof(FhirStarterSettings)));
services.AddMvc(options =>
{
options.OutputFormatters.Clear();
options.RespectBrowserAcceptHeader = true;
options.OutputFormatters.Add(new XmlFhirSerializerOutputFormatter());
options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
options.OutputFormatters.Add(new JsonFhirFormatter());
})
.SetCompatibilityVersion(dotNetCoreVersion);
services.Add(new ServiceDescriptor(typeof(IConfigurationRoot),fhirStarterSettings));
}

#region Assembly

private static void RegisterServices(IServiceCollection services, IConfigurationRoot fhirStarterSettings)
{
var fhirService = typeof(IFhirService);
Expand Down
Loading

0 comments on commit 0b74bb7

Please sign in to comment.