PixOperationsServiceImpl implements PixOperationsService { @SuppressWarnings("unchecked") protected void getQueryMessage(PRPAIN201310UV02 response, PixManagerBean pixMgrBean) { logger.debug("response ack code:" + response.getAcceptAckCode()); logger.debug("response type id: " + response.getTypeId()); final JXPathContext context = JXPathContext.newContext(response); final Iterator<MCCIMT000300UV01Acknowledgement> ackmntList = context .iterate("/acknowledgement"); while (ackmntList.hasNext()) { final MCCIMT000300UV01Acknowledgement ackmnt = ackmntList.next(); if (ackmnt.getTypeCode().getCode().equals("AA")) { final StringBuffer queryMsg = new StringBuffer( "Query Success! "); final Map<String, String> idMap = new HashMap<String, String>(); final Iterator<PRPAMT201307UV02PatientIdentifier> pidList = context .iterate("/controlActProcess/queryByParameter/value/parameterList/patientIdentifier"); while (pidList.hasNext()) { final PRPAMT201307UV02PatientIdentifier pid = pidList .next(); final List<II> ptIdList = pid.getValue(); for (final II ptId : ptIdList) { queryMsg.append(" Given PID: " + ptId.getExtension()); queryMsg.append(" Given UID: " + ptId.getRoot()); queryMsg.append("\t"); } } final Iterator<II> ptIdList = context .iterate("/controlActProcess/subject[1]/registrationEvent/subject1[typeCode='SBJ']/patient[classCode='PAT']/id"); while (ptIdList.hasNext()) { final II pId = ptIdList.next(); idMap.put(pId.getRoot(), pId.getExtension()); } pixMgrBean.setQueryMessage(queryMsg.toString()); pixMgrBean.setQueryIdMap(idMap); break; } else if (ackmnt.getTypeCode().getCode().equals("AE")) { final List<MCCIMT000300UV01AcknowledgementDetail> ackmntDetList = ackmnt .getAcknowledgementDetail(); for (final MCCIMT000300UV01AcknowledgementDetail ackDet : ackmntDetList) { logger.error("Query Failure! " + ackDet.getText().getContent()); pixMgrBean.setQueryMessage("Query Failure! " + ackDet.getText().getContent()); pixMgrBean.setQueryIdMap(null); break; } } else { pixMgrBean.setQueryMessage("Query Failure! "); pixMgrBean.setQueryIdMap(null); } } }  @Override MCCIIN000002UV01 addPatientRegistryRecord(String c32xml); @Override String addPerson(String reqXMLPath); SimpleMarshaller getMarshaller(); XdsbRepositoryService getXdsbRepository(); XmlAttributeSetter getXmlAttributeSetter(); @Override RegistryResponse provideAndRegisterClinicalDocument(String c32xml); @Override PixManagerBean queryPerson(String xmlFilePath); @Override MCCIIN000002UV01 revisePatientRegistryRecord(String c32xml); void setMarshaller(SimpleMarshaller marshaller); void setPixManagerTransformService(
			PixManagerTransformService pixManagerTransformService); void setPixMgrService(PixManagerService pixMgrService); void setRequestXMLToJava(PixManagerRequestXMLToJava requestXMLToJava); void setXdsbRegistryGetter(XdsbRegistryGetter xdsbRegistryGetter); void setXdsbRepository(XdsbRepositoryService xdsbRepository); void setXmlAttributeSetter(XmlAttributeSetter xmlAttributeSetter); @Override String updatePatientAndAuthorId(String c32xml); @Override String updatePerson(String reqXMLPath);  }
@Test public void testGetQueryMessage() throws JAXBException { final PRPAIN201310UV02 pRPAIN201310UV02 = (PRPAIN201310UV02) getPIXResObject( "xml/QuerySample_PRPA_IN201310UV02.xml", PixManagerConstants.ENCODE_STRING); final PixManagerBean pixManagerBean = new PixManagerBean(); sut.getQueryMessage(pRPAIN201310UV02, pixManagerBean); assertTrue("Actual query message " + pixManagerBean.getQueryMessage(), pixManagerBean.getQueryMessage().startsWith("Query Success! ")); }
@Test public void testGetQueryMessage_error() throws JAXBException { final PRPAIN201310UV02 pRPAIN201310UV02 = (PRPAIN201310UV02) getPIXResObject( "xml/QuerySampleError_PRPA_IN201310UV02.xml", PixManagerConstants.ENCODE_STRING); final PixManagerBean pixManagerBean = new PixManagerBean(); sut.getQueryMessage(pRPAIN201310UV02, pixManagerBean); assertTrue("Actual query message " + pixManagerBean.getQueryMessage(), pixManagerBean.getQueryMessage().startsWith("Query Failure! ")); }
@Test public void testGetQueryMessage_errorcode() throws JAXBException { final PRPAIN201310UV02 pRPAIN201310UV02 = (PRPAIN201310UV02) getPIXResObject( "xml/QuerySampleErrorCode_PRPA_IN201310UV02.xml", PixManagerConstants.ENCODE_STRING); final PixManagerBean pixManagerBean = new PixManagerBean(); sut.getQueryMessage(pRPAIN201310UV02, pixManagerBean); assertTrue("Actual query message " + pixManagerBean.getQueryMessage(), pixManagerBean.getQueryMessage().startsWith("Query Failure! ")); }