import 'package:fis_jsonrpc/services/followUp.m.dart'; import 'package:vital_local_database/index.dart'; import 'syncable.dart'; /// 随访 class FollowUpEntity extends SyncableEntity { static const String _tableName = "followup"; static final _columns = FollowUpColumnsDefine(); // ignore: constant_identifier_names static const TABLE_CREATE_SQL = 'CREATE TABLE IF NOT EXISTS "$_tableName" (' '"id" INTEGER NOT NULL,' '"code" VARCHAR(100) NOT NULL,' '"userCode" VARCHAR(100) NOT NULL,' '"patientCode" VARCHAR(100) NOT NULL,' '"contractDoctor" VARCHAR(100) NOT NULL,' '"typeKey" VARCHAR(100) NOT NULL,' '"templateCode" VARCHAR(100) NOT NULL,' '"dataJson" TEXT NOT NULL,' '"mode" INTEGER NOT NULL,' '"followUpTime" DATETIME NOT NULL,' '"nextFollowUpTime" DATETIME NOT NULL,' '"followUpPhtots" TEXT NOT NULL,' '"syncType" INTEGER NOT NULL,' '"syncState" INTEGER NOT NULL,' '"createTime" DATETIME NOT NULL,' '"updateTime" DATETIME NULL,' '"isValid" INTEGER NOT NULL,' 'PRIMARY KEY ("id")' ');'; @override IDbColumnsDefine get columns => _columns; @override String get tableName => _tableName; /// 居民档案编码 String patientCode = ''; /// 签约医生 /// /// - 现在取 主治医师 字段 String contractDoctor = ''; /// 分类Key String typeKey = ''; /// 模板Code String templateCode = ''; /// 随访方式 FollowUpModeEnum mode = FollowUpModeEnum.Outpatient; /// 随访时间 DateTime followUpTime = DateTime(1900, 1, 1); /// 下次随访时间 DateTime nextFollowUpTime = DateTime(1900, 1, 1); /// 随访照片 List followUpPhtots = []; @override Map toJson() { final map = super.toJson(); map['patientCode'] = patientCode; map['contractDoctor'] = contractDoctor; map['typeKey'] = typeKey; map['templateCode'] = templateCode; map['mode'] = mode.index; map['followUpTime'] = f2d_DateTime(followUpTime); map['nextFollowUpTime'] = f2d_DateTime(nextFollowUpTime); // 符号 `|` 分隔 map['followUpPhtots'] = followUpPhtots.join('|'); return map; } @override FollowUpEntity fromJson(Map map) { super.fromJson(map); patientCode = map['patientCode']; contractDoctor = map['contractDoctor']; typeKey = map['typeKey']; templateCode = map['templateCode']; mode = FollowUpModeEnum.values[map["mode"]]; followUpTime = d2f_DateTime(map['followUpTime']); nextFollowUpTime = d2f_DateTime(map['nextFollowUpTime']); followUpPhtots = (map['followUpPhtots'] as String).split('|'); return this; } } class FollowUpColumnsDefine extends SyncableColumnsDefine implements IDbColumnsDefine { /// 居民档案编码 final patientCode = DbColumn("patientCode"); /// 分类Key final typeKey = DbColumn("typeKey"); /// 模板Code final templateCode = DbColumn("templateCode"); /// 随访方式 final mode = DbColumn("mode"); /// 随访时间 final followUpTime = DbColumn("followUpTime"); }