Skip to content

Commit

Permalink
Merge pull request #26 from SylvainGuilbaud/fhir-utils
Browse files Browse the repository at this point in the history
FHIR.utils
  • Loading branch information
evshvarov authored Mar 12, 2024
2 parents 9e06c98 + 7f6e7fe commit b4fcf88
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"objectscript.conn" :{
"ns": "FHIRSERVER",
"active": false,
"active": true,
"username": "_SYSTEM",
"password": "SYS",
"docker-compose": {
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ WORKDIR /home/irisowner/irisdev
# copy all the source into container and run iris. also run a initial script
RUN --mount=type=bind,src=.,dst=. \
iris start IRIS && \
iris merge IRIS merge.cpf && \
iris session IRIS < iris.script && \
iris stop IRIS quietly

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ services:
context: .
dockerfile: Dockerfile
restart: always
hostname: fhir-template
container_name: fhir-template
# command: --check-caps false
ports:
- 32782:1972
Expand All @@ -14,3 +16,6 @@ services:
- -a
- iris session iris -U%SYS '##class(Security.Users).UnExpireUserPasswords("*")'
- --check-caps false
volumes:
- ./data:/data
- ./:/home/irisowner/irisdev
13 changes: 6 additions & 7 deletions iris.script
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
zn "USER"
zpm "install fhir-portal"
zpm "load /home/irisowner/irisdev/ -v"
// After FHIRSERVER creation
// need to add User.SQLvar.cls in FHIRSERVER
// in order to be able to run SQL queries
// with JSON functions
zn "FHIRSERVER"
do $System.OBJ.LoadDir("/home/irisowner/irisdev/src/User","ck",,1)
#; zpm "install fhir-portal"
#; Use FHIR.utils.install
#; to add new FHIR servers
#; zn "USER"
#; do ##class(FHIR.utils).install("PID")
#; do ##class(FHIR.utils).install("CLINIC")
halt
14 changes: 14 additions & 0 deletions merge.cpf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Actions]
# Service CallIn
ModifyService:Name=%Service_CallIn,Enabled=1,AutheEnabled=48

# %ALL
CreateNamespace:Name=%ALL,Globals=%DEFAULTDB,Routines=%DEFAULTDB
CreateMapPackage:Namespace=%ALL,Name=User,Database=USER

# FHIRSERVER
CreateResource:Name=%DB_FHIRSERVER_DATA,Description="FHIRSERVER_DATA database"
CreateDatabase:Name=FHIRSERVER_DATA,Directory=/usr/irissys/mgr/FHIRSERVER_DATA
CreateResource:Name=%DB_FHIRSERVER_CODE,Description="FHIRSERVER_CODE database"
CreateDatabase:Name=FHIRSERVER_CODE,Directory=/usr/irissys/mgr/FHIRSERVER_CODE
CreateNamespace:Name=FHIRSERVER,Globals=FHIRSERVER_DATA,Routines=FHIRSERVER_CODE,Interop=1
28 changes: 28 additions & 0 deletions merge_PID_CLINIC.cpf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Actions]
# Service CallIn
ModifyService:Name=%Service_CallIn,Enabled=1,AutheEnabled=48

# %ALL
CreateNamespace:Name=%ALL,Globals=%DEFAULTDB,Routines=%DEFAULTDB
CreateMapPackage:Namespace=%ALL,Name=User.SQLvar,Database=USER

# FHIRSERVER
CreateResource:Name=%DB_FHIRSERVER_DATA,Description="FHIRSERVER_DATA database"
CreateDatabase:Name=FHIRSERVER_DATA,Directory=/usr/irissys/mgr/FHIRSERVER_DATA
CreateResource:Name=%DB_FHIRSERVER_CODE,Description="FHIRSERVER_CODE database"
CreateDatabase:Name=FHIRSERVER_CODE,Directory=/usr/irissys/mgr/FHIRSERVER_CODE
CreateNamespace:Name=FHIRSERVER,Globals=FHIRSERVER_DATA,Routines=FHIRSERVER_CODE,Interop=1

# CLINIC
CreateResource:Name=%DB_CLINIC_DATA,Description="CLINIC_DATA database"
CreateDatabase:Name=CLINIC_DATA,Directory=/usr/irissys/mgr/CLINIC_DATA
CreateResource:Name=%DB_CLINIC_CODE,Description="CLINIC_CODE database"
CreateDatabase:Name=CLINIC_CODE,Directory=/usr/irissys/mgr/CLINIC_CODE
CreateNamespace:Name=CLINIC,Globals=CLINIC_DATA,Routines=CLINIC_CODE,Interop=1

