View Javadoc
1   /*
2    * Copyright 2018 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  
17  package org.openehealth.ipf.commons.ihe.fhir.audit.codes;
18  
19  import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
20  import lombok.Getter;
21  import org.openehealth.ipf.commons.audit.types.EnumeratedCodedValue;
22  import org.openehealth.ipf.commons.audit.types.EnumeratedValueSet;
23  import org.openehealth.ipf.commons.audit.types.EventType;
24  
25  /**
26   * @author Christian Ohr
27   */
28  public enum FhirEventTypeCode implements EventType, EnumeratedCodedValue<EventType> {
29  
30      ProvideDocumentBundle("ITI-65", "Provide Document Bundle"),
31      MobileDocumentManifestQuery("ITI-66", "Mobile Document Manifest Query"),
32      MobileDocumentReferenceQuery("ITI-67", "Mobile Document Reference Query"),
33      MobileDocumentRetrieval("ITI-68", "Mobile Document Retrieval"),
34      MobilePatientDemographicsQuery("ITI-78", "Mobile Patient Demographics Query"),
35      MobilePatientIdentifierCrossReferenceQuery("ITI-83", "Mobile Patient Identifier Cross-reference Query"),
36      MobileQueryExistingData("PCC-44", "Mobile Query Existing Data");
37  
38      @Getter
39      private EventType value;
40  
41      FhirEventTypeCode(String code, String displayName) {
42          this.value = EventType.of(code, "IHE Transactions", displayName);
43      }
44  
45      public static EventType fromRestOperationType(RestOperationTypeEnum operation) {
46          return fromRestOperationType(operation, null);
47      }
48  
49      public static EventType fromRestOperationType(RestOperationTypeEnum operation, String originalText) {
50          return EventType.of(
51                  operation.getCode(),
52                  "http://hl7.org/fhir/restful-interaction",
53                  originalText != null ? originalText : operation.getCode());
54      }
55  
56  }