Skip to content

Commit 786528a

Browse files
author
Grahame Grieve
committed
check for modifier extensions more thoroughly
1 parent 8f039c3 commit 786528a

6 files changed

Lines changed: 81 additions & 6 deletions

File tree

library/fhir/fhir_common.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ interface
6565

6666
const
6767
CODES_TFhirFilterOperator: Array[TFilterOperator] of String = ('', '=', 'is-a', 'descendent-of', 'is-not-a', 'regex', 'in', 'not-in', 'generalizes', 'exists', 'child-of', 'descendent-leaf', 'of');
68+
CODES_TFhirFilterOperatorVCL: Array[TFilterOperator] of String = ('', '=', '<<', '<', '~<<', '/', '^', '~^', '>>', '?', '<!', '!!<', '.');
6869
CODES_TPublicationStatus: Array[TPublicationStatus] of String = ('', 'draft', 'active', 'retired');
6970
CODES_TTokenCategory : array [TTokenCategory] of String = ('Clinical', 'Data', 'Meds', 'Schedule', 'Audit', 'Documents', 'Financial', 'MedicationDefinitions', 'Other');
7071
CODES_TOpIssueCode : array [TOpIssueCode] of String = ('', 'not-in-vs', 'this-code-not-in-vs', 'invalid-code', 'code-comment', 'invalid-display', 'display-comment', 'not-found', 'code-rule', 'vs-invalid', 'cannot-infer', 'status-check', 'invalid-data', 'process-note', 'version-error');

library/fhir/fhir_tx.pas

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TTerminologyOperationContext = class (TTxOperationContext)
4343
procedure clearContexts;
4444

4545
procedure log(note : String); override;
46-
procedure addNote(vs : TFHIRValueSetW; note : String);
46+
procedure addNote(vs : TFHIRValueSetW; note : String; indentCount : integer);
4747
function diagnostics : String;
4848
property OnGetCurrentRequestCount : TGetCurrentRequestCountEvent read FOnGetCurrentRequestCount write FOnGetCurrentRequestCount;
4949

@@ -53,6 +53,7 @@ TTerminologyOperationContext = class (TTxOperationContext)
5353
class function renderCoded(system, version, code, display : String) : String; overload;
5454
class function renderCoded(code : TFhirCodingW) : String; overload;
5555
class function renderCoded(code : TFhirCodeableConceptW) : String; overload;
56+
class function renderInclude(inc : TFhirValueSetComposeIncludeW) : String; overload;
5657
end;
5758

5859
{ TFHIRCachedMetadataResource }
@@ -244,6 +245,7 @@ TFHIRTxOperationParams = class (TFslObject)
244245

