@Test public void getSrsShouldLogShowPredictionIfPredictionIsIncluded() throws Exception { srsServiceUnderTest.getSrs(user, "intyg-id-123", "191212121212", "F438A", true, true, true, new ArrayList<SrsQuestionResponse>(), 15); verify(logService, times(1)).logShowPrediction(eq("191212121212"), eq("intyg-id-123")); }
@Override public SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode, boolean performRiskPrediction, boolean addMeasures, boolean addStatistics, List<SrsQuestionResponse> answers, Integer daysIntoSickLeave) throws InvalidPersonNummerException { LOG.debug("getSrs(user: [not logged], certificateId: {}, personalIdentificationNumber: [not logged], diagnosisCode: {}," + "performRiskPrediction: {}, addMeasures: {}, addStatistics: {}, answers: [not logged], daysIntoSickLeave: {})", certificateId, diagnosisCode, performRiskPrediction, addMeasures, addStatistics, daysIntoSickLeave); if (user == null) { throw new IllegalArgumentException("Missing user object"); } if (Strings.isNullOrEmpty(personalIdentificationNumber)) { throw new IllegalArgumentException("Missing personal identification number"); } if (Strings.isNullOrEmpty(diagnosisCode)) { throw new IllegalArgumentException("Missing diagnosis code"); } if (daysIntoSickLeave == null) { daysIntoSickLeave = 15; } Utdatafilter filter = buildResponseFilter(performRiskPrediction, addMeasures, addStatistics); List<SrsCertificate> extensionChain = getExtensionChain(certificateId); if (extensionChain.size() > 0) { extensionChain.get(0).setMainDiagnosisCode(diagnosisCode); } SrsResponse response = srsInfraService.getSrs(user, createPnr(personalIdentificationNumber), extensionChain, filter, answers, daysIntoSickLeave); response.getPredictions().forEach(p -> { if (p.getProbabilityOverLimit() != null) { logService.logShowPrediction(personalIdentificationNumber, p.getCertificateId()); } }); response.replaceExtensionChain(extensionChain); decorateWithDiagnosisDescription(response); return response; }
SrsServiceImpl implements SrsService { @Override public SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode, boolean performRiskPrediction, boolean addMeasures, boolean addStatistics, List<SrsQuestionResponse> answers, Integer daysIntoSickLeave) throws InvalidPersonNummerException { LOG.debug("getSrs(user: [not logged], certificateId: {}, personalIdentificationNumber: [not logged], diagnosisCode: {}," + "performRiskPrediction: {}, addMeasures: {}, addStatistics: {}, answers: [not logged], daysIntoSickLeave: {})", certificateId, diagnosisCode, performRiskPrediction, addMeasures, addStatistics, daysIntoSickLeave); if (user == null) { throw new IllegalArgumentException("Missing user object"); } if (Strings.isNullOrEmpty(personalIdentificationNumber)) { throw new IllegalArgumentException("Missing personal identification number"); } if (Strings.isNullOrEmpty(diagnosisCode)) { throw new IllegalArgumentException("Missing diagnosis code"); } if (daysIntoSickLeave == null) { daysIntoSickLeave = 15; } Utdatafilter filter = buildResponseFilter(performRiskPrediction, addMeasures, addStatistics); List<SrsCertificate> extensionChain = getExtensionChain(certificateId); if (extensionChain.size() > 0) { extensionChain.get(0).setMainDiagnosisCode(diagnosisCode); } SrsResponse response = srsInfraService.getSrs(user, createPnr(personalIdentificationNumber), extensionChain, filter, answers, daysIntoSickLeave); response.getPredictions().forEach(p -> { if (p.getProbabilityOverLimit() != null) { logService.logShowPrediction(personalIdentificationNumber, p.getCertificateId()); } }); response.replaceExtensionChain(extensionChain); decorateWithDiagnosisDescription(response); return response; } }
SrsServiceImpl implements SrsService { @Override public SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode, boolean performRiskPrediction, boolean addMeasures, boolean addStatistics, List<SrsQuestionResponse> answers, Integer daysIntoSickLeave) throws InvalidPersonNummerException { LOG.debug("getSrs(user: [not logged], certificateId: {}, personalIdentificationNumber: [not logged], diagnosisCode: {}," + "performRiskPrediction: {}, addMeasures: {}, addStatistics: {}, answers: [not logged], daysIntoSickLeave: {})", certificateId, diagnosisCode, performRiskPrediction, addMeasures, addStatistics, daysIntoSickLeave); if (user == null) { throw new IllegalArgumentException("Missing user object"); } if (Strings.isNullOrEmpty(personalIdentificationNumber)) { throw new IllegalArgumentException("Missing personal identification number"); } if (Strings.isNullOrEmpty(diagnosisCode)) { throw new IllegalArgumentException("Missing diagnosis code"); } if (daysIntoSickLeave == null) { daysIntoSickLeave = 15; } Utdatafilter filter = buildResponseFilter(performRiskPrediction, addMeasures, addStatistics); List<SrsCertificate> extensionChain = getExtensionChain(certificateId); if (extensionChain.size() > 0) { extensionChain.get(0).setMainDiagnosisCode(diagnosisCode); } SrsResponse response = srsInfraService.getSrs(user, createPnr(personalIdentificationNumber), extensionChain, filter, answers, daysIntoSickLeave); response.getPredictions().forEach(p -> { if (p.getProbabilityOverLimit() != null) { logService.logShowPrediction(personalIdentificationNumber, p.getCertificateId()); } }); response.replaceExtensionChain(extensionChain); decorateWithDiagnosisDescription(response); return response; }  }
SrsServiceImpl implements SrsService { @Override public SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode, boolean performRiskPrediction, boolean addMeasures, boolean addStatistics, List<SrsQuestionResponse> answers, Integer daysIntoSickLeave) throws InvalidPersonNummerException { LOG.debug("getSrs(user: [not logged], certificateId: {}, personalIdentificationNumber: [not logged], diagnosisCode: {}," + "performRiskPrediction: {}, addMeasures: {}, addStatistics: {}, answers: [not logged], daysIntoSickLeave: {})", certificateId, diagnosisCode, performRiskPrediction, addMeasures, addStatistics, daysIntoSickLeave); if (user == null) { throw new IllegalArgumentException("Missing user object"); } if (Strings.isNullOrEmpty(personalIdentificationNumber)) { throw new IllegalArgumentException("Missing personal identification number"); } if (Strings.isNullOrEmpty(diagnosisCode)) { throw new IllegalArgumentException("Missing diagnosis code"); } if (daysIntoSickLeave == null) { daysIntoSickLeave = 15; } Utdatafilter filter = buildResponseFilter(performRiskPrediction, addMeasures, addStatistics); List<SrsCertificate> extensionChain = getExtensionChain(certificateId); if (extensionChain.size() > 0) { extensionChain.get(0).setMainDiagnosisCode(diagnosisCode); } SrsResponse response = srsInfraService.getSrs(user, createPnr(personalIdentificationNumber), extensionChain, filter, answers, daysIntoSickLeave); response.getPredictions().forEach(p -> { if (p.getProbabilityOverLimit() != null) { logService.logShowPrediction(personalIdentificationNumber, p.getCertificateId()); } }); response.replaceExtensionChain(extensionChain); decorateWithDiagnosisDescription(response); return response; }  @Override SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode,
                              boolean performRiskPrediction, boolean addMeasures, boolean addStatistics,
                              List<SrsQuestionResponse> answers, Integer daysIntoSickLeave); @Override List<SrsQuestion> getQuestions(String diagnosisCode, String modelVersion); @Override Samtyckesstatus getConsent(String personalIdentityNumber, String careUnitHsaId); @Override ResultCodeEnum setConsent(String personalIdentificationNumber, String careUnitHsaId, boolean consent); @Override ResultCodeEnum setOwnOpinion(String personalIdentificationNumber, String careGiverHsaId, String careUnitHsaId,
                                        String certificateId, String diagnosisCode, String opinion); @Override List<String> getAllDiagnosisCodes(String modelVersion); @Override SrsForDiagnosisResponse getSrsForDiagnosis(String diagnosisCode); }
