@inclouded/fhirapi
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

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)

Dependencies (5)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @inclouded/fhirapi

    Weekly Downloads

    19

    Version

    4.0.0

    License

    none

    Unpacked Size

    326 kB

    Total Files

    30

    Last publish

    Collaborators

    • zbiacsi
    • bilickiv
    • m2m-deploy
    • jankiz
    • grindy