[text] vdas.service.ts

Viewer

copydownloadembedprintName: vdas.service.ts
  1. import { Injectable } from "@angular/core";
  2. import { EndpointConfigService } from "src/app/shared/services/endpoint-config.service";
  3. import { HttpClient } from "@angular/common/http";
  4. import { Observable } from "rxjs";
  5. import { environment } from "src/environments/environment";
  6. import { VDASQuery, VDASQueryVariables } from "src/app/shared/model/vdas-query";
  7.  
  8. @Injectable({
  9.     providedIn: 'root'
  10. })
  11. export class VDASService {
  12.  
  13.     constructor(private endpointConfigService: EndpointConfigService, private http: HttpClient) { }
  14.  
  15.     vdas(ssn: string, firstname?: string, lastname?: string, birthdate?: string): Observable<any> {
  16.         const body = this.createVDASBody(ssn, firstname, lastname, birthdate);
  17.         const apiURL = this.getApiUrlGraphQL() + (environment.envName === 'dev' ? '/vdas' : '');
  18.         return this.http.post(apiURL, body, { observe: 'response' });
  19.     }
  20.  
  21.     createVDASBody(ssn: string, firstname?: string, lastname?: string, birthdate?: string) {
  22.         let body: VDASQuery = new VDASQuery();
  23.         body.query = 'query ($ssn: String){vdasQuery(ssn: $ssn) {firstname lastname birthdate ssn sex insurance { svtCode svtName } patientZPI { demographicData { familyName givenName middleName prefix birthDate genderCode } patientAddress { streetName postalCode city } patientIdList  { id domain_oid namespace }}}}'
  24.         body.variables = new VDASQueryVariables();
  25.         body.variables.ssn = ssn;
  26.         return body;
  27.     }
  28.  
  29.     private getApiUrlGraphQL(): string {
  30.         return this.endpointConfigService.getEndpointUrl(EndpointConfigService.GRAPH_QL);
  31.     }
  32. }

Editor

You can edit this paste and save as new:


File Description
  • vdas.service.ts
  • Paste Code
  • 22 Oct-2020
  • 1.58 Kb
You can Share it: