Skip to content

Commit

Permalink
Merge pull request #25 from SylvainGuilbaud/sql
Browse files Browse the repository at this point in the history
sql
  • Loading branch information
evshvarov authored Feb 1, 2024
2 parents bbad010 + 2be5c8a commit 3f388a1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 67 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": true,
"active": false,
"username": "_SYSTEM",
"password": "SYS",
"docker-compose": {
Expand Down
47 changes: 10 additions & 37 deletions iris.script
Original file line number Diff line number Diff line change
@@ -1,37 +1,10 @@
zn "USER"
zpm "load /home/irisowner/irisdev/ -v":1:1
zpm "install fhir-portal"
halt
/// the below is not important anymore.

zn "HSLIB"
set namespace="FHIRSERVER"

Set appKey = "/fhir/r4"
Set strategyClass = "HS.FHIRServer.Storage.Json.InteractionsStrategy"
set metadataPackages = $lb("[email protected]")
set importdir="/opt/irisapp/src"

//Install a Foundation namespace and change to it
//Do ##class(HS.HC.Util.Installer).InstallFoundation(namespace)
Do ##class(HS.Util.Installer.Foundation).Install(namespace)

zn namespace

// Install elements that are required for a FHIR-enabled namespace
Do ##class(HS.FHIRServer.Installer).InstallNamespace()

// Install an instance of a FHIR Service into the current namespace
Do ##class(HS.FHIRServer.Installer).InstallInstance(appKey, strategyClass, metadataPackages)

// Configure FHIR Service instance to accept unauthenticated requests
set strategy = ##class(HS.FHIRServer.API.InteractionsStrategy).GetStrategyForEndpoint(appKey)
set config = strategy.GetServiceConfigData()
set config.DebugMode = 4
do strategy.SaveServiceConfigData(config)

zw ##class(HS.FHIRServer.Tools.DataLoader).SubmitResourceFiles("/opt/irisapp/fhirdata/", "FHIRServer", appKey)

do $System.OBJ.LoadDir("/opt/irisapp/src","ck",,1)
//zpm "install fhir-portal"
halt
zn "USER"
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"
halt
60 changes: 33 additions & 27 deletions misc/sql/example.sql
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
/* Select all Observation of Patient/1 */
/* Select all Patients */
SELECT
*
FROM HSFHIR_X0001_S.Patient;
/* Select all Observation of Patient/4 */
SELECT
* FROM HSFHIR_X0001_S.Observation
where patient = 'Patient/4';
/* Select all Observation of Patient/4 with lonic code 718-7 (Hemoglobin [Mass/volume] in Blood)*/
SELECT
*
FROM HSFHIR_I0001_S.Observation
where patient = 'Patient/1' ;
FROM HSFHIR_X0001_S.Observation
where patient = 'Patient/4' and code [ '718-7';

/* Select all Observation of Patient/1 with lonic code 718-7 (Hemoglobin [Mass/volume] in Blood)*/
/* Get detail of the Observation/81 */
SELECT
*
FROM HSFHIR_I0001_S.Observation
where patient = 'Patient/1' and code [ '718-7';
FROM HSFHIR_X0001_R.Rsrc where Key = 'Observation/81';

/* Get detail of the observation/16 */
/* Get valueQuantity of the Observation/81 */
SELECT
*
FROM HSFHIR_I0001_R.Rsrc where Key = 'Observation/16';

/* Get valueQuantity of the observation/16 */
SELECT
ID, Key, ResourceString,
GetJSON(ResourceString,'valueQuantity') as valueQuantity
FROM HSFHIR_I0001_R.Rsrc where Key = 'Observation/16';
ID
, Key
, ResourceString
, GetJSON(ResourceString,'valueQuantity') as valueQuantity
FROM HSFHIR_X0001_R.Rsrc where Key = 'Observation/81';

/* Get value of valueQuantity of the observation/16 */
/* Get value of valueQuantity of the Observation/81 */
SELECT
ID, Key, ResourceString,
GetJSON(ResourceString,'valueQuantity') as valueQuantity,
GetProp(GetJSON(ResourceString,'valueQuantity'),'value') as value
FROM HSFHIR_I0001_R.Rsrc where Key = 'Observation/16';
ID
, Key
, ResourceString
, GetJSON(ResourceString,'valueQuantity') as valueQuantity
, GetProp(GetJSON(ResourceString,'valueQuantity'),'value') as value
FROM HSFHIR_X0001_R.Rsrc where Key = 'Observation/81';

/* An complexe example */
SELECT
ID, Key, ResourceString,
GetJSON(ResourceString,'code') as code,
GetJSON(GetJSON(ResourceString,'code'),'coding') as coding,
GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0) as coding1,
GetJSON(GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0),'display') as display,
GetProp(GetJSON(GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0),'display'),'display') as value
FROM HSFHIR_I0001_R.Rsrc where Key = 'Observation/16';
ID, Key, ResourceString
, GetJSON(ResourceString,'code') as code
, GetJSON(GetJSON(ResourceString,'code'),'coding') as coding
, GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0) as coding1
, GetJSON(GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0),'display') as display
, GetProp(GetJSON(GetAtJSON(GetJSON(GetJSON(ResourceString,'code'),'coding'),0),'display'),'display') as value
FROM HSFHIR_X0001_R.Rsrc where Key = 'Observation/81';
1 change: 1 addition & 0 deletions module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<Invoke Class="fhirtemplate.Setup" Method="SetupFHIRServer" Phase="Activate" When="After" ></Invoke>
</Invokes>
<Resource Name="fhirtemplate.PKG"/>
<Resource Name="User.PKG"/>
<FileCopy Name="data/fhir/" Target="${mgrdir}test-data-fhir/"/>
<CSPApplication
Url="/fhirUI"
Expand Down
3 changes: 1 addition & 2 deletions src/fhirtemplate/SQLvar.cls → src/User/SQLvar.cls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Class fhirtemplate.SQLvar
Class User.SQLvar
{

ClassMethod GetJSON(json As %String, name As %String) As %String(MAXLEN="") [ SqlName = GetJSON, SqlProc ]
Expand Down Expand Up @@ -79,4 +79,3 @@ ClassMethod GetFHIRPathOne(json As %String, path As %String, resourceType As %St
}

}

0 comments on commit 3f388a1

Please sign in to comment.