npm package: @inclouded/fhir-communication
Description: ``` npm install --save @inclouded/fhir-communication ```
Latest version: 2.0.0

# FHIR Communication Firestore SDK

```
npm install --save @inclouded/fhir-communication
```

## Introduction

In the repository the Firebase Cloud Firestore SDK can be found that was made for the FHIR Communication 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. The SDK can be used in a Service in the following way:

```typescript
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CommunicationApi } from '@inclouded/fhir-communication';
import { AngularFirestore } from '@angular/fire/firestore';
import { ICommunication } from '@ahryman40k/ts-fhir-types/lib/R4';

@Injectable()
export class CommunicationService {

    CommunicationApi: CommunicationApi;
    constructor(private afs: AngularFirestore) {
        this.CommunicationApi = new CommunicationApi(this.afs);
    }

    getCommunications(): Observable<ICommunication[]> {
        return this.CommunicationApi.getAll();
    }

    addCommunication(communication: ICommunication) {
        return this.CommunicationApi.add(communication);
    }

    deleteCommunication(communicationId: string) {
        return this.CommunicationApi.delete(communicationId);
    }

    updateCommunication(communication: ICommunication) {
        return this.CommunicationApi.update(communication);
    }

    getCommunicationsbyReasonReference(reasonReference: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationsbyReasonReference(reasonReference);
    }

    getCommunicationById(id: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getById(id);
    }

    getCommunicationByPatient(patinent: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByPatient(patinent);
    }

    getCommunicationByDate(dateStart: Date, dateEnd: Date): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByDate(dateStart, dateEnd);
    }

    getCommunicationByStatus(status: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByStatus(status);
    }

    getCommunicationByBasedOn(basedOn: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByBasedOn(basedOn);
    }

    getCommunicationByCategory(category: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByCategory(category);
    }

    getCommunicationByEncounter(encounter: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByEncounter(encounter);
    }

    getCommunicationByReceived(received: Date): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByReceived(received);
    }

    getCommunicationByPatientAndPriority(patient: string, priority: string): Observable<ICommunication[]> {
        return this.CommunicationApi.getCommunicationByPatientAndPriority(patient, priority);
    }
}

```

## Usage with MongoDB

See in the description of FhirApi:
[a link](https://www.npmjs.com/package/@inclouded/fhirapi)

> The Communication class must be equal with the form.value, this way there's no need for building the object locally. For the usage of the more complex objects there are more available interfaces, the properties of Communication that possess more complex objects build upon these. 

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