npm package: @softheon/lighthouse
Description: This library includes functionalities to generate Lighthouse ticket entities for other UI applications.
Latest version: 21.0.0

# Lighthouse

This library includes functionalities to generate Lighthouse ticket entities for other UI applications.

## Usage

### Include the module

First, include the following module import in your angular root module.

```js
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    LighthouseModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
```

### Embed the components

Next, embed the lighthouse components. There is a component lists you can embed.

- lighthouse-service-request

#### lighthouse-service-request

**app.component.html**

```html
<div>
<lighthouse-service-request [config]="yourConfig" (apiCallCountEmitter)="yourMethod1($event)" (serviceRequestEmitter)="yourMethod2($event)" (isSubmitSuccessEmitter)="yourMethod3($event)"></lighthouse-service-request>
</div>
```

**app.component.ts**

```ts
/** The app component */
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  /** The application title */
  public title: string = 'Lighthouse';

  /** Your customized config */
  public yourConfig = {
    serviceRequest: {
        information: {
            address2: '',
            city: '',
            encounterType: '',
            subscriberID: '',
            workPhone: '',
            state: '',
            memberID: '',
            groupID: '',
            incomingPhone: '',
            lastName: '',
            homePhone: '',
            companyName: '',
            address1: '',
            brokerID: '',
            emailAddress: '',
            employerID: '',
            memberFolderID: '',
            memberEnrollmentFolderID: '',
            mobilePhone: '',
            remoteFolderID: 0,
            zip: '',
            ssn: '',
            fax: '',
            firstName: '',
            tin: '',
            dob: '',
            currentPaidThroughDate: ''
        } as InformationProfile,
        request: {
            subcategory: '',
            request: '',
            priorCase: 0,
            action: '',
            receivedDateTime: new Date(),
            currentValue: '',
            primaryRequest: '',
            optOutOfEmails: 0,
            articleID: '',
            statusCode: 0,
            newValue: '',
            response: '',
            newValues: [{key: '', value: ''} as NewValuesRow]
        } as RequestProfile,
        expedite: {
            emailAddress: '',
            severity: 0,
            requestedBy: '',
            expediteSource: '',
            reOpenedCase: 0,
            expediteMethod: ''
        } as ExpediteProfile,
        internal: {
            internalResponse: '',
            processType: 0
        } as InternalProfile,
        approval: {
            approver: ''
        } as ApprovalProfile,
        drawerId: 0,
        id: 0,
        name: '',
        state: 'Undefined'
    } as ServiceRequestModel,
    baseUri: 'https://YOUR_HOST/lighthouse.api',
    isFullUri: false,
    serviceRequestFullUri: '', // You have to specify if isFullUri is TRUE
    attachmentFullUri: '', // You have to specify if isFullUri is TRUE
    drawerId: 0,
    entityId: 0,
    accessToken: 'access_token',
    languagePath: 'lighthouse-service-request.'
  } as ServiceRequestConfig;

  /**
   * The constructor
   * @param translateService The i18n angular translate service
   */
  constructor(private translateService: TranslateService) {
    const defaultLanguage = 'en';
    localStorage.setItem(StorageKeys.LANGUAGE, defaultLanguage);
    translateService.setDefaultLang(defaultLanguage);
    translateService.use(defaultLanguage);
  }

  /**
   * Your Method 1
   * @param event The current number of api calls
   */
  public yourMethod1(event: number): void {
      // Do something
  }

  /**
   * Your Method 2
   * @param event The created service request model
   */
  public yourMethod2(event: ServiceRequestModel): void {
      // Do something
  }

  /**
   * Your Method 3
   * @param event The boolean value to specify whether the api call is succeed
   */
  public yourMethod3(event: boolean): void {
      // Do something
  }
}
```

## Verbiage

The UI component comes with default verbiage that can be overwritten by the consuming application on a pick and choose basis. The tokenizer will prioritize any verbiage coming from the parent TranslateModule. If there is no related key in the parent TranslateModule or that module is not imported, the tokenizer will use the internal default verbiage.

