public void setResourceId(Long resourceId) {
this.resourceId = resourceId;
}
public List<FMPatient> getPatientList(String hrn) {
Resource resource = null;
EntityManager em = PersistenceService.getInstance().getEntityManager();
try {
resource = em.find(Resource.class, resourceId);
} catch (NoResultException ex) {
logger.warn(ex);
}
// TODO: Why are credentials a list
logger.debug("hrn " + hrn);
logger.debug(resource.getResourceLocationPath());
logger.debug(resource.getResourceCredentials().get(0).getUsername());
logger.debug(resource.getResourceNamespace());
logger.debug(resource.getResourceLocalPart());
long startTime, endTime;
startTime = System.currentTimeMillis();
PhrCcrService service = null;
QName qName = null;
try {
service = new PhrCcrService(
new URL(resource.getResourceLocationPath()),
new QName(resource.getResourceNamespace(), resource.getResourceLocalPart())
);
} catch (MalformedURLException ex) {
logger.warn(ex);
}
// boolean response = false;
// try {
// ((BindingProvider) serviceProxy).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
// response = serviceProxy.ccrServiceLogin(
// resource.getResourceCredentials().get(0).getUsername(),
// resource.getResourceCredentials().get(0).getPassword()
// );
// logger.debug("login response:" + response);
// } catch (AuthenticationServiceException_Exception ex) {
// logger.debug(ex);
// }
endTime = System.currentTimeMillis();
logger.debug("Time to login:" + (endTime - startTime) + " milliseconds");
try {
CCRServiceSoap serviceProxy = service.getCCRServiceSoap();
startTime = System.currentTimeMillis();
// Christopher says pick a number between 1 and 50000
// `100 is a "programmers trick" to get by DFN
// so this will fetch record for IEN=100, not by the ID
// if you put in 100, you will get a list of records where the ID starts with 100
List<FMPatient> patients = serviceProxy.lookupPatientsByID(resource.getResourceCredentials().get(0).getUsername(), resource.getResourceCredentials().get(0).getPassword(), hrn);
if (patients == null) {
return Collections.EMPTY_LIST;
}