Skip to content

Commit

Permalink
fill out expression and issue type on issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Dec 28, 2023
1 parent 81d49cc commit d2748ee
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 55 deletions.
4 changes: 3 additions & 1 deletion library/fhir/fhir_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ interface
TObservationStatus = (obssNull, obssRegistered, obssPreliminary, obssFinal, obssAmended, obssCorrected, obssCancelled, obssEnteredInError, obssUnknown);
TTokenCategory = (tcClinical, tcData, tcMeds, tcSchedule, tcAudit, tcDocuments, tcFinancial, tcMedicationDefinition, tcOther);
TIdentifierUse = (iuNull, iuUsual, iuOfficial, iuTemp, iuSecondary, iuOld);
TOpIssueCode = (oicVoid, oicNotInVS, oicThisNotInVS, oicInvalidCode, oicDisplay, oicNotFound, oicCodeRule, oicVSProcessing, oicInferFailed, oicStatusCheck);

const
CODES_TFhirFilterOperator: Array[TFilterOperator] of String = ('', '=', 'is-a', 'descendent-of', 'is-not-a', 'regex', 'in', 'not-in', 'generalizes', 'exists', 'child-of', 'descendent-leaf');
CODES_TPublicationStatus: Array[TPublicationStatus] of String = ('', 'draft', 'active', 'retired');
CODES_TTokenCategory : array [TTokenCategory] of String = ('Clinical', 'Data', 'Meds', 'Schedule', 'Audit', 'Documents', 'Financial', 'MedicationDefinitions', 'Other');
CODES_TOpIssueCode : array [TOpIssueCode] of String = ('', 'not-in-vs', 'this-code-not-in-vs', 'invalid-code', 'invalid-display', 'not-found', 'code-rule', 'vs-invalid', 'cannot-infer', 'status-check');

type

Expand Down Expand Up @@ -383,7 +385,7 @@ TFhirOperationOutcomeW = class (TFHIRXVersionResourceWrapper)
function code : TFhirIssueType; virtual; abstract;

