XdsbRegistryAdapter { public List<XdsbDocumentReference> extractXdsbDocumentReferenceList( AdhocQueryResponse adhocQueryResponse) throws Exception, Throwable { String adhocQueryResponseXmlString = marshaller .marshal(adhocQueryResponse); Document doc = documentXmlConverter .loadDocument(adhocQueryResponseXmlString); NodeList extrinsicObjects = doc.getElementsByTagName("ExtrinsicObject"); Map<Integer, String> documentUniqueIdMap = new HashMap<Integer, String>(); Map<Integer, String> repositoryUniqueIdMap = new HashMap<Integer, String>(); for (int i = 0; i < extrinsicObjects.getLength(); i++) { Node extrinsicObject = extrinsicObjects.item(i); NodeList extrinsicObjectItems = extrinsicObject.getChildNodes(); for (int j = 0; j < extrinsicObjectItems.getLength(); j++) { Node extrinsicObjectItem = extrinsicObjectItems.item(j); if ("ExternalIdentifier".equals(extrinsicObjectItem .getNodeName()) && UUID_XDS_DOCUMENTENTRY_UNIQUEID .equals(extrinsicObjectItem.getAttributes() .getNamedItem("identificationScheme") .getNodeValue())) { documentUniqueIdMap.put(i, extrinsicObjectItem .getAttributes().getNamedItem("value") .getNodeValue()); } if ("Slot".equals(extrinsicObjectItem.getNodeName()) && "repositoryUniqueId".equals(extrinsicObjectItem .getAttributes().getNamedItem("name") .getNodeValue())) { repositoryUniqueIdMap.put(i, extrinsicObjectItem .getChildNodes().item(0).getChildNodes().item(0) .getTextContent()); } } } Set<Integer> keys = documentUniqueIdMap.keySet(); List<XdsbDocumentReference> repositoryAndDocumentUniqueIdList = new LinkedList<XdsbDocumentReference>(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); repositoryAndDocumentUniqueIdList.add(xdsbDocumentReference); } return repositoryAndDocumentUniqueIdList; } XdsbRegistryAdapter(XdsbRegistryWebServiceClient xdsbRegistry,
			AdhocQueryResponseFilter responseFilter,
			SimpleMarshaller marshaller,
			DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); AdhocQueryResponse registryStoredQuery(
			AdhocQueryRequest adhocQueryRequest); AdhocQueryResponse registryStoredQuery(String patientId,
			String domainId, String authorId,
			XdsbDocumentType xdsbDocumentType, boolean serviceTimeAware,
			String messageId); AdhocQueryResponse registryStoredQuery(String patientUniqueId,
			String authorNPI, XdsbDocumentType xdsbDocumentType,
			boolean serviceTimeAware, String messageId); AdhocQueryResponse registryStoredQuery(AdhocQueryRequest req,
			String authorNPI, String messageId); List<String> findDeprecatedDocumentUniqueIds(
			String submissionSetPatientId, String submissionSetAuthorPerson,
			String messageId); AdhocQueryResponse findSubmissionSets(String submissionSetPatientId,
			String submissionSetAuthorPerson); AdhocQueryResponse getSubmissionSetAndContents(
			String submissionSetUniqueId, String messageId); List<String> extractSubmissionSetUniqueIds(
			AdhocQueryResponse response); String extractDeprecatedDocumentUniqueId(
			AdhocQueryResponse response, String messageId); List<XdsbDocumentReference> extractXdsbDocumentReferenceList(
			AdhocQueryResponse adhocQueryResponse); RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(
			AdhocQueryResponse adhocQueryResponse); String extractPatientId(AdhocQueryRequest req); String extractFormatCode(AdhocQueryRequest req); String extractResponseOptionReturnType(AdhocQueryRequest req); String extractDocumentEntryStatus(AdhocQueryRequest req); String getPatientUniqueId(String patientId, String domainId); static final String FORMAT_CODE_CLINICAL_DOCUMENT; static final String FORMAT_CODE_PRIVACY_CONSENT; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_FORMAT_CODE; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_PATIENT_ID; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_STATUS; static final String UUID_XDS_DOCUMENTENTRY; static final String UUID_XDS_DOCUMENTENTRY_UNIQUEID; static final String UUID_XDS_DOCUMENTENTRY_AUTHOR; static final String UUID_XDS_SUBMISSION_SET_UNIQUEID; }
@Test public void testExtractXdsbDocumentReferenceList_Given_AdhocQueryResponse_ClinicalDocument() throws Exception, Throwable { XdsbDocumentReference xdsbDocumentReference1 = new XdsbDocumentReference( "41421263015.98411.41414.91230.401390172014139", "1.3.6.1.4.1.21367.2010.1.2.1040"); XdsbDocumentReference xdsbDocumentReference2 = new XdsbDocumentReference( "1513150391310.11184.4632.11139.05080551281557", "1.3.6.1.4.1.21367.2010.1.2.1040"); String adhocQueryResponseString = fileReader .readFile("adhocQueryResponseClinicalDocument.xml"); AdhocQueryResponse adhocQueryResponse = marshaller.unmarshalFromXml( AdhocQueryResponse.class, adhocQueryResponseString); when(marshallerMock.marshal(adhocQueryResponse)).thenReturn( adhocQueryResponseString); Document doc = documentXmlConverter .loadDocument(adhocQueryResponseString); when(documentXmlConverterMock.loadDocument(adhocQueryResponseString)) .thenReturn(doc); List<XdsbDocumentReference> list = xdsbRegistryAdapterSpy .extractXdsbDocumentReferenceList(adhocQueryResponse); assertEquals(2, list.size()); assertTrue(list.contains(xdsbDocumentReference1)); assertTrue(list.contains(xdsbDocumentReference2)); }
@Test public void testExtractXdsbDocumentReferenceList_Given_AdhocQueryResponse_PrivacyConsent() throws Exception, Throwable { XdsbDocumentReference xdsbDocumentReference1 = new XdsbDocumentReference( "2931513224.111050.43108.1114145.628015389614413", "1.3.6.1.4.1.21367.2010.1.2.1040"); XdsbDocumentReference xdsbDocumentReference2 = new XdsbDocumentReference( "12132124715.97915.410413.87115.61142312711102135", "1.3.6.1.4.1.21367.2010.1.2.1040"); String adhocQueryResponseString = fileReader .readFile("adhocQueryResponsePrivacyConsent.xml"); AdhocQueryResponse adhocQueryResponse = marshaller.unmarshalFromXml( AdhocQueryResponse.class, adhocQueryResponseString); when(marshallerMock.marshal(adhocQueryResponse)).thenReturn( adhocQueryResponseString); Document doc = documentXmlConverter .loadDocument(adhocQueryResponseString); when(documentXmlConverterMock.loadDocument(adhocQueryResponseString)) .thenReturn(doc); List<XdsbDocumentReference> list = xdsbRegistryAdapterSpy .extractXdsbDocumentReferenceList(adhocQueryResponse); assertEquals(2, list.size()); assertTrue(list.contains(xdsbDocumentReference1)); assertTrue(list.contains(xdsbDocumentReference2)); }