View Javadoc
1   /*
2    * Copyright 2009 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.metadata;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.Setter;
21  import lombok.ToString;
22  import org.openehealth.ipf.commons.ihe.xds.core.metadata.jaxbadapters.PatientInfoAdapter;
23  import org.openehealth.ipf.commons.ihe.xds.core.metadata.jaxbadapters.PatientInfoXml;
24  
25  import javax.xml.bind.annotation.*;
26  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
27  import java.io.Serializable;
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * Represents an XDS document entry according to the IHE XDS specification.
33   * <p>
34   * All non-list members of this class are allowed to be <code>null</code>.
35   * The lists are pre-created and can therefore never be <code>null</code>.
36   * 
37   * @author Jens Riemschneider
38   */
39  @XmlAccessorType(XmlAccessType.FIELD)
40  @XmlType(name = "DocumentEntry", propOrder = {
41          "sourcePatientId", "sourcePatientInfo", "creationTime", "authors", "legalAuthenticator", "serviceStartTime",
42          "serviceStopTime", "classCode", "confidentialityCodes", "eventCodeList", "formatCode",
43          "healthcareFacilityTypeCode", "languageCode", "practiceSettingCode", "typeCode", "repositoryUniqueId",
44          "mimeType", "size", "hash", "uri", "type", "referenceIdList", "documentAvailability"})
45  @XmlRootElement(name = "documentEntry")
46  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
47  @ToString(callSuper = true, doNotUseGetters = true)
48  public class DocumentEntry extends XDSMetaClass implements Serializable {
49      private static final long serialVersionUID = -4779500440504776909L;
50      
51      @XmlElement(name = "author")
52      @Getter private final List<Author> authors = new ArrayList<>();
53      @Getter @Setter private Code classCode;
54      @XmlElement(name = "confidentialityCode")
55      @Getter private final List<Code> confidentialityCodes = new ArrayList<>();
56      @Getter private Timestamp creationTime;
57      @XmlElement(name = "eventCode")
58      @Getter private final List<Code> eventCodeList = new ArrayList<>();
59      @Getter @Setter private Code formatCode;
60      @Getter @Setter private String hash;
61      @Getter @Setter private Code healthcareFacilityTypeCode;
62      @Getter @Setter private String languageCode;
63      @Getter @Setter private Person legalAuthenticator;
64      @Getter @Setter private String mimeType;
65      @Getter @Setter private Code practiceSettingCode;
66      @Getter private Timestamp serviceStartTime;
67      @Getter private Timestamp serviceStopTime;
68      @Getter @Setter private Long size;
69      @Getter @Setter private Identifiable sourcePatientId;
70      @XmlJavaTypeAdapter(PatientInfoAdapter.class)
71      @XmlElement(name = "sourcePatientInfo", type = PatientInfoXml.class)
72      @Getter @Setter private PatientInfo sourcePatientInfo;
73      @Getter @Setter private Code typeCode;
74      @Getter @Setter private String uri;
75      @Getter @Setter private String repositoryUniqueId;
76      @Getter @Setter private DocumentEntryType type = DocumentEntryType.STABLE;
77      @Getter private List<ReferenceId> referenceIdList = new ArrayList<>();
78      @Getter @Setter private DocumentAvailability documentAvailability;
79  
80      /**
81       * @param author
82       *          the author of the document.
83       * @deprecated please add the author to the list returned by {@link #getAuthors()}
84       */
85      @Deprecated
86      public void setAuthor(Author author) {
87          authors.clear();
88          authors.add(author);
89      }
90  
91      /**
92       * @return the author of the document. If the document has multiple authors
93       *          this method returns only the first in the list. If the document
94       *          has no authors, this method returns {@code null}.
95       * @deprecated please iterate over the list returned by {@link #getAuthors()}
96       */
97      @Deprecated
98      public Author getAuthor() {
99          return authors.isEmpty() ? null : authors.get(0);
100     }
101 
102 
103     public void setCreationTime(Timestamp creationTime) {
104         this.creationTime = creationTime;
105     }
106 
107     public void setCreationTime(String creationTime) {
108         this.creationTime = Timestamp.fromHL7(creationTime);
109     }
110 
111     public void setServiceStartTime(Timestamp serviceStartTime) {
112         this.serviceStartTime = serviceStartTime;
113     }
114 
115     public void setServiceStartTime(String serviceStartTime) {
116         this.serviceStartTime = Timestamp.fromHL7(serviceStartTime);
117     }
118 
119     public void setServiceStopTime(Timestamp serviceStopTime) {
120         this.serviceStopTime = serviceStopTime;
121     }
122 
123     public void setServiceStopTime(String serviceStopTime) {
124         this.serviceStopTime = Timestamp.fromHL7(serviceStopTime);
125     }
126 
127 }