1 package ca.uhn.fhir.validation;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
24
25
26
27
28
29
30
31 public class ValidationResult {
32 private OperationOutcome myOperationOutcome;
33
34 private ValidationResult(OperationOutcome myOperationOutcome) {
35 this.myOperationOutcome = myOperationOutcome;
36 }
37
38 public static ValidationResult valueOf(OperationOutcome myOperationOutcome) {
39 return new ValidationResult(myOperationOutcome);
40 }
41
42 public OperationOutcome getOperationOutcome() {
43 return myOperationOutcome;
44 }
45
46 @Override
47 public String toString() {
48 return "ValidationResult{" +
49 "myOperationOutcome=" + myOperationOutcome +
50 ", description='" + toDescription() + '\'' +
51 '}';
52 }
53
54 private String toDescription() {
55 StringBuilder b = new StringBuilder(100);
56 if (myOperationOutcome != null) {
57 OperationOutcome.Issue issueFirstRep = myOperationOutcome.getIssueFirstRep();
58 b.append(issueFirstRep.getDetails().getValue());
59 b.append(" - ");
60 b.append(issueFirstRep.getLocationFirstRep().getValue());
61 }
62 return b.toString();
63 }
64
65
66
67
68
69 public boolean isSuccessful() {
70 return myOperationOutcome == null || myOperationOutcome.getIssue().isEmpty();
71 }
72 }