@Test public void testGetPatientIdsQueryWithDfn() { when(mockRpcResponse.toLinesList()). thenReturn(toLinesList("1008520438V882204^NI^USVHA^200M\r\n852043888^NI^USDOD^200DOD^A\r\n")); String vistaId = "9E7A"; String pid = "9E7A;7168937"; PatientIds patientIds = vistaPatientIdentityService.getPatientIdentifiers(vistaId, pid); assertNotNull(patientIds); assertThat(patientIds.getDfn(), is("7168937")); assertThat(patientIds.getIcn(), is("1008520438V882204")); assertThat(patientIds.getEdipi(), is("852043888")); assertThat(patientIds.getUid(), is("urn:va:patient:9E7A:7168937:1008520438V882204")); assertThat(patientIds.getPid(), is(pid)); }
@Override public PatientIds getPatientIdentifiers(String vistaId, String pid) { if (StringUtils.isBlank(vistaId)) throw new IllegalArgumentException("vistaId is blank"); if (StringUtils.isBlank(pid)) throw new IllegalArgumentException("pid is blank"); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers({}, {}) -- Entering method", vistaId, pid); List<VistaAccount> vistaAccounts = vistaAccountDao.findAllByVistaId(vistaId); if (vistaAccounts == null || vistaAccounts.isEmpty()) throw new PatientIdentityException("Cannot find a Vista Accounts associated with vistaId: " + vistaId); String siteCode = vistaAccounts.get(0).getDivision(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - siteCode: {}", siteCode); String rpcParams, uid = null, dfn = null, icn = null, edipi = null; if (pid.contains(";")) { dfn = pid.substring(pid.indexOf(";")+1, pid.length()); rpcParams = dfn + "^PI^USVHA^" + siteCode; } else { icn = pid; rpcParams = icn + "^NI^USVHA^200M"; } String uri = VISTA_RPC_BROKER_SCHEME + ": LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - VistA RPC Broker URI: {} ; RPC params: {}", uri, rpcParams); RpcRequest request = new RpcRequest(uri, rpcParams); request.setTimeout(TIMEOUT_SECONDS); List<String> lines = synchronizationRpcTemplate.execute(request).toLinesList(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - RPC Response: {}", lines); for(String line : lines) { String[] pieces = line.split("\\^"); String id = pieces.length > PIECE_IDX_ID ? pieces[PIECE_IDX_ID] : null; String idType = pieces.length > PIECE_IDX_IDTYPE ? pieces[PIECE_IDX_IDTYPE] : null; String idStatus = pieces.length > PIECE_IDX_IDSTATUS ? pieces[PIECE_IDX_IDSTATUS] : null; String assigningAuthority = pieces.length > PIECE_IDX_ASSIGNING_AUTHORITY ? pieces[PIECE_IDX_ASSIGNING_AUTHORITY] : null; if (StringUtils.isNotBlank(id)) { if ("PI".equals(idType) && "USVHA".equals(assigningAuthority)) { if(StringUtils.isBlank(dfn)) dfn = id; else if ("A".equals(idStatus)) dfn = id; } else if ("NI".equals(idType) && "USVHA".equals(assigningAuthority)) { if (StringUtils.isBlank(icn)) icn = id; else if ("A".equals(idStatus)) icn = id; } else if ("NI".equals(idType) && "USDOD".equals(assigningAuthority)) { if (StringUtils.isBlank(edipi)) edipi = id; else if ("A".equals(idStatus)) edipi = id; } } } if (StringUtils.isNotBlank(dfn)) { uid = "urn:va:patient:"+vistaId+":"+ dfn +":"+ (icn != null ? icn : dfn); } PatientIds patientIds = new PatientIds.Builder() .pid(pid) .dfn(dfn) .edipi(edipi) .icn(icn) .uid(uid) .build(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers -- Leaving method. PatientIds: {}", patientIds); return patientIds; }
VistaPatientIdentityService implements IPatientIdentityService { @Override public PatientIds getPatientIdentifiers(String vistaId, String pid) { if (StringUtils.isBlank(vistaId)) throw new IllegalArgumentException("vistaId is blank"); if (StringUtils.isBlank(pid)) throw new IllegalArgumentException("pid is blank"); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers({}, {}) -- Entering method", vistaId, pid); List<VistaAccount> vistaAccounts = vistaAccountDao.findAllByVistaId(vistaId); if (vistaAccounts == null || vistaAccounts.isEmpty()) throw new PatientIdentityException("Cannot find a Vista Accounts associated with vistaId: " + vistaId); String siteCode = vistaAccounts.get(0).getDivision(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - siteCode: {}", siteCode); String rpcParams, uid = null, dfn = null, icn = null, edipi = null; if (pid.contains(";")) { dfn = pid.substring(pid.indexOf(";")+1, pid.length()); rpcParams = dfn + "^PI^USVHA^" + siteCode; } else { icn = pid; rpcParams = icn + "^NI^USVHA^200M"; } String uri = VISTA_RPC_BROKER_SCHEME + ": LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - VistA RPC Broker URI: {} ; RPC params: {}", uri, rpcParams); RpcRequest request = new RpcRequest(uri, rpcParams); request.setTimeout(TIMEOUT_SECONDS); List<String> lines = synchronizationRpcTemplate.execute(request).toLinesList(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - RPC Response: {}", lines); for(String line : lines) { String[] pieces = line.split("\\^"); String id = pieces.length > PIECE_IDX_ID ? pieces[PIECE_IDX_ID] : null; String idType = pieces.length > PIECE_IDX_IDTYPE ? pieces[PIECE_IDX_IDTYPE] : null; String idStatus = pieces.length > PIECE_IDX_IDSTATUS ? pieces[PIECE_IDX_IDSTATUS] : null; String assigningAuthority = pieces.length > PIECE_IDX_ASSIGNING_AUTHORITY ? pieces[PIECE_IDX_ASSIGNING_AUTHORITY] : null; if (StringUtils.isNotBlank(id)) { if ("PI".equals(idType) && "USVHA".equals(assigningAuthority)) { if(StringUtils.isBlank(dfn)) dfn = id; else if ("A".equals(idStatus)) dfn = id; } else if ("NI".equals(idType) && "USVHA".equals(assigningAuthority)) { if (StringUtils.isBlank(icn)) icn = id; else if ("A".equals(idStatus)) icn = id; } else if ("NI".equals(idType) && "USDOD".equals(assigningAuthority)) { if (StringUtils.isBlank(edipi)) edipi = id; else if ("A".equals(idStatus)) edipi = id; } } } if (StringUtils.isNotBlank(dfn)) { uid = "urn:va:patient:"+vistaId+":"+ dfn +":"+ (icn != null ? icn : dfn); } PatientIds patientIds = new PatientIds.Builder() .pid(pid) .dfn(dfn) .edipi(edipi) .icn(icn) .uid(uid) .build(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers -- Leaving method. PatientIds: {}", patientIds); return patientIds; } }
VistaPatientIdentityService implements IPatientIdentityService { @Override public PatientIds getPatientIdentifiers(String vistaId, String pid) { if (StringUtils.isBlank(vistaId)) throw new IllegalArgumentException("vistaId is blank"); if (StringUtils.isBlank(pid)) throw new IllegalArgumentException("pid is blank"); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers({}, {}) -- Entering method", vistaId, pid); List<VistaAccount> vistaAccounts = vistaAccountDao.findAllByVistaId(vistaId); if (vistaAccounts == null || vistaAccounts.isEmpty()) throw new PatientIdentityException("Cannot find a Vista Accounts associated with vistaId: " + vistaId); String siteCode = vistaAccounts.get(0).getDivision(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - siteCode: {}", siteCode); String rpcParams, uid = null, dfn = null, icn = null, edipi = null; if (pid.contains(";")) { dfn = pid.substring(pid.indexOf(";")+1, pid.length()); rpcParams = dfn + "^PI^USVHA^" + siteCode; } else { icn = pid; rpcParams = icn + "^NI^USVHA^200M"; } String uri = VISTA_RPC_BROKER_SCHEME + ": LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - VistA RPC Broker URI: {} ; RPC params: {}", uri, rpcParams); RpcRequest request = new RpcRequest(uri, rpcParams); request.setTimeout(TIMEOUT_SECONDS); List<String> lines = synchronizationRpcTemplate.execute(request).toLinesList(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - RPC Response: {}", lines); for(String line : lines) { String[] pieces = line.split("\\^"); String id = pieces.length > PIECE_IDX_ID ? pieces[PIECE_IDX_ID] : null; String idType = pieces.length > PIECE_IDX_IDTYPE ? pieces[PIECE_IDX_IDTYPE] : null; String idStatus = pieces.length > PIECE_IDX_IDSTATUS ? pieces[PIECE_IDX_IDSTATUS] : null; String assigningAuthority = pieces.length > PIECE_IDX_ASSIGNING_AUTHORITY ? pieces[PIECE_IDX_ASSIGNING_AUTHORITY] : null; if (StringUtils.isNotBlank(id)) { if ("PI".equals(idType) && "USVHA".equals(assigningAuthority)) { if(StringUtils.isBlank(dfn)) dfn = id; else if ("A".equals(idStatus)) dfn = id; } else if ("NI".equals(idType) && "USVHA".equals(assigningAuthority)) { if (StringUtils.isBlank(icn)) icn = id; else if ("A".equals(idStatus)) icn = id; } else if ("NI".equals(idType) && "USDOD".equals(assigningAuthority)) { if (StringUtils.isBlank(edipi)) edipi = id; else if ("A".equals(idStatus)) edipi = id; } } } if (StringUtils.isNotBlank(dfn)) { uid = "urn:va:patient:"+vistaId+":"+ dfn +":"+ (icn != null ? icn : dfn); } PatientIds patientIds = new PatientIds.Builder() .pid(pid) .dfn(dfn) .edipi(edipi) .icn(icn) .uid(uid) .build(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers -- Leaving method. PatientIds: {}", patientIds); return patientIds; }  }
VistaPatientIdentityService implements IPatientIdentityService { @Override public PatientIds getPatientIdentifiers(String vistaId, String pid) { if (StringUtils.isBlank(vistaId)) throw new IllegalArgumentException("vistaId is blank"); if (StringUtils.isBlank(pid)) throw new IllegalArgumentException("pid is blank"); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers({}, {}) -- Entering method", vistaId, pid); List<VistaAccount> vistaAccounts = vistaAccountDao.findAllByVistaId(vistaId); if (vistaAccounts == null || vistaAccounts.isEmpty()) throw new PatientIdentityException("Cannot find a Vista Accounts associated with vistaId: " + vistaId); String siteCode = vistaAccounts.get(0).getDivision(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - siteCode: {}", siteCode); String rpcParams, uid = null, dfn = null, icn = null, edipi = null; if (pid.contains(";")) { dfn = pid.substring(pid.indexOf(";")+1, pid.length()); rpcParams = dfn + "^PI^USVHA^" + siteCode; } else { icn = pid; rpcParams = icn + "^NI^USVHA^200M"; } String uri = VISTA_RPC_BROKER_SCHEME + ": LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - VistA RPC Broker URI: {} ; RPC params: {}", uri, rpcParams); RpcRequest request = new RpcRequest(uri, rpcParams); request.setTimeout(TIMEOUT_SECONDS); List<String> lines = synchronizationRpcTemplate.execute(request).toLinesList(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - RPC Response: {}", lines); for(String line : lines) { String[] pieces = line.split("\\^"); String id = pieces.length > PIECE_IDX_ID ? pieces[PIECE_IDX_ID] : null; String idType = pieces.length > PIECE_IDX_IDTYPE ? pieces[PIECE_IDX_IDTYPE] : null; String idStatus = pieces.length > PIECE_IDX_IDSTATUS ? pieces[PIECE_IDX_IDSTATUS] : null; String assigningAuthority = pieces.length > PIECE_IDX_ASSIGNING_AUTHORITY ? pieces[PIECE_IDX_ASSIGNING_AUTHORITY] : null; if (StringUtils.isNotBlank(id)) { if ("PI".equals(idType) && "USVHA".equals(assigningAuthority)) { if(StringUtils.isBlank(dfn)) dfn = id; else if ("A".equals(idStatus)) dfn = id; } else if ("NI".equals(idType) && "USVHA".equals(assigningAuthority)) { if (StringUtils.isBlank(icn)) icn = id; else if ("A".equals(idStatus)) icn = id; } else if ("NI".equals(idType) && "USDOD".equals(assigningAuthority)) { if (StringUtils.isBlank(edipi)) edipi = id; else if ("A".equals(idStatus)) edipi = id; } } } if (StringUtils.isNotBlank(dfn)) { uid = "urn:va:patient:"+vistaId+":"+ dfn +":"+ (icn != null ? icn : dfn); } PatientIds patientIds = new PatientIds.Builder() .pid(pid) .dfn(dfn) .edipi(edipi) .icn(icn) .uid(uid) .build(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers -- Leaving method. PatientIds: {}", patientIds); return patientIds; }  @Autowired void setSynchronizationRpcTemplate(RpcOperations synchronizationRpcTemplate); @Autowired void setVistaAccountDao(IVistaAccountDao vistaAccountDao); @Override PatientIds getPatientIdentifiers(String vistaId, String pid); }
VistaPatientIdentityService implements IPatientIdentityService { @Override public PatientIds getPatientIdentifiers(String vistaId, String pid) { if (StringUtils.isBlank(vistaId)) throw new IllegalArgumentException("vistaId is blank"); if (StringUtils.isBlank(pid)) throw new IllegalArgumentException("pid is blank"); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers({}, {}) -- Entering method", vistaId, pid); List<VistaAccount> vistaAccounts = vistaAccountDao.findAllByVistaId(vistaId); if (vistaAccounts == null || vistaAccounts.isEmpty()) throw new PatientIdentityException("Cannot find a Vista Accounts associated with vistaId: " + vistaId); String siteCode = vistaAccounts.get(0).getDivision(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - siteCode: {}", siteCode); String rpcParams, uid = null, dfn = null, icn = null, edipi = null; if (pid.contains(";")) { dfn = pid.substring(pid.indexOf(";")+1, pid.length()); rpcParams = dfn + "^PI^USVHA^" + siteCode; } else { icn = pid; rpcParams = icn + "^NI^USVHA^200M"; } String uri = VISTA_RPC_BROKER_SCHEME + ": LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - VistA RPC Broker URI: {} ; RPC params: {}", uri, rpcParams); RpcRequest request = new RpcRequest(uri, rpcParams); request.setTimeout(TIMEOUT_SECONDS); List<String> lines = synchronizationRpcTemplate.execute(request).toLinesList(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers - RPC Response: {}", lines); for(String line : lines) { String[] pieces = line.split("\\^"); String id = pieces.length > PIECE_IDX_ID ? pieces[PIECE_IDX_ID] : null; String idType = pieces.length > PIECE_IDX_IDTYPE ? pieces[PIECE_IDX_IDTYPE] : null; String idStatus = pieces.length > PIECE_IDX_IDSTATUS ? pieces[PIECE_IDX_IDSTATUS] : null; String assigningAuthority = pieces.length > PIECE_IDX_ASSIGNING_AUTHORITY ? pieces[PIECE_IDX_ASSIGNING_AUTHORITY] : null; if (StringUtils.isNotBlank(id)) { if ("PI".equals(idType) && "USVHA".equals(assigningAuthority)) { if(StringUtils.isBlank(dfn)) dfn = id; else if ("A".equals(idStatus)) dfn = id; } else if ("NI".equals(idType) && "USVHA".equals(assigningAuthority)) { if (StringUtils.isBlank(icn)) icn = id; else if ("A".equals(idStatus)) icn = id; } else if ("NI".equals(idType) && "USDOD".equals(assigningAuthority)) { if (StringUtils.isBlank(edipi)) edipi = id; else if ("A".equals(idStatus)) edipi = id; } } } if (StringUtils.isNotBlank(dfn)) { uid = "urn:va:patient:"+vistaId+":"+ dfn +":"+ (icn != null ? icn : dfn); } PatientIds patientIds = new PatientIds.Builder() .pid(pid) .dfn(dfn) .edipi(edipi) .icn(icn) .uid(uid) .build(); LOG.debug("VistaPatientIdentifiers::getPatientIdentifiers -- Leaving method. PatientIds: {}", patientIds); return patientIds; }  @Autowired void setSynchronizationRpcTemplate(RpcOperations synchronizationRpcTemplate); @Autowired void setVistaAccountDao(IVistaAccountDao vistaAccountDao); @Override PatientIds getPatientIdentifiers(String vistaId, String pid);  }