### Customize Verbiage

If you want to customize the verbiage, then pass the `key` value for your language file to `languagePath` field of `ServiceRequestConfig`. If there is no proper `languagePath` provided to access your customized language, then this library utilizes the default verbiage based on the current language value settings which defined on your browser local storage. The key for local storage is `language`. The value of this should be either `en` for English or `es` for Spanish. The current version only supports English and Spanish.

### Verbiage Example for `en.json`

```json
{
    "lighthouse-service-request": {
        "additionalInfoCommentsLabel": "Comments",
        "commonButtonChooseFile": "Choose File",
        "commonButtonNext": "Next",
        "commonButtonPrev": "Back",
        "commonButtonSubmitRequest": "Submit Request",
        "commonSnackBarCheckRequiredField": "Please check if there is any required field you missed.",
        "commonSnackBarClose": "Close",
        "fileUploaderDragFileHere": "Drag Files Here",
        "fileUploaderSnackbarFileSizeOver": "Max file size limit is {{maxFileSize}} MB.",
        "fileUploaderSnackbarInvalidType": "The file type for {{fileName}} is not supported.",
        "fileUploaderSnackbarQueueLimitOver": "Queue limit is {{queueLimit}}.",
        "fileUploaderTableColumnAction": "Action",
        "fileUploaderTableColumnName": "Name",
        "fileUploaderTableColumnSize": "Size",
        "fileUploaderWarningFileSizeOver": "File size limit is over",
        "fileUploaderWarningQueueLimitOver": "Queue limit is over",
        "serviceCategoryBeginDateLabel": "Begin Date",
        "serviceCategoryCarrierNameLabel": "Carrier Name",
        "serviceCategoryCarrierNamePlaceholder": "Enter Carrier Name",
        "serviceCategoryCategoryLabel": "Category",
        "serviceCategoryCategoryPlaceholder": "Select Category",
        "serviceCategoryContactDueDateLabel": "Contact Due Date",
        "serviceCategoryCorrectionReasonLabel": "Correction Reason(s):",
        "serviceCategoryCorrectionTypeLabel": "Correction Type:",
        "serviceCategoryCoverageEndDateLabel": "Coverage End Date",
        "serviceCategoryCoverageStartDateLabel": "Coverage Start Date",
        "serviceCategoryCurrentBillingPeriodInformation": "An updated invoice will be created for the most recent billing period.",
        "serviceCategoryDateLabel": "Date",
        "serviceCategoryDedupMemberAdd": "Add Member",
        "serviceCategoryDedupMemberDelete": "Delete Member",
        "serviceCategoryDiscountAmountError": "Must be more than {{min}} and less than or equal to {{max}}.",
        "serviceCategoryDiscountAmountLabel": "Discount Amount",
        "serviceCategoryDiscountAmountPlaceholder": "Enter Discount Amount",
        "serviceCategoryDiscountApprovedOrDeniedLabel": "Discount Approved or Denied",
        "serviceCategoryDiscountApprovedOrDeniedPlaceholder": "Select Discount Approval Status",
        "serviceCategoryDiscountEndDateLabel": "Discount End Date",
        "serviceCategoryDiscountStartDateLabel": "Discount Start Date",
        "serviceCategoryDiscountTypeLabel": "Discount Type",
        "serviceCategoryDiscountTypePlaceholder": "Select Discount Type",
        "serviceCategoryDiscountAmountTypeLabel": "Discount Amount Type",
        "serviceCategoryDiscountAmountTypePlaceholder": "Select Discount Amount Type",
        "serviceCategoryDisplayedCategoriesAssistance": "Other",
        "serviceCategoryDisplayedCategoriesCommunications": "Generate Notice,Regenerate Notice,Invoice Correction,1095A Correction,Generate New Invoice",
        "serviceCategoryDisplayedCategoriesEnrollment": "Re-export Effectuation,Incorrect Status,Incorrect Rate,Change Issuer ID,Change End Date,Missing Policy,Retro Enrollment,Retro Termination,Forward Enrollment,Hardship Waiver,Convert to Non-Hix Dental,Update Handicap",
        "serviceCategoryDisplayedCategoriesPayments": "Incorrect Balance Due,Incorrect Paid Through Date,Bank Discrepancy,Missing Payment,Refund Investigation",
        "serviceCategoryDisplayedCorrectionReason": "Part I - Recipient Information,Part II - Covered Individuals,Part III - Coverage Information",
        "serviceCategoryDisplayedCorrectionType": "Void,Corrected",
        "serviceCategoryDisplayedDiscountApprovedOrDenied": "Approved,Denied",
        "serviceCategoryDisplayedDiscountType": "Flat,Percentage",
        "serviceCategoryDisplayedDiscountAmountType": "Health Coverage Monthly Premium,Other",
        "serviceCategoryDisplayedGeneratedNoticeType": "Duplicate Coverage Subsidies Ending",
        "serviceCategoryDisplayedIssues": "Assistance,Communications,Payments,Enrollment",
        "serviceCategoryDisplayedReason": "Death,Declined Coverage,Non-Payment,Plan Change,Termination of Benefits,Voluntary Withdrawal,Other",
        "serviceCategoryDisplayedRegeneratedNoticeType": "Invoice,Cancellation Notice,Termination Notice,Late Payment Notice",
        "serviceCategoryDisplayedSeverities": "Low,Medium,High,HICS - Level 1,HICS - Level 2",
        "serviceCategoryDisplayedUpdateHandicap": "Add Handicap Indicator,Update Handicap Indicator",
        "serviceCategoryEndDateLabel": "End Date",
        "serviceCategoryExchangeMemberIdLabel": "Exchange Member Id",
        "serviceCategoryExchangeMemberIdPlaceholder": "Enter Exchange Member Id",
        "serviceCategoryExpectedAPTCLabel": "Expected APTC",
        "serviceCategoryExpectedAPTCPlaceholder": "Enter Expected APTC",
        "serviceCategoryExpectedBalanceLabel": "Expected Balance",
        "serviceCategoryExpectedCSRLabel": "Expected CSR",
        "serviceCategoryExpectedCSRPlaceholder": "Enter Expected CSR",
        "serviceCategoryExpectedIssuerMemberIdLabel": "Expected Issuer Member Id",
        "serviceCategoryExpectedIssuerMemberIdPlaceholder": "Enter Expected Issuer Member Id",
        "serviceCategoryExpectedIssuerSubscriberIdLabel": "Expected Issuer Subscriber Id",
        "serviceCategoryExpectedIssuerSubscriberIdPlaceholder": "Enter Expected Issuer Subscriber Id",
        "serviceCategoryExpectedPaidThroughDateLabel": "Expected Paid Through Date",
        "serviceCategoryExpectedPremiumLabel": "Expected Premium",
        "serviceCategoryExpectedPremiumPlaceholder": "Enter Expected Premium",
        "serviceCategoryExpectedRateLabel": "Expected Rate",
        "serviceCategoryExpectedRatePlaceholder": "Enter Expected Rate",
        "serviceCategoryExpectedStatusLabel": "Expected Status",
        "serviceCategoryExpectedStatusPlaceholder": "Enter Expected Status",
        "serviceCategoryGroupPolicyLabel": "Group/Policy Number",
        "serviceCategoryGroupPolicyNumberPlaceholder": "Enter Group or Policy Number",
        "serviceCategoryIncorrectBalanceDuePlaceholder": "Enter Expected Balance",
        "serviceCategoryInvoicePeriodLabel": "Invoice Period:",
        "serviceCategoryInvoicePeriodPlaceholder": "Invoice Period",
        "serviceCategoryIssueLabel": "Issue",
        "serviceCategoryIssuePlaceholder": "Select Issue",
        "serviceCategoryMemberIdLabel": "Member Id",
        "serviceCategoryMemberIdPlaceholder": "Enter Member Id",
        "serviceCategoryMemberNameLabel": "Member Name",
        "serviceCategoryMemberNamePlaceholder": "Enter Member Name",
        "serviceCategoryMonthlyPremiumLabel": "Monthly Premium",
        "serviceCategoryMonthlyPremiumPlaceholder": "Enter Monthly Premium",
        "serviceCategoryNoticeTypeLabel": "Notice Type",
        "serviceCategoryNoticeTypePlaceholder": "Select Notice Type",
        "serviceCategoryOriginalRefundServiceRequestNumberLabel": "Original Refund Service Request Number",
        "serviceCategoryPlanNameLabel": "Plan Name",
        "serviceCategoryPlanNamePlaceholder": "Enter Plan Name",
        "serviceCategoryProofDueDateLabel": "Proof Due Date",
        "serviceCategoryReasonLabel": "Reason",
        "serviceCategoryReasonPlaceholder": "Select Reason",
        "serviceCategoryRefundCanceledOption": "Refund Canceled",
        "serviceCategoryRefundInProgressOption": "Refund In Progress",
        "serviceCategoryRefundIssuedOption": "Refund Issued",
        "serviceCategoryRefundPendingOption": "Refund Pending",
        "serviceCategoryRefundRequestCreationDate": "Refund Service Request Date of Creation",
        "serviceCategoryRefundServiceRequestDateOfCreationDateLabel": "Refund Service Request Date of Creation",
        "serviceCategoryRefundServiceRequestStatus": "Refund Service Request Status",
        "serviceCategoryRefundStatusLabel": "Refund Status",
        "serviceCategoryRefundStatusPlaceholder": "Select Refund Service Request Status",
        "serviceCategorySeverityLabel": "Severity",
        "serviceCategorySeverityPlaceholder": "Select Level of Severity",
        "serviceCategorySpanFolderIdLabel": "Span Folder Id",
        "serviceCategorySpanFolderIdPlaceholder": "Enter Span Folder Id",
        "serviceCategoryStartDateLabel": "Start Date",
        "serviceCategoryTaxYearPlaceholder": "Tax Year",
        "serviceCategoryUpdateHandicapLabel": "Update Handicap",
        "serviceCategoryUpdateHandicapPlaceholder": "Select Update Handicap",
        "serviceRequestSnackbarCreateAttachmentFailure": "Submit the additional attachment fails. Please reach out to our customer service team via Lighthouse portal.",
        "serviceRequestSnackbarCreateEntityFailure": "Submit to create the service request fails. Please reach out to our customer service team via Lighthouse portal."
    }
}
```

