Skip to content

Commit

Permalink
Merge pull request #12 from FHIR/dev
Browse files Browse the repository at this point in the history
Remove dotnet setup action from test action (included in default image)
  • Loading branch information
GinoCanessa authored Sep 9, 2024
2 parents a1c9789 + 77beafc commit e1aed7a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 22 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Tests
# Basics from https://learn.microsoft.com/en-us/dotnet/devops/dotnet-test-github-action
on:
push:
pull_request:
branches: [ main ]
paths:
Expand All @@ -21,11 +20,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: actions/checkout@v4

- name: Install dependencies
run: dotnet restore
Expand All @@ -34,4 +29,4 @@ jobs:
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal
run: dotnet test --configuration Release --no-restore --verbosity normal
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ The server will load initial data specified by the `--fhir-source` argument. If
is a relative path, the software will look for the directory starting at the current running path.

If the system is loading multiple tenants, it will check the path for additional directories based
on the tenant names. For example, a path like `data` passed into the default server will look for
`data/r4`, `data/r4b`, and `data/r5`. If tenant directories are not found, all tenants will try to
on the tenant names. For example, a path like `fhirData` passed into the default server will look for
`fhirData/r4`, `fhirData/r4b`, and `fhirData/r5`. If tenant directories are not found, all tenants will try to
load resources from the specified path.

### Subscriptions Reference Implementation
Expand Down
15 changes: 14 additions & 1 deletion src/fhir-candle/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,20 @@ public static string FindRelativeDir(
string dirName,
bool throwIfNotFound = true)
{
string currentDir = string.IsNullOrEmpty(startDir) ? Path.GetDirectoryName(AppContext.BaseDirectory) ?? string.Empty : startDir;
if (dirName.Contains('~'))
{
// we have a relative path from the user directory
dirName = dirName.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}

if (Directory.Exists(dirName))
{
return Path.GetFullPath(dirName);
}

string currentDir = string.IsNullOrEmpty(startDir)
? Path.GetDirectoryName(AppContext.BaseDirectory) ?? string.Empty
: startDir;
string testDir = Path.Combine(currentDir, dirName);

while (!Directory.Exists(testDir))
Expand Down
6 changes: 2 additions & 4 deletions src/fhir-candle/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
"profiles": {
"candle": {
"commandName": "Project",
"commandLineArgs": "--r4 r4 --smart-optional r4",
"commandLineArgs": "--r4 r4 --smart-optional * --fhir-source ~/fhirData",
"launchBrowser": true,
"applicationUrl": "http://localhost:5826",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4318",
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf"
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"candle-test-data": {
Expand Down
58 changes: 50 additions & 8 deletions src/fhir-candle/Services/FhirStoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void Init()

_isInitialized = true;

// make sure the package service has been initalized
// make sure the package service has been initialized
_packageService.Init();

_logger.LogInformation("FhirStoreManager <<< Creating FHIR tenants...");
Expand Down Expand Up @@ -196,6 +196,8 @@ public void Init()
LoadRequestedPackages(supplemental, _serverConfig.LoadPackageExamples == true).Wait();
}

bool loadedContent = false;

// sort through RI info
if (!string.IsNullOrEmpty(_serverConfig.ReferenceImplementation))
{
Expand All @@ -205,6 +207,41 @@ public void Init()
: Path.Combine(_serverConfig.SourceDirectory, _serverConfig.ReferenceImplementation);

LoadRiContents(supplemental);

loadedContent = true;
}

if (!loadedContent && (!string.IsNullOrEmpty(_serverConfig.SourceDirectory)))
{
// look for a package supplemental directory
string supplementalRoot = Program.FindRelativeDir(string.Empty, _serverConfig.SourceDirectory, false);

if ((!string.IsNullOrEmpty(supplementalRoot)) &&
Directory.Exists(supplementalRoot))
{
loadContents(supplementalRoot);
loadedContent = true;
}
}
else if (!loadedContent)
{
// look for a package supplemental directory
string supplementalRoot = Program.FindRelativeDir(string.Empty, "fhirData", false);

if ((!string.IsNullOrEmpty(supplementalRoot)) &&
Directory.Exists(supplementalRoot))
{
// only allow the root load if the directory does NOT have any subfolders
if (Directory.GetDirectories(supplementalRoot).Length == 0)
{
loadContents(supplementalRoot, true);
}
else
{
loadContents(supplementalRoot, false);
}
loadedContent = true;
}
}

// load packages
Expand Down Expand Up @@ -357,17 +394,15 @@ private void LoadPackagePages()
}
}

/// <summary>Loads ri contents.</summary>
/// <param name="dir">The dir.</param>
public void LoadRiContents(string dir)
private void loadContents(string dir, bool allowRootLoad = true)
{
if (string.IsNullOrEmpty(dir) ||
!Directory.Exists(dir))
{
return;
}

_logger.LogInformation("FhirStoreManager <<< Loading RI contents...");
_logger.LogInformation($"FhirStoreManager <<< Loading contents of {Path.GetFullPath(dir)}...");

// loop over controllers to see where we can add this
foreach ((string tenantName, TenantConfiguration config) in _tenants)
Expand All @@ -391,7 +426,7 @@ public void LoadRiContents(string dir)
Path.Combine(dir, tenantName),
true);
}
else
else if (allowRootLoad)
{
_storesByController[tenantName].LoadPackage(
string.Empty,
Expand All @@ -417,7 +452,7 @@ public void LoadRiContents(string dir)
Path.Combine(dir, tenantName),
true);
}
else
else if (allowRootLoad)
{
_storesByController[tenantName].LoadPackage(
string.Empty,
Expand All @@ -443,7 +478,7 @@ public void LoadRiContents(string dir)
Path.Combine(dir, tenantName),
true);
}
else
else if (allowRootLoad)
{
_storesByController[tenantName].LoadPackage(
string.Empty,
Expand All @@ -458,6 +493,13 @@ public void LoadRiContents(string dir)
}
}

/// <summary>Loads ri contents.</summary>
/// <param name="dir">The dir.</param>
public void LoadRiContents(string dir)
{
loadContents(dir);
}

/// <summary>Loads requested packages.</summary>
/// <exception cref="Exception">Thrown when an exception error condition occurs.</exception>
/// <param name="supplementalRoot">The supplemental root.</param>
Expand Down

0 comments on commit e1aed7a

Please sign in to comment.