Skip to content

Commit

Permalink
chore(#123): add validation on total patient
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Lorena Rodriguez Viruel authored and Maria Lorena Rodriguez Viruel committed May 22, 2024
1 parent 12fb4f3 commit 1c92542
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions mediator/test/workflows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,45 +80,13 @@ const configureCHT = async () => {
}
};

const cleanCHT = async () => {
const deleteUserResponse = await request(CHT.url)
.delete(' /api/v1/users/' + chwUserName)
.auth(CHT.username, CHT.password)
.send();

if (deleteUserResponse.status !== 200) {
throw new Error(`CHT user deletion failed: Reason ${deleteUserResponse.body}`);
}

const docs = {
"docs": [
{ "_id": placeId },
{ "_id": contactId },
{ "_id": patientId }
]
}

const bultDeleteResponse = await request(CHT.url)
.post('/api/v1/bulk-delete')
.auth(CHT.username, CHT.password)
.send(docs);

if (bultDeleteResponse.status !== 200) {
throw new Error(`CHT bulk delete failed: Reason ${bultDeleteResponse.status}`);
}
};

describe('Workflows', () => {

beforeAll(async () => {
await installMediatorConfiguration();
await configureCHT();
});

/*afterAll(async () => {
await cleanCHT();
});*/

describe('Loss To Follow-Up (LTFU) workflow', () => {
let encounterUrl: string;
let endpointId: string;
Expand Down Expand Up @@ -181,6 +149,7 @@ describe('Workflows', () => {
.auth(FHIR.username, FHIR.password);

expect(retrieveFhirPatientIdResponse.status).toBe(200);
expect(retrieveFhirPatientIdResponse.body.total).toBe(1);

const serviceRequest = ServiceRequestFactory.build();
serviceRequest.subject.reference = `Patient/${patientId}`;
Expand Down Expand Up @@ -209,7 +178,7 @@ describe('Workflows', () => {
.auth(FHIR.username, FHIR.password);

expect(retrieveFhirDbEncounter.status).toBe(200);
//expect(retrieveFhirDbEncounter.body.total).toBe(1);
expect(retrieveFhirDbEncounter.body.total).toBe(1);
});
});

Expand Down Expand Up @@ -238,6 +207,7 @@ describe('Workflows', () => {
.auth(FHIR.username, FHIR.password);

expect(retrieveFhirPatientIdResponse.status).toBe(200);
expect(retrieveFhirPatientIdResponse.body.total).toBe(2);

});

Expand Down

0 comments on commit 1c92542

Please sign in to comment.