On the above example case, the value of  `lighthouse-service-request.` should be passed as the input of `languagePath` field of `ServiceRequestConfig`

## API

### Components

#### ServiceRequestComponent

##### Properties

| Name                                                                 | Description                                                                                              |
| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `@Input() config: ServiceRequestConfig`                              | The config to instantiate service request component                                                      |
| `@Output() apiCallCountEmitter: EventEmitter<number>`                | The event emitter to indicate how many api calls the component currently has                             |
| `@Output() serviceRequestEmitter: EventEmitter<ServiceRequestModel>` | The event emitter to pass the calculated service request model by this component to its parent component |
| `@Output() isSubmitSuccessEmitter: EventEmitter<boolean>`            | The event emitter to notify the result of api call submission to parent components                       |

### Services

#### AbstractEntityService

The interface for entity services.

##### Methods

| Name                             | Description                   |
| -------------------------------- | ----------------------------- |
| `createEntity: Promise<T>`       | The method to create entity   |
| `retrieveEntity: Promise<T>`     | The method to retrieve entity |
| `updateEntity: Promise<T>`       | The method to update entity   |
| `deleteEntity: Promise<boolean>` | The method to delete entity   |


#### ServiceRequestEntityService

The concrete entity service for service request.

##### Methods

| Name                                           | Description                   |
| ---------------------------------------------- | ----------------------------- |
| `createEntity: Promise<ServiceRequestModel>`   | The method to create entity   |
| `retrieveEntity: Promise<ServiceRequestModel>` | The method to retrieve entity |
| `updateEntity: Promise<ServiceRequestModel>`   | The method to update entity   |
| `deleteEntity: Promise<boolean>`               | The method to delete entity   |

