Skip to content

Commit

Permalink
Merge branch 'HealthIntersections:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
costateixeira authored Jul 24, 2023
2 parents 071bafc + 80387cb commit 50b3ba7
Show file tree
Hide file tree
Showing 70 changed files with 3,836 additions and 331 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ utilities/codescan/codescan.app/Contents/Info.plist
utilities/codescan/codescan.app/Contents/MacOS/

utilities/codescan/codescan.app/Contents/

exec/cert/
15 changes: 13 additions & 2 deletions library/fhir/fhir_client.pas
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ TFHIRClientCommunicator = class (TFslObject)

// version independent API
function conformanceV(summary : boolean) : TFHIRResourceV; virtual; abstract;
function conformanceModeV(mode : string) : TFHIRResourceV; virtual; abstract;
function transactionV(bundle : TFHIRResourceV) : TFHIRResourceV; virtual; abstract;
function createResourceV(resource : TFHIRResourceV; var id : String) : TFHIRResourceV; virtual; abstract;
function readResourceV(atype : TFhirResourceTypeV; id : String) : TFHIRResourceV; virtual; abstract;
Expand All @@ -230,6 +231,8 @@ TFHIRClientCommunicator = class (TFslObject)

TFhirClientProgressEvent = procedure (client : TObject; details : String; pct : integer; done : boolean) of Object;

{ TFhirClientV }

TFhirClientV = class abstract (TFslObject)
private
FCommunicator : TFHIRClientCommunicator;
Expand Down Expand Up @@ -284,6 +287,7 @@ TFhirClientV = class abstract (TFslObject)

// version independent API
function conformanceV(summary : boolean) : TFHIRResourceV;
function conformanceModeV(mode : string) : TFHIRResourceV;
function transactionV(bundle : TFHIRResourceV) : TFHIRResourceV;
function createResourceV(resource : TFHIRResourceV; var id : String) : TFHIRResourceV;
function readResourceV(atype : TFhirResourceTypeV; id : String) : TFHIRResourceV;
Expand Down Expand Up @@ -508,7 +512,8 @@ function TFHIRClientCommunicator.sizeInBytesV(magic : integer) : cardinal;

{ TFhirClientV }

constructor TFhirClientV.create(worker : TFHIRWorkerContextV; const lang : THTTPLanguages; communicator : TFHIRClientCommunicator);
constructor TFhirClientV.Create(worker: TFHIRWorkerContextV;
const lang: THTTPLanguages; communicator: TFHIRClientCommunicator);
begin
inherited Create;
FWorker := worker;
Expand Down Expand Up @@ -587,6 +592,11 @@ function TFhirClientV.conformanceV(summary : boolean) : TFHIRResourceV;
result := FCommunicator.conformanceV(summary);
end;

function TFhirClientV.conformanceModeV(mode : string) : TFHIRResourceV;
begin
result := FCommunicator.conformanceModeV('terminology');
end;