# PID
CreateResource:Name=%DB_PID_DATA,Description="PID_DATA database"
CreateDatabase:Name=PID_DATA,Directory=/usr/irissys/mgr/PID_DATA
CreateResource:Name=%DB_PID_CODE,Description="PID_CODE database"
CreateDatabase:Name=PID_CODE,Directory=/usr/irissys/mgr/PID_CODE
CreateNamespace:Name=PID,Globals=PID_DATA,Routines=PID_CODE,Interop=1
1 change: 1 addition & 0 deletions module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</Invokes>
<Resource Name="fhirtemplate.PKG"/>
<Resource Name="User.PKG"/>
<Resource Name="FHIR.PKG"/>
<FileCopy Name="data/fhir/" Target="${mgrdir}test-data-fhir/"/>
<CSPApplication
Url="/fhirUI"
Expand Down
93 changes: 93 additions & 0 deletions src/FHIR/utils.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Class FHIR.utils
{

ClassMethod install(NAMESPACE As %String = "FHIRDEMO") As %Status
{
set sc = $$$OK
set ns = $NAMESPACE
zn "HSLIB"
Set appKey = "/"_$zcvt(NAMESPACE,"l")_"/fhir/r4"
Set strategyClass = "HS.FHIRServer.Storage.Json.InteractionsStrategy"
Set metadataConfigKey = "HL7v40"

//Install a Foundation namespace and change to it
// https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=HSSYS&CLASSNAME=HS.Util.Installer.Foundation#Install
Do ##class(HS.Util.Installer.Foundation).Install(NAMESPACE)

zn NAMESPACE

// Install elements that are required for a FHIR-enabled namespace
// https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=HSSYS&CLASSNAME=HS.FHIRServer.Installer#InstallNamespace
Do ##class(HS.FHIRServer.Installer).InstallNamespace()

// Install an instance of a FHIR Service into the current namespace
// https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=HSSYS&CLASSNAME=HS.FHIRServer.Installer#InstallInstance
Do ##class(HS.FHIRServer.Installer).InstallInstance(appKey, strategyClass, metadataConfigKey)
#; do ##class(Ens.Director).StopProduction()

#; zw $classmethod("Ens.Director", "SetAutoStart", NAMESPACE_"PKG.FoundationProduction", 0)

#; set cspConfig = ##class(HS.Util.RESTCSPConfig).URLIndexOpen(appKey)
#; set cspConfig.ServiceConfigName = "HS.FHIRServer.Interop.Service"
#; set cspConfig.AllowUnauthenticatedAccess = 1
#; zw cspConfig.%Save()

#; set strategy = ##class(HS.FHIRServer.API.InteractionsStrategy).GetStrategyForEndpoint(appKey)
#; set config = strategy.GetServiceConfigData()
#; set config.DebugMode = 4
#; do strategy.SaveServiceConfigData(config)
zn ns
return sc
}

ClassMethod uninstall(NAMESPACE As %String = "FHIRDEMO") As %Status
{
set sc = $$$OK
set ns = $NAMESPACE

zn "HSLIB"
set appKey = "/"_$zcvt(NAMESPACE,"l")_"/fhir/r4"

//Uninstall a Foundation namespace and change to it
/// https://docs.intersystems.com/irisforhealthlatest/csp/documatic/%25CSP.Documatic.cls?LIBRARY=HSSYS&CLASSNAME=HS.Util.Installer.Foundation#UnInstall
Do ##class(HS.Util.Installer.Foundation).UnInstall(NAMESPACE)

zn NAMESPACE

#; // Uninstall an instance of a FHIR Service into the current namespace
Do ##class(HS.FHIRServer.Installer).UninstallInstance(appKey)

zn ns
return sc
}

/// Delete all resources from the FHIR Server
ClassMethod purge(pServiceName As %String = "/fhirhl7v2demo/fhir/r4") As %Status
{
Try {
set sc = $$$OK
set strategy = ##class(HS.FHIRServer.API.InteractionsStrategy).GetStrategyForEndpoint(pServiceName)
set options("deleteDataOnly") = 1
do strategy.Delete(.options)
}
Catch ex {
set sc=ex.AsStatus()
}

return sc
}

/// Load resources in the FHIR Server
ClassMethod load(pInputDirectory As %String = "/data/fhir/", pServiceType As %String = "FHIRServer", pServiceName As %String = "/fhir/r4", pDisplayProgress As %Boolean = 1) As %Status
{
Try {
set sc = $$$OK
set sc = ##class(HS.FHIRServer.Tools.DataLoader).SubmitResourceFiles(pInputDirectory, pServiceType, pServiceName, pDisplayProgress)
}
Catch ex {
set tSC=ex.AsStatus()
}
return sc
}

}

0 comments on commit b4fcf88

Please sign in to comment.