Program.fromJson constructor
Program.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Program.fromJson(Map<String, dynamic> json) {
final trackedEntityType = json['trackedEntityType'] != null
? json['trackedEntityType'] is String
? json['trackedEntityType']
: json['trackedEntityType']['id'] ?? json['trackedEntityType']
: null;
return Program(
id: json['id'],
name: json['name'],
created: json['created'],
shortName: json['shortName'],
code: json['code'],
displayName: json['displayName'],
description: json['description'],
dirty: json['dirty'] ?? false,
captureCoordinates: json['captureCoordinates'],
completeEventsExpiryDays: json['completeEventsExpiryDays'],
displayFrontPageList: json['displayFrontPageList'],
displayIncidentDate: json['displayIncidentDate'],
enrollmentDateLabel: json['enrollmentDateLabel'],
featureType: json['featureType'],
ignoreOverdueEvents: json['ignoreOverdueEvents'],
incidentDateLabel: json['incidentDateLabel'],
onlyEnrollOnce: json['onlyEnrollOnce'],
organisationUnits: json['organisationUnits']?.toString() ?? null,
programRuleVariables: List<dynamic>.from(json['programRuleVariables'] ?? [])
.map((programRuleVariable) => ProgramRuleVariable.fromJson(
{...programRuleVariable, 'program': json['id'], 'dirty': false}))
.toList(),
programType: json['programType'],
selectEnrollmentDatesInFuture: json['selectEnrollmentDatesInFuture'],
selectIncidentDatesInFuture: json['selectIncidentDatesInFuture'],
trackedEntity: json['trackedEntity'],
trackedEntityType: trackedEntityType,
useFirstStageDuringRegistration:
json['useFirstStageDuringRegistration'],
withoutRegistration: json['withoutRegistration'],
programStages: List<dynamic>.from(json['programStages'] ?? [])
.map((programStage) => ProgramStage.fromJson(
{...programStage, 'program': json['id'], 'dirty': false}))
.toList(),
programSections: List<dynamic>.from(json['programSections'] ?? [])
.map((programSection) => ProgramSection.fromJson(
{...programSection, 'program': json['id'], 'dirty': false}))
.toList(),
programTrackedEntityAttributes:
List<dynamic>.from(json['programTrackedEntityAttributes'] ?? [])
.map((programTrackedEntityAttribute) =>
ProgramTrackedEntityAttribute.fromJson(
{...programTrackedEntityAttribute, 'program': json['id'], 'dirty': false}))
.toList());
}