View Javadoc
1   /*
2    * Copyright 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query;
17  
18  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
19  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsForMultiplePatientsQuery;
20  
21  import static org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter.*;
22  
23  /**
24   * Transforms between a {@link FindDocumentsForMultiplePatientsQuery} and {@link EbXMLAdhocQueryRequest}.
25   * @author Michael Ottati
26   */
27  public class FindDocumentsForMultiplePatientsQueryTransformer extends DocumentsQueryTransformer<FindDocumentsForMultiplePatientsQuery> {
28  
29      @Override
30      public void toEbXML(FindDocumentsForMultiplePatientsQuery query, EbXMLAdhocQueryRequest ebXML) {
31          if (query == null || ebXML == null) {
32              return;
33          }
34  
35          super.toEbXML(query, ebXML);
36  
37          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
38          slots.fromPatientIdList(DOC_ENTRY_PATIENT_ID, query.getPatientIds());
39          slots.fromDocumentEntryType(DOC_ENTRY_TYPE, query.getDocumentEntryTypes());
40          slots.fromStatus(DOC_ENTRY_STATUS, query.getStatus());
41      }
42  
43  
44      public void fromEbXML(FindDocumentsForMultiplePatientsQuery query, EbXMLAdhocQueryRequest ebXML) {
45          if (query == null || ebXML == null) {
46              return;
47          }
48  
49          super.fromEbXML(query, ebXML);
50          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
51  
52          query.setPatientIds(slots.toPatientIdList(DOC_ENTRY_PATIENT_ID));
53          query.setDocumentEntryTypes(slots.toDocumentEntryType(DOC_ENTRY_TYPE));
54          query.setStatus(slots.toStatus(DOC_ENTRY_STATUS));
55      }
56  }