Merge pull request #258 in TEA/mina-sidor-fa-web from bugfix/TV-889-avrop-model to develop

Squashed commit of the following:

commit 8e98b79d711a708eec7908417506d8f707d023b4
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Fri Nov 12 10:16:54 2021 +0100

    Added personnummer to deltagare avrop

commit 6ac1849fa61b65346084c2304339a628844a7617
Merge: 095585ff 0cf61c0b
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Fri Nov 12 09:52:10 2021 +0100

    Merged develop and fixed conflicts

commit 095585ffa78b25f5d5ddd6987dcd3702c78bb494
Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se>
Date:   Thu Nov 11 09:07:46 2021 +0100

    Updated avrop model for nya deltagare
This commit is contained in:
Erik Tiekstra
2021-11-12 10:17:27 +01:00
parent 0cf61c0b44
commit 8682ca963a
42 changed files with 287 additions and 201 deletions

View File

@@ -1,6 +1,6 @@
import { PaginationMeta } from '@msfa-models/pagination-meta.model';
export interface AvropResponse {
export interface DeltagareAvropResponse {
id: string;
fullName: string;
tjanst: string;
@@ -19,8 +19,49 @@ export interface AvropResponse {
handledare: string;
hasAvbrott: boolean;
hasGemensamPlanering: boolean;
kommun: string;
personnummer: string;
}
//personnummer: string;
export interface AvropResponse {
id: string;
deltagare: string;
genomforandeReferens: number;
kommun: string;
adress: string;
tjansteNamn: string;
startdatumAvrop: Date;
slutdatumAvrop: Date;
tolkbehov: string | null;
sprakstod: string | null;
sparkod: string;
// These are not used, but are available inside the response
leverantorId: number;
organisationsnummer: string;
utforandeVerksamhetId: number;
utforandeverksamhet: string;
kommunKod: string;
utforandeAdressId: number;
bokningsId: number;
ordernummer: string;
personnummer: string;
sokandeId: number;
tjanstekod: string;
deltagandeGrad: number;
sparNamn: string;
aktnummerDiariet: string;
handledareCiamUserId: string | null;
handledare: string | null;
exported: boolean;
avbrottHandelseId: string | null;
avbrottHandelse: string | null;
handelser: unknown[] | null;
handlingar: unknown[] | null;
recievedTimestamp: Date;
isDeltagare: boolean;
hasGemensamPlanering: boolean;
hasAvbrott: boolean;
}
export interface AvropAndMetaResponse {

View File

@@ -1,5 +1,5 @@
import { PaginationMeta } from '@msfa-models/pagination-meta.model';
import { AvropResponse } from './avrop.response.model';
import { DeltagareAvropResponse } from './avrop.response.model';
import { ContactInformationResponse } from './contact-information.response.model';
import { DisabilitiesResponse } from './disabilities.response.model';
import { DriversLicenseResponse } from './drivers-license.response.model';
@@ -32,7 +32,7 @@ export interface DeltagareResponse {
workLanguages: WorkLanguagesResponse;
disabilities: DisabilitiesResponse;
workExperiences: WorkExperiencesResponse;
avropInformation: AvropResponse;
avropInformation: DeltagareAvropResponse;
}
export interface DeltagareCompactApiResponse {

View File

@@ -1,8 +1,9 @@
import { TrackName } from '@msfa-enums/track-name.enum';
import { AvropResponse } from './api/avrop.response.model';
import { mapStringToSsn } from '@msfa-shared/utils/map-string-to-ssn.util';
import { AvropResponse, DeltagareAvropResponse } from './api/avrop.response.model';
import { PaginationMeta } from './pagination-meta.model';
export interface Avrop {
export interface DeltagareAvrop {
id: string;
fullName: string;
tjanst: string;
@@ -22,9 +23,22 @@ export interface Avrop {
receivedTimestamp: Date;
hasGemensamPlanering: boolean;
hasAvbrott: boolean;
ssn: string; // personnummer
kommun: string;
ssn: string;
}
export interface Avrop {
id: string;
fullName: string;
tjanst: string;
startDate: Date;
endDate: Date;
sprakstod: string;
tolkbehov: string;
utforandeAdress: string;
kommun: string;
trackName: TrackName;
genomforandeReferens: number;
}
export interface AvropAndMeta {
@@ -32,7 +46,37 @@ export interface AvropAndMeta {
meta: PaginationMeta;
}
export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
export function mapResponseToAvrop(data: AvropResponse): Avrop {
const {
id,
deltagare,
tjansteNamn,
startdatumAvrop,
slutdatumAvrop,
sprakstod,
tolkbehov,
adress,
kommun,
sparkod,
genomforandeReferens,
} = data;
return {
id,
fullName: deltagare,
tjanst: tjansteNamn,
startDate: new Date(startdatumAvrop),
endDate: new Date(slutdatumAvrop),
sprakstod,
tolkbehov,
utforandeAdress: adress,
kommun,
trackName: (TrackName[sparkod] || TrackName.UNKNOWN) as TrackName,
genomforandeReferens,
};
}
export function mapResponseToDeltagareAvrop(data: DeltagareAvropResponse): DeltagareAvrop {
const {
id,
fullName,
@@ -52,9 +96,8 @@ export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
handledare,
hasAvbrott,
hasGemensamPlanering,
// kommun
// personnummer,
kommun,
personnummer,
} = data;
return {
@@ -68,12 +111,10 @@ export function mapAvropResponseToAvrop(data: AvropResponse): Avrop {
sprakstod,
utforandeVerksamhet,
utforandeAdress,
// kommun,
kommun: '',
kommun: kommun || '',
trackCode: sparkod,
trackName: (TrackName[sparkod] || TrackName.UNKNOWN) as TrackName,
// ssn: mapStringToSsn(personnummer),
ssn: '',
ssn: mapStringToSsn(personnummer),
genomforandeReferens,
participationFrequency,
handledareCiamUserId,

View File

@@ -1,6 +1,6 @@
import { Address } from './address.model';
import { DeltagareCompactResponse, DeltagareResponse } from './api/deltagare.response.model';
import { Avrop, mapAvropResponseToAvrop } from './avrop.model';
import { DeltagareAvrop, mapResponseToDeltagareAvrop } from './avrop.model';
import { mapResponseToContactInformation } from './contact-information.model';
import { Disability, mapResponseToDisability } from './disability.model';
import { DriversLicense, mapResponseToDriversLicense } from './drivers-license.model';
@@ -42,7 +42,7 @@ export interface Deltagare {
disabilities: Disability[];
workLanguages: string[];
workExperiences: WorkExperience[];
avropInformation: Avrop;
avropInformation: DeltagareAvrop;
}
export interface DeltagareCompactData {
@@ -105,6 +105,6 @@ export function mapResponseToDeltagare(data: DeltagareResponse): Deltagare {
workExperiences:
workExperiences &&
workExperiences.arbetslivserfarenheter.map(workExperience => mapResponseToWorkExperience(workExperience)),
avropInformation: avropInformation && mapAvropResponseToAvrop(avropInformation),
avropInformation: avropInformation && mapResponseToDeltagareAvrop(avropInformation),
};
}

View File

@@ -5,9 +5,8 @@ import { AvropFilterResponse } from '@msfa-models/api/avrop-filter.response.mode
import { AvropAndMetaResponse } from '@msfa-models/api/avrop.response.model';
import { Params } from '@msfa-models/api/params.model';
import { AvropFilter, mapResponseToAvropFilter } from '@msfa-models/avrop-filter.model';
import { Avrop, AvropAndMeta, mapAvropResponseToAvrop } from '@msfa-models/avrop.model';
import { Avrop, AvropAndMeta, mapResponseToAvrop } from '@msfa-models/avrop.model';
import { CustomError, errorToCustomError } from '@msfa-models/error/custom-error';
import { Handledare } from '@msfa-models/handledare.model';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { catchError, filter, map } from 'rxjs/operators';
@@ -17,7 +16,6 @@ import { catchError, filter, map } from 'rxjs/operators';
export class AvropApiService {
private _apiBaseUrl = `${environment.api.url}/avrop`;
private _lockedAvropSnapshot$ = new BehaviorSubject<Avrop[]>(null);
private _availableHandledareSnapshot$ = new BehaviorSubject<Handledare[]>(null);
private _showUnauthorizedError$ = new BehaviorSubject<boolean>(false);
public showUnauthorizedError$: Observable<boolean> = this._showUnauthorizedError$.asObservable();
@@ -31,14 +29,14 @@ export class AvropApiService {
return this.httpClient
.get<AvropAndMetaResponse>(`${this._apiBaseUrl}`, { params })
.pipe(
map(({ data, meta }) => ({ data: data.map(avrop => mapAvropResponseToAvrop(avrop)), meta })),
map(({ data, meta }) => ({ data: data.map(avrop => mapResponseToAvrop(avrop)), meta })),
catchError((error: Error & { status: number }) => {
if (error.status === 403) {
this._showUnauthorizedError$.next(true);
return of(null as null);
} else {
throw new CustomError(
errorToCustomError({ ...error, message: `Kunde inte hämta deltagare.\n\n${error.message}` })
errorToCustomError({ ...error, message: `Kunde inte hämta nya deltagare.\n\n${error.message}` })
);
}
})

View File

@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@msfa-environment';
import { AvropResponse } from '@msfa-models/api/avrop.response.model';
import { DeltagareAvropResponse } from '@msfa-models/api/avrop.response.model';
import { ContactInformationResponse } from '@msfa-models/api/contact-information.response.model';
import { DeltagareCompactApiResponse } from '@msfa-models/api/deltagare.response.model';
import { DisabilityResponse } from '@msfa-models/api/disability.response.model';
@@ -13,7 +13,7 @@ import { ReportsDataResponse } from '@msfa-models/api/report.response.model';
import { TranslatorResponse } from '@msfa-models/api/translator.response.model';
import { WorkExperiencesResponse } from '@msfa-models/api/work-experiences.response.model';
import { WorkLanguagesResponse } from '@msfa-models/api/work-languages.response.model';
import { Avrop, mapAvropResponseToAvrop } from '@msfa-models/avrop.model';
import { DeltagareAvrop, mapResponseToDeltagareAvrop } from '@msfa-models/avrop.model';
import { ContactInformation, mapResponseToContactInformation } from '@msfa-models/contact-information.model';
import { DeltagareCompactData, mapResponseToDeltagareCompact } from '@msfa-models/deltagare.model';
import { Disability, mapResponseToDisability } from '@msfa-models/disability.model';
@@ -217,14 +217,16 @@ export class DeltagareApiService {
);
}
public fetchAvropInformation$(genomforandeReferens: number): Observable<Avrop> {
return this.httpClient.get<{ data: AvropResponse }>(`${this._apiBaseUrl}/${genomforandeReferens}/avrop`).pipe(
map(({ data }) => mapAvropResponseToAvrop(data)),
catchError((error: Error) => {
throw new CustomError(
errorToCustomError({ ...error, message: `Kunde inte hämta avropsinformation.\n\n${error.message}` })
);
})
);
public fetchAvropInformation$(genomforandeReferens: number): Observable<DeltagareAvrop> {
return this.httpClient
.get<{ data: DeltagareAvropResponse }>(`${this._apiBaseUrl}/${genomforandeReferens}/avrop`)
.pipe(
map(({ data }) => mapResponseToDeltagareAvrop(data)),
catchError((error: Error) => {
throw new CustomError(
errorToCustomError({ ...error, message: `Kunde inte hämta avropsinformation.\n\n${error.message}` })
);
})
);
}
}

View File

@@ -4,7 +4,7 @@ import { ErrorType } from '@msfa-enums/error-type.enum';
import { environment } from '@msfa-environment';
import { FranvaroReasonResponse } from '@msfa-models/api/franvaro-reason.response.model';
import { FranvaroReportRequest } from '@msfa-models/api/franvaro-request.model';
import { Avrop } from '@msfa-models/avrop.model';
import { DeltagareAvrop } from '@msfa-models/avrop.model';
import { CustomError, errorToCustomError } from '@msfa-models/error/custom-error';
import { FranvaroReason, mapResponseToFranvaroReason } from '@msfa-models/franvaro-reason.model';
import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
@@ -44,7 +44,7 @@ export class FranvaroReportApiService {
);
}
public fetchAvropInformation$(genomforandeReferens: number): Observable<Avrop> {
public fetchAvropInformation$(genomforandeReferens: number): Observable<DeltagareAvrop> {
return this.deltagareApiService.fetchAvropInformation$(genomforandeReferens);
}

View File

@@ -5,7 +5,7 @@ import { environment } from '@msfa-environment';
import { Activity, mapResponseToActivity } from '@msfa-models/activity.model';
import { ActivityResponse } from '@msfa-models/api/activity.response.model';
import { GemensamPlaneringPostRequest } from '@msfa-models/api/gemensam-planering.request.model';
import { Avrop } from '@msfa-models/avrop.model';
import { DeltagareAvrop } from '@msfa-models/avrop.model';
import { CustomError, errorToCustomError } from '@msfa-models/error/custom-error';
import { DeltagareApiService } from '@msfa-services/api/deltagare.api.service';
import { Observable } from 'rxjs';
@@ -31,7 +31,7 @@ export class GemensamPlaneringApiService {
);
}
public fetchAvropInformation$(genomforandeReferens: number): Observable<Avrop> {
public fetchAvropInformation$(genomforandeReferens: number): Observable<DeltagareAvrop> {
return this.deltagareApiService.fetchAvropInformation$(genomforandeReferens);
}