Daftar Isi:

export class DirectInsertLogqueueService implements LogQueueService {
  constructor(private repository: LogQueueRepository) {}

  async create(data: string): Promise<Response> {
    return await this.repository.create(data)
  }
}

nitip model screening.model

import { COGScreening } from './cog.screening.model'
import { Patient } from './patient.model'
import { TBCScreening } from './tbc.screening.model'
import { Registration } from './registration.mode'

export interface Screening {
  id: number
  clinicId: string
  registrationId: number
  serviceId: number
  patientId: string
  screeningTypeId: number
  date: string
  additional: string
  createdBy?: number
  updatedBy?: number
  deletedBy?: number
}

export type ScreeningCreate = Omit<Screening, 'deletedBy'>

export interface RawScreening {
  queue_id: number
  clinic_id: string
  screening_id: number
  patient_id: string
  service_id: number
  type_name: string
  type: ScreeningId
  action_type: ScreeningType
  date: string
  detail: ScreeningDetail
  patient: Patient
  service: Record<string, any>
  registration: Registration
}

enum ScreeningId {
  TBC = '1',
  COG = '7',
}

enum ScreeningType {
  TBC = 'TBC',
  COG = 'COG',
}

type ScreeningDetail = COGScreening | TBCScreening

function a(s: RawScreening) {
  switch (s.type) {
    case ScreeningType.COG:
      processCOG(s.detail as COGScreening)
      break
    case ScreeningType.TBC:
      processTBC(s.detail as TBCScreening)
      break
  }

  if (s.type === ScreeningType.COG) processCOG(s.detail as COGScreening)
  else if (s.type === ScreeningType.TBC) processTBC(s.detail as TBCScreening)
}

function processCOG(d: COGScreening) {}
function processTBC(d: TBCScreening) {}

const uniqueRawPatient = this.rawPatient.filter(
          (item, index, self) => index === self.findIndex((t) => t.id === item.id)
        )