· 6 years ago · Mar 17, 2020, 01:50 PM
1ocr #JSON with OCR output
2unifiedResultParams #JSON fetched from central config
3detailsObject #JSON of JSONs that contains code and details string for each check - not specific to client
4expectedDocumentSide #This is an input to OCR API
5channel = "" #This will contain ‘green’,’red’ or ‘orange’
6details = JSON Object #This will contain details about Orange channel or red channel. If red channel, the single reason is returned immediately as the user is anyway asked to recapture. For orange channel, an array of reasons is given to make manual review easier.
7
8
9
10for key,value in unifiedResultParams.other_checks{
11
12 switch key: {
13 case "wrong_document_side":
14 if expectedDocumentSide != "front" && ocr.result.documentType.contains("front"):
15 channel = unifiedResultsParams["wrong_document_side"]
16 details.append(detailsObject.get("wrong_document_side"))
17
18 case "black_and_white":
19 if ocr.results.fraudCheck("isBlackAndWhite") == "yes"::
20 channel = unifiedResultsParams["black_and_white"]
21 details.append(detailsObject.get("wrong_document_side"))
22
23 ##Other Cases##
24 }
25
26 if "channel" == "red":
27 return(channel, details);
28}
29
30fraud_check_results = ocr.result.details.fraudChecks
31
32for key,value in unifiedResultParams.fraud_checks {
33 for check in unifiedResultParams.fraud_checks:
34 if check in fraud_check_results:
35 for key2,value2 in check:
36 if fraud_check_results.key == value2:
37 channel = key2
38 details.append(detailsObject.get(check))
39}
40
41
42for key,value in unifiedResultParams.ocr_checks {
43fields = unifiedResultParams.ocr_checks(ocr.result.documentType)
44
45 for field in fields:
46 var conf = 0
47 if ocr.result.details.field exists
48 conf = ocr.result.details.field.conf
49
50 if field.red exists conf <= field.red {
51 channel = red
52 details.append(detailsObject.get(field))
53 }else if field.orange exists conf <= field.orange {
54 channel = orange
55 details.append(detailsObject.get(field))
56 }
57
58 if "channel" == "red":
59 return(channel, details);
60}
61
62
63if channel = "":
64 channel = "green"