Enrollment.fromJson constructor

Enrollment.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory Enrollment.fromJson(Map<String, dynamic> json) {
  final dynamic lastSyncSummary = json['lastSyncSummary'] != null
      ? EnrollmentImportSummary.fromJson(jsonDecode(json['lastSyncSummary']))
      : null;

  final Geometry? geometry = json["geometry"] != null
      ? Geometry.fromJson(json["geometry"].runtimeType == String
          ? jsonDecode(json["geometry"])
          : json["geometry"])
      : null;

  return Enrollment(
      id: json['enrollment'],
      enrollment: json['enrollment'],
      name: json['enrollment'],
      created: json['created'],
      lastUpdated: json['lastUpdated'],
      incidentDate: json['incidentDate'],
      enrollmentDate: json['enrollmentDate'],
      trackedEntityType: json['trackedEntityType'],
      orgUnit: json['orgUnit'],
      program: json['program'],
      status: json['status'] ?? 'ACTIVE',
      synced: json['synced'],
      syncFailed: json['syncFailed'],
      lastSyncSummary: lastSyncSummary,
      geometry: geometry,
      lastSyncDate: json['lastSyncDate'],
      events: List<dynamic>.from(json['events'] ?? [])
          .map((event) => Event.fromJson({
                ...event,
                'dirty': json['dirty'] ?? false,
                'synced': json['synced'] ?? false
              }))
          .toList(),
      trackedEntityInstance: json['trackedEntityInstance'],
      dirty: json['dirty'] ?? false);
}