View Javadoc
1   /*
2    * Copyright 2015 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.hl7v2.audit.iti10;
17  
18  import ca.uhn.hl7v2.model.Message;
19  import org.openehealth.ipf.commons.audit.AuditContext;
20  import org.openehealth.ipf.commons.audit.codes.EventActionCode;
21  import org.openehealth.ipf.commons.audit.model.AuditMessage;
22  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategySupport;
23  import org.openehealth.ipf.commons.ihe.core.atna.event.PatientRecordEventBuilder;
24  import org.openehealth.ipf.commons.ihe.hl7v2.audit.codes.MllpEventTypeCode;
25  import org.openehealth.ipf.commons.ihe.hl7v2.audit.QueryAuditDataset;
26  
27  import java.util.Map;
28  
29  public class Iti10AuditStrategy extends AuditStrategySupport<QueryAuditDataset> {
30  
31      public Iti10AuditStrategy(boolean serverSide) {
32          super(serverSide);
33      }
34  
35      @Override
36      public QueryAuditDataset createAuditDataset() {
37          return new QueryAuditDataset(isServerSide());
38      }
39  
40      @Override
41      public QueryAuditDataset enrichAuditDatasetFromRequest(QueryAuditDataset auditDataset, Object msg, Map<String, Object> parameters) {
42          Iti10AuditStrategyUtils.enrichAuditDatasetFromRequest(auditDataset, (Message) msg);
43          return auditDataset;
44      }
45  
46      @Override
47      public AuditMessage[] makeAuditMessage(AuditContext auditContext, QueryAuditDataset auditDataset) {
48          return new PatientRecordEventBuilder(
49                  auditContext,
50                  auditDataset,
51                  isServerSide() ? EventActionCode.Update : EventActionCode.Read,
52                  MllpEventTypeCode.PIXUpdateNotification)
53  
54                  // Type=MSH-10 (the literal string), Value=the value of MSH-10 (from the message content, base64 encoded)
55                  .addPatients("MSH-10", auditDataset.getMessageControlId(), auditDataset.getPatientIds())
56                  .getMessages();
57  
58      }
59  
60  
61  }