#### AttachmentService

The service to create files to entities.

| Name                               | Description                            |
| ---------------------------------- | -------------------------------------- |
| `createAttachments: Promise<void>` | The method to create files to entities |

### Models

#### ServiceRequestConfig

The configuration model as an input for `ServiceRequestComponent`

#### Properties

| Name                                                                         | Description                                                                                                                      |
|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| `serviceRequest: ServiceRequestModel`                                        | The service request model                                                                                                        |
| `drawerId: number`                                                           | The drawer Id                                                                                                                    |
| `entityId: number`                                                           | The entity Id                                                                                                                    |
| `baseUri: string`                                                            | The base uri for api call                                                                                                        |
| `isFullUri: boolean`                                                         | The flag to check the api call uri will use full uri                                                                             |
| `serviceRequestFullUri: string`                                              | The full uri for service request api call. If the `isFullUri` flag has true value, this value should be specified                |
| `attachmentFullUri: string`                                                  | The full uri for attachment api call. If the `isFullUri` flag has true value, this value should be specified                     |
| `accessToken: string`                                                        | The access token for api call                                                                                                    |
| `languagePath: string`                                                       | The language path to customize the verbiages in the library. Should have the format `SOMETHING_YOU_WANT.`.                       |
| `encounterType: string`                                                      | The encounter type for this service request. If the passed service request model already has this value, then just being ignored |
| `issueCategoryConfiguration: Array<IssueCategoryConfiguration>`              | Array of IssueCategoryConfiguration                                                                                              |
| `additionalFieldsConfiguration: Array<AdditionalFieldsConfiguration>`        | Array of AdditionalFieldsConfiguration                                                                                           |
| `modifiedExistingFieldsConfig: Array<ExistingAdditionalFieldsConfiguration>` | Array of ExistingAdditionalFieldsConfiguration                                                                                   |
| `healthCoverageMonthlyPremium: number`                                       | The amount for the health coverage monthly premium for the selected policy                                                       |

