patient.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import 'package:vital_local_database/core/index.dart';
  2. import 'package:vitalapp/database/entities/defines.dart';
  3. import 'package:vitalapp/database/entities/patient.dart';
  4. import 'interfaces/patient.dart';
  5. class PatientRepository
  6. extends BaseDbRepository<PatientEntity, PatientColumnsDefine>
  7. implements IPatientRepository {
  8. PatientRepository(super.database);
  9. @override
  10. PatientEntity createEntityInstance() => PatientEntity();
  11. @override
  12. Future<PatientEntity?> singleByCode(
  13. String code,
  14. String userCode,
  15. ) async {
  16. final entity = await queryable
  17. .where((x) => [
  18. x.isValid.equals(true),
  19. x.code.equals(code),
  20. x.userCode.equals(userCode), //添加用户Code
  21. ])
  22. .first();
  23. return entity;
  24. }
  25. @override
  26. Future<bool> isNotUploadedPatient(
  27. String code,
  28. String userCode,
  29. ) async {
  30. final entity = await singleByCode(code, userCode);
  31. return entity != null && entity.syncState != OfflineDataSyncState.success;
  32. }
  33. }