react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
685 lines (633 loc) • 20.1 kB
text/typescript
/// Auto-generated with ScanbotSDKCodegenV3. Modifications will be overwritten.
/// Generated from core/schemas/MedicalCertificateTypes.yaml
import { DocumentDetectionResult } from '../document_scanner/DocumentScannerTypes';
import { ImageRef } from '../imageRef/image';
import { ToJsonConfiguration } from '../utils/json/JsonSerializationTypes';
import { DeepPartial, PartiallyConstructible, Point } from '../utils/utils';
/**
Parameters for the medical certificate scanning. The scanner supports
Form 1 (Arbeitsunfähigkeitsbescheinigung) and
Form 21a (Ärztliche Bescheinigung für den Bezug von Krankengeld bei Erkrankung eines Kindes)
from the KBV (Kassenärztliche Bundesvereinigung) list of forms.
*/
export class MedicalCertificateScanningParameters extends PartiallyConstructible {
/**
Document will be detected and cropped before recognition.
If false, a cropped image of a document is assumed.
Default is true
*/
public shouldCropDocument: boolean = true;
/**
All data in the patient info box will be extracted.
If false, the patient info box is ignored.
Default is true
*/
public recognizePatientInfoBox: boolean = true;
/**
Some forms are printed with an extra barcode that encodes the same information as the document.
Reading the barcode is more reliable than OCR and is recommended when possible.
If false, the barcode will not be scanned.
Default is true
*/
public recognizeBarcode: boolean = true;
/**
If true, cropped document image will be extracted and returned.
Default is false
*/
public extractCroppedImage: boolean = false;
/**
If true, the image is sharpened before processing.
Default is false
*/
public preprocessInput: boolean = false;
/** @param source {@displayType `DeepPartial<MedicalCertificateScanningParameters>`} */
public constructor(source: DeepPartial<MedicalCertificateScanningParameters> = {}) {
super();
if (source.shouldCropDocument !== undefined) {
this.shouldCropDocument = source.shouldCropDocument;
}
if (source.recognizePatientInfoBox !== undefined) {
this.recognizePatientInfoBox = source.recognizePatientInfoBox;
}
if (source.recognizeBarcode !== undefined) {
this.recognizeBarcode = source.recognizeBarcode;
}
if (source.extractCroppedImage !== undefined) {
this.extractCroppedImage = source.extractCroppedImage;
}
if (source.preprocessInput !== undefined) {
this.preprocessInput = source.preprocessInput;
}
}
}
/**
Type of the checkbox.
- `UNKNOWN`:
Unknown checkbox type.
- `WORK_ACCIDENT`:
(Form 1) Work accident (Arbeitsunfall, Arbeitsunfall-folgen, Berufskrankheit) checkbox.
- `ASSIGNED_TO_ACCIDENT_INSURANCE_DOCTOR`:
(Form 1) Assigned to accident insurance doctor (dem Durchgangsarzt zugewiesen) checkbox.
- `INITIAL_CERTIFICATE`:
(Form 1) Initial certificate (Erstbescheinigung) checkbox.
- `RENEWED_CERTIFICATE`:
(Form 1) Renewed certificate (Folgebescheinigung) checkbox.
- `INSURED_PAY_CASE`:
(Form 1) Insured pay case (ab 7. AU-Woche oder sonstiger Krankengeldfall) checkbox.
- `FINAL_CERTIFICATE`:
(Form 1) Final certificate (Endbescheinigung) checkbox.
- `REQUIRES_CARE_YES`:
(Form 21a) Requires care yes (Die Art der Erkrankung macht die Betreuung und Beaufsichtigung notwendig... ja) checkbox.
- `REQUIRES_CARE_NO`:
(Form 21a) Requires care no (Die Art der Erkrankung macht die Betreuung und Beaufsichtigung notwendig... nein) checkbox.
- `ACCIDENT_YES`:
(Form 21a) Accident yes (Unfall... ja) checkbox.
- `ACCIDENT_NO`:
(Form 21a) Accident no (Unfall... nein) checkbox.
- `OTHER_ACCIDENT`:
(Form 1) Other accident (Sonstiger Unfall, Unfallfolgen) checkbox.
- `ENTITLEMENT_TO_CONTINUED_PAYMENT_YES`:
(Form 21a) Entitlement to continued payment yes (Anspruch auf Entgeltfortzahlung) checkbox.
- `ENTITLEMENT_TO_CONTINUED_PAYMENT_NO`:
(Form 21a) Entitlement to continued payment no (keinen Anspruch auf Entgeltfortzahlung) checkbox.
- `SICK_PAY_WAS_CLAIMED_NO`:
(Form 21a) Sick pay was claimed no (Krankengeld aus Anlass einer früheren Erkrankung des umseitig genannten Kindes wurde in diesem Kalenderjahr NICHT bezogen) checkbox.
- `SICK_PAY_WAS_CLAIMED_YES`:
(Form 21a) Sick pay was claimed yes (Krankengeld aus Anlass einer früheren Erkrankung des umseitig genannten Kindes wurde in diesem Kalenderjahr bezogen) checkbox.
- `SINGLE_PARENT_NO`:
(Form 21a) Single parent no (Ich bin Alleinerziehende(r)... nein) checkbox.
- `SINGLE_PARENT_YES`:
(Form 21a) Single parent yes (Ich bin Alleinerziehende(r)... ja) checkbox.
*/
export type MedicalCertificateCheckBoxType =
| 'UNKNOWN'
| 'WORK_ACCIDENT'
| 'ASSIGNED_TO_ACCIDENT_INSURANCE_DOCTOR'
| 'INITIAL_CERTIFICATE'
| 'RENEWED_CERTIFICATE'
| 'INSURED_PAY_CASE'
| 'FINAL_CERTIFICATE'
| 'REQUIRES_CARE_YES'
| 'REQUIRES_CARE_NO'
| 'ACCIDENT_YES'
| 'ACCIDENT_NO'
| 'OTHER_ACCIDENT'
| 'ENTITLEMENT_TO_CONTINUED_PAYMENT_YES'
| 'ENTITLEMENT_TO_CONTINUED_PAYMENT_NO'
| 'SICK_PAY_WAS_CLAIMED_NO'
| 'SICK_PAY_WAS_CLAIMED_YES'
| 'SINGLE_PARENT_NO'
| 'SINGLE_PARENT_YES';
export const MedicalCertificateCheckBoxTypeValues: MedicalCertificateCheckBoxType[] = [
'UNKNOWN',
'WORK_ACCIDENT',
'ASSIGNED_TO_ACCIDENT_INSURANCE_DOCTOR',
'INITIAL_CERTIFICATE',
'RENEWED_CERTIFICATE',
'INSURED_PAY_CASE',
'FINAL_CERTIFICATE',
'REQUIRES_CARE_YES',
'REQUIRES_CARE_NO',
'ACCIDENT_YES',
'ACCIDENT_NO',
'OTHER_ACCIDENT',
'ENTITLEMENT_TO_CONTINUED_PAYMENT_YES',
'ENTITLEMENT_TO_CONTINUED_PAYMENT_NO',
'SICK_PAY_WAS_CLAIMED_NO',
'SICK_PAY_WAS_CLAIMED_YES',
'SINGLE_PARENT_NO',
'SINGLE_PARENT_YES',
];
/**
Structure to contain full information about found box.
*/
export class MedicalCertificateCheckBox extends PartiallyConstructible {
/**
Box type.
Default is UNKNOWN
*/
public readonly type: MedicalCertificateCheckBoxType = 'UNKNOWN';
/**
True if the box is checked.
Default is false
*/
public readonly checked: boolean = false;
/**
Confidence of the checked/unchecked prediction.
Default is 0.0
*/
public readonly checkedConfidence: number = 0.0;
/**
Points of the box.
*/
public readonly quad: Point[];
/** @param source {@displayType `DeepPartial<MedicalCertificateCheckBox>`} */
public constructor(source: DeepPartial<MedicalCertificateCheckBox> = {}) {
super();
if (source.type !== undefined) {
this.type = source.type;
}
if (source.checked !== undefined) {
this.checked = source.checked;
}
if (source.checkedConfidence !== undefined) {
this.checkedConfidence = source.checkedConfidence;
}
if (source.quad !== undefined) {
this.quad = source.quad.map((it: any) => {
return { x: it.x, y: it.y };
});
} else {
throw new Error('quad must be present in constructor argument');
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<MedicalCertificateCheckBox> {
return {
type: this.type,
checked: this.checked,
checkedConfidence: this.checkedConfidence,
quad: this.quad.map((it: any) => {
return it;
}),
};
}
}
/**
Type of a date record.
- `INCAPABLE_OF_WORK_SINCE`:
(Form 1) Incapable of work since (arbeitsunfähig seit) date.
- `INCAPABLE_OF_WORK_UNTIL`:
(Form 1) Incapable of work until (voraussichtlich arbeitsunfähig bis einschließlich oder letzter Tag der Arbeitsunfähigkeit) date.
- `DIAGNOSED_ON`:
(Form 1) Diagnosed on (festgestellt am) date.
- `DOCUMENT_DATE`:
Document date.
- `BIRTH_DATE`:
Birthdate (geb. am).
- `CHILD_NEEDS_CARE_FROM`:
(Form 21a) Child needs care from (Das genannte Kind bedarf/bedurfte vom) date.
- `CHILD_NEEDS_CARE_UNTIL`:
(Form 21a) Child needs care until (Das genannte Kind bedarf/bedurfte bis einschließlich) date.
- `UNDEFINED`:
Undefined date type.
*/
export type MedicalCertificateDateRecordType =
| 'INCAPABLE_OF_WORK_SINCE'
| 'INCAPABLE_OF_WORK_UNTIL'
| 'DIAGNOSED_ON'
| 'DOCUMENT_DATE'
| 'BIRTH_DATE'
| 'CHILD_NEEDS_CARE_FROM'
| 'CHILD_NEEDS_CARE_UNTIL'
| 'UNDEFINED';
export const MedicalCertificateDateRecordTypeValues: MedicalCertificateDateRecordType[] = [
'INCAPABLE_OF_WORK_SINCE',
'INCAPABLE_OF_WORK_UNTIL',
'DIAGNOSED_ON',
'DOCUMENT_DATE',
'BIRTH_DATE',
'CHILD_NEEDS_CARE_FROM',
'CHILD_NEEDS_CARE_UNTIL',
'UNDEFINED',
];
/**
Structure to contain date record information.
*/
export class MedicalCertificateDateRecord extends PartiallyConstructible {
/**
Date box.
*/
public readonly quad: Point[];
/**
Validated date string.
Default is ""
*/
public readonly value: string = '';
/**
Raw date string.
Default is ""
*/
public readonly rawString: string = '';
/**
Date type.
Default is UNDEFINED
*/
public readonly type: MedicalCertificateDateRecordType = 'UNDEFINED';
/**
Confidence in the recognized value.
Default is 0.0
*/
public readonly recognitionConfidence: number = 0.0;
/** @param source {@displayType `DeepPartial<MedicalCertificateDateRecord>`} */
public constructor(source: DeepPartial<MedicalCertificateDateRecord> = {}) {
super();
if (source.quad !== undefined) {
this.quad = source.quad.map((it: any) => {
return { x: it.x, y: it.y };
});
} else {
throw new Error('quad must be present in constructor argument');
}
if (source.value !== undefined) {
this.value = source.value;
}
if (source.rawString !== undefined) {
this.rawString = source.rawString;
}
if (source.type !== undefined) {
this.type = source.type;
}
if (source.recognitionConfidence !== undefined) {
this.recognitionConfidence = source.recognitionConfidence;
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<MedicalCertificateDateRecord> {
return {
quad: this.quad.map((it: any) => {
return it;
}),
value: this.value,
rawString: this.rawString,
type: this.type,
recognitionConfidence: this.recognitionConfidence,
};
}
}
/**
Type of a field in the patient info box.
- `INSURANCE_PROVIDER`:
Insurance provider (Krankenkasse bzw. Kostenträger).
- `FIRST_NAME`:
First name (Vorname des Versicherten).
- `LAST_NAME`:
Last name (Name des Versicherten).
- `ADDRESS_STRING1`:
First line of address.
- `ADDRESS_STRING2`:
Second line of address.
- `DIAGNOSE`:
Diagnose.
- `HEALTH_INSURANCE_NUMBER`:
Number of the health insurance provider (Kostenträgerkennung).
- `INSURED_PERSON_NUMBER`:
Personal number of the insured person (Versicherten-Nr.).
- `STATUS`:
Status.
- `PLACE_OF_OPERATION_NUMBER`:
Number of the place of operation (Betriebsstätten-Nr.).
- `DOCTOR_NUMBER`:
Number of the doctor (Arzt-Nr.).
- `UNDEFINED`:
Undefined.
*/
export type MedicalCertificatePatientInfoFieldType =
| 'INSURANCE_PROVIDER'
| 'FIRST_NAME'
| 'LAST_NAME'
| 'ADDRESS_STRING1'
| 'ADDRESS_STRING2'
| 'DIAGNOSE'
| 'HEALTH_INSURANCE_NUMBER'
| 'INSURED_PERSON_NUMBER'
| 'STATUS'
| 'PLACE_OF_OPERATION_NUMBER'
| 'DOCTOR_NUMBER'
| 'UNDEFINED';
export const MedicalCertificatePatientInfoFieldTypeValues: MedicalCertificatePatientInfoFieldType[] =
[
'INSURANCE_PROVIDER',
'FIRST_NAME',
'LAST_NAME',
'ADDRESS_STRING1',
'ADDRESS_STRING2',
'DIAGNOSE',
'HEALTH_INSURANCE_NUMBER',
'INSURED_PERSON_NUMBER',
'STATUS',
'PLACE_OF_OPERATION_NUMBER',
'DOCTOR_NUMBER',
'UNDEFINED',
];
/**
Patient information field.
*/
export class MedicalCertificatePatientInfoField extends PartiallyConstructible {
/**
Field type.
*/
public readonly type: MedicalCertificatePatientInfoFieldType;
/**
Field value.
*/
public readonly value: string;
/**
Confidence in the recognized value.
*/
public readonly recognitionConfidence: number;
/** @param source {@displayType `DeepPartial<MedicalCertificatePatientInfoField>`} */
public constructor(source: DeepPartial<MedicalCertificatePatientInfoField> = {}) {
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.recognitionConfidence !== undefined) {
this.recognitionConfidence = source.recognitionConfidence;
} else {
throw new Error('recognitionConfidence must be present in constructor argument');
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<MedicalCertificatePatientInfoField> {
return {
type: this.type,
value: this.value,
recognitionConfidence: this.recognitionConfidence,
};
}
}
/**
Patient information box.
*/
export class MedicalCertificatePatientInfoBox extends PartiallyConstructible {
/**
Four corners of the patient info box.
*/
public readonly quad: Point[];
/**
Vector of found fields.
*/
public readonly fields: MedicalCertificatePatientInfoField[];
/**
Whether the patient info box has contents.
Default is false
*/
public readonly hasContents: boolean = false;
/** @param source {@displayType `DeepPartial<MedicalCertificatePatientInfoBox>`} */
public constructor(source: DeepPartial<MedicalCertificatePatientInfoBox> = {}) {
super();
if (source.quad !== undefined) {
this.quad = source.quad.map((it: any) => {
return { x: it.x, y: it.y };
});
} else {
throw new Error('quad must be present in constructor argument');
}
if (source.fields !== undefined) {
this.fields = source.fields.map((it: any) => {
return new MedicalCertificatePatientInfoField(it);
});
} else {
throw new Error('fields must be present in constructor argument');
}
if (source.hasContents !== undefined) {
this.hasContents = source.hasContents;
}
}
public serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): DeepPartial<MedicalCertificatePatientInfoBox> {
return {
quad: this.quad.map((it: any) => {
return it;
}),
fields: this.fields.map((it: any) => {
return it.serialize(config);
}),
hasContents: this.hasContents,
};
}
}
/**
Type of the medical certificate form.
- `UNKNOWN`:
Unknown form type.
- `FORM_1A`:
Form 1A.
- `FORM_1B`:
Form 1B.
- `FORM_1C`:
Form 1C.
- `FORM_1D`:
Form 1D.
- `FORM_21A`:
Form 21A.
- `FORM_21A_BACK`:
Form 21A back.
- `FORM_1B_CUSTOM`:
Form 1B custom.
*/
export type MedicalCertificateFormType =
| 'UNKNOWN'
| 'FORM_1A'
| 'FORM_1B'
| 'FORM_1C'
| 'FORM_1D'
| 'FORM_21A'
| 'FORM_21A_BACK'
| 'FORM_1B_CUSTOM';
export const MedicalCertificateFormTypeValues: MedicalCertificateFormType[] = [
'UNKNOWN',
'FORM_1A',
'FORM_1B',
'FORM_1C',
'FORM_1D',
'FORM_21A',
'FORM_21A_BACK',
'FORM_1B_CUSTOM',
];
/**
The result of the medical certificate scanning.
*/
export class MedicalCertificateScanningResult extends PartiallyConstructible {
/**
True if scanning was successful.
Default is false
*/
public readonly scanningSuccessful: boolean = false;
/**
Patient info box.
*/
public readonly patientInfoBox: MedicalCertificatePatientInfoBox;
/**
Found checkboxes.
*/
public readonly checkBoxes: MedicalCertificateCheckBox[];
/**
Found dates.
*/
public readonly dates: MedicalCertificateDateRecord[];
/**
Form type.
Default is UNKNOWN
*/
public readonly formType: MedicalCertificateFormType = 'UNKNOWN';
/**
The number of 90-degree clockwise rotations that were applied to the original image.
The same number of counter-clockwise rotations are necessary to make the image upright again.
Default is 0
*/
public readonly clockwiseRotations: number = 0;
/**
The cropped image used for recognition.
*/
public readonly croppedImage: ImageRef | null = null;
/**
The scale factor used to scale the image to the recognition size.
Default is 1.0
*/
public readonly scaleX: number = 1.0;
/**
The scale factor used to scale the image to the recognition size.
Default is 1.0
*/
public readonly scaleY: number = 1.0;
/**
Result of the document detection in the input image. Is available only if the shouldCropDocument parameter is set to true.
*/
public readonly documentDetectionResult: DocumentDetectionResult | null;
/** @param source {@displayType `DeepPartial<MedicalCertificateScanningResult>`} */
public constructor(source: DeepPartial<MedicalCertificateScanningResult> = {}) {
super();
if (source.scanningSuccessful !== undefined) {
this.scanningSuccessful = source.scanningSuccessful;
}
if (source.patientInfoBox !== undefined) {
this.patientInfoBox = new MedicalCertificatePatientInfoBox(source.patientInfoBox);
} else {
throw new Error('patientInfoBox must be present in constructor argument');
}
if (source.checkBoxes !== undefined) {
this.checkBoxes = source.checkBoxes.map((it: any) => {
return new MedicalCertificateCheckBox(it);
});
} else {
throw new Error('checkBoxes must be present in constructor argument');
}
if (source.dates !== undefined) {
this.dates = source.dates.map((it: any) => {
return new MedicalCertificateDateRecord(it);
});
} else {
throw new Error('dates must be present in constructor argument');
}
if (source.formType !== undefined) {
this.formType = source.formType;
}
if (source.clockwiseRotations !== undefined) {
this.clockwiseRotations = source.clockwiseRotations;
}
if (source.croppedImage !== undefined) {
this.croppedImage = source.croppedImage != null ? ImageRef.From(source.croppedImage) : null;
}
if (source.scaleX !== undefined) {
this.scaleX = source.scaleX;
}
if (source.scaleY !== undefined) {
this.scaleY = source.scaleY;
}
if (source.documentDetectionResult !== undefined) {
this.documentDetectionResult =
source.documentDetectionResult != null
? new DocumentDetectionResult(source.documentDetectionResult)
: null;
} else {
throw new Error('documentDetectionResult must be present in constructor argument');
}
}
public async serialize(
config: ToJsonConfiguration = new ToJsonConfiguration()
): Promise<DeepPartial<MedicalCertificateScanningResult>> {
return {
scanningSuccessful: this.scanningSuccessful,
patientInfoBox: this.patientInfoBox.serialize(config),
checkBoxes: this.checkBoxes.map((it: any) => {
return it.serialize(config);
}),
dates: this.dates.map((it: any) => {
return it.serialize(config);
}),
formType: this.formType,
clockwiseRotations: this.clockwiseRotations,
croppedImage: config.serializeImages
? this.croppedImage != null
? await this.croppedImage.serialize(config.imageSerializationMode)
: null
: undefined,
scaleX: this.scaleX,
scaleY: this.scaleY,
documentDetectionResult:
this.documentDetectionResult != null
? this.documentDetectionResult.serialize(config)
: null,
};
}
private _released: Boolean = false;
public release() {
if (this._released) {
return;
}
{
if (this.croppedImage != null) {
this.croppedImage.release();
}
}
this._released = true;
}
public async encodeImages(): Promise<void> {
if (this.croppedImage != null) {
await this.croppedImage.encodeInPlace();
}
}
}