Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
export class AuthService {
 private sessionMessageSubject = new BehaviorSubject<NAPMessage | undefined>(
    undefined
  );

  /**
   * The current session
   *
   * @memberof AuthService
   */
  public session$ = this.sessionMessageSubject.asObservable();

  constructor(private napSDK: NapAngularService) {
    this.napSDK.incomming$incoming$
      .pipe(
        filterEvents([
          NAPEventCatalogue.v1.SessionOpen,
          NAPEventCatalogue.v1.SessionClose,
        ])
      )
      .subscribe((napMessage) => {
        if (napMessage.event.type === NAPEventCatalogue.v1.SessionOpen) {
          this.sessionMessageSubject.next(napMessage);
        } else {
          this.sessionMessageSubject.next(undefined);
        }
      });

    const napMsg: NAPMessage = {
      date: new Date().toISOString(),
      id: UUID(),
      event: { type: NAPEventCatalogue.v1.SessionOpen },
    };

    // Ask for the SAMLassertion in host
    this.napSDK.sendMessage(napMsg);
  }

  /**
   * Tricker logout event
   */
  logout(): void {
    this.sessionMessageSubject.next(undefined);
    const napMsg: NAPMessage = {
      date: new Date().toISOString(),
      id: UUID(),
      event: { type: NAPEventCatalogue.v1.SessionClose },
    };
    this.napSDK.sendMessage(napMsg);
  }
}

...

Code Block
  constructor(
    private napSDK: NapAngularService,
    private appointmentService: AppointmentService,
    private authService: AuthService
  ) {
    const napMsg: NAPMessage = {
      date: new Date().toISOString(),
      id: UUID(),
      event: {
        type: NAPEventCatalogue.v1.PatientOpen,
      },
    };
    this.napSDK.sendMessage(napMsg);
  }

  public currentPatient$: Observable<NAPPatientInfo | undefined> = this.napSDK.incomming$incoming$.pipe(
    filterEvent(NAPEventCatalogue.v1.PatientOpen),
    map(message => FHIRValueGetter.getPatientInfo(message))
  );

...