# @inclouded/fhirapi

> ## Introduction

Latest version **4.0.0** (published 2021-08-05) · 0 weekly downloads

## Install

```sh
npm install @inclouded/fhirapi
pnpm add @inclouded/fhirapi
yarn add @inclouded/fhirapi
bun add @inclouded/fhirapi
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-08-05 |
| First published | 2019-11-08 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 318 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | bilickiv, m2m-deploy, jankiz, grindy |

## Links

- npm: https://www.npmjs.com/package/@inclouded/fhirapi
- npm.io page: https://npm.io/package/@inclouded/fhirapi

## Dependencies (5)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0
- [firebase](https://npm.io/package/firebase.md) ^8.8.1
- [@angular/fire](https://npm.io/package/@angular/fire.md) ^6.1.5
- [ngx-socket-io](https://npm.io/package/ngx-socket-io.md) 3.0.1
- [@ahryman40k/ts-fhir-types](https://npm.io/package/@ahryman40k/ts-fhir-types.md) 4.0.23

## Recent versions

- 4.0.0 (latest) — 2021-08-05
- 3.0.1 — 2021-02-15
- 2.1.4 — 2021-02-15
- 3.0.0 — 2021-01-25
- 2.1.3 — 2021-01-15
- 2.1.2 — 2020-11-05
- 2.1.1 — 2020-11-04
- 2.1.0 — 2020-11-03
- 2.0.7 — 2020-06-30
- 2.0.6 — 2020-06-30
- 2.0.5 — 2020-04-28
- 2.0.4 — 2020-04-23
- 2.0.3 — 2020-04-14
- 2.0.2 — 2020-02-03
- 2.0.1 — 2020-01-31
- … 13 more at https://npm.io/package/@inclouded/fhirapi/versions

## README

# 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):

```typescript
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;
}
```

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

```javascript
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.

```javascript
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)

---
_Source: https://npm.io/package/@inclouded/fhirapi · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
