Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIMSBIOHUB-353/325: Survey form updates #1149

Merged
merged 13 commits into from
Oct 31, 2023
Merged
9 changes: 0 additions & 9 deletions api/src/models/survey-create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,6 @@ describe('PostPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal(null);
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.equal(null);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});
Expand All @@ -396,7 +392,6 @@ describe('PostPurposeAndMethodologyData', () => {
const obj = {
intended_outcome_id: 1,
additional_details: 'additional_detail',
field_method_id: 2,
vantage_code_ids: [4, 5],
surveyed_all_areas: true
};
Expand All @@ -413,10 +408,6 @@ describe('PostPurposeAndMethodologyData', () => {
expect(data.additional_details).to.eql(obj.additional_details);
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.eql(obj.field_method_id);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_code_ids);
});
Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ export class PostProprietorData {
export class PostPurposeAndMethodologyData {
intended_outcome_id: number;
additional_details: string;
field_method_id: number;
vantage_code_ids: number[];
surveyed_all_areas: boolean;

constructor(obj?: any) {
this.intended_outcome_id = obj?.intended_outcome_id || null;
this.additional_details = obj?.additional_details || null;
this.field_method_id = obj?.field_method_id || null;
this.vantage_code_ids = obj?.vantage_code_ids || [];
this.surveyed_all_areas = obj?.surveyed_all_areas || null;
}
Expand Down
9 changes: 0 additions & 9 deletions api/src/models/survey-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ describe('PutPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal(null);
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.equal(null);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});
Expand All @@ -363,7 +359,6 @@ describe('PutPurposeAndMethodologyData', () => {
const obj = {
intended_outcome_id: 1,
additional_details: 'additional_detail',
field_method_id: 2,
vantage_code_ids: [4, 5],
surveyed_all_areas: 'true',
revision_count: 0
Expand All @@ -381,10 +376,6 @@ describe('PutPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal(obj.additional_details);
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.equal(obj.field_method_id);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_code_ids);
});
Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,13 @@ export class PutSurveyProprietorData {
}
export class PutSurveyPurposeAndMethodologyData {
intended_outcome_id: number;
field_method_id: number;
additional_details: string;
vantage_code_ids: number[];
surveyed_all_areas: boolean;
revision_count: number;

constructor(obj?: any) {
this.intended_outcome_id = obj?.intended_outcome_id || null;
this.field_method_id = obj?.field_method_id || null;
this.additional_details = obj?.additional_details || null;
this.vantage_code_ids = (obj?.vantage_code_ids?.length && obj.vantage_code_ids) || [];
this.surveyed_all_areas = obj?.surveyed_all_areas === 'true' || false;
Expand Down
9 changes: 0 additions & 9 deletions api/src/models/survey-view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
expect(data.additional_details).to.equal('');
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.equal(null);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql([]);
});
Expand All @@ -359,7 +355,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
const obj = {
intended_outcome_id: 1,
additional_details: 'additional_detail',
field_method_id: 2,
vantage_ids: [4, 5],
revision_count: 'count'
};
Expand All @@ -376,10 +371,6 @@ describe('GetSurveyPurposeAndMethodologyData', () => {
expect(data.additional_details).to.eql(obj.additional_details);
});

it('sets field_method_id', () => {
expect(data.field_method_id).to.eql(obj.field_method_id);
});

it('sets vantage_code_ids', () => {
expect(data.vantage_code_ids).to.eql(obj.vantage_ids);
});
Expand Down
2 changes: 0 additions & 2 deletions api/src/models/survey-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ export class GetPermitData {
export class GetSurveyPurposeAndMethodologyData {
intended_outcome_id: number;
additional_details: string;
field_method_id: number;
revision_count: number;
vantage_code_ids: number[];

constructor(obj?: any) {
this.intended_outcome_id = obj?.intended_outcome_id || null;
this.additional_details = obj?.additional_details || '';
this.field_method_id = obj?.field_method_id || null;
this.vantage_code_ids = (obj?.vantage_ids?.length && obj.vantage_ids) || [];
this.revision_count = obj?.revision_count ?? 0;
}
Expand Down
15 changes: 0 additions & 15 deletions api/src/paths/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ GET.apiDoc = {
'system_roles',
'project_roles',
'administrative_activity_status_type',
'field_methods',
'intended_outcomes',
'vantage_codes',
'site_selection_strategies'
Expand Down Expand Up @@ -262,20 +261,6 @@ GET.apiDoc = {
}
}
},
field_methods: {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'number'
},
name: {
type: 'string'
}
}
}
},
intended_outcomes: {
type: 'array',
items: {
Expand Down
4 changes: 1 addition & 3 deletions api/src/paths/project/{projectId}/survey/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ POST.apiDoc = {
additional_details: {
type: 'string'
},
field_method_id: {
type: 'number'
},
vantage_code_ids: {
type: 'array',
items: {
Expand Down Expand Up @@ -242,6 +239,7 @@ POST.apiDoc = {
properties: {
strategies: {
type: 'array',
minItems: 1,
items: {
type: 'string'
}
Expand Down
11 changes: 1 addition & 10 deletions api/src/paths/project/{projectId}/survey/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,8 @@ GET.apiDoc = {
purpose_and_methodology: {
description: 'Survey Details',
type: 'object',
required: [
'field_method_id',
'additional_details',
'intended_outcome_id',
'vantage_code_ids',
'revision_count'
],
required: ['additional_details', 'intended_outcome_id', 'vantage_code_ids', 'revision_count'],
properties: {
field_method_id: {
type: 'number'
},
additional_details: {
type: 'string',
nullable: true
Expand Down
12 changes: 2 additions & 10 deletions api/src/paths/project/{projectId}/survey/{surveyId}/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,14 @@ PUT.apiDoc = {
},
purpose_and_methodology: {
type: 'object',
required: [
'intended_outcome_id',
'additional_details',
'field_method_id',
'vantage_code_ids',
'revision_count'
],
required: ['intended_outcome_id', 'additional_details', 'vantage_code_ids', 'revision_count'],
properties: {
intended_outcome_id: {
type: 'number'
},
additional_details: {
type: 'string'
},
field_method_id: {
type: 'number'
},
vantage_code_ids: {
type: 'array',
items: {
Expand Down Expand Up @@ -276,6 +267,7 @@ PUT.apiDoc = {
properties: {
strategies: {
type: 'array',
minItems: 1,
items: {
type: 'string'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,8 @@ GET.apiDoc = {
purpose_and_methodology: {
description: 'Survey Details',
type: 'object',
required: [
'field_method_id',
'additional_details',
'intended_outcome_id',
'vantage_code_ids',
'revision_count'
],
required: ['additional_details', 'intended_outcome_id', 'vantage_code_ids', 'revision_count'],
properties: {
field_method_id: {
type: 'number'
},
additional_details: {
type: 'string',
nullable: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('survey/{surveyId}/view', () => {
},
funding_sources: [],
purpose_and_methodology: {
field_method_id: 1,
additional_details: 'details',
intended_outcome_id: 8,
vantage_code_ids: [1, 2],
Expand Down Expand Up @@ -117,7 +116,6 @@ describe('survey/{surveyId}/view', () => {
},
funding_sources: [],
purpose_and_methodology: {
field_method_id: 1,
additional_details: null,
intended_outcome_id: null,
vantage_code_ids: [],
Expand Down
11 changes: 1 addition & 10 deletions api/src/paths/project/{projectId}/survey/{surveyId}/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,8 @@ GET.apiDoc = {
purpose_and_methodology: {
description: 'Survey Details',
type: 'object',
required: [
'field_method_id',
'additional_details',
'intended_outcome_id',
'vantage_code_ids',
'revision_count'
],
required: ['additional_details', 'intended_outcome_id', 'vantage_code_ids', 'revision_count'],
properties: {
field_method_id: {
type: 'number'
},
additional_details: {
type: 'string',
nullable: true
Expand Down
23 changes: 0 additions & 23 deletions api/src/repositories/code-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const IAllCodeSets = z.object({
system_roles: CodeSet(),
project_roles: CodeSet(),
administrative_activity_status_type: CodeSet(),
field_methods: CodeSet(z.object({ id: z.number(), name: z.string(), description: z.string() }).shape),
intended_outcomes: CodeSet(z.object({ id: z.number(), name: z.string(), description: z.string() }).shape),
vantage_codes: CodeSet(),
survey_jobs: CodeSet(),
Expand Down Expand Up @@ -160,28 +159,6 @@ export class CodeRepository extends BaseRepository {
return response.rows;
}

/**
* Fetch field method codes.
*
* @return {*}
* @memberof CodeRepository
*/
async getFieldMethods() {
const sqlStatement = SQL`
SELECT
field_method_id as id,
name, description
FROM
field_method
WHERE
record_end_date is null;
`;

const response = await this.connection.sql(sqlStatement);

return response.rows;
}

/**
* Fetch vantage codes.
*
Expand Down
6 changes: 0 additions & 6 deletions api/src/repositories/survey-repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ describe('SurveyRepository', () => {
survey_types: [1, 2]
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y'
Expand All @@ -493,7 +492,6 @@ describe('SurveyRepository', () => {
survey_types: [1, 2]
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y'
Expand All @@ -520,7 +518,6 @@ describe('SurveyRepository', () => {
survey_types: [1, 2]
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y'
Expand Down Expand Up @@ -845,7 +842,6 @@ describe('SurveyRepository', () => {
revision_count: 1
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y',
Expand Down Expand Up @@ -873,7 +869,6 @@ describe('SurveyRepository', () => {
revision_count: 1
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y',
Expand Down Expand Up @@ -901,7 +896,6 @@ describe('SurveyRepository', () => {
revision_count: 1
},
purpose_and_methodology: {
field_method_id: 1,
additional_details: '',
intended_outcome_id: 1,
surveyed_all_areas: 'Y',
Expand Down
Loading
Loading