fromJson static method

InvoiceItem? fromJson(
  1. dynamic value
)

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

Implementation

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

    return InvoiceItem(
      dateCode: mapValueOfType<int>(json, r'dateCode'),
      codeNomenclature: mapValueOfType<int>(json, r'codeNomenclature')!,
      relatedCode: mapValueOfType<int>(json, r'relatedCode'),
      eidItem: EIDItem.fromJson(json[r'eidItem']),
      insuranceRef: mapValueOfType<String>(json, r'insuranceRef'),
      insuranceRefDate: mapValueOfType<int>(json, r'insuranceRefDate'),
      units: mapValueOfType<int>(json, r'units')!,
      reimbursedAmount: mapValueOfType<int>(json, r'reimbursedAmount')!,
      patientFee: mapValueOfType<int>(json, r'patientFee')!,
      doctorSupplement: mapValueOfType<int>(json, r'doctorSupplement')!,
      sideCode: InvoiceItemSideCodeEnum.fromJson(json[r'sideCode']),
      timeOfDay: InvoiceItemTimeOfDayEnum.fromJson(json[r'timeOfDay']),
      override3rdPayerCode: mapValueOfType<int>(json, r'override3rdPayerCode'),
      gnotionNihii: mapValueOfType<String>(json, r'gnotionNihii'),
      derogationMaxNumber: InvoiceItemDerogationMaxNumberEnum.fromJson(json[r'derogationMaxNumber']),
      prescriberNorm: InvoiceItemPrescriberNormEnum.fromJson(json[r'prescriberNorm']),
      prescriberNihii: mapValueOfType<String>(json, r'prescriberNihii'),
      prescriptionDate: mapValueOfType<int>(json, r'prescriptionDate'),
      personalInterventionCoveredByThirdPartyCode: mapValueOfType<int>(json, r'personalInterventionCoveredByThirdPartyCode'),
      doctorIdentificationNumber: mapValueOfType<String>(json, r'doctorIdentificationNumber'),
      invoiceRef: mapValueOfType<String>(json, r'invoiceRef'),
      percentNorm: InvoiceItemPercentNormEnum.fromJson(json[r'percentNorm']),
    );
  }
  return null;
}