From afb1afc26097735f89b731aadc3d327ddb9800f0 Mon Sep 17 00:00:00 2001 From: Adam Page <115618858+APageNHS@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:32:03 +0000 Subject: [PATCH] Update common.js.ts --- src/common.js.ts | 55 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/common.js.ts b/src/common.js.ts index 737313f..e77ab4e 100644 --- a/src/common.js.ts +++ b/src/common.js.ts @@ -252,6 +252,7 @@ function getErrorOrWarningFull(issue: OperationOutcomeIssue) { } function raiseWarning(issue: OperationOutcomeIssue, failOnWarning:boolean): boolean { if (issue != undefined && issue.diagnostics != undefined) { + //THESE WARNINGS SHOULD ALWAYS ERROR if (issue.diagnostics.includes('incorrect type for element')) { return true; @@ -262,15 +263,27 @@ function raiseWarning(issue: OperationOutcomeIssue, failOnWarning:boolean): bool if (issue.diagnostics.includes('must be of the format')) { return true; } + // these warnings can always be silently ignored // i.e. known and not resolvable issues with dm+ and languages if (issue.diagnostics.includes('Code system https://dmd.nhs.uk/ could not be resolved.')) return false if (issue.diagnostics.includes('Inappropriate CodeSystem URL') && issue.diagnostics.includes('for ValueSet: http://hl7.org/fhir/ValueSet/all-languages')) { return false } - // LOINC Related warnings can be ignored? + + // LOINC Related warnings can be ignored if (issue.diagnostics.includes('http://loinc.org')) return false; if (issue.diagnostics.includes('LOINC is not indexed!')) return false; + + //DICOM warnings can be ignored + if (issue.diagnostics.includes('ValueSet http://dicom.nema.org/')) return false; + + //Fragment codesystems can't be checked + if (issue.diagnostics.includes('Unknown code in fragment CodeSystem')) { + if (issue.diagnostics.includes('https://fhir.nhs.uk/CodeSystem/NHSDigital-SDS-JobRoleCode')) return false + } + + // these warnings need checking /* if (issue.diagnostics.includes('Could not confirm that the codes provided are in the value set')) { @@ -280,11 +293,9 @@ function raiseWarning(issue: OperationOutcomeIssue, failOnWarning:boolean): bool if (issue.diagnostics.includes('https://fhir.nhs.uk/CodeSystem/organisation-role')) return false; } if (issue.diagnostics.includes('The markdown contains content that appears to be an embedded HTML tag starting at')) return false; - + if (issue.diagnostics.includes('Error HTTP 403 Forbidden validating CodeableConcept')) return false; - if (issue.diagnostics.includes('Unknown code')) { - if (issue.diagnostics.includes('https://fhir.nhs.uk/CodeSystem/NHSDigital-SDS-JobRoleCode')) return false - } + if (issue.diagnostics.includes('None of the codings provided are in the value set')) { if (issue.diagnostics.includes('https://fhir.nhs.uk/CodeSystem/NHSDigital-SDS-JobRoleCode')) return false if (issue.diagnostics.includes('http://snomed.info/sct')) { @@ -294,35 +305,37 @@ function raiseWarning(issue: OperationOutcomeIssue, failOnWarning:boolean): bool } */ } - + // COMMENT WAS: TODO this needs to be turned to true 1/8/2022 Warnings not acceptable on NHS Digital resources // Actual comment is: if error not handled above, return error if FailOnWarning is true - process.env.SKIPPEDWARNINGS +=1; return failOnWarning; } function raiseError(issue: OperationOutcomeIssue) : boolean { if (issue != undefined) { if (issue.diagnostics != undefined) { // List of errors to ALWAYS ignore + // languages, known issue! if (issue.diagnostics.includes('Inappropriate CodeSystem URL') && issue.diagnostics.includes('for ValueSet: http://hl7.org/fhir/ValueSet/all-languages')) { return false } + // Ignore LOINC Errors for now if (issue.diagnostics.includes('http://loinc.org')) return false; + + // ignore dm+d / read errors + if (issue.diagnostics.includes('Code system https://dmd.nhs.uk/ could not be resolved.')) return false + if (issue.diagnostics.includes('http://read.info/ctv3')) return false + // there Errors need checking /* if (issue.diagnostics.includes('could not be resolved, so has not been checked')) return false; - + // fault with current 5.5.1 validation if (issue.diagnostics.includes('http://hl7.org/fhir/ValueSet/units-of-time')) return false; if (issue.diagnostics.includes('NHSNumberVerificationStatus')) return false; if (issue.diagnostics.includes('Validation failed for \'http://example.org/fhir')) return false; if (issue.diagnostics.includes('Unrecognised property \'@fhir_comments')) return false; - if (issue.diagnostics.includes('Code system https://dmd.nhs.uk/ could not be resolved.')) return false - if (issue.diagnostics.includes('http://read.info/ctv3')) { - if (issue.diagnostics.includes('https://fhir.hl7.org.uk/ValueSet/UKCore-ConditionCode')) return false - } if (issue.diagnostics.includes('https://fhir.nhs.uk/CodeSystem/NHSDigital-SDS-JobRoleCode')) return false; if (issue.diagnostics.includes('java.net.SocketTimeoutException')) { console.error(issue.diagnostics) @@ -338,6 +351,7 @@ function raiseError(issue: OperationOutcomeIssue) : boolean { } + export function testFileError(testDescription, file,message) { describe(file, () => { const resource: any = fs.readFileSync(file, 'utf8'); @@ -722,7 +736,9 @@ export function testFile( folderName: string, fileName: string, failOnWarning :b test('Check profiles are not present in resource (Implementation Guide Best Practice)', () => { // Disable profile check for Parameters if (json.meta != undefined && json.resourceType !== 'Parameters') { - expect(json.meta.profile == undefined).toBeTruthy() + if (failOnWarning == true) { + expect(json.meta.profile == undefined).toBeTruthy() + } } if (json.resourceType === 'Bundle') { let bundle : Bundle = json @@ -730,7 +746,9 @@ export function testFile( folderName: string, fileName: string, failOnWarning :b for (let entry of bundle.entry) { // Disable profile check for Parameters if (entry.resource !== undefined && entry.resource.meta != undefined && entry.resource.resourceType !== 'Parameters') { + if (failOnWarning == true) { expect(entry.resource.meta.profile == undefined).toBeTruthy() + } } } } @@ -815,13 +833,16 @@ export function testFile( folderName: string, fileName: string, failOnWarning :b return error.response }) expect(response.status === 200 || response.status === 400).toBeTruthy() - resourceChecks(response, failOnWarning) + + //we can ignore warnings on retired resources - these would not be in a balloted package + if (resource.status == "retired") { + resourceChecks(response, false) + } else { + resourceChecks(response, failOnWarning) + } expect(response.status).toEqual(200) }); } } ) } - - -