import { Component, OnInit } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router'
import { MermsServiceProviderService } from './../providers/merms-service-provider.service';
import { MermsSessionService } from './../merms-session.service';

@Component({
  selector: 'app-merms-mypatients',
  templateUrl: './merms-mypatients.page.html',
  styleUrls: ['./merms-mypatients.page.scss'],
})
export class MermsMypatientsPage implements OnInit {

  patientsData: any;
  currentProviderData: {
    sessionid: string,
    member_id: number,
    card_count: number
    card_type: number
  };

  constructor(
    private router: Router,
    private mermsServiceProviderService: MermsServiceProviderService,
    private mermsSessionService: MermsSessionService
  ) {
    this.currentProviderData = {
      sessionid: this.mermsSessionService.session,
      member_id: this.mermsSessionService.member_id,
      card_count: 100,
      card_type: 22000
    };


    try {
      this.mermsServiceProviderService.genericGetService('provider/mypatients', this.currentProviderData).subscribe(patientsData => {
        console.log("card data result 22k: ", patientsData[0]['payload']);
        this.patientsData = patientsData[0]['payload'];

      });
    } catch (e) {
      console.log(e);
    }


  }


  ngOnInit() {
  }
  goBack() {

  }
  goSelectPatient(patientData: any) {
    let navigationExtras: NavigationExtras = {
      queryParams: {
        special: JSON.stringify(patientData)
      }
    };
    this.router.navigateByUrl('/merms-selectedpatient',navigationExtras);
  }

  goAddPatient() {
    //merms-managepatient
    this.router.navigateByUrl('/merms-managepatient');
  }


}