##### IssueCategoryConfiguration

This configuration model is a property defined in serviceRequestConfig that is given as input in the service request config for configuring issue type with its categories and their
corresponding action(mail boxes)

| Name                                    | Description                                                                                                                      |
| ----------------------------------------| -------------------------------------------------------------------------------------------------------------------------------- |
| `issueType: string`                     | The issue type                                                                                                                   |
| `categoryActionMap: Map<string, string>`| The category and its corresponding mailbox                                                                                       |

##### AdditionalFieldsConfiguration

This configuration model is a property defined in serviceRequestConfig that is given as input in the service request config for configuring additional fields under any issue type and category

| Name                                    | Description                                                                                                                      |
| ----------------------------------------| -------------------------------------------------------------------------------------------------------------------------------- |
| `issueType: string`                     | The issue type                                                                                                                   |
| `category: string`                      | The category                                                                                                                     |
| `label: string`                         | The label (name) for the additional field                                                                                        |
| `inputType: string`                     | The input types can be of textarea, dropdown, currency, checkbox, radiobutton, input and date                                    |
| `formControlName: string`               | The formControlName for the additional field                                                                                     |
| `inputTypeOptions: Array<string>`       | The options for the input types like dropdown, checkbox, radiobutton                                                             |

##### ExistingAdditionalFieldsConfiguration
This configuration model is a property defined in serviceRequestConfig that is given as input in the service request config for configuring the existing additional fields under any issue and category. The default configurations can be found under Package\projects\lighthouse\src\lib\shared\constants\existing-fields-config.ts

