fromJson static method

HealthcarePartyDto? fromJson(
  1. dynamic value
)

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

Implementation

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

    return HealthcarePartyDto(
      id: mapValueOfType<String>(json, r'id')!,
      rev: mapValueOfType<String>(json, r'rev'),
      created: mapValueOfType<int>(json, r'created'),
      modified: mapValueOfType<int>(json, r'modified'),
      deletionDate: mapValueOfType<int>(json, r'deletionDate'),
      name: mapValueOfType<String>(json, r'name'),
      lastName: mapValueOfType<String>(json, r'lastName'),
      firstName: mapValueOfType<String>(json, r'firstName'),
      names: PersonNameDto.listFromJson(json[r'names'])!,
      gender: HealthcarePartyDtoGenderEnum.fromJson(json[r'gender']),
      civility: mapValueOfType<String>(json, r'civility'),
      companyName: mapValueOfType<String>(json, r'companyName'),
      speciality: mapValueOfType<String>(json, r'speciality'),
      bankAccount: mapValueOfType<String>(json, r'bankAccount'),
      bic: mapValueOfType<String>(json, r'bic'),
      proxyBankAccount: mapValueOfType<String>(json, r'proxyBankAccount'),
      proxyBic: mapValueOfType<String>(json, r'proxyBic'),
      invoiceHeader: mapValueOfType<String>(json, r'invoiceHeader'),
      cbe: mapValueOfType<String>(json, r'cbe'),
      ehp: mapValueOfType<String>(json, r'ehp'),
      userId: mapValueOfType<String>(json, r'userId'),
      parentId: mapValueOfType<String>(json, r'parentId'),
      convention: mapValueOfType<int>(json, r'convention'),
      nihii: mapValueOfType<String>(json, r'nihii'),
      nihiiSpecCode: mapValueOfType<String>(json, r'nihiiSpecCode'),
      ssin: mapValueOfType<String>(json, r'ssin'),
      addresses: AddressDto.listFromJson(json[r'addresses'])!,
      languages: json[r'languages'] is List ? (json[r'languages'] as List).cast<String>() : const [],
      picture: mapValueOfType<String>(json, r'picture'),
      statuses: HealthcarePartyDtoStatusesEnum.listFromJson(json[r'statuses'])!.toSet(),
      statusHistory: HealthcarePartyHistoryStatusDto.listFromJson(json[r'statusHistory'])!,
      specialityCodes: CodeStubDto.listFromJson(json[r'specialityCodes'])!.toSet(),
      sendFormats: mapCastOfType<String, String>(json, r'sendFormats')!,
      notes: mapValueOfType<String>(json, r'notes'),
      financialInstitutionInformation: FinancialInstitutionInformationDto.listFromJson(json[r'financialInstitutionInformation'])!,
      billingType: mapValueOfType<String>(json, r'billingType'),
      type: mapValueOfType<String>(json, r'type'),
      contactPerson: mapValueOfType<String>(json, r'contactPerson'),
      contactPersonHcpId: mapValueOfType<String>(json, r'contactPersonHcpId'),
      supervisorId: mapValueOfType<String>(json, r'supervisorId'),
      flatRateTarifications: FlatRateTarificationDto.listFromJson(json[r'flatRateTarifications'])!,
      importedData: mapCastOfType<String, String>(json, r'importedData')!,
      options: mapCastOfType<String, String>(json, r'options')!,
      properties: PropertyStubDto.listFromJson(json[r'properties'])!.toSet(),
      hcPartyKeys: json[r'hcPartyKeys'] == null ? const {} : mapWithListOfStringsFromJson(json[r'hcPartyKeys']),
      aesExchangeKeys: json[r'aesExchangeKeys'] == null ? const {} : mapOf(json[r'aesExchangeKeys'], (el) => mapWithMapOfStringsFromJson(el)),
      transferKeys: json[r'transferKeys'] == null ? const {} : mapWithMapOfStringsFromJson(json[r'transferKeys']),
      privateKeyShamirPartitions: mapCastOfType<String, String>(json, r'privateKeyShamirPartitions')!,
      publicKey: mapValueOfType<String>(json, r'publicKey'),
    );
  }
  return null;
}