Skip to content

Commit 02a7384

Browse files
Imunization list filter (#288)
* facility fixes * immunizations * fix * fix * fix * fix
1 parent 57ab69f commit 02a7384

23 files changed

+608
-561
lines changed

src/app/_common-components/menu/menu.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const routesConfig: RouteItem[] = [
1919
{ link: 'events/list', label: 'captions.mainMenuEvents', selectedLink: 'events' },
2020
{ link: 'contacts/list', label: 'captions.mainMenuContacts', selectedLink: 'contacts' },
2121
{ link: 'samples/list', label: 'captions.mainMenuSamples', selectedLink: 'samples' },
22+
{ link: 'immunizations/list', label: 'Immunizations', selectedLink: 'immunizations' },
2223
{ link: 'user-profile', label: 'mainMenuMyProfile', selectedLink: 'user-profile' },
2324
{ link: 'stats', label: 'captions.mainMenuStatistics', selectedLink: 'stats' },
2425
{ link: 'persons/list', label: 'captions.mainMenuPersons', selectedLink: 'persons' },

src/app/_constants/api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,11 @@ export const API_ROUTE_EVENT_GROUPS = {
218218
ADD: 'eventGroups/push',
219219
DELETE: 'eventGroups/delete',
220220
};
221+
222+
export const API_ROUTE_IMMUNIZATIONS = {
223+
ENDPOINT: 'immunizations',
224+
GET_ALL: 'immunizations/indexList',
225+
UPDATE: 'immunizations/push',
226+
ADD: 'immunizations/push',
227+
DELETE: 'immunizations/delete',
228+
};

src/app/_constants/form-identifiers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ export const TASK_FILTERS_FORM_ID = 'taskFilters';
4444

4545
export const USER_DETAILS_FORM_ID = 'user';
4646
export const USER_FILTERS_FORM_ID = 'userFilters';
47+
48+
export const IMMUNIZATION_FILTERS_FORM_ID = 'immunizationFilters';

src/app/_constants/storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export const CONFIG_EVENTS = 'configEvents';
44
export const CONFIG_SAMPLES = 'configSamples';
55
export const CONFIG_PERSONS = 'configPersons';
66
export const CONFIG_USERS = 'configUsers';
7+
export const CONFIG_IMMUNIZATIONS = 'configImmunizations';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* eslint-disable no-param-reassign */
2+
import { Serializer } from './base.serializer';
3+
import { deserializeDates, serializeDates } from './date-parse';
4+
import { ImmunizationDto } from '../_models/immunizationDto';
5+
6+
export class ImmunizationSerializer implements Serializer {
7+
fromJson(json: any): ImmunizationDto {
8+
json.id = json.id ?? json.uuid;
9+
deserializeDates(json);
10+
return json;
11+
}
12+
13+
toJson(caseItem: ImmunizationDto): any {
14+
serializeDates(caseItem);
15+
return caseItem;
16+
}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Injectable } from '@angular/core';
2+
import { HttpClient } from '@angular/common/http';
3+
4+
import { BaseService } from './base.service';
5+
6+
import * as constants from '../../app.constants';
7+
import { HelperService } from '../helper.service';
8+
import { ImmunizationDto } from '../../_models/immunizationDto';
9+
import { ImmunizationSerializer } from '../../_serializers/immunization.serializer';
10+
11+
@Injectable({
12+
providedIn: 'root',
13+
})
14+
export class ImmunizationService extends BaseService<ImmunizationDto> {
15+
constructor(httpClient: HttpClient, helperService: HelperService) {
16+
super(
17+
httpClient,
18+
helperService,
19+
'',
20+
constants.API_ROUTE_IMMUNIZATIONS,
21+
new ImmunizationSerializer()
22+
);
23+
}
24+
}

src/app/app-routing.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ const routes: Routes = [
4343
loadChildren: () => import('./events/events.module').then((m) => m.EventsModule),
4444
canActivate: [Guard],
4545
},
46+
{
47+
path: 'immunizations',
48+
loadChildren: () =>
49+
import('./immunizations/immunizations.module').then((m) => m.ImmunizationsModule),
50+
canActivate: [Guard],
51+
},
4652
{
4753
path: 'user-profile',
4854
loadChildren: () =>
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import {
2+
FORM_DATA_SELECT,
3+
FORM_DATA_SEARCHBOX,
4+
Disease,
5+
FORM_DATA_DATE,
6+
DateFilterOptions,
7+
} from '../../app.constants';
8+
import { FormGroupStyleType } from '../../_models/common';
9+
10+
import { EnumToKeyValuePipe } from '../../_pipes/enum-to-key-value/enum-to-key-value.pipe';
11+
12+
const pipe = new EnumToKeyValuePipe();
13+
14+
const diseaseOptions = pipe.transform(Disease);
15+
const dateFilterOptions = pipe.transform(DateFilterOptions);
16+
17+
export const FORM_DATA_IMMUNIZATION_FILTERS = [
18+
{
19+
id: 'search',
20+
title: '',
21+
appearance: FormGroupStyleType.BASIC,
22+
fields: [
23+
{
24+
...FORM_DATA_SEARCHBOX,
25+
key: 'immunizationLike',
26+
placeholder: 'strings.promptCampaignSearch',
27+
className: 'fullwidth',
28+
},
29+
],
30+
},
31+
{
32+
id: 'birthdate',
33+
title: 'headingBirthdate',
34+
appearance: FormGroupStyleType.COLLAPSABLE,
35+
fields: [
36+
{
37+
...FORM_DATA_SELECT,
38+
key: 'birthdateYYYY',
39+
options: [],
40+
placeholder: 'captions.Person.birthdateYYYY',
41+
className: 'fullwidth',
42+
},
43+
{
44+
...FORM_DATA_SELECT,
45+
key: 'birthdateMM',
46+
options: [],
47+
placeholder: 'captions.Person.birthdateMM',
48+
className: 'fullwidth',
49+
},
50+
{
51+
...FORM_DATA_SELECT,
52+
key: 'birthdateDD',
53+
options: [],
54+
placeholder: 'captions.Person.birthdateDD',
55+
className: 'fullwidth',
56+
},
57+
],
58+
},
59+
{
60+
id: 'medicalAspect',
61+
title: 'headingMedicalAspects',
62+
appearance: FormGroupStyleType.COLLAPSABLE,
63+
fields: [
64+
{
65+
...FORM_DATA_SELECT,
66+
key: 'disease',
67+
placeholder: 'captions.disease',
68+
options: diseaseOptions,
69+
className: 'fullwidth',
70+
},
71+
],
72+
},
73+
{
74+
id: 'adminAspect',
75+
title: 'headingAdminAspect',
76+
appearance: FormGroupStyleType.COLLAPSABLE,
77+
fields: [
78+
{
79+
...FORM_DATA_SELECT,
80+
key: 'region.uuid',
81+
options: [],
82+
service: 'regionService',
83+
placeholder: 'strings.entityRegion',
84+
className: 'fullwidth',
85+
},
86+
{
87+
...FORM_DATA_SELECT,
88+
key: 'district.uuid',
89+
options: [],
90+
service: 'districtService',
91+
determinedBy: 'region.uuid',
92+
placeholder: 'strings.entityDistricts',
93+
className: 'fullwidth',
94+
},
95+
{
96+
...FORM_DATA_SELECT,
97+
key: 'community.uuid',
98+
options: [],
99+
service: 'communityService',
100+
determinedBy: 'district.uuid',
101+
placeholder: 'strings.entityCommunities',
102+
className: 'fullwidth',
103+
},
104+
],
105+
},
106+
{
107+
id: 'facility',
108+
title: 'captions.facility',
109+
appearance: FormGroupStyleType.COLLAPSABLE,
110+
fields: [
111+
{
112+
...FORM_DATA_SELECT,
113+
key: 'facilityTypeGroup',
114+
placeholder: 'captions.facilityTypeGroup',
115+
options: [],
116+
className: 'fullwidth',
117+
},
118+
{
119+
...FORM_DATA_SELECT,
120+
key: 'facilityType',
121+
placeholder: 'captions.CaseData.facilityType',
122+
options: [],
123+
className: 'fullwidth',
124+
},
125+
{
126+
...FORM_DATA_SELECT,
127+
key: 'healthFacility',
128+
placeholder: 'captions.facility',
129+
options: [],
130+
className: 'fullwidth',
131+
},
132+
],
133+
},
134+
{
135+
id: 'date',
136+
title: 'headingDateFilter',
137+
appearance: FormGroupStyleType.COLLAPSABLE,
138+
fields: [
139+
{
140+
...FORM_DATA_SELECT,
141+
key: 'dateFilterOption',
142+
options: dateFilterOptions,
143+
value: 'DATE',
144+
className: 'fullwidth',
145+
},
146+
{
147+
...FORM_DATA_DATE,
148+
key: 'newImmunizationDateFrom',
149+
hint: 'strings.date',
150+
className: 'fullwidth',
151+
},
152+
{
153+
...FORM_DATA_DATE,
154+
key: 'newImmunizationDateTo',
155+
hint: 'strings.date.to',
156+
className: 'fullwidth',
157+
},
158+
],
159+
},
160+
];
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { TranslateModule } from '@ngx-translate/core';
4+
import { ImmunizationFiltersComponent } from './immunization-filters.component';
5+
6+
describe('ImmunizationFiltersComponent', () => {
7+
let component: ImmunizationFiltersComponent;
8+
let fixture: ComponentFixture<ImmunizationFiltersComponent>;
9+
10+
beforeEach(async () => {
11+
await TestBed.configureTestingModule({
12+
declarations: [ImmunizationFiltersComponent],
13+
imports: [TranslateModule.forRoot()],
14+
}).compileComponents();
15+
});
16+
17+
beforeEach(() => {
18+
fixture = TestBed.createComponent(ImmunizationFiltersComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
import { FiltersFormComponent } from '../../shared/filters/filters-form/filters-form.component';
3+
4+
@Component({
5+
selector: 'app-immunization-filters',
6+
templateUrl: '../../shared/filters/filters-form/filters-form.component.html',
7+
})
8+
export class ImmunizationFiltersComponent extends FiltersFormComponent {}

0 commit comments

Comments
 (0)