fromJson static method

MedexInfoDto? fromJson(
  1. dynamic value
)

Returns a new MedexInfoDto instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static MedexInfoDto? fromJson(dynamic value) {
  if (value is MedexInfoDto) {
    return value;
  }
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "MedexInfoDto[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "MedexInfoDto[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return MedexInfoDto(
      beginDate: mapValueOfType<int>(json, r'beginDate')!,
      endDate: mapValueOfType<int>(json, r'endDate')!,
      author: HealthcarePartyDto.fromJson(json[r'author']),
      patient: PatientDto.fromJson(json[r'patient']),
      patientLanguage: mapValueOfType<String>(json, r'patientLanguage')!,
      incapacityType: mapValueOfType<String>(json, r'incapacityType')!,
      incapacityReason: mapValueOfType<String>(json, r'incapacityReason')!,
      outOfHomeAllowed: mapValueOfType<bool>(json, r'outOfHomeAllowed')!,
      certificateDate: mapValueOfType<int>(json, r'certificateDate'),
      contentDate: mapValueOfType<int>(json, r'contentDate'),
      diagnosisICPC: mapValueOfType<String>(json, r'diagnosisICPC'),
      diagnosisICD: mapValueOfType<String>(json, r'diagnosisICD'),
      diagnosisDescr: mapValueOfType<String>(json, r'diagnosisDescr'),
    );
  }
  return null;
}