fromJson static method

Patient? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static Patient? fromJson(dynamic 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 "Patient[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "Patient[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return Patient(
      id: mapValueOfType<String>(json, r'id'),
      rev: mapValueOfType<String>(json, r'rev'),
      identifiers: Identifier.listFromJson(json[r'identifiers'])!,
      created: mapValueOfType<int>(json, r'created'),
      modified: mapValueOfType<int>(json, r'modified'),
      author: mapValueOfType<String>(json, r'author'),
      responsible: mapValueOfType<String>(json, r'responsible'),
      labels: CodingReference.listFromJson(json[r'labels'])!.toSet(),
      codes: CodingReference.listFromJson(json[r'codes'])!.toSet(),
      endOfLife: mapValueOfType<int>(json, r'endOfLife'),
      deletionDate: mapValueOfType<int>(json, r'deletionDate'),
      firstName: mapValueOfType<String>(json, r'firstName'),
      lastName: mapValueOfType<String>(json, r'lastName'),
      names: PersonName.listFromJson(json[r'names'])!,
      companyName: mapValueOfType<String>(json, r'companyName'),
      languages: json[r'languages'] is List ? (json[r'languages'] as List).cast<String>() : const [],
      addresses: Address.listFromJson(json[r'addresses'])!,
      civility: mapValueOfType<String>(json, r'civility'),
      gender: PatientGenderEnum.fromJson(json[r'gender']),
      birthSex: PatientBirthSexEnum.fromJson(json[r'birthSex']),
      mergeToPatientId: mapValueOfType<String>(json, r'mergeToPatientId'),
      mergedIds: json[r'mergedIds'] is Set
          ? (json[r'mergedIds'] as Set).cast<String>()
          : json[r'mergedIds'] is List
          ? ((json[r'mergedIds'] as List).toSet()).cast<String>()
          : const {},
      alias: mapValueOfType<String>(json, r'alias'),
      active: mapValueOfType<bool>(json, r'active')!,
      deactivationReason: PatientDeactivationReasonEnum.fromJson(json[r'deactivationReason'])!,
      ssin: mapValueOfType<String>(json, r'ssin'),
      maidenName: mapValueOfType<String>(json, r'maidenName'),
      spouseName: mapValueOfType<String>(json, r'spouseName'),
      partnerName: mapValueOfType<String>(json, r'partnerName'),
      personalStatus: PatientPersonalStatusEnum.fromJson(json[r'personalStatus']),
      dateOfBirth: mapValueOfType<int>(json, r'dateOfBirth'),
      dateOfDeath: mapValueOfType<int>(json, r'dateOfDeath'),
      placeOfBirth: mapValueOfType<String>(json, r'placeOfBirth'),
      placeOfDeath: mapValueOfType<String>(json, r'placeOfDeath'),
      deceased: mapValueOfType<bool>(json, r'deceased'),
      education: mapValueOfType<String>(json, r'education'),
      profession: mapValueOfType<String>(json, r'profession'),
      note: mapValueOfType<String>(json, r'note'),
      administrativeNote: mapValueOfType<String>(json, r'administrativeNote'),
      nationality: mapValueOfType<String>(json, r'nationality'),
      race: mapValueOfType<String>(json, r'race'),
      ethnicity: mapValueOfType<String>(json, r'ethnicity'),
      picture: mapValueOfType<String>(json, r'picture'),
      externalId: mapValueOfType<String>(json, r'externalId'),
      partnerships: Partnership.listFromJson(json[r'partnerships'])!,
      patientHealthCareParties: PatientHealthCareParty.listFromJson(json[r'patientHealthCareParties'])!,
      patientProfessions: CodingReference.listFromJson(json[r'patientProfessions'])!,
      parameters: json[r'parameters'] == null ? const {} : mapWithListOfStringsFromJson(json[r'parameters']),
      properties: Property.listFromJson(json[r'properties'])!.toSet(),
      systemMetaData: SystemMetaDataOwnerEncrypted.fromJson(json[r'systemMetaData']),
    );
  }
  return null;
}