-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCapabilityStatementService.cs
More file actions
77 lines (68 loc) · 3.18 KB
/
Copy pathCapabilityStatementService.cs
File metadata and controls
77 lines (68 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using Hl7.Fhir.Model;
using Spark.Engine;
using Spark.Engine.Core;
using Spark.Engine.Service.FhirServiceExtensions;
namespace spark_example;
public class CapabilityStatementService : ICapabilityStatementService
{
private readonly IFhirModel _fhirModel;
private readonly ServerVersion _serverVersion;
private readonly FHIRVersion _fhirVersion;
public CapabilityStatementService(
IFhirModel fhirModel,
ServerVersion serverVersion,
FHIRVersion fhirVersion)
{
_fhirModel = fhirModel;
_serverVersion = serverVersion;
_fhirVersion = fhirVersion;
}
public CapabilityStatement GetSparkCapabilityStatement()
{
return new CapabilityStatementBuilder()
.WithName("Spark FHIR Server Example")
.WithVersion(_serverVersion)
.WithFhirVersion(_fhirVersion)
.WithDate(DateTimeOffset.UtcNow)
.WithStatus(PublicationStatus.Active)
.WithExperimental(true)
.WithKind(CapabilityStatementKind.Capability)
.WithAcceptFormat(["json", "xml"])
.WithRest(restBuilder =>
{
restBuilder.WithMode(CapabilityStatement.RestfulCapabilityMode.Server);
foreach (var resourceType in _fhirModel.SupportedResources)
{
restBuilder.WithResource(resourceBuilder =>
{
resourceBuilder.WithType(resourceType)
.WithVersioning(CapabilityStatement.ResourceVersionPolicy.NoVersion)
.WithReadHistory(false)
.WithUpdateCreate(true)
.WithInteraction(CapabilityStatement.TypeRestfulInteraction.Create)
.WithInteraction(CapabilityStatement.TypeRestfulInteraction.Read)
.WithInteraction(CapabilityStatement.TypeRestfulInteraction.Update)
.WithInteraction(CapabilityStatement.TypeRestfulInteraction.Delete)
.WithInteraction(CapabilityStatement.TypeRestfulInteraction.SearchType);
foreach (var searchParameter in _fhirModel.FindSearchParameters(resourceType))
resourceBuilder.WithSearchParam(
searchParameter.Name,
searchParameter.Type ?? SearchParamType.String,
documentation: searchParameter.Description
);
resourceBuilder.WithSearchParam(
"_summary",
SearchParamType.String,
documentation: "Summary for resource"
);
return resourceBuilder;
}
);
}
return restBuilder;
}
)
.Build();
}
}