import type { CreateUpdatePatientDto, CreateUpdatePatientRecordDto, PatientDto, PatientRecordDto } from './dto/models';
import type { Patient } from './models';
import { RestService, Rest } from '@abp/ng.core';
import type { PagedResultDto } from '@abp/ng.core';
import { Injectable } from '@angular/core';
import type { EntityDocument } from '../documents/models';
import type { DropDownItems, FileDownloadDto, PagingSortPatientResultDto } from '../dto/models';

@Injectable({
  providedIn: 'root',
})
export class PatientService {
  apiName = 'Default';
  

  createPatient = (input: CreateUpdatePatientDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientDto>({
      method: 'POST',
      url: '/api/app/patient/patient',
      body: input,
    },
    { apiName: this.apiName,...config });
  

  createPatientRecord = (input: CreateUpdatePatientRecordDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientRecordDto>({
      method: 'POST',
      url: '/api/app/patient/patient-record',
      body: input,
    },
    { apiName: this.apiName,...config });
  

  deletePatient = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, void>({
      method: 'DELETE',
      url: `/api/app/patient/${id}/patient`,
    },
    { apiName: this.apiName,...config });
  

  deletePatientRecord = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, void>({
      method: 'DELETE',
      url: `/api/app/patient/${id}/patient-record`,
    },
    { apiName: this.apiName,...config });
  

  getExportPatientData = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, FileDownloadDto>({
      method: 'GET',
      url: '/api/app/patient/export-patient-data',
    },
    { apiName: this.apiName,...config });
  

  getExportPatientRecord = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, FileDownloadDto>({
      method: 'GET',
      url: '/api/app/patient/export-patient-record',
    },
    { apiName: this.apiName,...config });
  

  getPatientById = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientDto>({
      method: 'GET',
      url: `/api/app/patient/${id}/patient-by-id`,
    },
    { apiName: this.apiName,...config });
  

  getPatientList = (input: PagingSortPatientResultDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PagedResultDto<PatientDto>>({
      method: 'GET',
      url: '/api/app/patient/patient-list',
      params: { search: input.search, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount },
    },
    { apiName: this.apiName,...config });
  

  getPatientRecordById = (id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientRecordDto>({
      method: 'GET',
      url: `/api/app/patient/${id}/patient-record-by-id`,
    },
    { apiName: this.apiName,...config });
  

  getPatientRecordList = (input: PagingSortPatientResultDto, Id: string, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PagedResultDto<PatientRecordDto>>({
      method: 'GET',
      url: `/api/app/patient/patient-record-list/${Id}`,
      params: { search: input.search, sorting: input.sorting, skipCount: input.skipCount, maxResultCount: input.maxResultCount },
    },
    { apiName: this.apiName,...config });
  

  getStatusDropdown = (config?: Partial<Rest.Config>) =>
    this.restService.request<any, DropDownItems[]>({
      method: 'GET',
      url: '/api/app/patient/status-dropdown',
    },
    { apiName: this.apiName,...config });
  

  saveFileToDocumentByPatientAndUniqueIdsAndIsNew = (patient: Patient, uniqueIds: string[], isNew?: boolean, config?: Partial<Rest.Config>) =>
    this.restService.request<any, EntityDocument[]>({
      method: 'POST',
      url: '/api/app/patient/save-file-to-document',
      params: { isNew },
      body: uniqueIds,
    },
    { apiName: this.apiName,...config });
  

  updatePatient = (id: string, input: CreateUpdatePatientDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientDto>({
      method: 'PUT',
      url: `/api/app/patient/${id}/patient`,
      body: input,
    },
    { apiName: this.apiName,...config });
  

  updatePatientRecord = (id: string, input: CreateUpdatePatientRecordDto, config?: Partial<Rest.Config>) =>
    this.restService.request<any, PatientRecordDto>({
      method: 'PUT',
      url: `/api/app/patient/${id}/patient-record`,
      body: input,
    },
    { apiName: this.apiName,...config });
  

  uploadFile = (TagName: string, file: FormData, config?: Partial<Rest.Config>) =>
    this.restService.request<any, string>({
      method: 'POST',
      responseType: 'text',
      url: '/api/app/patient/upload-file',
      params: { tagName: TagName },
      body: file,
    },
    { apiName: this.apiName,...config });

  constructor(private restService: RestService) {}
}
