fromJson static method
Returns a new AmppDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AmppDto? fromJson(dynamic value) {
if (value is AmppDto) {
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 "AmppDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "AmppDto[$key]" has a null value in JSON.');
});
return true;
}());
return AmppDto(
from: mapValueOfType<int>(json, r'from'),
to: mapValueOfType<int>(json, r'to'),
index: mapValueOfType<double>(json, r'index'),
ctiExtended: mapValueOfType<String>(json, r'ctiExtended'),
orphan: mapValueOfType<bool>(json, r'orphan')!,
leafletLink: SamTextDto.fromJson(json[r'leafletLink']),
spcLink: SamTextDto.fromJson(json[r'spcLink']),
rmaPatientLink: SamTextDto.fromJson(json[r'rmaPatientLink']),
rmaProfessionalLink: SamTextDto.fromJson(json[r'rmaProfessionalLink']),
parallelCircuit: mapValueOfType<int>(json, r'parallelCircuit'),
parallelDistributor: mapValueOfType<String>(json, r'parallelDistributor'),
packMultiplier: mapValueOfType<int>(json, r'packMultiplier'),
packAmount: QuantityDto.fromJson(json[r'packAmount']),
packDisplayValue: mapValueOfType<String>(json, r'packDisplayValue'),
status: AmppDtoStatusEnum.fromJson(json[r'status']),
atcs: AtcDto.listFromJson(json[r'atcs'])!,
crmLink: SamTextDto.fromJson(json[r'crmLink']),
deliveryModusCode: mapValueOfType<String>(json, r'deliveryModusCode'),
deliveryModus: SamTextDto.fromJson(json[r'deliveryModus']),
deliveryModusSpecificationCode: mapValueOfType<String>(json, r'deliveryModusSpecificationCode'),
deliveryModusSpecification: SamTextDto.fromJson(json[r'deliveryModusSpecification']),
dhpcLink: SamTextDto.fromJson(json[r'dhpcLink']),
distributorCompany: CompanyDto.fromJson(json[r'distributorCompany']),
singleUse: mapValueOfType<bool>(json, r'singleUse'),
speciallyRegulated: mapValueOfType<int>(json, r'speciallyRegulated'),
abbreviatedName: SamTextDto.fromJson(json[r'abbreviatedName']),
prescriptionName: SamTextDto.fromJson(json[r'prescriptionName']),
note: SamTextDto.fromJson(json[r'note']),
posologyNote: SamTextDto.fromJson(json[r'posologyNote']),
noGenericPrescriptionReasons: SamTextDto.listFromJson(json[r'noGenericPrescriptionReasons']) ?? const [],
exFactoryPrice: mapValueOfType<double>(json, r'exFactoryPrice'),
reimbursementCode: mapValueOfType<int>(json, r'reimbursementCode'),
definedDailyDose: QuantityDto.fromJson(json[r'definedDailyDose']),
officialExFactoryPrice: mapValueOfType<double>(json, r'officialExFactoryPrice'),
realExFactoryPrice: mapValueOfType<double>(json, r'realExFactoryPrice'),
pricingInformationDecisionDate: mapValueOfType<int>(json, r'pricingInformationDecisionDate'),
components: AmppComponentDto.listFromJson(json[r'components']) ?? const [],
commercializations: CommercializationDto.listFromJson(json[r'commercializations']) ?? const [],
supplyProblems: SupplyProblemDto.listFromJson(json[r'supplyProblems']) ?? const [],
dmpps: DmppDto.listFromJson(json[r'dmpps'])!,
vaccineIndicationCodes: json[r'vaccineIndicationCodes'] is List ? (json[r'vaccineIndicationCodes'] as List).cast<String>() : const [],
);
}
return null;
}