Skip to content

Commit faac0d5

Browse files
committed
feat: include Practitioner in default resource types for mCSD synchronization
- Updated default `DirectoryResourceTypes` to include `Practitioner`. - Adjusted Helm charts, configuration files, and documentation to reflect the change. - Refactored component initialization with `DefaultConfig()` for better default handling. - Enhanced unit tests to verify functionality with updated defaults.
1 parent 67649f8 commit faac0d5

File tree

7 files changed

+62
-46
lines changed

7 files changed

+62
-46
lines changed

cmd/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Config struct {
2929

3030
func DefaultConfig() Config {
3131
return Config{
32+
MCSD: mcsd.DefaultConfig(),
3233
Nuts: nutsnode.Config{
3334
Enabled: false,
3435
},

cmd/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ func TestLoadConfig_Default(t *testing.T) {
1616
// Should have default values
1717
assert.False(t, config.Nuts.Enabled)
1818
assert.Equal(t, "", config.MCSDAdmin.FHIRBaseURL)
19+
20+
// MCSD should have default DirectoryResourceTypes
21+
expectedResourceTypes := []string{"Organization", "Endpoint", "Location", "HealthcareService", "PractitionerRole", "Practitioner"}
22+
assert.Equal(t, expectedResourceTypes, config.MCSD.DirectoryResourceTypes)
1923
}
2024

2125
func TestLoadConfig_FromYAML(t *testing.T) {

component/mcsd/component.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
var _ component.Lifecycle = &Component{}
2525

2626
var rootDirectoryResourceTypes = []string{"Organization", "Endpoint"}
27-
var defaultDirectoryResourceTypes = []string{"Organization", "Endpoint", "Location", "HealthcareService", "PractitionerRole"}
27+
var defaultDirectoryResourceTypes = []string{"Organization", "Endpoint", "Location", "HealthcareService", "PractitionerRole", "Practitioner"}
2828

2929
// clockSkewBuffer is subtracted from local time when Bundle meta.lastUpdated is not available
3030
// to account for potential clock differences between client and FHIR server
@@ -58,6 +58,12 @@ type Component struct {
5858
updateMux *sync.RWMutex
5959
}
6060

61+
func DefaultConfig() Config {
62+
return Config{
63+
DirectoryResourceTypes: defaultDirectoryResourceTypes,
64+
}
65+
}
66+
6167
type Config struct {
6268
AdministrationDirectories map[string]DirectoryConfig `koanf:"admin"`
6369
QueryDirectory DirectoryConfig `koanf:"query"`
@@ -87,20 +93,14 @@ type DirectoryUpdateReport struct {
8793
}
8894

8995
func New(config Config) (*Component, error) {
90-
// Use configured directory resource types, or default if not specified
91-
directoryResourceTypes := config.DirectoryResourceTypes
92-
if len(directoryResourceTypes) == 0 {
93-
directoryResourceTypes = defaultDirectoryResourceTypes
94-
}
95-
9696
result := &Component{
9797
config: config,
9898
fhirClientFn: func(baseURL *url.URL) fhirclient.Client {
9999
return fhirclient.New(baseURL, http.DefaultClient, &fhirclient.Config{
100100
UsePostSearch: false,
101101
})
102102
},
103-
directoryResourceTypes: directoryResourceTypes,
103+
directoryResourceTypes: config.DirectoryResourceTypes,
104104
lastUpdateTimes: make(map[string]string),
105105
updateMux: &sync.RWMutex{},
106106
}

component/mcsd/component_test.go

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ func TestComponent_update_regression(t *testing.T) {
5959
server := httptest.NewServer(mux)
6060

6161
localClient := &test.StubFHIRClient{}
62-
component, err := New(Config{
63-
AdministrationDirectories: map[string]DirectoryConfig{
64-
"lrza": {
65-
FHIRBaseURL: server.URL,
66-
},
62+
config := DefaultConfig()
63+
config.AdministrationDirectories = map[string]DirectoryConfig{
64+
"lrza": {
65+
FHIRBaseURL: server.URL,
6766
},
68-
})
67+
}
68+
component, err := New(config)
6969
require.NoError(t, err)
7070
component.fhirClientFn = func(baseURL *url.URL) fhirclient.Client {
7171
if baseURL.String() == server.URL {
@@ -113,6 +113,7 @@ func TestComponent_update(t *testing.T) {
113113
"/HealthcareService/_history": &emptyResponseStr,
114114
"/Location/_history": &emptyResponseStr,
115115
"/PractitionerRole/_history": &emptyResponseStr,
116+
"/Practitioner/_history": &emptyResponseStr,
116117
})
117118

118119
rootDirServer := httptest.NewServer(rootDirMux)
@@ -144,6 +145,7 @@ func TestComponent_update(t *testing.T) {
144145
"/fhir/Location/_history": &emptyResponseStr,
145146
"/fhir/HealthcareService/_history": &emptyResponseStr,
146147
"/fhir/PractitionerRole/_history": &emptyResponseStr,
148+
"/fhir/Practitioner/_history": &emptyResponseStr,
147149
})
148150

149151
org1DirServer := httptest.NewServer(org1DirMux)
@@ -156,16 +158,16 @@ func TestComponent_update(t *testing.T) {
156158
org1DirOrganizationHistoryPage1Response = strings.ReplaceAll(org1DirOrganizationHistoryPage1Response, "{{ORG1_DIR_BASEURL}}", orgDir1BaseURL)
157159

158160
localClient := &test.StubFHIRClient{}
159-
component, err := New(Config{
160-
AdministrationDirectories: map[string]DirectoryConfig{
161-
"rootDir": {
162-
FHIRBaseURL: rootDirServer.URL,
163-
},
161+
config := DefaultConfig()
162+
config.AdministrationDirectories = map[string]DirectoryConfig{
163+
"rootDir": {
164+
FHIRBaseURL: rootDirServer.URL,
164165
},
165-
QueryDirectory: DirectoryConfig{
166-
FHIRBaseURL: "http://example.com/local/fhir",
167-
},
168-
})
166+
}
167+
config.QueryDirectory = DirectoryConfig{
168+
FHIRBaseURL: "http://example.com/local/fhir",
169+
}
170+
component, err := New(config)
169171
require.NoError(t, err)
170172

171173
unknownFHIRServerClient := &test.StubFHIRClient{
@@ -290,16 +292,16 @@ func TestComponent_incrementalUpdates(t *testing.T) {
290292
rootDirServer := httptest.NewServer(rootDirMux)
291293

292294
localClient := &test.StubFHIRClient{}
293-
component, err := New(Config{
294-
AdministrationDirectories: map[string]DirectoryConfig{
295-
"rootDir": {
296-
FHIRBaseURL: rootDirServer.URL,
297-
},
295+
config := DefaultConfig()
296+
config.AdministrationDirectories = map[string]DirectoryConfig{
297+
"rootDir": {
298+
FHIRBaseURL: rootDirServer.URL,
298299
},
299-
QueryDirectory: DirectoryConfig{
300-
FHIRBaseURL: "http://example.com/local/fhir",
301-
},
302-
})
300+
}
301+
config.QueryDirectory = DirectoryConfig{
302+
FHIRBaseURL: "http://example.com/local/fhir",
303+
}
304+
component, err := New(config)
303305
require.NoError(t, err)
304306

305307
component.fhirClientFn = func(baseURL *url.URL) fhirclient.Client {
@@ -688,6 +690,14 @@ func TestComponent_updateFromDirectory(t *testing.T) {
688690
w.Header().Set("Content-Type", "application/json")
689691
w.Write([]byte(`{"resourceType": "Bundle", "type": "history", "entry": []}`))
690692
})
693+
mux.HandleFunc("/fhir/PractitionerRole/_history", func(w http.ResponseWriter, r *http.Request) {
694+
w.Header().Set("Content-Type", "application/json")
695+
w.Write([]byte(`{"resourceType": "Bundle", "type": "history", "entry": []}`))
696+
})
697+
mux.HandleFunc("/fhir/Practitioner/_history", func(w http.ResponseWriter, r *http.Request) {
698+
w.Header().Set("Content-Type", "application/json")
699+
w.Write([]byte(`{"resourceType": "Bundle", "type": "history", "entry": []}`))
700+
})
691701

692702
component, err := New(Config{
693703
QueryDirectory: DirectoryConfig{
@@ -962,19 +972,18 @@ func TestComponent_updateFromDirectory(t *testing.T) {
962972
})
963973

964974
t.Run("uses default DirectoryResourceTypes when not configured", func(t *testing.T) {
965-
// This test verifies that when DirectoryResourceTypes is not configured,
966-
// the default resource types are used.
975+
// This test verifies that when using DefaultConfig(),
976+
// the default resource types are set.
967977

968-
component, err := New(Config{
969-
QueryDirectory: DirectoryConfig{
970-
FHIRBaseURL: "http://example.com/local/fhir",
971-
},
972-
// DirectoryResourceTypes not specified
973-
})
978+
config := DefaultConfig()
979+
config.QueryDirectory = DirectoryConfig{
980+
FHIRBaseURL: "http://example.com/local/fhir",
981+
}
982+
component, err := New(config)
974983
require.NoError(t, err)
975984

976985
// Verify the component uses default resource types
977-
expectedDefaults := []string{"Organization", "Endpoint", "Location", "HealthcareService", "PractitionerRole"}
986+
expectedDefaults := []string{"Organization", "Endpoint", "Location", "HealthcareService", "PractitionerRole", "Practitioner"}
978987
assert.Equal(t, expectedDefaults, component.directoryResourceTypes)
979988
})
980989
}
@@ -991,6 +1000,8 @@ func startMockServer(t *testing.T, filesToServe map[string]string) *httptest.Ser
9911000
"/fhir/Organization/_history": &emptyResponseStr,
9921001
"/fhir/Location/_history": &emptyResponseStr,
9931002
"/fhir/HealthcareService/_history": &emptyResponseStr,
1003+
"/fhir/PractitionerRole/_history": &emptyResponseStr,
1004+
"/fhir/Practitioner/_history": &emptyResponseStr,
9941005
}
9951006
for path, filename := range filesToServe {
9961007
data, err := os.ReadFile(filename)

config/knooppunt.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ mcsd:
2222
# - "https://fhir.other-excluded.org/fhir" # Add more exclusions as needed
2323

2424
# Resource types to synchronize from discovered mCSD directories
25-
# If not specified, defaults to: Organization, Endpoint, Location, HealthcareService, PractitionerRole
25+
# If not specified, defaults to: Organization, Endpoint, Location, HealthcareService, PractitionerRole, Practitioner
2626
# directoryresourcetypes:
2727
# - "Organization"
2828
# - "Endpoint"
2929
# - "Location"
3030
# - "HealthcareService"
3131
# - "PractitionerRole"
32-
# # - "Practitioner" # Uncomment to also sync Practitioner resources
32+
# - "Practitioner"
3333

3434
# mCSD Admin configuration
3535
mcsdadmin:

docs/CONFIGURATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Environment variables use the prefix `KNPT_` followed by the configuration path
2525
| `KNPT_MCSD_QUERY_FHIRBASEURL` | `mcsd.query.fhirbaseurl` | FHIR base URL of the local mCSD Query Directory to synchronize to. |
2626
| `KNPT_MCSD_ADMIN_<KEY>_FHIRBASEURL` | `mcsd.admin.<key>.fhirbaseurl` | Map of root directories (mCSD Admin Directory FHIR base URLs) to synchronize from. |
2727
| `KNPT_MCSD_ADMINEXCLUDE` | `mcsd.adminexclude` | (Optional) List of FHIR base URLs to exclude from being registered as administration directories. Useful to prevent self-referencing loops when the query directory is discovered as an Endpoint. Multiple values can be specified as a comma-separated list. |
28-
| `KNPT_MCSD_DIRECTORYRESOURCETYPES` | `mcsd.directoryresourcetypes` | (Optional) List of resource types to synchronize from discovered mCSD directories. Defaults to: `Organization`, `Endpoint`, `Location`, `HealthcareService`, `PractitionerRole`. Multiple values can be specified as a comma-separated list. |
28+
| `KNPT_MCSD_DIRECTORYRESOURCETYPES` | `mcsd.directoryresourcetypes` | (Optional) List of resource types to synchronize from discovered mCSD directories. Defaults to: `Organization`, `Endpoint`, `Location`, `HealthcareService`, `PractitionerRole`, `Practitioner`. Multiple values can be specified as a comma-separated list. |
2929
| **Localization / NVI** | | |
3030
| `KNPT_NVI_BASEURL` | `nvi.baseurl` | Base URL of the NVI service. |
3131
| `KNPT_NVI_AUDIENCE` | `nvi.audience` | Name of the NVI service, used for creating BSN transport tokens.<br/>Defaults to `nvi`. |

helm/nuts-knooppunt/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ config:
164164
# - "https://fhir.other-excluded.org/fhir" # Add more exclusions as needed
165165

166166
# Resource types to synchronize from discovered mCSD directories
167-
# If not specified, defaults to: Organization, Endpoint, Location, HealthcareService, PractitionerRole
167+
# If not specified, defaults to: Organization, Endpoint, Location, HealthcareService, PractitionerRole, Practitioner
168168
# directoryresourcetypes:
169169
# - "Organization"
170170
# - "Endpoint"
171171
# - "Location"
172172
# - "HealthcareService"
173173
# - "PractitionerRole"
174-
# # - "Practitioner" # Uncomment to also sync Practitioner resources
174+
# - "Practitioner"
175175

176176
# mCSD Admin configuration (web interface)
177177
# mcsdadmin:

0 commit comments

Comments
 (0)