diagnosis.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:vital_local_database/core/interface/entity.dart';
  2. import 'package:vital_local_database/core/sqlite/entity.dart';
  3. import 'package:vitalapp/database/entities/syncable.dart';
  4. /// 检测记录表实体
  5. class DiagnosisEntity extends SyncableEntity<DiagnosisEntity> {
  6. static const String _tableName = "diagnosis";
  7. static final _columns = DiagnosisColumnsDefine();
  8. // ignore: constant_identifier_names
  9. static const TABLE_CREATE_SQL = 'CREATE TABLE IF NOT EXISTS "diagnosis" ('
  10. '"id" INTEGER NOT NULL,'
  11. '"code" VARCHAR(100) NOT NULL,'
  12. '"patientCode" VARCHAR(100) NOT NULL,'
  13. '"dataJson" TEXT NOT NULL,'
  14. '"syncType" INTEGER NOT NULL,'
  15. '"syncState" INTEGER NOT NULL,'
  16. '"createTime" DATETIME NOT NULL,'
  17. '"updateTime" DATETIME NULL,'
  18. '"isValid" INTEGER NOT NULL,'
  19. 'PRIMARY KEY ("id")'
  20. ');';
  21. @override
  22. DiagnosisColumnsDefine get columns => _columns;
  23. @override
  24. String get tableName => _tableName;
  25. /// 居民Code
  26. String patientCode = "";
  27. @override
  28. Map<String, dynamic> toJson() {
  29. final map = super.toJson();
  30. map['patientCode'] = patientCode;
  31. return map;
  32. }
  33. @override
  34. DiagnosisEntity fromJson(Map<String, dynamic> map) {
  35. super.fromJson(map);
  36. patientCode = map['patientCode'];
  37. return this;
  38. }
  39. }
  40. /// 检测记录字段定义
  41. class DiagnosisColumnsDefine extends SyncableColumnsDefine<DiagnosisEntity>
  42. implements IDbColumnsDefine<DiagnosisEntity> {
  43. final patientCode = DbColumn<String>("patientCode");
  44. }