SrsServiceImpl implements SrsService { @Override public SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode, boolean performRiskPrediction, boolean addMeasures, boolean addStatistics, List<SrsQuestionResponse> answers, Integer daysIntoSickLeave) throws InvalidPersonNummerException { LOG.debug("getSrs(user: [not logged], certificateId: {}, personalIdentificationNumber: [not logged], diagnosisCode: {}," + "performRiskPrediction: {}, addMeasures: {}, addStatistics: {}, answers: [not logged], daysIntoSickLeave: {})", certificateId, diagnosisCode, performRiskPrediction, addMeasures, addStatistics, daysIntoSickLeave); if (user == null) { throw new IllegalArgumentException("Missing user object"); } if (Strings.isNullOrEmpty(personalIdentificationNumber)) { throw new IllegalArgumentException("Missing personal identification number"); } if (Strings.isNullOrEmpty(diagnosisCode)) { throw new IllegalArgumentException("Missing diagnosis code"); } if (daysIntoSickLeave == null) { daysIntoSickLeave = 15; } Utdatafilter filter = buildResponseFilter(performRiskPrediction, addMeasures, addStatistics); List<SrsCertificate> extensionChain = getExtensionChain(certificateId); if (extensionChain.size() > 0) { extensionChain.get(0).setMainDiagnosisCode(diagnosisCode); } SrsResponse response = srsInfraService.getSrs(user, createPnr(personalIdentificationNumber), extensionChain, filter, answers, daysIntoSickLeave); response.getPredictions().forEach(p -> { if (p.getProbabilityOverLimit() != null) { logService.logShowPrediction(personalIdentificationNumber, p.getCertificateId()); } }); response.replaceExtensionChain(extensionChain); decorateWithDiagnosisDescription(response); return response; }  @Override SrsResponse getSrs(WebCertUser user, String certificateId, String personalIdentificationNumber, String diagnosisCode,
                              boolean performRiskPrediction, boolean addMeasures, boolean addStatistics,
                              List<SrsQuestionResponse> answers, Integer daysIntoSickLeave); @Override List<SrsQuestion> getQuestions(String diagnosisCode, String modelVersion); @Override Samtyckesstatus getConsent(String personalIdentityNumber, String careUnitHsaId); @Override ResultCodeEnum setConsent(String personalIdentificationNumber, String careUnitHsaId, boolean consent); @Override ResultCodeEnum setOwnOpinion(String personalIdentificationNumber, String careGiverHsaId, String careUnitHsaId,
                                        String certificateId, String diagnosisCode, String opinion); @Override List<String> getAllDiagnosisCodes(String modelVersion); @Override SrsForDiagnosisResponse getSrsForDiagnosis(String diagnosisCode);  }