function TFhirClientV.transactionV(bundle : TFHIRResourceV) : TFHIRResourceV;
begin
result := FCommunicator.transactionV(bundle);
Expand Down Expand Up @@ -672,7 +682,8 @@ function TFhirClientV.historyTypeV(atype : TFHIRResourceTypeV; allRecords : bool
result := FCommunicator.historyTypeV(aType, allRecords, encodeParams(params));
end;

function TFhirClientV.historyInstanceV(atype : TFHIRResourceTypeV; id : String; allRecords : boolean; params : TStringList) : TFHIRResourceV;
function TFhirClientV.historyinstanceV(atype: TFHIRResourceTypeV; id: String;
allRecords: boolean; params: TStringList): TFHIRResourceV;
begin
result := FCommunicator.historyinstanceV(aType, id, allRecords, encodeParams(params));
end;
Expand Down
41 changes: 31 additions & 10 deletions library/fhir/fhir_client_http.pas
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ interface
TFhirHTTPClientHTTPVerb = (httpGet, httpPost, httpPut, httpDelete, httpOptions, httpPatch);

// use only in one thread at a time

{ TFHIRHTTPCommunicator }

TFHIRHTTPCommunicator = class (TFHIRClientCommunicator)
private
FUrl : String;
Expand Down Expand Up @@ -111,6 +114,7 @@ TFHIRHTTPCommunicator = class (TFHIRClientCommunicator)
function address : String; override;

function conformanceV(summary : boolean) : TFHIRResourceV; override;
function conformanceModeV(mode : string) : TFHIRResourceV; override;
function transactionV(bundle : TFHIRResourceV) : TFHIRResourceV; override;
function createResourceV(resource : TFHIRResourceV; var id : String) : TFHIRResourceV; override;
function readResourceV(atype : TFhirResourceTypeV; id : String) : TFHIRResourceV; override;
Expand Down Expand Up @@ -176,7 +180,7 @@ constructor TFHIRHTTPCommunicator.Create(url: String);
{$ENDIF}
end;

destructor TFHIRHTTPCommunicator.destroy;
destructor TFHIRHTTPCommunicator.Destroy;
begin
ssl.Free;
indy.free;
Expand Down Expand Up @@ -722,6 +726,13 @@ function TFHIRHTTPCommunicator.conformanceV(summary : boolean): TFHIRResourceV;
result := FetchResource(MakeUrl('metadata'), httpGet, nil, headers);
end;

function TFHIRHTTPCommunicator.conformanceModeV(mode: string): TFHIRResourceV;
var
headers : THTTPHeaders;
begin
result := FetchResource(MakeUrl('metadata')+'?mode='+mode, httpGet, nil, headers);
end;

function TFHIRHTTPCommunicator.transactionV(bundle : TFHIRResourceV) : TFHIRResourceV;
Var
src : TStream;
Expand All @@ -735,7 +746,8 @@ function TFHIRHTTPCommunicator.transactionV(bundle : TFHIRResourceV) : TFHIRReso
end;
end;

function TFHIRHTTPCommunicator.createResourceV(resource: TFhirResourceV; var id : String): TFHIRResourceV;
function TFHIRHTTPCommunicator.createResourceV(resource: TFHIRResourceV;
var id: String): TFHIRResourceV;
Var
src : TStream;
headers : THTTPHeaders;
Expand Down Expand Up @@ -781,7 +793,8 @@ function TFHIRHTTPCommunicator.vreadResourceV(atype: TFhirResourceTypeV; id, vid
end;
end;

function TFHIRHTTPCommunicator.updateResourceV(resource : TFhirResourceV) : TFHIRResourceV;
function TFHIRHTTPCommunicator.updateResourceV(resource: TFHIRResourceV
): TFHIRResourceV;
Var
src : TStream;
headers : THTTPHeaders;
Expand All @@ -799,14 +812,16 @@ function TFHIRHTTPCommunicator.updateResourceV(resource : TFhirResourceV) : TFHI
end;
end;

procedure TFHIRHTTPCommunicator.deleteResourceV(atype : TFhirResourceTypeV; id : String);
procedure TFHIRHTTPCommunicator.deleteResourceV(atype: TFHIRResourceTypeV;
id: String);
var
headers : THTTPHeaders;
begin
exchange(MakeUrl(aType+'/'+id), httpDelete, nil, headers).free;
end;

function TFHIRHTTPCommunicator.searchV(atype: TFhirResourceTypeV; allRecords: boolean; params: string): TFHIRResourceV;
function TFHIRHTTPCommunicator.searchV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: string): TFHIRResourceV;
var
s : String;
bnd : TFHIRResourceV;
Expand Down Expand Up @@ -847,7 +862,9 @@ function TFHIRHTTPCommunicator.searchAgainV(link: String): TFHIRResourceV;
result := fetchResource(link, httpGet, nil, headers) as TFHIRResourceV;
end;

function TFHIRHTTPCommunicator.searchPostV(atype: TFhirResourceTypeV; allRecords: boolean; params: TStringList; resource: TFhirResourceV): TFHIRResourceV;
function TFHIRHTTPCommunicator.searchPostV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: TStringList; resource: TFHIRResourceV
): TFHIRResourceV;
var
src, frm : TStream;
ct : String;
Expand All @@ -867,7 +884,8 @@ function TFHIRHTTPCommunicator.searchPostV(atype: TFhirResourceTypeV; allRecords
end;
end;

function TFHIRHTTPCommunicator.operationV(atype : TFhirResourceTypeV; opName : String; params : TFHIRResourceV) : TFHIRResourceV;
function TFHIRHTTPCommunicator.operationV(atype: TFHIRResourceTypeV;
opName: String; params: TFHIRResourceV): TFHIRResourceV;
Var
src : TStream;
headers : THTTPHeaders;
Expand All @@ -884,7 +902,8 @@ function TFHIRHTTPCommunicator.operationV(atype : TFhirResourceTypeV; opName : S
end;
end;

function TFHIRHTTPCommunicator.operationV(atype : TFhirResourceTypeV; id, opName : String; params : TFHIRResourceV) : TFHIRResourceV;
function TFHIRHTTPCommunicator.operationV(atype: TFHIRResourceTypeV; id,
opName: String; params: TFHIRResourceV): TFHIRResourceV;
Var
src : TStream;
headers : THTTPHeaders;
Expand Down Expand Up @@ -933,7 +952,8 @@ function TFHIRHTTPCommunicator.patchResourceV(atype: TFhirResourceTypeV; id: Str
end;
end;

function TFHIRHTTPCommunicator.historyTypeV(atype: TFhirResourceTypeV; allRecords: boolean; params: string): TFHIRResourceV;
function TFHIRHTTPCommunicator.historyTypeV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: string): TFHIRResourceV;
var
s : String;
feed : TFHIRResourceV;
Expand Down Expand Up @@ -967,7 +987,8 @@ function TFHIRHTTPCommunicator.historyTypeV(atype: TFhirResourceTypeV; allRecord
end;
end;

function TFHIRHTTPCommunicator.historyInstanceV(atype: TFhirResourceTypeV; id : String; allRecords: boolean; params: string): TFHIRResourceV;
function TFHIRHTTPCommunicator.historyInstanceV(atype: TFHIRResourceTypeV;
id: String; allRecords: boolean; params: string): TFHIRResourceV;
var
s : String;
feed : TFHIRResourceV;
Expand Down
61 changes: 50 additions & 11 deletions library/fhir/fhir_client_threaded.pas
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ interface

type

{ TFhirThreadedClientPackage }

TFhirThreadedClientPackage = class (TFslObject)
private
FCommand: TFHIRCommandType;
FMode: string;
FSummary: boolean;
FError: String;
FResult: TFhirResourceV;
Expand Down Expand Up @@ -74,6 +77,7 @@ TFhirThreadedClientPackage = class (TFslObject)

property command : TFHIRCommandType read FCommand write FCommand;
property summary : boolean read FSummary write FSummary;
property mode : string read FMode write FMode;
property resourceType : TFhirResourceTypeV read FResourceType write FResourceType;
property allRecords : boolean read FAllRecords write FAllRecords;
property params : TStringList read FParams write FParams;
Expand Down Expand Up @@ -103,6 +107,8 @@ TFhirThreadedClientThread = class (TThread)
destructor Destroy; override;
end;

{ TFhirFacadeCommunicator }

TFhirFacadeCommunicator = class abstract (TFHIRClientCommunicator)
protected
FInternal : TFhirClientV;
Expand All @@ -112,7 +118,8 @@ TFhirFacadeCommunicator = class abstract (TFHIRClientCommunicator)
destructor Destroy; override;

function address : String; override;
function conformanceV(summary : boolean) : TFHIRResourceV; override;
function conformanceV(summary : boolean) : TFHIRResourceV; override;
function conformanceModeV(mode : string) : TFHIRResourceV; override;
function transactionV(bundle : TFHIRResourceV) : TFHIRResourceV; override;
function createResourceV(resource : TFHIRResourceV; var id : String) : TFHIRResourceV; override;
function readResourceV(atype : TFhirResourceTypeV; id : String) : TFHIRResourceV; override;
Expand Down Expand Up @@ -224,7 +231,10 @@ procedure TFhirThreadedClientThread.execute;
try
try
case FPackage.command of
fcmdMetadata: FPackage.result := FClient.conformanceV(FPackage.summary);
fcmdMetadata: if FPackage.mode <> '' then
FPackage.result := FClient.conformanceModeV(FPackage.mode)
else
FPackage.result := FClient.conformanceV(FPackage.summary);
fcmdTransaction : FPackage.result := FCLient.transactionV(FPackage.resource as TFHIRResourceV);
fcmdRead : FPackage.result := FClient.readResourceV(FPackage.ResourceType, FPackage.id);
fcmdVersionRead : FPackage.result := FClient.vreadResourceV(FPackage.ResourceType, FPackage.id, FPackage.vid);
Expand Down Expand Up @@ -311,7 +321,27 @@ function TFhirFacadeCommunicator.conformanceV(summary: boolean): TFHIRResourceV;
end;
end;

function TFhirFacadeCommunicator.createResourceV(resource: TFhirResourceV; var id: String): TFHIRResourceV;
function TFhirFacadeCommunicator.conformanceModeV(mode: string): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
pack := TFhirThreadedClientPackage.create;
try
pack.command := fcmdMetadata;
pack.mode := mode;
pack.Thread := TFhirThreadedClientThread.create(FInternal.link, pack.Link);
process(pack);
result := pack.result.link;
FHeaders := FInternal.LastHeaders;
FClient.LastUrl := pack.lastUrl;
FClient.LastStatus := pack.lastStatus;
finally
pack.free;
end;
end;

function TFhirFacadeCommunicator.createResourceV(resource: TFHIRResourceV;
var id: String): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
Expand Down Expand Up @@ -374,22 +404,26 @@ function TFhirFacadeCommunicator.customPost(path: String; headers: THTTPHeaders;
end;
end;

procedure TFhirFacadeCommunicator.deleteResourceV(atype: TFhirResourceTypeV; id: String);
procedure TFhirFacadeCommunicator.deleteResourceV(atype: TFHIRResourceTypeV;
id: String);
begin
raise EFHIRTodo.create('TFhirThreadedCommunicator.deleteResourceV');
end;

function TFhirFacadeCommunicator.historyTypeV(atype: TFhirResourceTypeV; allRecords: boolean; params : string): TFHIRResourceV;
function TFhirFacadeCommunicator.historyTypeV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: string): TFHIRResourceV;
begin
raise EFHIRTodo.create('TFhirThreadedCommunicator.historyTypeV');
end;

function TFhirFacadeCommunicator.historyInstanceV(atype: TFhirResourceTypeV; id : String; allRecords: boolean; params : string): TFHIRResourceV;
function TFhirFacadeCommunicator.historyInstanceV(atype: TFHIRResourceTypeV;
id: String; allRecords: boolean; params: string): TFHIRResourceV;
begin
raise EFHIRTodo.create('TFhirThreadedCommunicator.historyInstanceV');
end;

function TFhirFacadeCommunicator.operationV(atype: TFhirResourceTypeV; id, opName: String; params: TFHIRResourceV): TFHIRResourceV;
function TFhirFacadeCommunicator.operationV(atype: TFHIRResourceTypeV; id,
opName: String; params: TFHIRResourceV): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
Expand Down Expand Up @@ -421,7 +455,8 @@ function TFhirFacadeCommunicator.patchResourceV(atype: TFhirResourceTypeV; id: S
raise EFslException.Create('not done yet');
end;

function TFhirFacadeCommunicator.operationV(atype: TFhirResourceTypeV; opName: String; params: TFHIRResourceV): TFHIRResourceV;
function TFhirFacadeCommunicator.operationV(atype: TFHIRResourceTypeV;
opName: String; params: TFHIRResourceV): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
Expand Down Expand Up @@ -483,7 +518,8 @@ function TFhirFacadeCommunicator.vreadResourceV(atype: TFhirResourceTypeV; id, v
end;
end;

function TFhirFacadeCommunicator.searchV(atype: TFhirResourceTypeV; allRecords: boolean; params : string): TFHIRResourceV;
function TFhirFacadeCommunicator.searchV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: string): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
Expand Down Expand Up @@ -524,7 +560,9 @@ function TFhirFacadeCommunicator.searchAgainV(link: String): TFHIRResourceV;
end;
end;

function TFhirFacadeCommunicator.searchPostV(atype: TFhirResourceTypeV; allRecords: boolean; params : TStringList; resource: TFhirResourceV): TFHIRResourceV;
function TFhirFacadeCommunicator.searchPostV(atype: TFHIRResourceTypeV;
allRecords: boolean; params: TStringList; resource: TFHIRResourceV
): TFHIRResourceV;
begin
raise EFHIRTodo.create('TFhirThreadedCommunicator.searchPostV');
end;
Expand All @@ -548,7 +586,8 @@ function TFhirFacadeCommunicator.transactionV(bundle: TFHIRResourceV): TFHIRReso
end;
end;

function TFhirFacadeCommunicator.updateResourceV(resource: TFhirResourceV): TFHIRResourceV;
function TFhirFacadeCommunicator.updateResourceV(resource: TFHIRResourceV
): TFHIRResourceV;
var
pack : TFhirThreadedClientPackage;
begin
Expand Down
17 changes: 13 additions & 4 deletions library/fhir/fhir_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ TFHIRXVersionElementWrapper = class abstract (TFHIRObject)
procedure deleteExtensionW(extension : TFHIRExtensionW);
procedure deleteExtensionByUrl(url : String); override;
procedure stripExtensions(exemptUrls : TStringArray); override;
procedure copyExtensions(src : TFHIRObject; exemptUrls : TStringArray); override;
end;
TFHIRXVersionElementWrapperClass = class of TFHIRXVersionElementWrapper;

Expand Down Expand Up @@ -841,7 +842,8 @@ TFhirValueSetExpansionContainsW = class (TFHIRXVersionElementWrapper)

procedure addDesignation(lang, use, value : String); overload; virtual; abstract;
procedure addDesignation(lang : TIETFLang; use : TFHIRCodingW; value : TFHIRPrimitiveW; extensions : TFslList<TFHIRExtensionW>); overload; virtual; abstract;
procedure addProperty(code : String; value : TFHIRObject); virtual; abstract;
procedure addProperty(code : String; value : TFHIRObject); virtual; abstract; overload;
procedure addProperty(code : String; value : TFhirCodeSystemConceptPropertyW); virtual; abstract; overload;
procedure addContains(contained : TFhirValueSetExpansionContainsW); virtual; abstract;
procedure clearContains(); virtual; abstract;
function contains : TFslList<TFhirValueSetExpansionContainsW>; virtual; abstract;
Expand Down Expand Up @@ -949,6 +951,7 @@ TFhirValueSetW = class (TFHIRMetadataResourceW)
function source : String; virtual; abstract;

function checkCompose(place, role : String) : boolean; virtual; abstract;
function getComposeExtensions : TFslList<TFHIRExtensionW>; virtual; abstract;
function checkExpansion(place, role : String) : boolean; virtual; abstract;
function imports : TArray<String>; virtual; abstract; // only in R2
function hasInlineCS : boolean; virtual; abstract;
Expand Down Expand Up @@ -1924,6 +1927,11 @@ procedure TFHIRXVersionElementWrapper.stripExtensions(exemptUrls: TStringArray);
FElement.stripExtensions(exemptUrls);
end;

procedure TFHIRXVersionElementWrapper.copyExtensions(src: TFHIRObject; exemptUrls: TStringArray);
begin
FElement.copyExtensions(src, exemptUrls);
end;

constructor TFHIRXVersionElementWrapper.Create(elem : TFHIRObject);
begin
inherited create;
Expand Down Expand Up @@ -2486,9 +2494,10 @@ function TFHIRGroupCharacteristicW.Link: TFHIRGroupCharacteristicW;

function TFHIRMetadataResourceW.GetVUrl: String;
begin
result := url;
if version <> '' then
result := result + '|'+version;
if version = '' then
result := url
else
result := url + '|'+version;
end;

function TFHIRMetadataResourceW.link: TFHIRMetadataResourceW;
Expand Down
Loading

0 comments on commit 50b3ba7

Please sign in to comment.