diff --git a/projects/common/src/fm/models/code.list.item.ts b/projects/common/src/fm/models/code.list.item.ts new file mode 100644 index 0000000..e09997f --- /dev/null +++ b/projects/common/src/fm/models/code.list.item.ts @@ -0,0 +1,28 @@ +export interface ICodeListItem { + codelist: string; + code: string; + codeGroup?: string; + unit?: string; + description?: string; + validFrom?: Date; + validTo?: Date; + created?: Date; + updated?: Date; + data?:any +} + +export class CodeListItem implements ICodeListItem { + public codelist: string; + public code: string; + public codeGroup?: string; + public unit?: string; + public description:string; + public validFrom?: Date; + public validTo?: Date; + public created?: Date; + public updated?: Date; + public data?:any; + + constructor() { + } +} diff --git a/projects/common/src/fm/services/codelistitem.service.ts b/projects/common/src/fm/services/codelistitem.service.ts new file mode 100644 index 0000000..d75320c --- /dev/null +++ b/projects/common/src/fm/services/codelistitem.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { HttpClient, HttpParams } from "@angular/common/http"; +import { AppConfig } from "../shared/app.config"; +import { ICodeListItem } from '../models/code.list.item'; + +@Injectable({ + providedIn: 'root', +}) +export class CodeListItemService { + constructor(public httpClient: HttpClient, public appConfig: AppConfig) { + } + + ApiEndpoint() { + return this.appConfig.getConfig("apiEndPoint"); + } + + getCodeListItems(codelist: string[], codegroup?: string, dataFilter?: any, onlyBetweenValidFromAndTo: boolean = true): Observable { + var params = new HttpParams(); + params = params.append("cl", codelist.join(",")); + if (codegroup) params = params.append("g", codegroup); + if (onlyBetweenValidFromAndTo) params = params.append("v", onlyBetweenValidFromAndTo); + if (dataFilter) params = params.append("df", dataFilter); + return this.httpClient.get(`${this.ApiEndpoint()}/api/v1/codelistitems/`, { params: params }); + } +}