8bbc9dbff2
- Flutter + PocketBase dental lab management system - Clinic & lab dashboards, job tracking, patient management - Product catalog, finance tracking, multi-language support - AI assistant integration, realtime notifications - Windows installer (Inno Setup) included - Developed by kovakyazilim.com
41 lines
1.4 KiB
Dart
41 lines
1.4 KiB
Dart
import 'package:pocketbase/pocketbase.dart';
|
|
import '../../../core/api/pocketbase_client.dart';
|
|
import '../../../models/connection.dart';
|
|
|
|
class ClinicConnectionsRepository {
|
|
ClinicConnectionsRepository._();
|
|
static final instance = ClinicConnectionsRepository._();
|
|
|
|
PocketBase get _pb => PocketBaseClient.instance.pb;
|
|
|
|
Future<List<Connection>> listConnections(String clinicTenantId) async {
|
|
final result = await _pb.collection('connections').getList(
|
|
filter: 'clinic_tenant_id = "$clinicTenantId"',
|
|
expand: 'lab_tenant_id,clinic_tenant_id',
|
|
perPage: 100,
|
|
);
|
|
return (result.items.map((r) => Connection.fromJson(r.toJson())).toList()
|
|
..sort((a, b) => (b.dateCreated ?? '').compareTo(a.dateCreated ?? '')));
|
|
}
|
|
|
|
Future<Connection> requestConnection({
|
|
required String clinicTenantId,
|
|
required String labTenantId,
|
|
}) async {
|
|
final record = await _pb.collection('connections').create(body: {
|
|
'clinic_tenant_id': clinicTenantId,
|
|
'lab_tenant_id': labTenantId,
|
|
'status': 'pending',
|
|
});
|
|
return Connection.fromJson(record.toJson());
|
|
}
|
|
|
|
Future<List<Map<String, dynamic>>> searchLabs(String query) async {
|
|
final result = await _pb.collection('tenants').getList(
|
|
filter: 'kind = "lab" && company_name ~ "$query"',
|
|
perPage: 20,
|
|
);
|
|
return result.items.map((r) => r.toJson()).toList();
|
|
}
|
|
}
|