245246
TTerminologyWorker = class (TFslObject)
246247
protected
248+
FIndentCount : integer;
247249
FOpContext : TTerminologyOperationContext;
248250
FFactory : TFHIRFactory;
249251
FOnGetCSProvider : TGetProviderEvent;
@@ -313,7 +315,6 @@ constructor TTerminologyOperationContext.Create(i18n: TI18nSupport; id : String;
313315
FTimeTracker := TFslTimeTracker.create
314316
else
315317
FTimeTracker := tt;
316-
FTimeTracker.step('tx-op');
317318
end;
318319

319320
destructor TTerminologyOperationContext.Destroy;
@@ -387,11 +388,12 @@ procedure TTerminologyOperationContext.log(note: String);
387388
FTimeTracker.step(s);
388389
end;
389390

390-
procedure TTerminologyOperationContext.addNote(vs : TFHIRValueSetW; note : String);
391+
procedure TTerminologyOperationContext.addNote(vs : TFHIRValueSetW; note : String; indentCount : integer);
391392
var
392393
s : string;
393394
begin
394-
s := inttostr(GetTickCount64 - FStartTime)+'ms '+vs.vurl+': '+note;
395+
s := StringPadRight(inttostr(GetTickCount64 - FStartTime)+'ms', ' ', 4)+' '+
396+
StringPadLeft('', ' ', indentCount*2)+'#'+inttostr(SerialNumber)+': '+note;
395397
//if UnderDebugger then
396398
// Logging.log(s);
397399
FTimeTracker.step(s);
@@ -442,6 +444,62 @@ class function TTerminologyOperationContext.renderCoded(code: TFhirCodeableConce
442444
result := '['+result+']';
443445
end;
444446

447+
class function TTerminologyOperationContext.renderInclude(inc: TFhirValueSetComposeIncludeW): String;
448+
var
449+
first : boolean;
450+
cc : TFhirValueSetComposeIncludeConceptW;
451+
ci : TFhirValueSetComposeIncludeFilterW;
452+
s : String;
453+
begin
454+
if inc.systemUri <> '' then
455+
begin
456+
result := '('+inc.systemUri+')';
457+
if inc.hasConcepts then
458+
begin
459+
result := result + '(';
460+
first := true;
461+
for cc in inc.concepts.forEnum do
462+
begin
463+
if first then
464+
first := false
465+
else
466+
result := result + ',';
467+
result := result + cc.code;
468+
end;
469+
result := result+')';
470+
end;
471+
if (inc.hasFilters) then
472+
begin
473+
result := result + '(';
474+
first := true;
475+
for ci in inc.filters.forEnum do
476+
begin
477+
if first then
478+
first := false
479+
else
480+
result := result + ',';
481+
result := result + ci.prop+CODES_TFhirFilterOperatorVCL[ci.op]+ci.value;
482+
end;
483+
result := result+')';
484+
end;
485+
end
486+
else
487+
begin
488+
result := '';
489+
result := result + '(';
490+
first := true;
491+
for s in inc.valueSets do
492+
begin
493+
if first then
494+
first := false
495+
else
496+
result := result + ',';
497+
result := result + '^'+s;
498+
end;
499+
result := result+')';
500+
end;
501+
end;
502+
445503
{ TFHIRCachedMetadataResource }
446504

447505
procedure TFHIRCachedMetadataResource.SetLoadedCS(AValue: TFHIRCodeSystemEntry);
@@ -773,7 +831,7 @@ procedure TTerminologyWorker.deadCheck(place: String);
773831
SetThreadStatus(ClassName+'.'+place);
774832
if FOpContext.deadCheck(time) then
775833
begin
776-
FOpContext.addNote(vsHandle, 'Operation took too long @ '+place+' ('+className+')');
834+
FOpContext.addNote(vsHandle, 'Operation took too long @ '+place+' ('+className+')', FIndentCount);
777835
Logging.log('Operation took too long @ '+place+' ('+className+')');
778836
raise costDiags(ETooCostly.create(FI18n.translate('VALUESET_TOO_COSTLY_TIME', FParams.HTTPlanguages, ['??', inttostr(time), opName])));
779837
end;
@@ -1306,7 +1364,7 @@ function TFhirExpansionParamsVersionRule.link: TFhirExpansionParamsVersionRule;
13061364

13071365
function TFhirExpansionParamsVersionRule.asString: String;
13081366
begin
1309-
result := Fsystem+'#'+Fversion+'/'+inttostr(ord(FMode));
1367+
result := NAMES_TFhirExpansionParamsVersionRuleMode[FMode]+':'+Fsystem+'#'+Fversion;
13101368
end;
13111369

13121370
function TFhirExpansionParamsVersionRule.asParam: String;

library/fhir3/fhir3_factory.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ procedure TFHIRFactoryR3.checkNoModifiers(res: TFHIRObject; method, param: strin
221221
TFHIRDomainResource(res).checkNoModifiers(method, param)
222222
else if res is TFHIRBackboneElement then
223223
TFHIRBackboneElement(res).checkNoModifiers(method, param)
224+
else if res is TFHIRXVersionElementWrapper then
225+
checkNoModifiers((res as TFHIRXVersionElementWrapper).Element, method, param, allowed)
226+
else if res is TFHIRXVersionResourceWrapper then
227+
checkNoModifiers((res as TFHIRXVersionResourceWrapper).Resource, method, param, allowed)
224228
end;
225229

226230
function TFHIRFactoryR3.corePackage: String;

library/fhir4/fhir4_factory.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ procedure TFHIRFactoryR4.checkNoModifiers(res: TFHIRObject; method, param: strin
225225
TFHIRDomainResource(res).checkNoModifiers(method, param)
226226
else if res is TFHIRBackboneElement then
227227
TFHIRBackboneElement(res).checkNoModifiers(method, param)
228+
else if res is TFHIRXVersionElementWrapper then
229+
checkNoModifiers((res as TFHIRXVersionElementWrapper).Element, method, param, allowed)
230+
else if res is TFHIRXVersionResourceWrapper then
231+
checkNoModifiers((res as TFHIRXVersionResourceWrapper).Resource, method, param, allowed)
228232
end;
229233

230234
function TFHIRFactoryR4.corePackage: String;

library/fhir4b/fhir4b_factory.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ procedure TFHIRFactoryR4B.checkNoModifiers(res: TFHIRObject; method,
223223
TFHIRDomainResource(res).checkNoModifiers(method, param)
224224
else if res is TFHIRBackboneElement then
225225
TFHIRBackboneElement(res).checkNoModifiers(method, param)
226+
else if res is TFHIRXVersionElementWrapper then
227+
checkNoModifiers((res as TFHIRXVersionElementWrapper).Element, method, param, allowed)
228+
else if res is TFHIRXVersionResourceWrapper then
229+
checkNoModifiers((res as TFHIRXVersionResourceWrapper).Resource, method, param, allowed)
226230
end;
227231

228232
function TFHIRFactoryR4B.corePackage: String;

library/fhir5/fhir5_factory.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ procedure TFHIRFactoryR5.checkNoModifiers(res: TFHIRObject; method, param: strin
225225
TFHIRDomainResource(res).checkNoModifiers(method, param)
226226
else if res is TFHIRBackboneElement then
227227
TFHIRBackboneElement(res).checkNoModifiers(method, param)
228+
else if res is TFHIRXVersionElementWrapper then
229+
checkNoModifiers((res as TFHIRXVersionElementWrapper).Element, method, param, allowed)
230+
else if res is TFHIRXVersionResourceWrapper then
231+
checkNoModifiers((res as TFHIRXVersionResourceWrapper).Resource, method, param, allowed)
228232
end;
229233

230234
function TFHIRFactoryR5.corePackage: String;

0 commit comments

Comments
 (0)