react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
296 lines (267 loc) • 9.96 kB
text/typescript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/EuropeanHealthInsuranceCardTypes.yaml
import { EuropeanHealthInsuranceCardIssuingCountry } from '../document_data_extractor/DocumentDataExtractorConfigurationTypes';
import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes';
import { DeepPartial, PartiallyConstructible } from '../utils/utils';
/**
The result of the health insurance card recognition.
*/
export class EuropeanHealthInsuranceCardRecognitionResult extends PartiallyConstructible {
/**
Health insurance card fields.
*/
public readonly fields: EuropeanHealthInsuranceCardRecognitionResult.Field[];
/**
Recognition status.
Default is FAILED_DETECTION
*/
public readonly status: EuropeanHealthInsuranceCardRecognitionResult.RecognitionStatus =
'FAILED_DETECTION';
/** @param source {@displayType `DeepPartial<EuropeanHealthInsuranceCardRecognitionResult>`} */
public constructor(source: DeepPartial<EuropeanHealthInsuranceCardRecognitionResult> = {}) {
super();
if (source.fields !== undefined) {
this.fields = source.fields.map((it: any) => {
return new EuropeanHealthInsuranceCardRecognitionResult.Field(it);
});
} else {
throw new Error('fields must be present in constructor argument');
}
if (source.status !== undefined) {
this.status = source.status;
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<EuropeanHealthInsuranceCardRecognitionResult> {
return {
fields: this.fields.map((it: any) => {
return it.serialize(config);
}),
status: this.status,
};
}
}
export namespace EuropeanHealthInsuranceCardRecognitionResult {
/**
Card recognition status.
- `SUCCESS`:
Detection successful. The fields array is filled with all of the extracted data. All validatable fields have passed validation.
- `FAILED_DETECTION`:
No document found or the document doesn't look like the back of an EHIC.
- `INCOMPLETE_VALIDATION`:
A potential EHIC was found but one or more fields failed validation.
*/
export type RecognitionStatus = 'SUCCESS' | 'FAILED_DETECTION' | 'INCOMPLETE_VALIDATION';
export const RecognitionStatusValues: RecognitionStatus[] = [
'SUCCESS',
'FAILED_DETECTION',
'INCOMPLETE_VALIDATION',
];
/**
Health insurance card field.
*/
export class Field extends PartiallyConstructible {
/**
Health insurance card field type.
*/
public readonly type: EuropeanHealthInsuranceCardRecognitionResult.Field.FieldType;
/**
Recognized value.
*/
public readonly value: string;
/**
Recognition confidence.
*/
public readonly confidence: number;
/**
Field validation status.
Default is NOT_VALIDATED
*/
public readonly validationStatus: EuropeanHealthInsuranceCardRecognitionResult.Field.ValidationStatus =
'NOT_VALIDATED';
/** @param source {@displayType `DeepPartial<Field>`} */
public constructor(source: DeepPartial<Field> = {}) {
super();
if (source.type !== undefined) {
this.type = source.type;
} else {
throw new Error('type must be present in constructor argument');
}
if (source.value !== undefined) {
this.value = source.value;
} else {
throw new Error('value must be present in constructor argument');
}
if (source.confidence !== undefined) {
this.confidence = source.confidence;
} else {
throw new Error('confidence must be present in constructor argument');
}
if (source.validationStatus !== undefined) {
this.validationStatus = source.validationStatus;
}
}
public serialize(config: ToJsonConfiguration = new ToJsonConfiguration()): DeepPartial<Field> {
return {
type: this.type,
value: this.value,
confidence: this.confidence,
validationStatus: this.validationStatus,
};
}
}
export namespace Field {
/**
Health insurance card field validation status.
- `NOT_VALIDATED`:
Field shouldn't be validated.
- `FAILURE`:
Field is not valid.
- `SUCCESS`:
Field is valid.
- `CONFIRMED`:
Field is valid and confirmed across multiple frames.
*/
export type ValidationStatus = 'NOT_VALIDATED' | 'FAILURE' | 'SUCCESS' | 'CONFIRMED';
export const ValidationStatusValues: ValidationStatus[] = [
'NOT_VALIDATED',
'FAILURE',
'SUCCESS',
'CONFIRMED',
];
/**
Health insurance card field type.
- `SURNAME`:
Surname.
- `GIVEN_NAME`:
Given name.
- `DATE_OF_BIRTH`:
Date of birth.
- `PERSONAL_IDENTIFICATION_NUMBER`:
Personal identification number.
- `INSTITUTION_NUMBER`:
Institution number.
- `INSTITUTION_NAME`:
Institution name.
- `CARD_NUMBER`:
Card number.
- `CARD_EXPIRATION_DATE`:
Card expiration date.
- `COUNTRY`:
Country.
*/
export type FieldType =
| 'SURNAME'
| 'GIVEN_NAME'
| 'DATE_OF_BIRTH'
| 'PERSONAL_IDENTIFICATION_NUMBER'
| 'INSTITUTION_NUMBER'
| 'INSTITUTION_NAME'
| 'CARD_NUMBER'
| 'CARD_EXPIRATION_DATE'
| 'COUNTRY';
export const FieldTypeValues: FieldType[] = [
'SURNAME',
'GIVEN_NAME',
'DATE_OF_BIRTH',
'PERSONAL_IDENTIFICATION_NUMBER',
'INSTITUTION_NUMBER',
'INSTITUTION_NAME',
'CARD_NUMBER',
'CARD_EXPIRATION_DATE',
'COUNTRY',
];
}
}
/**
Configuration for the European health insurance card (EHIC) recognizer.
*/
export class EuropeanHealthInsuranceCardRecognizerConfiguration extends PartiallyConstructible {
/**
List of allowed countries for the EHIC. If:
- single country: validation rules for the given country are used starting from the first
frame. If the country cannot be inferred or the inferred country doesn't
match the given country, the result of recognize() will be IncompleteValidation.
- multiple countries: the country is inferred from the card number first.
Until the country is detected, the document fields are not OCR'd and
accumulated. Once the country is inferred, the field accumulation starts
and the inferred country validation rules are applied.
If the country cannot be inferred or the inferred country doesn't match
any of the countries in the list, the result status will be IncompleteValidation.
- empty list: same as "multiple countries" with one additional detail.
If the country cannot be inferred within `maxCountryDetectionAttempts` successive frames in which the
part of the card number that stores the country code was successfully OCR'd, then the country is
inferred to be Unknown and no validation rules are applied. Field accumulation then proceeds normally.
In this case recognize() can eventually return Success and the document will have a CountryType of Unknown.
*/
public allowedCountries: EuropeanHealthInsuranceCardIssuingCountry[] = [];
/**
Minimum year of birth.
Default is 0
*/
public minBirthYear: number = 0;
/**
Maximum year of birth.
Default is 2999
*/
public maxBirthYear: number = 2999;
/**
Minimum card expiration year.
Default is 0
*/
public minExpirationYear: number = 0;
/**
Maximum card expiration year.
Default is 2999
*/
public maxExpirationYear: number = 2999;
/**
Maximum number of attempts before giving up on country detection. After the specified number of
attempts, the country field is considered to be unknown and validation is skipped.
This option is ignored if allowedCountries is not empty.
Default is 5
*/
public maxCountryDetectionAttempts: number = 5;
/**
Minimum number of accumulated frames that should have equal result for a field.
Once satisfied, the corresponding field is considered to be successfully-recognized and won't be considered in the subsequent frames.
Default is 4
*/
public minEqualFrameCount: number = 4;
/**
Maximum number of partial frame results to keep in cache while waiting to gather minEqualFrameCount equal results.
Default is 10
*/
public maxAccumulatedFrameCount: number = 10;
/** @param source {@displayType `DeepPartial<EuropeanHealthInsuranceCardRecognizerConfiguration>`} */
public constructor(source: DeepPartial<EuropeanHealthInsuranceCardRecognizerConfiguration> = {}) {
super();
if (source.allowedCountries !== undefined) {
this.allowedCountries = source.allowedCountries.map((it: any) => {
return it;
});
}
if (source.minBirthYear !== undefined) {
this.minBirthYear = source.minBirthYear;
}
if (source.maxBirthYear !== undefined) {
this.maxBirthYear = source.maxBirthYear;
}
if (source.minExpirationYear !== undefined) {
this.minExpirationYear = source.minExpirationYear;
}
if (source.maxExpirationYear !== undefined) {
this.maxExpirationYear = source.maxExpirationYear;
}
if (source.maxCountryDetectionAttempts !== undefined) {
this.maxCountryDetectionAttempts = source.maxCountryDetectionAttempts;
}
if (source.minEqualFrameCount !== undefined) {
this.minEqualFrameCount = source.minEqualFrameCount;
}
if (source.maxAccumulatedFrameCount !== undefined) {
this.maxAccumulatedFrameCount = source.maxAccumulatedFrameCount;
}
}
}