@Test public void testSearchDiagnosisByCodeKSH97P() { assertEquals(DiagnosResponseType.NOT_FOUND, service.searchDiagnosisByCode("A11", KSH97P, 1).getResultat()); DiagnosResponse res = service.searchDiagnosisByCode("A00-", KSH97P, 1); assertEquals(DiagnosResponseType.OK, res.getResultat()); assertFalse(res.getDiagnoser().isEmpty()); }
@Override public DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults) { Assert.isTrue(nbrOfResults + 1 > 1, "nbrOfResults must be larger that 0"); Diagnoskodverk codeSystem = getDiagnoskodverk(codeSystemStr); if (!validateDiagnosisCode(codeFragment, codeSystem)) { return DiagnosResponse.invalidCode(); } List<Diagnos> matches; switch (codeSystem) { case ICD_10_SE: matches = icd10seDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; case KSH_97_P: matches = ksh97pDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; default: LOG.warn("Unknown code system '{}'", codeSystem); return DiagnosResponse.invalidCodesystem(); } if (matches.isEmpty()) { return DiagnosResponse.notFound(); } if (matches.size() <= nbrOfResults) { return DiagnosResponse.ok(matches, false); } LOG.debug("Returning {} diagnosises out of a match of {}", nbrOfResults, matches.size()); return DiagnosResponse.ok(matches.subList(0, nbrOfResults), true); }
DiagnosServiceImpl implements DiagnosService { @Override public DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults) { Assert.isTrue(nbrOfResults + 1 > 1, "nbrOfResults must be larger that 0"); Diagnoskodverk codeSystem = getDiagnoskodverk(codeSystemStr); if (!validateDiagnosisCode(codeFragment, codeSystem)) { return DiagnosResponse.invalidCode(); } List<Diagnos> matches; switch (codeSystem) { case ICD_10_SE: matches = icd10seDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; case KSH_97_P: matches = ksh97pDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; default: LOG.warn("Unknown code system '{}'", codeSystem); return DiagnosResponse.invalidCodesystem(); } if (matches.isEmpty()) { return DiagnosResponse.notFound(); } if (matches.size() <= nbrOfResults) { return DiagnosResponse.ok(matches, false); } LOG.debug("Returning {} diagnosises out of a match of {}", nbrOfResults, matches.size()); return DiagnosResponse.ok(matches.subList(0, nbrOfResults), true); } }
DiagnosServiceImpl implements DiagnosService { @Override public DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults) { Assert.isTrue(nbrOfResults + 1 > 1, "nbrOfResults must be larger that 0"); Diagnoskodverk codeSystem = getDiagnoskodverk(codeSystemStr); if (!validateDiagnosisCode(codeFragment, codeSystem)) { return DiagnosResponse.invalidCode(); } List<Diagnos> matches; switch (codeSystem) { case ICD_10_SE: matches = icd10seDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; case KSH_97_P: matches = ksh97pDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; default: LOG.warn("Unknown code system '{}'", codeSystem); return DiagnosResponse.invalidCodesystem(); } if (matches.isEmpty()) { return DiagnosResponse.notFound(); } if (matches.size() <= nbrOfResults) { return DiagnosResponse.ok(matches, false); } LOG.debug("Returning {} diagnosises out of a match of {}", nbrOfResults, matches.size()); return DiagnosResponse.ok(matches.subList(0, nbrOfResults), true); }  }
DiagnosServiceImpl implements DiagnosService { @Override public DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults) { Assert.isTrue(nbrOfResults + 1 > 1, "nbrOfResults must be larger that 0"); Diagnoskodverk codeSystem = getDiagnoskodverk(codeSystemStr); if (!validateDiagnosisCode(codeFragment, codeSystem)) { return DiagnosResponse.invalidCode(); } List<Diagnos> matches; switch (codeSystem) { case ICD_10_SE: matches = icd10seDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; case KSH_97_P: matches = ksh97pDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; default: LOG.warn("Unknown code system '{}'", codeSystem); return DiagnosResponse.invalidCodesystem(); } if (matches.isEmpty()) { return DiagnosResponse.notFound(); } if (matches.size() <= nbrOfResults) { return DiagnosResponse.ok(matches, false); } LOG.debug("Returning {} diagnosises out of a match of {}", nbrOfResults, matches.size()); return DiagnosResponse.ok(matches.subList(0, nbrOfResults), true); }  @PostConstruct void initDiagnosRepository(); @Override DiagnosResponse getDiagnosisByCode(String code, String codeSystemStr); @Override DiagnosResponse getDiagnosisByCode(String code, Diagnoskodverk codeSystem); @Override DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults); @Override DiagnosResponse searchDiagnosisByDescription(String searchString, String codeSystemStr, int nbrOfResults); @Override boolean validateDiagnosisCode(String diagnosisCode, String codeSystemStr); }
DiagnosServiceImpl implements DiagnosService { @Override public DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults) { Assert.isTrue(nbrOfResults + 1 > 1, "nbrOfResults must be larger that 0"); Diagnoskodverk codeSystem = getDiagnoskodverk(codeSystemStr); if (!validateDiagnosisCode(codeFragment, codeSystem)) { return DiagnosResponse.invalidCode(); } List<Diagnos> matches; switch (codeSystem) { case ICD_10_SE: matches = icd10seDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; case KSH_97_P: matches = ksh97pDiagnosRepo.searchDiagnosisByCode(codeFragment, nbrOfResults + 1); break; default: LOG.warn("Unknown code system '{}'", codeSystem); return DiagnosResponse.invalidCodesystem(); } if (matches.isEmpty()) { return DiagnosResponse.notFound(); } if (matches.size() <= nbrOfResults) { return DiagnosResponse.ok(matches, false); } LOG.debug("Returning {} diagnosises out of a match of {}", nbrOfResults, matches.size()); return DiagnosResponse.ok(matches.subList(0, nbrOfResults), true); }  @PostConstruct void initDiagnosRepository(); @Override DiagnosResponse getDiagnosisByCode(String code, String codeSystemStr); @Override DiagnosResponse getDiagnosisByCode(String code, Diagnoskodverk codeSystem); @Override DiagnosResponse searchDiagnosisByCode(String codeFragment, String codeSystemStr, int nbrOfResults); @Override DiagnosResponse searchDiagnosisByDescription(String searchString, String codeSystemStr, int nbrOfResults); @Override boolean validateDiagnosisCode(String diagnosisCode, String codeSystemStr);  }