Skip to content

Commit

Permalink
Remove unnecessary non nullish checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kahummer committed Jul 17, 2024
1 parent 99009c3 commit 8987116
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/fhir-flag/src/components/Utils/payloadConfigs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable @typescript-eslint/no-explicit-any
/* eslint-disable @typescript-eslint/no-explicit-any */
import { IEncounter } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/IEncounter';
import { IObservation } from '@smile-cdr/fhirts/dist/FHIR-R4/interfaces/IObservation';

Expand Down
1 change: 1 addition & 0 deletions packages/fhir-flag/src/components/Utils/tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const flag: IFlag = {
reference: 'Group/e44e26d0-1f7a-41d6-aa57-99c5712ddd66',
},
period: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
start: '2024-04-29T20:37:45+03:00' as any,
},
encounter: {
Expand Down
10 changes: 5 additions & 5 deletions packages/fhir-flag/src/components/Utils/tests/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ describe('Utility functions', () => {
expect(mockUpdate).toHaveBeenCalledWith(payload);
});
it('should generate correct encounter payload with location reference', () => {
// const conceptsHaveCodings = jest.fn();
const practitionerId = 'practitioner123';
const locationReference = 'Location/123';
const { conceptsHaveCodings } = require('@opensrp/fhir-helpers');

(conceptsHaveCodings as jest.Mock).mockReturnValue(false);

Expand All @@ -111,7 +109,7 @@ describe('Utility functions', () => {
tag: flag.meta?.tag,
},
resourceType: 'Encounter',
partOf: { reference: flag?.encounter?.reference },
partOf: { reference: flag.encounter?.reference },
location: [{ location: { reference: 'Location/123' }, status: 'active' }],
participant: [
{
Expand All @@ -133,6 +131,7 @@ describe('Utility functions', () => {
it('should generate correct observation payload with location reference', () => {
const practitionerId = 'practitioner123';
const locationReference = 'Location/123';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const values = { comments: 'Test comments', status: 'test status' as any }; // Example CloseFlagFormFields

(conceptsHaveCodings as jest.Mock).mockReturnValue(false);
Expand All @@ -143,7 +142,7 @@ describe('Utility functions', () => {
meta: {
tag: flag.meta?.tag,
},
subject: { reference: flag.subject?.reference },
subject: { reference: flag.subject.reference },
encounter: { reference: 'Encounter/mocked-uuid' },
focus: [{ reference: 'Location/123' }, { reference: `Flag/${flag.id}` }],
performer: undefined,
Expand All @@ -168,6 +167,7 @@ describe('Utility functions', () => {
it('should generate correct observation payload with performer and focus flag reference', () => {
const practitionerId = 'practitioner123';
const locationReference = 'Location/123';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const values = { comments: 'Test comments', status: 'active' as any }; // Example CloseFlagFormFields

(conceptsHaveCodings as jest.Mock).mockReturnValue(true);
Expand All @@ -178,7 +178,7 @@ describe('Utility functions', () => {
meta: {
tag: flag.meta?.tag,
},
subject: { reference: flag.subject?.reference },
subject: { reference: flag.subject.reference },
encounter: { reference: 'Encounter/mocked-uuid' },
focus: [{ reference: `Flag/1a3a0d65-b6ad-40af-b6cd-2e8801614de9` }],
performer: [{ reference: `Practitioner/practitioner123` }],
Expand Down
4 changes: 2 additions & 2 deletions packages/fhir-flag/src/components/Utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const generateEncounterPayload = (
return {
...encounter,
...commonProperties,
partOf: { reference: flag?.encounter?.reference },
partOf: { reference: flag.encounter?.reference },
location: [{ location: { reference }, status: 'active' }],
participant: [
{
Expand Down Expand Up @@ -110,7 +110,7 @@ export const generateObservationPayload = (
return {
...observation,
...commonProperties,
subject: { reference: flag.subject?.reference },
subject: { reference: flag.subject.reference },
encounter: { reference: `Encounter/${encounterProperties.id}` },
focus: isSPCHECKOrCNBEN
? [{ reference: `Flag/${flag.id}` }]
Expand Down
8 changes: 4 additions & 4 deletions packages/fhir-flag/src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const URL_CLOSE_FLAGS = `${URL_ADMIN}/close-flags`;
export const thatiMinutes = 30 * 60 * 1000;

// form fields
export const locationName = "locationName" as const
export const productName = "productName" as const
export const status = "status" as const
export const comments = "comments" as const
export const locationName = 'locationName' as const;
export const productName = 'productName' as const;
export const status = 'status' as const;
export const comments = 'comments' as const;

0 comments on commit 8987116

Please sign in to comment.