import 'package:vital_local_database/core/index.dart';
import 'package:vitalapp/database/entities/patient.dart';

import 'interfaces/patient.dart';

class PatientRepository
    extends BaseDbRepository<PatientEntity, PatientColumnsDefine>
    implements IPatientRepository {
  PatientRepository(super.database);

  @override
  PatientEntity createEntityInstance() => PatientEntity();

  @override
  Future<PatientEntity?> singleByCode(String code) async {
    final entity = await queryable
        .where((x) => [
              x.isValid.equals(true),
              x.code.equals(code),
            ])
        .first();
    return entity;
  }
}
