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

# FHIR ServiceRequest Firestore SDK

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

## Introduction

In the repository the Firebase Cloud Firestore SDK can be found that was made for the FHIR ServiceRequest 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 { ServiceRequestApi } from '@inclouded/fhir-servicerequest';
import { AngularFirestore } from '@angular/fire/firestore';
import { IServiceRequest } from '@ahryman40k/ts-fhir-types/lib/R4';

@Injectable()
export class ServiceRequestService {

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

    getServiceRequests(): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getAll();
    }

    addServiceRequest(Servicerequest: IServiceRequest) {
        return this.ServiceRequestApi.add(Servicerequest);
    }

    deleteServiceRequest(ServicerequestId: string) {
        return this.ServiceRequestApi.delete(ServicerequestId);
    }

    updateServiceRequest(Servicerequest: IServiceRequest) {
        return this.ServiceRequestApi.update(Servicerequest);
    }

    getServiceRequestById(id: string): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getById(id);
    }

    getServiceRequestsByReplaces(replaces: string): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getServiceRequestsByReplaces(replaces);
    }

    getServiceRequestsByOccurenceDateTime(startDate: Date, endDate: Date): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getServiceRequestsByOccurenceDateTime(startDate, endDate);
    }

    getServiceRequestsByStatus(status: string): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getServiceRequestsByReplaces(status);
    }

    getServiceRequestsBySubject(subject: string): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getServiceRequestsBySubject(subject);
    }

    getServiceRequestsByRequesterStatusAndTimeInterval(
        requester: string, status: string | string[], fromDate: Date,
        toDate: Date, orderBy: OrderBy, paging?: Paging): Observable<IServiceRequest[]> {
        return this.ServiceRequestApi.getServiceRequestsByRequesterStatusAndTimeInterval(requester, status, fromDate, toDate);
    }
}

```

## Usage with MongoDB

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

> The ServiceRequest 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 ServiceRequest of Provenance 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)