Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,29 @@
"RuleName": "8.Transform.UpdatedRecordExcludedAndDMS",
"LocalParams": [
{
"Name": "IsPrimaryCareProviderNullOnUpdatedParticipant",
"Expression": "participant.PrimaryCareProvider == null"
"Name": "DMSInSMU",
"Expression": "participant.CurrentPosting == \"DMS\" && dbLookup.CheckIfPrimaryCareProviderInExcludedSmuList(participant.PrimaryCareProvider)"
},
{
"Name": "IsPrimaryCareProviderNullDatabaseParticipant",
"Expression": "databaseParticipant.PrimaryCareProvider == null"
},
{
"Name": "IsNewRecordInSMU",
"Expression": "participant.CurrentPosting == \"DMS\" && (IsPrimaryCareProviderNullOnUpdatedParticipant ? false : !excludedSMUList.Contains(participant.PrimaryCareProvider)) || new string[] { \"English\", \"NHAIS\", \"Cipher\", \"ENG\", \"IM\" }.Contains(participant.CurrentPosting)"
},
{
"Name": "IsOldRecordInSMU",
"Expression": "databaseParticipant.CurrentPosting == \"DMS\" && (IsPrimaryCareProviderNullDatabaseParticipant ? false : excludedSMUList.Contains(databaseParticipant.PrimaryCareProvider)) || new string[] { \"Welsh\", \"NHAIS\", \"Cipher\", \"CYM\" }.Contains(databaseParticipant.CurrentPosting)"
"Name": "WelshCurrentPosting",
"Expression": "dbLookup.RetrievePostingCategory(participant.CurrentPosting) == \"WALES\" || participant.CurrentPosting == \"CYM\""
}
],
"Expression": "participant.RecordType == Actions.Amended && IsNewRecordInSMU && IsOldRecordInSMU",
"Expression": "(participant.RecordType == Actions.Amended) && (DMSInSMU || WelshCurrentPosting)",
"Actions": {
"OnSuccess": {
"Name": "TransformAction",
"Context": {
"transformFields": [
{
"isExpression": false,
"isExpression": true,
Comment thread
Joseph2910 marked this conversation as resolved.
Outdated
"field": "PrimaryCareProvider",
"value": null
},
{
"field": "ReasonForRemoval",
"value": "ORR",
"isExpression": false
"isExpression": true
},
{
"field": "ReasonForRemovalEffectiveFromDate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@
}
}
},
{
"RuleName": "3601.ValidatePrimaryCareProvider.BSSelect.NonFatal",
"Expression": "ValidPrimaryCareProvider",
"Actions": {
"OnFailure": {
"Name": "OutputExpression",
"Context": {
"Expression": "\"Invalid primary care provider GP practice code\""
}
}
}
},
{
"RuleName": "45.GPPracticeCodeDoesNotExist.BSSelect.NonFatal",
"LocalParams": [
Expand All @@ -45,18 +33,18 @@
},
{
"Name": "InvalidPostingCategory",
"Expression": "!(EnglishPostingCategory || new[] {\"ENG\", \"DMS\", \"IM\"}.Contains(newParticipant.CurrentPosting))"
"Expression": "!(EnglishPostingCategory || newParticipant.CurrentPosting == \"ENG\" || newParticipant.CurrentPosting == \"IM\" || newParticipant.CurrentPosting == \"DMS\")"
},
{
"Name": "PrimaryCareExists",
"Expression": "dbLookup.CheckIfPrimaryCareProviderExists(newParticipant.PrimaryCareProvider)"
},
},
{
"Name": "IsExcluded",
"Expression": "dbLookup.CheckIfPrimaryCareProviderInExcludedSmuList(newParticipant.PrimaryCareProvider)"
}
],
"Expression": "(InvalidPostingCategory || string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) || PrimaryCareExists || IsExcluded)",
"Expression": "(InvalidPostingCategory || ValidPrimaryCareProvider || IsExcluded)",
"Actions": {
"OnFailure": {
"Name": "OutputExpression",
Expand Down Expand Up @@ -88,37 +76,7 @@
}
],
"Expression": "!(reasonForRemoval AND postcode AND primaryCareProvider)"
},
{
"RuleName": "51.ParticipantLocationRemainingOutsideOfCohort.ParticipantLocationRemainingOutsideOfCohort.NonFatal",
"LocalParams": [
{
"Name": "ExistingParticipantInDMS",
"Expression": "(!string.IsNullOrEmpty(existingParticipant.CurrentPosting) AND existingParticipant.CurrentPosting == \"DMS\" AND !string.IsNullOrEmpty(existingParticipant.PrimaryCareProvider) AND dbLookup.CheckIfPrimaryCareProviderInExcludedSmuList(existingParticipant.PrimaryCareProvider))"
},
{
"Name": "existingParticipantPosting",
"Expression": "ExistingParticipantInDMS OR (dbLookup.RetrievePostingCategory(existingParticipant.CurrentPosting) == \"WALES\")"
},
{
"Name": "NewParticipantInDMS",
"Expression": "(!string.IsNullOrEmpty(existingParticipant.CurrentPosting) AND newParticipant.CurrentPosting == \"DMS\" AND !string.IsNullOrEmpty(newParticipant.PrimaryCareProvider) AND dbLookup.CheckIfPrimaryCareProviderInExcludedSmuList(newParticipant.PrimaryCareProvider))"
},
{
"Name": "newParticipantPosting",
"Expression": "NewParticipantInDMS OR (dbLookup.RetrievePostingCategory(newParticipant.CurrentPosting) == \"WALES\")"
}
],
"Expression": "!(existingParticipantPosting AND newParticipantPosting)",
"Actions": {
"OnSuccess": {
"Name": "OutputExpression",
"Context": {
"Expression": "\"Resident in not included area in cohort moving to same or another area not included in cohort.\""
}
}
}
}
]
}
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
import { test, expect, APIRequestContext, TestInfo } from "@playwright/test";
import { TestHooks } from "../../hooks/test-hooks";
import { cleanupDatabaseFromAPI, getApiTestData, processFileViaStorage, validateSqlDatabaseFromAPI } from "../../steps/steps";
import { createParquetFromJson } from "../../../parquet/parquet-multiplier";
import { getRecordsFromCohortDistributionService } from "../../../api/dataService/cohortDistributionService";
import { getValidationExceptions } from "../../../api/dataService/exceptionService";

