import 'package:get/get.dart';
import 'package:vnoteapp/architecture/defines.dart';
import 'package:vnoteapp/managers/interfaces/contract.dart';

import 'state.dart';

class ContractRecordsHtmlController extends FControllerBase {
  final state = ContractRecordsHtmlState();
  final _contractManager = Get.find<IContractManager>();
  late String patientCode;
  @override
  void onReady() {
    super.onReady();
    _initData();
    getContractRecordDetailAsync(patientCode);
  }

  _initData() {
    update(["contract_records"]);
    final p = Get.parameters;
    patientCode = p['patientCode'] ?? "";
  }

  Future<void> getContractRecordDetailAsync(String patientCode) async {
    busy = true;
    var result =
        await _contractManager.getContractRecordDetailAsync(patientCode);
    if (result != null) {
      state.contractRecordDTO = result;
    }
    busy = false;
  }
}
