Skip to content

Commit

Permalink
refactor parameters per FHIR-41229 and FHIR-41230
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Dec 28, 2023
1 parent d2748ee commit 32e063e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 40 deletions.
58 changes: 29 additions & 29 deletions library/ftx/fhir_valuesets.pas
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ interface
TTrueFalseUnknown = (bTrue, bFalse, bUnknown);

TFhirExpansionParamsVersionRuleMode = (fvmDefault, fvmCheck, fvmOverride);
TValueSetValidationMode = (vsvmAllChecks, vsvmMembershipOnly, vsvmNoMembership);

{ TFhirExpansionParamsVersionRule }

Expand Down Expand Up @@ -94,7 +93,7 @@ TFHIRExpansionParams = class (TFslObject)
FincludeDesignations: boolean;
FincludeDefinition: boolean;
FUid: String;
FValueSetMode: TValueSetValidationMode;
FMembershipOnly : boolean;
FDefaultToLatestVersion : boolean;
FIncompleteOK: boolean;
FProperties : TStringList;
Expand All @@ -114,7 +113,7 @@ TFHIRExpansionParams = class (TFslObject)
FHasDefaultToLatestVersion : boolean;
FHasIncompleteOK : boolean;
FHasexcludeNotForUI : boolean;
FHasValueSetMode : boolean;
FHasMembershipOnly : boolean;
FHasDisplayWarning : boolean;
FAltCodeRules : TAlternateCodeOptions;

Expand All @@ -132,7 +131,7 @@ TFHIRExpansionParams = class (TFslObject)
procedure SetDefaultToLatestVersion(value : boolean);
procedure SetIncompleteOK(value : boolean);
procedure SetDisplayWarning(value : boolean);
procedure SetValueSetMode(value : TValueSetValidationMode);
procedure SetMembershipOnly(value : boolean);
protected
function sizeInBytesV(magic : integer) : cardinal; override;
public
Expand All @@ -159,7 +158,7 @@ TFHIRExpansionParams = class (TFslObject)
property excludeNested : boolean read FexcludeNested write SetexcludeNested;
property excludeNotForUI : boolean read FexcludeNotForUI write SetexcludeNotForUI;
property excludePostCoordinated : boolean read FexcludePostCoordinated write SetexcludePostCoordinated;
property valueSetMode : TValueSetValidationMode read FValueSetMode write SetValueSetMode;
property membershipOnly : boolean read FMembershipOnly write SetMembershipOnly;
property uid : String read FUid write FUid;
property defaultToLatestVersion : boolean read FDefaultToLatestVersion write SetDefaultToLatestVersion;
property incompleteOK : boolean read FIncompleteOK write SetIncompleteOK;
Expand All @@ -177,7 +176,7 @@ TFHIRExpansionParams = class (TFslObject)
property hasExcludeNested : boolean read FHasexcludeNested;
property hasExcludeNotForUI : boolean read FHasexcludeNotForUI;
property hasExcludePostCoordinated : boolean read FHasexcludePostCoordinated;
property hasValueSetMode : boolean read FHasValueSetMode;
property hasMembershipOnly : boolean read FHasMembershipOnly;
property hasDefaultToLatestVersion : boolean read FHasDefaultToLatestVersion;
property hasIncompleteOK : boolean read FHasIncompleteOK;
property hasDisplayWarning : boolean read FHasDisplayWarning;
Expand Down Expand Up @@ -1220,7 +1219,7 @@ function TValueSetChecker.check(path, system, version, code: String; abstractOk,
cs.free;
end;
end
else if (FParams.valueSetMode = vsvmNoMembership) then
else if (false) then
begin
// anyhow, we ignore the value set (at least for now)
cs := findCodeSystem(system, version, FParams, true);
Expand Down Expand Up @@ -1312,6 +1311,7 @@ function TValueSetChecker.check(path, system, version, code: String; abstractOk,
end
else
begin
// todo: we can never get here?
if (system = '') and inferSystem then
begin
system := determineSystem(code);
Expand Down Expand Up @@ -1380,7 +1380,7 @@ function TValueSetChecker.check(path, system, version, code: String; abstractOk,
cs := findCodeSystem(system, v, FParams, true);
if (cs = nil) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
if (v = '') then
begin
Expand Down Expand Up @@ -1483,7 +1483,7 @@ function TValueSetChecker.check(path, system, version, code: String; abstractOk,
cs := findCodeSystem(system, v, FParams, true);
if (cs = nil) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
if (v = '') then
begin
Expand Down Expand Up @@ -1816,7 +1816,7 @@ function TValueSetChecker.check(issuePath : String; code: TFhirCodeableConceptW;
if (pdisp = '') then
pdisp := list.preferredDisplay;
end
else if (FParams.valueSetMode <> vsvmMembershipOnly) then
else if (not FParams.membershipOnly) then
begin
prov := findCodeSystem(ws, c.version, FParams, true);
try
Expand Down Expand Up @@ -2112,18 +2112,18 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
result := false;
if loc = nil then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itCodeInvalid, addToPath(path, 'code'), FI18n.translate('Unknown_Code_in_Version', FParams.languages, [code, cs.systemUri(nil), cs.version(nil)]), oicInvalidCode)
end
else if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else if FValueSet.excludeInactives and cs.IsInactive(loc) then
begin
result := false;
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
inactive := true;
if (inactive) then
Expand Down Expand Up @@ -2160,13 +2160,13 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
listDisplays(displays, cc, vs);
if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else if FValueSet.excludeInactives and cs.IsInactive(loc) then
begin
result := false;
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
inactive := true;
vstatus := cs.getCodeStatus(loc);
Expand Down Expand Up @@ -2213,13 +2213,13 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
listDisplays(displays, cs, loc);
if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else if FValueSet.excludeInactives and cs.IsInactive(loc) then
begin
result := false;
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
inactive := true;
vstatus := cs.getCodeStatus(loc);
Expand Down Expand Up @@ -2252,7 +2252,7 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
listDisplays(displays, cs, loc);
if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else
Expand Down Expand Up @@ -2282,13 +2282,13 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
listDisplays(displays, cs, loc);
if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else if FValueSet.excludeInactives and cs.IsInactive(loc) then
begin
result := false;
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
inactive := true;
vstatus := cs.getCodeStatus(loc);
Expand Down Expand Up @@ -2320,13 +2320,13 @@ function TValueSetChecker.checkConceptSet(path : String; cs: TCodeSystemProvider
listDisplays(displays, cs, loc);
if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else if FValueSet.excludeInactives and cs.IsInactive(loc) then
begin
result := false;
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
begin
inactive := true;
vstatus := cs.getCodeStatus(loc);
Expand Down Expand Up @@ -2371,12 +2371,12 @@ function TValueSetChecker.checkExpansion(path: String; cs: TCodeSystemProvider;
result := false;
if loc = nil then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itCodeInvalid, addToPath(path, 'code'), FI18n.translate('Unknown_Code_in_Version', FParams.languages, [code, cs.systemUri(nil), cs.version(nil)]), oicInvalidCode)
end
else if not (abstractOk or not cs.IsAbstract(loc)) then
begin
if (FParams.valueSetMode <> vsvmMembershipOnly) then
if (not FParams.membershipOnly) then
op.addIssue(isError, itBusinessRule, addToPath(path, 'code'), FI18n.translate('ABSTRACT_CODE_NOT_ALLOWED', FParams.languages, [cs.systemUri(nil), code]), oicCodeRule)
end
else
Expand Down Expand Up @@ -3803,10 +3803,10 @@ procedure TFHIRExpansionParams.SetDisplayWarning(value : boolean);
FHasDisplayWarning := true;
end;

procedure TFHIRExpansionParams.SetValueSetMode(value : TValueSetValidationMode);
procedure TFHIRExpansionParams.SetMembershipOnly(value : boolean);
begin
FValueSetMode := value;
FHasValueSetMode := true;
FMembershipOnly := value;
FHasMembershipOnly := true;
end;

function TFHIRExpansionParams.sizeInBytesV(magic : integer) : cardinal;
Expand Down Expand Up @@ -3888,11 +3888,11 @@ function TFHIRExpansionParams.hash: String;
result := '0|';
end;
begin
s := FUid+'|'+ inttostr(ord(FValueSetMode)) + '|' + FProperties.CommaText+'|'+
s := FUid+'|'+ b(FMembershipOnly) + '|' + FProperties.CommaText+'|'+
b(FactiveOnly)+b(FIncompleteOK)+b(FDisplayWarning)+b(FexcludeNested)+b(FGenerateNarrative)+b(FlimitedExpansion)+b(FexcludeNotForUI)+b(FexcludePostCoordinated)+
b(FincludeDesignations)+b(FincludeDefinition)+b(FHasactiveOnly)+b(FHasExcludeNested)+b(FHasGenerateNarrative)+
b(FHasLimitedExpansion)+b(FHesExcludeNotForUI)+b(FHasExcludePostCoordinated)+b(FHasIncludeDesignations)+
b(FHasIncludeDefinition)+b(FHasDefaultToLatestVersion)+b(FHasIncompleteOK)+b(FHasDisplayWarning)+b(FHasexcludeNotForUI)+b(FHasValueSetMode)+b(FDefaultToLatestVersion);
b(FHasIncludeDefinition)+b(FHasDefaultToLatestVersion)+b(FHasIncompleteOK)+b(FHasDisplayWarning)+b(FHasexcludeNotForUI)+b(FHasMembershipOnly)+b(FDefaultToLatestVersion);

if hasLanguages then
s := s + FLanguages.AsString(true)+'|';
Expand Down
15 changes: 5 additions & 10 deletions server/tx_operations.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,10 @@ procedure TFhirTerminologyOperation.processExpansionParams(request: TFHIRRequest
result.languages := THTTPLanguageList.create(p.valueString, not isValidation)
else if (p.name = 'property') then
result.properties.add(p.valueString)
else if (p.name = 'mode') and (p.valueString = 'lenient-display-validation') then
result.displayWarning := true
else if (p.name = 'lenient-display-validation') and (p.valueString = 'true') then
result.displayWarning := true
else if (p.name = 'valueset-membership-only') and (p.valueString = 'true') then
result.membershipOnly := true
else if (p.name = 'includeAlternateCodes') then
result.altCodeRules.seeParam(p.valueString)
else if (p.name = 'designation') then
Expand All @@ -1284,14 +1286,7 @@ procedure TFhirTerminologyOperation.processExpansionParams(request: TFHIRRequest
end;
end
end;
result.valueSetMode := vsvmAllChecks;
if (params.has('valueSetMode')) then
begin
if (params.str('valueSetMode') = 'CHECK_MEMBERSHIP_ONLY') then
result.valueSetMode := vsvmMembershipOnly
else if (params.str('valueSetMode') = 'NO_MEMBERSHIP_CHECK') then
result.valueSetMode := vsvmNoMembership
end;

if not result.hasLanguages and (request.ContentLanguage <> '') then
result.languages := THTTPLanguageList.create(request.ContentLanguage, not isValidation);;
if not result.hasLanguages and (request.LangList <> nil) and (request.LangList.source <> '') then
Expand Down
2 changes: 1 addition & 1 deletion server/tx_server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ function TTerminologyServer.codeInValueSet(c : TFHIRCodingW; valueSet: String):
exit(false);
profile := TFHIRExpansionParams.Create;
try
profile.valueSetMode := vsvmMembershipOnly;
profile.membershipOnly := true;
p := validate(vs, c, profile, true, false, nil, summary);
try
result := p.bool('result');
Expand Down

0 comments on commit 32e063e

Please sign in to comment.