annotation: [{
type: 'Requirement',
description: 'Tests - https://nhsd-jira.digital.nhs.uk/browse/DTOSS-9935'
}]

test.describe('@regression @e2e @epic4-validation-test Rule 8 Tests', () => {

TestHooks.setupAllTestHooks();

test('@DTOSS-A451-01 - AC1 - Verify participant is in CohortDistribution and that a transformation rule 8 exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [checkInDatabase, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a rule 8 transformation exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request, {exceptionCategory: 8});
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length === 1).toBe(true);
})


})

test('@DTOSS-A452-01 - AC1 - Verify participant is in CohortDistribution table with no exceptions', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [checkInDatabase, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should not raise a transformation exception', async ()=> {
const response = await getValidationExceptions(request, {exceptionCategory: 8});
expect(response.data === null || (Array.isArray(response.data) && response.data.length === 0)).toBe(true);
})


})

test('@DTOSS-A453-01 - AC1 - Verify participant is in CohortDistribution and that a transformation rule 8 exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [checkInDatabase, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a rule 8 transformation exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request, {exceptionCategory: 8});
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length === 1).toBe(true);
})


})

test('@DTOSS-A454-01 - AC1 - Verify participant is in CohortDistribution and that a transformation rule 8 exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a rule 8 transformation exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request, {exceptionCategory: 8});
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length === 1).toBe(true);
})


})


test('@DTOSS-A455-01 - AC1 - Verify participant is in CohortDistribution table with no exceptions', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [checkInDatabase, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should not raise a transformation exception', async ()=> {
const response = await getValidationExceptions(request, {exceptionCategory: 8});
expect(response.data === null || (Array.isArray(response.data) && response.data.length === 0)).toBe(true);
})

})

test('@DTOSS-A456-01 - AC1 - Verify participant is in CohortDistribution and that a transformation rule 8 exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a rule 8 transformation exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request, {exceptionCategory: 8});
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length === 1).toBe(true);
})


})

test('@DTOSS-A457-01 - AC1 - Verify participant is in CohortDistribution table with no exceptions', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [checkInDatabase, inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should not raise a transformation exception', async ()=> {
const response = await getValidationExceptions(request, {exceptionCategory: 8});
expect(response.data === null || (Array.isArray(response.data) && response.data.length === 0)).toBe(true);
})

})

test('@DTOSS-A458-01 - AC1 - Verify participant is in CohortDistribution and that a transformation rule 8 exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a rule 8 transformation exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request, {exceptionCategory: 8});
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length === 1).toBe(true);
})


})

test('@DTOSS-A459-01 - AC1 - Verify participant is in CohortDistribution and that a general exception exists in Exception table', async ({ request }: { request: APIRequestContext }, testInfo: TestInfo) => {
const [inputParticipantRecord, nhsNumbers, testFilesPath] = await getApiTestData(testInfo.title);

await cleanupDatabaseFromAPI(request, nhsNumbers);

const parquetFile = await createParquetFromJson(nhsNumbers, inputParticipantRecord, testFilesPath);

await test.step(`When I ADD participant is processed via storage`, async () => {
await processFileViaStorage(parquetFile);
});

await test.step('Then participant should be in cohort distribution', async ()=> {
const cohortResponse = await getRecordsFromCohortDistributionService(request);
if (!cohortResponse || !Array.isArray(cohortResponse.data)) {
throw new Error('No data returned from cohort distribution service');
}
})

await test.step('Then participant should raise a general exception', async ()=> {
const exceptionResponse = await getValidationExceptions(request);
expect(Array.isArray(exceptionResponse.data) && exceptionResponse.data.length >= 1).toBe(true);
})


})

})
Loading