@Test public void testExtractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest() throws Exception, Throwable { AdhocQueryResponse responseMock = mock(AdhocQueryResponse.class); String marshalledXmlStringMock = "marshalledXmlStringMock"; XdsbDocumentReference ref1 = new XdsbDocumentReference( "41421263015.98411.41414.91230.401390172014139", "1.3.6.1.4.1.21367.2010.1.2.1040"); XdsbDocumentReference ref2 = new XdsbDocumentReference( "1513150391310.11184.4632.11139.05080551281557", "1.3.6.1.4.1.21367.2010.1.2.1040"); when(marshallerMock.marshal(responseMock)).thenReturn( marshalledXmlStringMock); when(documentXmlConverterMock.loadDocument(marshalledXmlStringMock)) .thenReturn( documentXmlConverter.loadDocument(fileReader .readFile("adhocQueryResponseClinicalDocument.xml"))); RetrieveDocumentSetRequest actualResponse = xdsbRegistryAdapterSpy .extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(responseMock); assertTrue(actualResponse.getDocumentRequest().contains(ref1)); assertTrue(actualResponse.getDocumentRequest().contains(ref2)); }
public RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest( AdhocQueryResponse adhocQueryResponse) throws XdsbRegistryAdapterException { String adhocQueryResponseXmlString; try { 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(); RetrieveDocumentSetRequest retrieveDocumentSetRequest = new RetrieveDocumentSetRequest(); List<DocumentRequest> documentRequestList = retrieveDocumentSetRequest .getDocumentRequest(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); documentRequestList.add(xdsbDocumentReference); } return retrieveDocumentSetRequest; } catch (SimpleMarshallerException | DocumentXmlConverterException e) { throw new XdsbRegistryAdapterException(e); } }
XdsbRegistryAdapter { public RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest( AdhocQueryResponse adhocQueryResponse) throws XdsbRegistryAdapterException { String adhocQueryResponseXmlString; try { 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(); RetrieveDocumentSetRequest retrieveDocumentSetRequest = new RetrieveDocumentSetRequest(); List<DocumentRequest> documentRequestList = retrieveDocumentSetRequest .getDocumentRequest(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); documentRequestList.add(xdsbDocumentReference); } return retrieveDocumentSetRequest; } catch (SimpleMarshallerException | DocumentXmlConverterException e) { throw new XdsbRegistryAdapterException(e); } } }
XdsbRegistryAdapter { public RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest( AdhocQueryResponse adhocQueryResponse) throws XdsbRegistryAdapterException { String adhocQueryResponseXmlString; try { 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(); RetrieveDocumentSetRequest retrieveDocumentSetRequest = new RetrieveDocumentSetRequest(); List<DocumentRequest> documentRequestList = retrieveDocumentSetRequest .getDocumentRequest(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); documentRequestList.add(xdsbDocumentReference); } return retrieveDocumentSetRequest; } catch (SimpleMarshallerException | DocumentXmlConverterException e) { throw new XdsbRegistryAdapterException(e); } } XdsbRegistryAdapter(XdsbRegistryWebServiceClient xdsbRegistry,
			AdhocQueryResponseFilter responseFilter,
			SimpleMarshaller marshaller,
			DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); }
XdsbRegistryAdapter { public RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest( AdhocQueryResponse adhocQueryResponse) throws XdsbRegistryAdapterException { String adhocQueryResponseXmlString; try { 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(); RetrieveDocumentSetRequest retrieveDocumentSetRequest = new RetrieveDocumentSetRequest(); List<DocumentRequest> documentRequestList = retrieveDocumentSetRequest .getDocumentRequest(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); documentRequestList.add(xdsbDocumentReference); } return retrieveDocumentSetRequest; } catch (SimpleMarshallerException | DocumentXmlConverterException e) { throw new XdsbRegistryAdapterException(e); } } 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); }
XdsbRegistryAdapter { public RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest( AdhocQueryResponse adhocQueryResponse) throws XdsbRegistryAdapterException { String adhocQueryResponseXmlString; try { 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(); RetrieveDocumentSetRequest retrieveDocumentSetRequest = new RetrieveDocumentSetRequest(); List<DocumentRequest> documentRequestList = retrieveDocumentSetRequest .getDocumentRequest(); for (Integer key : keys) { XdsbDocumentReference xdsbDocumentReference = new XdsbDocumentReference( documentUniqueIdMap.get(key), repositoryUniqueIdMap.get(key)); documentRequestList.add(xdsbDocumentReference); } return retrieveDocumentSetRequest; } catch (SimpleMarshallerException | DocumentXmlConverterException e) { throw new XdsbRegistryAdapterException(e); } } 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; }