4.0.0 • Published 3 years ago

@inclouded/fhirapi v4.0.0

Weekly downloads
153
License
-
Repository
-
Last release
3 years ago

FhirApi SDK

Introduction

In the repository the Firebase Cloud Firestore SDK can be found that was made for the FHIRApi resource in an installable Angular folder form. The SDK can be installed for every Angular 2+ project. The SDK accomplishes the necessary CRUD operations.

Usage

  1. For using the SDK an Angular 2+ project is needed, in which we can establish a connection to a Firestore database instance. (configured in environments.ts)

  2. Related interfaces (FhirApi.ts, FirestoreDocument.ts):

export class FhirApi {
  db: AngularFirestore;
  collectionName: string;
  documentClass: any;
}

export interface OrderBy {
  orderBy?: string;
  direction?: string;
}

export interface Paging {
  limit?: number;
  startAfter?: string;
  startAt?: number;
  orderByField?: string;
}

export class FirestoreDocument {
    id: string;
    data: any;
}
  1. The SDK can be used in a Service in the following way:
import { Injectable } from '@angular/core';
import { FhirApi } from '@inclouded/fhirapi';
import { AngularFirestore } from '@angular/fire/firestore';

@Injectable()
export class FhirApiService {
 FhirApi: FhirApi;
 collectionName: string;
  constructor(private afs: AngularFirestore) {
    this.FhirApi = new FhirApi(this.afs, this.collectionName);
  }

  getAllFhirApis() {
    return this.FhirApi.getAll();
  }

  getAllbyId(id: string) {
    return this.FhirApi.getById(id);
  }

  addFhirApi(fhirApi: any, id?: string) {
    return this.FhirApi.add(fhirApi);
  }

  updateDevice(fhirApi: any) {
    return this.FhirApi.update(fhirApi);
  }

  deleteFhirApi(id: string) {
    return this.FhirApi.delete(id);
  }
}

Usage with MongoDB

  1. The usage is similar to the description above. The only difference is we need a mongoDB database here.

  2. The related interfaces are the same.

  3. They can be used in a Service in the following way:

    • In the cfg it is needed to set the requested parameters to reach the MongoDB.
    • Instead of the new FhirApi we can also use the already existing resources. In that case the collectionName and documentClass parameters can be left out.
import { Injectable } from '@angular/core';
import { FhirApi } from '@inclouded/fhirapi';
import { Paging, MongoDBConfig, MongoDBDAO, OrderBy } from '@inclouded/fhirapi';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class FhirApiService {
  cfg: MongoDBConfig = {
    httpClient: this.http,
    url: 'http://localhost:8080',
    username: 'username',
    password: 'password'
  };
  dao = new MongoDBDAO(this.http, this.cfg);
  collectionName: string;
  documentClass: any;
  FhirApi: FhirApi;

  constructor(private http: HttpClient) {
    this.FhirApi = new FhirApi(this.dao, this.collectionName, this.documentClass);
  }

  getAllFhirApis() {
    return this.FhirApi.getAll();
  }

  getAllbyId(id: string) {
    return this.FhirApi.getById(id);
  }

  addFhirApi(fhirApi: any, id?: string) {
    return this.FhirApi.add(fhirApi, id);
  }

  updateDevice(fhirApi: any) {
    return this.FhirApi.update(fhirApi);
  }

  deleteFhirApi(id: string) {
    return this.FhirApi.delete(id);
  }
}

Developer: Zoltán R. Jánki (jankiz@inf.u-szeged.hu), Gábor Simon (simonovszkij@gmail.com)

4.0.0

3 years ago

2.1.4

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.3

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.1

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago