View Javadoc
1   package ca.uhn.fhir.jpa.term;
2   
3   /*
4    * #%L
5    * HAPI FHIR JPA Server
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.hl7.fhir.r4.model.BooleanType;
24  import org.hl7.fhir.r4.model.Parameters;
25  import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
26  import org.hl7.fhir.r4.model.StringType;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  public class TranslationResult {
32  	private List<TranslationMatch> myMatches;
33  	private StringType myMessage;
34  	private BooleanType myResult;
35  
36  	public TranslationResult() {
37  		super();
38  
39  		myMatches = new ArrayList<>();
40  	}
41  
42  	public List<TranslationMatch> getMatches() {
43  		return myMatches;
44  	}
45  
46  	public void setMatches(List<TranslationMatch> theMatches) {
47  		myMatches = theMatches;
48  	}
49  
50  	public boolean addMatch(TranslationMatch theMatch) {
51  		return myMatches.add(theMatch);
52  	}
53  
54  	public StringType getMessage() {
55  		return myMessage;
56  	}
57  
58  	public void setMessage(StringType theMessage) {
59  		myMessage = theMessage;
60  	}
61  
62  	public BooleanType getResult() {
63  		return myResult;
64  	}
65  
66  	public void setResult(BooleanType theMatched) {
67  		myResult = theMatched;
68  	}
69  
70  	public Parameters toParameters() {
71  		Parameters retVal = new Parameters();
72  
73  		if (myResult != null) {
74  			retVal.addParameter().setName("result").setValue(myResult);
75  		}
76  
77  		if (myMessage != null) {
78  			retVal.addParameter().setName("message").setValue(myMessage);
79  		}
80  
81  		for (TranslationMatch translationMatch : myMatches) {
82  			ParametersParameterComponent matchParam = retVal.addParameter().setName("match");
83  			translationMatch.toParameterParts(matchParam);
84  		}
85  
86  		return retVal;
87  	}
88  }