| Name                                    | Description                                                                                                                      |
| ----------------------------------------| -------------------------------------------------------------------------------------------------------------------------------- |
| `issueType: string`                     | The issue type                                                                                                                   |
| `category: string`                      | The category                                                                                                                     |
| `fieldName: string`                     | The field name of the additional field                                                                                           |
| `inputOptions: string`                  | The input options for the existing additional fields (This is used when the input type is dropdown or checkbox or a radiobutton) |
| `inputDisplayOptions: Array<string>`    | The input display options are the displayed values for the input options                                                         |
| `required`                              | To configure whether that field needs to be displayed under that issue and category                                              | 

#### ServiceRequestModel

The service request model.

##### Properties

| Name                                   | Description               |
| -------------------------------------- | ------------------------- |
| `information: InformationProfile`      | The information profile   |
| `request: RequestProfile`              | The request profile       |
| `expedite: ExpediteProfile`            | The expedite profile      |
| `internal: InternalProfile`            | The internal profile      |
| `approval: ApprovalProfile`            | The approval profile      |
| `drawerId: number`                     | The drawer Id             |
| `id: number`                           | The entity Id             |
| `name: string`                         | The entity title          |
| `state: ServiceRequestModel.StateEnum` | The current entity status |

##### InformationProfile

| Name                               | Description                     |
| ---------------------------------- | ------------------------------- |
| `firstName: string`                | The first name                  |
| `lastName: string`                 | The last name                   |
| `address1: string`                 | The address 1                   |
| `address2: string`                 | The address 2                   |
| `city: string`                     | The city                        |
| `zip: string`                      | The zip code                    |
| `dob: string`                      | The date of birth               |
| `homePhone: string`                | The home phone                  |
| `mobilePhone: string`              | The mobile phone                |
| `incomingPhone: string`            | The incoming phone              |
| `emailAddress: string`             | The email address               |
| `ssn: string`                      | The social security number      |
| `fax: string`                      | The fax number                  |
| `tin: string`                      | The TIN number                  |
| `companyName: string`              | The company name                |
| `workPhone: string`                | The work phone                  |
| `state: string`                    | The state                       |
| `encounterType: string`            | The encounter type              |
| `currentPaidThroughDate: string`   | The current paid through date   |
| `subscriberID: string`             | The subscriber Id               |
| `memberID: string`                 | The member Id                   |
| `groupID: string`                  | The group Id                    |
| `brokerID: string`                 | The broker Id                   |
| `employerID: string`               | The employer Id                 |
| `memberFolderID: string`           | The member folder Id            |
| `memberEnrollmentFolderID: string` | The member enrollment folder Id |
| `remoteFolderID: number`           | The remote folder Id            |

##### RequestProfile

| Name                             | Description               |
| -------------------------------- | ------------------------- |
| `subcategory: string`            | The category value        |
| `request: string`                | The comments value        |
| `priorCase: number`              | The prior case            |
| `action: string`                 | The action                |
| `receivedDateTime: Date`         | The received date time    |
| `currentValue: string`           | The current value         |
| `primaryRequest: string`         | The issue value of UI     |
| `optOutOfEmails: number`         | The opt out of emails     |
| `articleID: string`              | The article Id            |
| `statusCode: string`             | The status code           |
| `newValue: string`               | The new value             |
| `response: string`               | The response              |
| `newValues: Array<NewValuesRow>` | The array of NewValuesRow |

##### ExpediteProfile

| Name                     | Description         |
| ------------------------ | ------------------- |
| `emailAddress: string`   | The email address   |
| `severity: number`       | The severity        |
| `requestedBy: string`    | The requested by    |
| `expediteSource: string` | The expedite source |
| `reOpenedCase: number`   | The reopened case   |
| `expediteMethod: string` | The expedite method |

##### InternalProfile

| Name                       | Description           |
| -------------------------- | --------------------- |
| `internalResponse: string` | The internal response |
| `processType: number`      | The process type      |

##### ApprovalProfile

| Name               | Description  |
| ------------------ | ------------ |
| `approver: string` | The approver |

##### NewValuesRow

| Name            | Description |
| --------------- | ----------- |
| `value: string` | The value   |
| `key: string`   | The key     |