-
Notifications
You must be signed in to change notification settings - Fork 9
/
HPV.py
58 lines (53 loc) · 1.95 KB
/
HPV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
import pyDMNrules
if __name__ == '__main__':
dmnRules = pyDMNrules.DMN()
status = dmnRules.load('ExampleHPV.xlsx')
if 'errors' in status:
print('ExampleHPV.xlsx has errors', status['errors'])
sys.exit(0)
else:
print('ExampleHPV.xlsx loaded')
data = {}
data['Participant Age'] = 36
data['In Test of Cure'] = True
data['Hysterectomy Flag'] = False
data['Cancer Flag'] = False
data['HPV-V'] = 'V0'
data['Current Participant Risk Category'] = 'low'
print('Testing',repr(data))
(status, newData) = dmnRules.decide(data)
print('Decision(newData)',repr(newData))
print()
print(newData.keys())
for key in newData.keys():
if isinstance(newData[key], dict):
print('\t', key, newData[key].keys())
if 'errors' in status:
print('With errors', status['errors'])
print()
(testStatus, results) = dmnRules.test()
for test in range(len(results)):
if 'Mismatches' not in results[test]:
print('Test ID', results[test]['Test ID'], 'passed')
else:
print('Test ID', results[test]['Test ID'], 'failed')
for failure in range(len(results[test]['Mismatches'])):
print(results[test]['Mismatches'][failure])
print(results[test]['DataAnnotations'])
print(results[test]['TestAnnotations'])
print(results[test]['data'])
print(results[test]['newData'])
if len(testStatus) > 0:
print('with errors', repr(testStatus))
sys.exit(0)
# Report the structure of results
print()
print(results[0].keys())
for key in results[0].keys():
if isinstance(results[0][key], dict):
print('\t', key, results[0][key].keys())
for subKey in results[0][key].keys():
if isinstance(results[0][key][subKey], dict):
print('\t', '\t', subKey, results[0][key][subKey].keys())
sys.exit(1)