1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 |
|
---|
6 | package gov.hhs.fha.nhinc.transform.audit;
|
---|
7 |
|
---|
8 | import org.apache.commons.logging.Log;
|
---|
9 | import org.apache.commons.logging.LogFactory;
|
---|
10 |
|
---|
11 | import com.services.nhinc.schema.auditmessage.AuditMessageType;
|
---|
12 | import com.services.nhinc.schema.auditmessage.AuditSourceIdentificationType;
|
---|
13 | import com.services.nhinc.schema.auditmessage.EventIdentificationType;
|
---|
14 | import com.services.nhinc.schema.auditmessage.ParticipantObjectIdentificationType;
|
---|
15 |
|
---|
16 | import gov.hhs.fha.nhinc.common.nhinccommon.HomeCommunityType;
|
---|
17 | import gov.hhs.fha.nhinc.common.nhinccommon.PersonNameType;
|
---|
18 | import gov.hhs.fha.nhinc.common.auditlog.LogDocRetrieveRequestType;
|
---|
19 | import gov.hhs.fha.nhinc.common.auditlog.DocRetrieveMessageType;
|
---|
20 | import gov.hhs.fha.nhinc.common.auditlog.LogDocRetrieveResultRequestType;
|
---|
21 | import gov.hhs.fha.nhinc.common.auditlog.DocRetrieveResponseMessageType;
|
---|
22 | import gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;
|
---|
23 | import gov.hhs.fha.nhinc.common.auditlog.LogEventRequestType;
|
---|
24 |
|
---|
25 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType;
|
---|
26 | import ihe.iti.xds_b._2007.RetrieveDocumentSetResponseType;
|
---|
27 | import ihe.iti.xds_b._2007.RetrieveDocumentSetRequestType.DocumentRequest;
|
---|
28 | import oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType;
|
---|
29 |
|
---|
30 | import org.junit.After;
|
---|
31 | import org.junit.AfterClass;
|
---|
32 | import org.junit.Before;
|
---|
33 | import org.junit.BeforeClass;
|
---|
34 | import org.junit.Test;
|
---|
35 | import static org.junit.Assert.*;
|
---|
36 | import gov.hhs.fha.nhinc.common.nhinccommon.UserType;
|
---|
37 |
|
---|
38 | /**
|
---|
39 | *
|
---|
40 | * @author mflynn02
|
---|
41 | */
|
---|
42 | public class DocumentRetrieveTransformsTest {
|
---|
43 | private static Log log = LogFactory.getLog(DocumentRetrieveTransformsTest.class);
|
---|
44 |
|
---|
45 | public DocumentRetrieveTransformsTest() {
|
---|
46 | }
|
---|
47 |
|
---|
48 | @BeforeClass
|
---|
49 | public static void setUpClass() throws Exception {
|
---|
50 | }
|
---|
51 |
|
---|
52 | @AfterClass
|
---|
53 | public static void tearDownClass() throws Exception {
|
---|
54 | }
|
---|
55 |
|
---|
56 | @Before
|
---|
57 | public void setUp() {
|
---|
58 | }
|
---|
59 |
|
---|
60 | @After
|
---|
61 | public void tearDown() {
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Test of transformDocRetrieveReq2AuditMsg method, of class DocumentRetrieveTransforms.
|
---|
66 | */
|
---|
67 | @Test
|
---|
68 | public void testTransformDocRetrieveReq2AuditMsg() {
|
---|
69 | log.debug("Begin - testTransformDocRetrieveReq2AuditMsg");
|
---|
70 | LogDocRetrieveRequestType logMessage = new LogDocRetrieveRequestType();
|
---|
71 | DocRetrieveMessageType docReqMessage = new DocRetrieveMessageType();
|
---|
72 | AssertionType assertion = new AssertionType();
|
---|
73 |
|
---|
74 | RetrieveDocumentSetRequestType message = new RetrieveDocumentSetRequestType();
|
---|
75 | DocumentRequest docReq = new DocumentRequest();
|
---|
76 | docReq.setDocumentUniqueId("123-45-6789");
|
---|
77 | docReq.setHomeCommunityId("2.16.840.1.113883.3.200");
|
---|
78 | message.getDocumentRequest().add(docReq);
|
---|
79 |
|
---|
80 | UserType userInfo = new UserType();
|
---|
81 | HomeCommunityType home = new HomeCommunityType();
|
---|
82 | home.setHomeCommunityId("2.16.840.1.113883.3.200");
|
---|
83 | home.setName("Federal - VA");
|
---|
84 | userInfo.setOrg(home);
|
---|
85 | PersonNameType person = new PersonNameType();
|
---|
86 | person.setFamilyName("Presley");
|
---|
87 | person.setGivenName("Elvis");
|
---|
88 | userInfo.setPersonName(person);
|
---|
89 | assertion.setUserInfo(userInfo);
|
---|
90 |
|
---|
91 | docReqMessage.setAssertion(assertion);
|
---|
92 | docReqMessage.setRetrieveDocumentSetRequest(message);
|
---|
93 | logMessage.setMessage(docReqMessage);
|
---|
94 |
|
---|
95 | AuditData auditData = new AuditData();
|
---|
96 | auditData.setReceiverPatientId("999999");
|
---|
97 | auditData.setMessageType("RetrieveDocumentSetRequest");
|
---|
98 |
|
---|
99 | AuditMessageType expResult = new AuditMessageType();
|
---|
100 |
|
---|
101 | AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant();
|
---|
102 | participant.setUserName(person.getGivenName() + " " + person.getFamilyName());
|
---|
103 | expResult.getActiveParticipant().add(participant);
|
---|
104 | AuditSourceIdentificationType sourceId = new AuditSourceIdentificationType();
|
---|
105 | sourceId.setAuditEnterpriseSiteID(home.getName());
|
---|
106 | expResult.getAuditSourceIdentification().add(sourceId);
|
---|
107 | ParticipantObjectIdentificationType partObjId = new ParticipantObjectIdentificationType();
|
---|
108 | partObjId.setParticipantObjectID(auditData.getReceiverPatientId() + "^^^&" + home.getHomeCommunityId() + "&ISO");
|
---|
109 | expResult.getParticipantObjectIdentification().add(partObjId);
|
---|
110 | EventIdentificationType eventId = new EventIdentificationType();
|
---|
111 | eventId.setEventActionCode(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_DOC);
|
---|
112 | expResult.setEventIdentification(eventId);
|
---|
113 | LogEventRequestType expected = new LogEventRequestType();
|
---|
114 | expected.setAuditMessage(expResult);
|
---|
115 | LogEventRequestType result = DocumentRetrieveTransforms.transformDocRetrieveReq2AuditMsg(logMessage);
|
---|
116 |
|
---|
117 | assertEquals(expected.getAuditMessage().getActiveParticipant().get(0).getUserName(), result.getAuditMessage().getActiveParticipant().get(0).getUserName());
|
---|
118 | assertEquals(expected.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID(), result.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID());
|
---|
119 | assertEquals(expected.getAuditMessage().getEventIdentification().getEventActionCode(), result.getAuditMessage().getEventIdentification().getEventID().getCode());
|
---|
120 |
|
---|
121 | log.debug("Begin - testTransformDocRetrieveReq2AuditMsg");
|
---|
122 | }
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Test of transformDocRetrieveResp2AuditMsg method, of class DocumentRetrieveTransforms.
|
---|
126 | */
|
---|
127 | @Test
|
---|
128 | public void testTransformDocRetrieveResp2AuditMsg() {
|
---|
129 | log.debug("Begin - testTransformDocRetrieveResp2AuditMsg");
|
---|
130 |
|
---|
131 | LogDocRetrieveResultRequestType logMessage = new LogDocRetrieveResultRequestType();
|
---|
132 | DocRetrieveResponseMessageType docRespMessage = new DocRetrieveResponseMessageType();
|
---|
133 | AssertionType assertion = new AssertionType();
|
---|
134 |
|
---|
135 | RetrieveDocumentSetResponseType message = new RetrieveDocumentSetResponseType();
|
---|
136 | DocumentRequest docReq = new DocumentRequest();
|
---|
137 | docReq.setDocumentUniqueId("987-06543-021");
|
---|
138 | docReq.setHomeCommunityId("2.16.840.1.113883.3.166.4");
|
---|
139 | RegistryResponseType resp = new RegistryResponseType();
|
---|
140 | resp.setStatus("DocRetrieve Response Status");
|
---|
141 | message.setRegistryResponse(resp);
|
---|
142 |
|
---|
143 | UserType userInfo = new UserType();
|
---|
144 | HomeCommunityType home = new HomeCommunityType();
|
---|
145 | home.setHomeCommunityId("2.16.840.1.113883.3.166.4");
|
---|
146 | home.setName("CareSpark");
|
---|
147 | userInfo.setOrg(home);
|
---|
148 | PersonNameType person = new PersonNameType();
|
---|
149 | person.setFamilyName("Jackson");
|
---|
150 | person.setGivenName("Andrew");
|
---|
151 | userInfo.setPersonName(person);
|
---|
152 | assertion.setUserInfo(userInfo);
|
---|
153 |
|
---|
154 | docRespMessage.setAssertion(assertion);
|
---|
155 | docRespMessage.setRetrieveDocumentSetResponse(message);
|
---|
156 | logMessage.setMessage(docRespMessage);
|
---|
157 |
|
---|
158 | AuditData auditData = new AuditData();
|
---|
159 | auditData.setReceiverPatientId("78987");
|
---|
160 | auditData.setMessageType("RetrieveDocumentSetResponse");
|
---|
161 |
|
---|
162 | AuditMessageType expResult = new AuditMessageType();
|
---|
163 | AuditMessageType.ActiveParticipant participant = new AuditMessageType.ActiveParticipant();
|
---|
164 | participant.setUserName(person.getGivenName() + " " + person.getFamilyName());
|
---|
165 | expResult.getActiveParticipant().add(participant);
|
---|
166 | AuditSourceIdentificationType sourceId = new AuditSourceIdentificationType();
|
---|
167 | sourceId.setAuditEnterpriseSiteID(home.getName());
|
---|
168 | expResult.getAuditSourceIdentification().add(sourceId);
|
---|
169 | ParticipantObjectIdentificationType partObjId = new ParticipantObjectIdentificationType();
|
---|
170 | partObjId.setParticipantObjectID(auditData.getReceiverPatientId() + "^^^&" + home.getHomeCommunityId() + "&ISO");
|
---|
171 | expResult.getParticipantObjectIdentification().add(partObjId);
|
---|
172 | EventIdentificationType eventId = new EventIdentificationType();
|
---|
173 | eventId.setEventActionCode(AuditDataTransformConstants.EVENT_ID_CODE_SYS_NAME_DOC);
|
---|
174 | expResult.setEventIdentification(eventId);
|
---|
175 | LogEventRequestType expected = new LogEventRequestType();
|
---|
176 | expected.setAuditMessage(expResult);
|
---|
177 |
|
---|
178 | LogEventRequestType result = DocumentRetrieveTransforms.transformDocRetrieveResp2AuditMsg(logMessage);
|
---|
179 |
|
---|
180 | assertEquals(expected.getAuditMessage().getActiveParticipant().get(0).getUserName(), result.getAuditMessage().getActiveParticipant().get(0).getUserName());
|
---|
181 | assertEquals(expected.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID(), result.getAuditMessage().getAuditSourceIdentification().get(0).getAuditEnterpriseSiteID());
|
---|
182 | assertEquals(expected.getAuditMessage().getEventIdentification().getEventActionCode(), result.getAuditMessage().getEventIdentification().getEventID().getCode());
|
---|
183 |
|
---|
184 | log.debug("End - testTransformDocRetrieveResp2AuditMsg");
|
---|
185 | }
|
---|
186 |
|
---|
187 | }
|
---|