Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Dec 31, 2023
1 parent fbd42bd commit 2c1c53f
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 6 deletions.
114 changes: 112 additions & 2 deletions library/fhir/fhir_factory.pas
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,90 @@ TFHIRFactoryX = class (TFHIRFactory)

implementation

type

{ TFhirSystemCoding }

TFhirSystemCoding = class (TFHIRCodingW)
private
function tuple : TFHIRSystemTuple;
protected
function getCode: String; override;
function getDisplay: String; override;
function getSystem: String; override;
function getVersion: String; override;
procedure setCode(Value: String); override;
procedure setDisplay(Value: String); override;
procedure setSystem(Value: String); override;
procedure setVersion(Value: String); override;
public
destructor Destroy; override;
end;

{ TFhirSystemCoding }

function TFhirSystemCoding.tuple: TFHIRSystemTuple;
begin
result := Element as TFhirSystemTuple;
end;

function TFhirSystemCoding.getCode: String;
begin
if tuple.Fields['code'] = nil then
result := ''
else
result := (tuple.Fields['code'] as TFHIRObject).ToString;
end;

function TFhirSystemCoding.getDisplay: String;
begin
if tuple.Fields['display'] = nil then
result := ''
else
result := (tuple.Fields['display'] as TFHIRObject).ToString;
end;

function TFhirSystemCoding.getSystem: String;
begin
if tuple.Fields['system'] = nil then
result := ''
else
result := (tuple.Fields['system'] as TFHIRObject).ToString;
end;

function TFhirSystemCoding.getVersion: String;
begin
if tuple.Fields['version'] = nil then
result := ''
else
result := (tuple.Fields['version'] as TFHIRObject).ToString;
end;

procedure TFhirSystemCoding.setCode(Value: String);
begin
raise EFSLException.create('TFhirSystemCoding.setCode is Not supported');
end;

procedure TFhirSystemCoding.setDisplay(Value: String);
begin
raise EFSLException.create('TFhirSystemCoding.setDisplay is Not supported');
end;

procedure TFhirSystemCoding.setSystem(Value: String);
begin
raise EFSLException.create('TFhirSystemCoding.setSystem is Not supported');
end;

procedure TFhirSystemCoding.setVersion(Value: String);
begin
raise EFSLException.create('TFhirSystemCoding.setVersion is Not supported');
end;

destructor TFhirSystemCoding.Destroy;
begin
inherited Destroy;
end;

{ TFHIRFactoryX }

function TFHIRFactoryX.versionName: String;
Expand Down Expand Up @@ -597,8 +681,31 @@ function TFHIRFactoryX.makeCodeableConcept(coding: TFHIRCodingW): TFHIRObject;
end;

function TFHIRFactoryX.makeCoding(systemUri, version, code, display: String): TFHIRObject;
var
t : TFHIRSystemTuple;
begin
raise EFslException.Create('makeCoding is not implemented in the non-versioned FHIRFactory');
t := TFHIRSystemTuple.create;
try
if (systemUri <> '') then
t.Fields.add('system', TFHIRSystemString.Create(systemUri))
else
t.Fields.add('system', nil);
if (version <> '') then
t.Fields.add('version', TFHIRSystemString.Create(version))
else
t.Fields.add('version', nil);
if (code <> '') then
t.Fields.add('code', TFHIRSystemString.Create(code))
else
t.Fields.add('code', nil);
if (display <> '') then
t.Fields.add('display', TFHIRSystemString.Create(display))
else
t.Fields.add('display', nil);
result := t.link;
finally
t.free;
end;
end;

function TFHIRFactoryX.makeString(s: string): TFHIRObject;
Expand Down Expand Up @@ -721,7 +828,10 @@ function TFHIRFactoryX.wrapExtension(o: TFHIRObject): TFhirExtensionW;

function TFHIRFactoryX.wrapCoding(o: TFHIRObject): TFhirCodingW;
begin
raise EFslException.Create('wrapCoding is not implemented in the non-versioned FHIRFactory');
if o = nil then
result := nil
else
result := TFhirSystemCoding.create(o);
end;

function TFHIRFactoryX.wrapCodeableConcept(o: TFHIRObject): TFhirCodeableConceptW;
Expand Down
1 change: 1 addition & 0 deletions library/fhir/fhir_objects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ TFHIRSystemString = class (TFHIRObject)
function ToString : String; override;
end;


TFHIRSystemTuple = class (TFHIRObject)
private
FFields : TFslMap<TFHIRObject>;
Expand Down
2 changes: 0 additions & 2 deletions library/fsl/tests/fsl_tests_web.pas
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ procedure TJWTTests.TestPacking;
s : String;
jwt : TJWT;
begin
raise EFslException.create('fix me');

jwk := TJWK.create(TJSONParser.Parse('{"kty": "oct", "k": "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow"}'));
try
// this test is from the spec
Expand Down
5 changes: 3 additions & 2 deletions library/web/fsl_crypto.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ class function TJWTUtils.Sign_ES256(input: TBytes; key: TJWK): TBytes;
var
ctx : PEVP_MD_CTX;
keysize : integer;
len, l : Cardinal;
len, l : QWord;
p : System.PByte;
pkey: PEVP_PKEY;
PkeyCtx: PEVP_PKEY_CTX;
Expand Down Expand Up @@ -1598,6 +1598,7 @@ class function TJWTUtils.Sign_ES256(input: TBytes; key: TJWK): TBytes;

// 2. do the signing
keysize := EVP_PKEY_size(pkey);
len := keysize;
SetLength(result, keysize);
ctx := EVP_MD_CTX_new;
try
Expand Down Expand Up @@ -1672,7 +1673,7 @@ class function TJWTUtils.Sign_Hmac_RSA256(input: TBytes; key: TJWK): TBytes;
var
ctx : PEVP_MD_CTX;
keysize : integer;
len : Cardinal;
len : QWord;
pkey: PEVP_PKEY;
rkey: PRSA;
keys : TJWKList;
Expand Down

0 comments on commit 2c1c53f

Please sign in to comment.