procedure addIssue(issue : TFhirOperationOutcomeIssueW; free : boolean); overload; virtual; abstract;
procedure addIssue(level : TIssueSeverity; cause : TFhirIssueType; path, message : String; addIfDuplicate : boolean = false); overload; virtual; abstract;
procedure addIssue(level : TIssueSeverity; cause : TFhirIssueType; path, message : String; issueCode : TOpIssueCode; addIfDuplicate : boolean = false); overload; virtual; abstract;
function hasIssues : boolean; virtual; abstract;
function issues : TFslList<TFhirOperationOutcomeIssueW>; virtual; abstract;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; virtual; abstract;
Expand Down
6 changes: 4 additions & 2 deletions library/fhir2/fhir2_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ TFhirOperationOutcome2 = class (TFhirOperationOutcomeW)
function text : String; override;
function code : TFhirIssueType; override;
procedure addIssue(issue : TFhirOperationOutcomeIssueW; owns : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; addIfDuplicate : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean); override;
function hasIssues : boolean; override;
function issues : TFslList<TFhirOperationOutcomeIssueW>; override;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; override;
Expand Down Expand Up @@ -1252,7 +1252,7 @@ procedure TFhirOperationOutcome2.addIssue(issue: TFhirOperationOutcomeIssueW; ow
issue.free;
end;

procedure TFhirOperationOutcome2.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; addIfDuplicate : boolean);
procedure TFhirOperationOutcome2.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean);
var
iss : TFhirOperationOutcomeIssue;
begin
Expand All @@ -1267,6 +1267,8 @@ procedure TFhirOperationOutcome2.addIssue(level: TIssueSeverity; cause: TFHIRIss
iss.code:= ExceptionTypeTranslations[cause];
iss.severity := ISSUE_SEVERITY_MAP2[level];
iss.details := TFHIRCodeableConcept.Create;
if (code <> oicVoid) then
iss.details.addCoding('http://hl7.org/fhir/tools/CodeSystem/tx-issue-type', '', CODES_TOpIssueCode[code], '');
iss.details.text := message;
iss.locationList.Add(path);
end;
Expand Down
9 changes: 6 additions & 3 deletions library/fhir3/fhir3_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ TFhirOperationOutcome3 = class (TFhirOperationOutcomeW)
function text : String; override;
function code : TFhirIssueType; override;
procedure addIssue(issue : TFhirOperationOutcomeIssueW; free : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; addIfDuplicate : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean); override;
function hasIssues : boolean; override;
function issues : TFslList<TFhirOperationOutcomeIssueW>; override;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; override;
Expand Down Expand Up @@ -1394,7 +1394,7 @@ procedure TFhirOperationOutcome3.addIssue(issue: TFhirOperationOutcomeIssueW; fr
issue.free;
end;

procedure TFhirOperationOutcome3.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; addIfDuplicate : boolean);
procedure TFhirOperationOutcome3.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean);
var
iss : TFhirOperationOutcomeIssue;
begin
Expand All @@ -1408,9 +1408,12 @@ procedure TFhirOperationOutcome3.addIssue(level: TIssueSeverity; cause: TFHIRIss
iss := (Fres as TFhirOperationOutcome).issueList.Append;
iss.code:= ExceptionTypeTranslations[cause];
iss.severity := ISSUE_SEVERITY_MAP2[level];
iss.details := TFHIRCodeableConcept.Create;
iss.details := TFHIRCodeableConcept.Create;
if (code <> oicVoid) then
iss.details.addCoding('http://hl7.org/fhir/tools/CodeSystem/tx-issue-type', '', CODES_TOpIssueCode[code], '');
iss.details.text := message;
iss.locationList.Add(path);
iss.expressionList.Add(path);
end;

function TFhirOperationOutcome3.code: TFhirIssueType;
Expand Down
7 changes: 5 additions & 2 deletions library/fhir4/fhir4_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TFhirOperationOutcome4 = class (TFhirOperationOutcomeW)
function text : String; override;
function code : TFhirIssueType; override;
procedure addIssue(issue : TFhirOperationOutcomeIssueW; free : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; addIfDuplicate : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean); override;
function hasIssues : boolean; override;
function issues : TFslList<TFhirOperationOutcomeIssueW>; override;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; override;
Expand Down Expand Up @@ -1366,7 +1366,7 @@ procedure TFhirOperationOutcome4.addIssue(issue: TFhirOperationOutcomeIssueW; fr
issue.free;
end;

procedure TFhirOperationOutcome4.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; addIfDuplicate : boolean);
procedure TFhirOperationOutcome4.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean);
var
iss : TFhirOperationOutcomeIssue;
begin
Expand All @@ -1386,8 +1386,11 @@ procedure TFhirOperationOutcome4.addIssue(level: TIssueSeverity; cause: TFHIRIss
iss.code:= ExceptionTypeTranslations[cause];
iss.severity := ISSUE_SEVERITY_MAP2[level];
iss.details := TFHIRCodeableConcept.Create;
if (code <> oicVoid) then
iss.details.addCoding('http://hl7.org/fhir/tools/CodeSystem/tx-issue-type', '', CODES_TOpIssueCode[code], '');
iss.details.text := message;
iss.locationList.Add(path);
iss.expressionList.Add(path);
end;

function TFhirOperationOutcome4.code: TFhirIssueType;
Expand Down
9 changes: 6 additions & 3 deletions library/fhir4b/fhir4b_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ TFhirOperationOutcome4B = class (TFhirOperationOutcomeW)
function text : String; override;
function code : TFhirIssueType; override;
procedure addIssue(issue : TFhirOperationOutcomeIssueW; free : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; addIfDuplicate : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean); override;
function hasIssues : boolean; override;
function issues : TFslList<TFhirOperationOutcomeIssueW>; override;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; override;
Expand Down Expand Up @@ -1365,7 +1365,7 @@ procedure TFhirOperationOutcome4B.addIssue(issue: TFhirOperationOutcomeIssueW; f
issue.free;
end;

procedure TFhirOperationOutcome4B.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; addIfDuplicate : boolean);
procedure TFhirOperationOutcome4B.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean);
var
iss : TFhirOperationOutcomeIssue;
begin
Expand All @@ -1379,9 +1379,12 @@ procedure TFhirOperationOutcome4B.addIssue(level: TIssueSeverity; cause: TFHIRIs
iss := (Fres as TFhirOperationOutcome).issueList.Append;
iss.code:= ExceptionTypeTranslations[cause];
iss.severity := ISSUE_SEVERITY_MAP2[level];
iss.details := TFHIRCodeableConcept.Create;
iss.details := TFHIRCodeableConcept.Create;
if (code <> oicVoid) then
iss.details.addCoding('http://hl7.org/fhir/tools/CodeSystem/tx-issue-type', '', CODES_TOpIssueCode[code], '');
iss.details.text := message;
iss.locationList.Add(path);
iss.expressionList.Add(path);
end;

function TFhirOperationOutcome4B.code: TFhirIssueType;
Expand Down
7 changes: 5 additions & 2 deletions library/fhir5/fhir5_common.pas
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ TFhirOperationOutcome5 = class (TFhirOperationOutcomeW)
function text : String; override;
function code : TFhirIssueType; override;
procedure addIssue(issue : TFhirOperationOutcomeIssueW; free : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; addIfDuplicate : boolean); override;
procedure addIssue(level : TIssueSeverity; cause : TFHIRIssueType; path, message : String; code : TOpIssueCode; addIfDuplicate : boolean); override;
function hasIssues : boolean; override;
function issues : TFslList<TFhirOperationOutcomeIssueW>; override;
function rule(level : TIssueSeverity; source : String; typeCode : TFhirIssueType; path : string; test : boolean; msg : string) : boolean; override;
Expand Down Expand Up @@ -1375,7 +1375,7 @@ procedure TFhirOperationOutcome5.addIssue(issue: TFhirOperationOutcomeIssueW; fr
issue.free;
end;

procedure TFhirOperationOutcome5.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; addIfDuplicate : boolean);
procedure TFhirOperationOutcome5.addIssue(level: TIssueSeverity; cause: TFHIRIssueType; path, message: String; code : TOpIssueCode; addIfDuplicate : boolean);
var
iss : TFhirOperationOutcomeIssue;
begin
Expand All @@ -1395,8 +1395,11 @@ procedure TFhirOperationOutcome5.addIssue(level: TIssueSeverity; cause: TFHIRIss
iss.code:= ExceptionTypeTranslations[cause];
iss.severity := ISSUE_SEVERITY_MAP2[level];
iss.details := TFHIRCodeableConcept.Create;
if (code <> oicVoid) then
iss.details.addCoding('http://hl7.org/fhir/tools/CodeSystem/tx-issue-type', '', CODES_TOpIssueCode[code], '');
iss.details.text := message;
iss.locationList.Add(path);
iss.expressionList.Add(path);
end;

function TFhirOperationOutcome5.code: TFhirIssueType;
Expand Down
Loading

0 comments on commit d2748ee

Please sign in to comment.