Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload from firely Terminal to Server #8

Open
jensdebernitzCGM opened this issue Aug 26, 2021 · 12 comments
Open

Upload from firely Terminal to Server #8

jensdebernitzCGM opened this issue Aug 26, 2021 · 12 comments

Comments

@jensdebernitzCGM
Copy link

Hello,

I have download 1 packages with 4 dependencies with fhir install mio.kbv.mutterpass 1.0.0.
As next I have an Fhir Server (Spark) and now I will pushed the new packages with StructureDefinitions, ValueSets and more to the Spark Server.

How can I make this?

@alexzautke
Copy link
Member

Hi @jensdebernitzCGM,

you can generate a list of all conformance resources with fhir canonicals <pkgname>. Combined with fhir resolve you can generate a stack all all needed resources. Once you have all resources on the stack, you can call fhir postor fhir put to load them into the server. See https://github.com/alexzautke/install-fhir-packages for a similar script.

@jensdebernitzCGM
Copy link
Author

Hello,

thanks for yout answer.

but with yout script end with an error

Here is wath I do

FHIR package name: de.basisprofil.r4
FHIR package version (latest): 0.9.11
Upload package to FHIR server: https://localhost:44305/fhir
Replaced alias 'https://localhost:44305/fhir' from https://localhost:44305/fhir to https://localhost:44305/fhir
Checking if https://localhost:44305/fhir/metadata can be reached
Successfully reached https://localhost:44305/fhir
Installing FHIR package 'de.basisprofil.r4' using version 0.9.11
Added: de.basisprofil.r4 0.9.11.
Restore completed.
Checking if FHIR 'de.basisprofil.r4' using version 0.9.11 was successfully installed
Failed to install package de.basisprofil.r4 using version 0.9.11

@alexzautke
Copy link
Member

alexzautke commented Aug 26, 2021

Can you check the output of fhir cache? You might need to adapt the script in line 59. Some version of packages get installed with <packageName>@<version> instead of <packageName>#<version>.

@jensdebernitzCGM
Copy link
Author

oh yes that it is.

muss I run the Script with Admin rights?

now I become this error

...ing to resolve http://fhir.de/CodeSystem/ifa/pzn
One or more errors occurred. (Access to the path 'C:\Users\jens.debernitz\Druckumgebung' is denied.)
parse error: Invalid numeric literal at line 1, column 4
() to https://localhost:44305/fhir/ifa/pzn
parse error: Invalid numeric literal at line 1, column 4

    The stack is empty.

@alexzautke
Copy link
Member

Sorry, never tried to run it under Windows. Either try running it with admin rights or run it using a Linux subsystem.

@jensdebernitzCGM
Copy link
Author

oh okay, I will test it tomorow under linux.

Thanks so lot for help

@jensDebernitz
Copy link

Hello,

it will not work.

Checking if https://localhost:44305/fhir/metadata can be reached
Successfully reached https://localhost:44305/fhir
Installing FHIR package 'de.basisprofil.r4' using version 0.9.11
Added: de.basisprofil.r4 0.9.11.
Restore completed.
Checking if FHIR 'de.basisprofil.r4' using version 0.9.11 was successfully installed
Successfully found package 'de.basisprofil.r4' with version '0.9.11' in cache

...ing to resolve
Resource was not found in the current scope.
parse error: Invalid numeric literal at line 1, column 4
() to https://localhost:44305/fhir
parse error: Invalid numeric literal at line 1, column 4

    The stack is empty.

@alexzautke
Copy link
Member

I will take a look at the end of the week. Please note that the script is not officially provided by Firely and therefore it's not covered by any of our support.

@alexzautke
Copy link
Member

@jensdebernitzCGM Could you check your version number of Firely Terminal using fhir --version? I can't reproduce any issues with the latest version.

@jensdebernitzCGM
Copy link
Author

Hello @alexzautke,

my version from fhir is
Firely Terminal 2.2.0
FHIR 4.0.1
HL7.FHIR SDK 3.2.0

I changed your shell script to a powershell script. At least it runs better under windows. if you want that I can make it available to you

@alexzautke
Copy link
Member

Yes please, I can see about debugging it on Windows

@jensdebernitzCGM
Copy link
Author

`$Tab = [char]9

$dependencies = @('jq', 'fhir')

foreach($dependency in $dependencies){

if (!(Get-Command $dependency -ErrorAction SilentlyContinue)){
    Write-Output $dependency + ' is not installed'    
    exit
}

}

$packageName = Read-Host "Package Name"
$packageVersion = Read-Host "Package Version"
$fhirServer = Read-Host "Fhir Server"

if ([string]::IsNullOrEmpty($packageName)) {
exit_with_message 'Its mandatory to specify the name of a FHIR package. Exiting...'
}

if ([string]::IsNullOrEmpty($packageVersion)) {
$command = 'fhir versions $packageName -- raw'
$output = call_command_with_output $command
Write-Host $output
}

if ([string]::IsNullOrEmpty($fhirServer)) {
exit_with_message "It's mandatory to specify the endpoint of a FHIR server. Exiting..."
}

$command = 'fhir server add ' + $fhirServer + ' ' + $fhirServer
$output = call_command_with_output $command
Write-Host $output

Write-Host 'Checking if ' + $fhirServer + '/metadata can be reached'
$webParams = @{
Uri = $fhirServer + '/metadata'
}

$webRepsonse = Invoke-WebRequest @webParams -UseBasicParsing | Select-Object -Expand StatusCode

if (!($webRepsonse = '200')) {
exit_with_message 'Could not reach FHIR Server ' + $fhirServer
}
else {
Write-Host "$Tab Successfully reached $fhirServer"
}

Write-Host "Installing FHIR package '$packageName' using version $packageVersion"
$command = 'fhir install ' + $packageName + ' ' + $packageVersion
$output = call_command_with_output $command
Write-Host $output

Write-Host "Checking if FHIR '$packageName' using version $packageVersion was successfully installed"

$command = 'fhir cache'
$output = call_command_with_output $command
Write-Host $output

if (!($output.Contains($packageName + '@' + $packageVersion))){
exit_with_message "Failed to install package $packageName using version $packageVersion"
}
else {
Write-Host "$Tab Successfully found package '$packageName' with version '$packageVersion' in cache"
}

$command = 'fhir canonicals ' + $packageName + ' ' + $packageVersion
$canonicals = call_command_with_output $command
$canonicals = $canonicals.Split("`n")

foreach($canonical in $canonicals){

if( !([string]::IsNullOrEmpty($canonical))) {
   Write-Host "$Tab Trying to resolve $canonical"
   $command = 'fhir resolve ' + $canonical
   $output = call_command_with_output $command
   Write-Host $output

   $command = 'fhir show --output json'
   $json = call_command_with_output $command

   $resourceType = $json | jq -r '.resourceType'
   Write-Host "Uploading $canonical ($resourceType) to $fhirServer"

   $id = $json | jq -r -e '.id'

   if( [string]::IsNullOrEmpty($id)) {
        $command = 'fhir put ' + $fhirServer
        $output = call_command_with_output $command
        Write-Host $output
   }
   else {
        $command = 'fhir post ' + $fhirServer
        $output = call_command_with_output $command
        Write-Host $output
   }

}
}

function call_command_with_output {
param ($cmd)

return & Invoke-Expression $cmd | Out-String

}

function exit_with_message {
param ($message)

Write-Output $message

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants