fromJson static method
Returns a new DecryptedPatientDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DecryptedPatientDto? fromJson(dynamic value) {
if (value is DecryptedPatientDto) {
return value;
}
if (value is Map) {
final json = {
"identifier": [],
"tags": {},
"codes": {},
"names": [],
"languages": [],
"addresses": [],
"mergedIds": {},
"insurabilities": [],
"partnerships": [],
"patientHealthCareParties": [],
"financialInstitutionInformation": [],
"medicalHouseContracts": [],
"patientProfessions": [],
"parameters": {},
"properties": {},
"hcPartyKeys": {},
"aesExchangeKeys": {},
"transferKeys": {},
"privateKeyShamirPartitions": {},
"secretForeignKeys": {},
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"nonDuplicateIds": {},
"encryptedAdministrativesDocuments": {},
"schoolingInfos": [],
"employementInfos": [],
...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 "DecryptedPatientDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "DecryptedPatientDto[$key]" has a null value in JSON.');
});
return true;
}());
return DecryptedPatientDto(
id: mapValueOfType<String>(json, r'id')!,
identifier: IdentifierDto.listFromJson(json[r'identifier'])!,
rev: mapValueOfType<String>(json, r'rev'),
created: mapValueOfType<int>(json, r'created'),
modified: mapValueOfType<int>(json, r'modified'),
author: mapValueOfType<String>(json, r'author'),
responsible: mapValueOfType<String>(json, r'responsible'),
tags: CodeStubDto.listFromJson(json[r'tags'])!.toSet(),
codes: CodeStubDto.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: PersonNameDto.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: AddressDto.listFromJson(json[r'addresses'])!,
civility: mapValueOfType<String>(json, r'civility'),
gender: PatientDtoGenderEnum.fromJson(json[r'gender']),
birthSex: PatientDtoBirthSexEnum.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: PatientDtoDeactivationReasonEnum.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: PatientDtoPersonalStatusEnum.fromJson(json[r'personalStatus']),
dateOfBirth: mapValueOfType<int>(json, r'dateOfBirth'),
dateOfDeath: mapValueOfType<int>(json, r'dateOfDeath'),
timestampOfLatestEidReading: mapValueOfType<int>(json, r'timestampOfLatestEidReading'),
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'),
preferredUserId: mapValueOfType<String>(json, r'preferredUserId'),
picture: mapValueOfType<String>(json, r'picture'),
externalId: mapValueOfType<String>(json, r'externalId'),
insurabilities: InsurabilityDto.listFromJson(json[r'insurabilities'])!,
partnerships: PartnershipDto.listFromJson(json[r'partnerships'])!,
patientHealthCareParties: PatientHealthCarePartyDto.listFromJson(json[r'patientHealthCareParties'])!,
financialInstitutionInformation: FinancialInstitutionInformationDto.listFromJson(json[r'financialInstitutionInformation'])!,
medicalHouseContracts: MedicalHouseContractDto.listFromJson(json[r'medicalHouseContracts'])!,
patientProfessions: CodeStubDto.listFromJson(json[r'patientProfessions'])!,
parameters: json[r'parameters'] == null ? const {} : mapWithListOfStringsFromJson(json[r'parameters']),
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'),
secretForeignKeys: json[r'secretForeignKeys'] is Set
? (json[r'secretForeignKeys'] as Set).cast<String>()
: json[r'secretForeignKeys'] is List
? ((json[r'secretForeignKeys'] as List).toSet()).cast<String>()
: const {},
cryptedForeignKeys: json[r'cryptedForeignKeys'] == null ? const {} : DelegationDto.mapListFromJson(json[r'cryptedForeignKeys']),
delegations: json[r'delegations'] == null ? const {} : DelegationDto.mapListFromJson(json[r'delegations']),
encryptionKeys: json[r'encryptionKeys'] == null ? const {} : DelegationDto.mapListFromJson(json[r'encryptionKeys']),
encryptedSelf: mapValueOfType<String>(json, r'encryptedSelf'),
medicalLocationId: mapValueOfType<String>(json, r'medicalLocationId'),
nonDuplicateIds: json[r'nonDuplicateIds'] is Set
? (json[r'nonDuplicateIds'] as Set).cast<String>()
: json[r'nonDuplicateIds'] is List
? ((json[r'nonDuplicateIds'] as List).toSet()).cast<String>()
: const {},
encryptedAdministrativesDocuments:
json[r'encryptedAdministrativesDocuments'] is Set ? (json[r'encryptedAdministrativesDocuments'] as Set).cast<String>() : const {},
comment: mapValueOfType<String>(json, r'comment'),
warning: mapValueOfType<String>(json, r'warning'),
fatherBirthCountry: CodeStubDto.fromJson(json[r'fatherBirthCountry']),
birthCountry: CodeStubDto.fromJson(json[r'birthCountry']),
nativeCountry: CodeStubDto.fromJson(json[r'nativeCountry']),
socialStatus: CodeStubDto.fromJson(json[r'socialStatus']),
mainSourceOfIncome: CodeStubDto.fromJson(json[r'mainSourceOfIncome']),
schoolingInfos: SchoolingInfoDto.listFromJson(json[r'schoolingInfos'])!,
employementInfos: EmploymentInfoDto.listFromJson(json[r'employementInfos'])!,
);
}
return null;
}