use of se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson in project webcert by sklintyg.
the class NotificationServiceImplTest method createFragaSvar.
private FragaSvar createFragaSvar() {
FragaSvar fs = new FragaSvar();
fs.setAmne(Amne.OVRIGT);
fs.setSistaDatumForSvar(LocalDate.of(2018, 12, 12));
fs.setInternReferens(FRAGASVAR_ID);
fs.setIntygsReferens(new IntygsReferens());
fs.getIntygsReferens().setIntygsId(INTYG_ID);
fs.getIntygsReferens().setIntygsTyp(INTYG_TYP_FK);
fs.setVardperson(new Vardperson());
fs.getVardperson().setEnhetsId(ENHET_ID);
fs.getVardperson().setEnhetsnamn(ENHET_NAMN);
fs.getVardperson().setHsaId(SIGNED_BY_HSA_ID);
return fs;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson in project webcert by sklintyg.
the class FragaSvarServiceImpl method saveNewQuestion.
@Override
public FragaSvar saveNewQuestion(String intygId, String typ, Amne amne, String frageText) {
// Argument check
if (Strings.isNullOrEmpty(frageText)) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "frageText cannot be empty!");
}
if (amne == null) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Amne cannot be null!");
} else if (!VALID_VARD_AMNEN.contains(amne)) {
// Businessrule RE-013
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Invalid Amne " + amne + " for new question from vard!");
}
// Fetch from Intygstjansten. Note that if Intygstjansten is unresponsive, the Intyg will be loaded from WebCert
// if possible.
IntygContentHolder intyg = intygService.fetchIntygData(intygId, typ, false);
WebCertUser user = webCertUserService.getUser();
// Get vardperson that posed the question
// Is user authorized to save an answer to this question?
verifyEnhetsAuth(intyg.getUtlatande().getGrundData().getSkapadAv().getVardenhet().getEnhetsid(), false);
// Verksamhetsregel FS-001 (Is the certificate sent to FK)
if (!isCertificateSentToFK(intyg.getStatuses())) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "FS-001: Certificate must be sent to FK first before sending question!");
}
// Verify that certificate is not revoked
if (intyg.isRevoked()) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "FS-XXX: Cannot save Fraga when certificate is revoked!");
}
IntygsReferens intygsReferens = FragaSvarConverter.convertToIntygsReferens(intyg.getUtlatande());
HoSPersonal hoSPersonal = IntygConverterUtil.buildHosPersonalFromWebCertUser(user, null);
Vardperson vardPerson = FragaSvarConverter.convert(hoSPersonal);
FragaSvar fraga = new FragaSvar();
fraga.setFrageStallare(FrageStallare.WEBCERT.getKod());
fraga.setAmne(amne);
fraga.setFrageText(frageText);
LocalDateTime now = LocalDateTime.now();
fraga.setFrageSkickadDatum(now);
fraga.setFrageSigneringsDatum(now);
fraga.setIntygsReferens(intygsReferens);
fraga.setVardperson(vardPerson);
fraga.setStatus(Status.PENDING_EXTERNAL_ACTION);
fraga.setVardAktorHsaId(user.getHsaId());
fraga.setVardAktorNamn(user.getNamn());
// Ok, lets save the question
FragaSvar saved = fragaSvarRepository.save(fraga);
// Send to external party (FK)
SendMedicalCertificateQuestionType sendType = new SendMedicalCertificateQuestionType();
QuestionToFkType question = FKQuestionConverter.convert(saved);
// Remove ASAP.
if ("true".equalsIgnoreCase(forceFullstandigtNamn)) {
question.getLakarutlatande().getPatient().setFullstandigtNamn("---");
}
sendType.setQuestion(question);
AttributedURIType logicalAddress = new AttributedURIType();
logicalAddress.setValue(sendQuestionToFkLogicalAddress);
SendMedicalCertificateQuestionResponseType response;
try {
response = sendQuestionToFKClient.sendMedicalCertificateQuestion(logicalAddress, sendType);
} catch (SOAPFaultException e) {
LOGGER.error("Failed to send question to FK, error was: " + e.getMessage());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getMessage());
}
if (!response.getResult().getResultCode().equals(ResultCodeEnum.OK)) {
LOGGER.error("Failed to send question to FK, result was " + response.getResult().toString());
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, response.getResult().getErrorText());
}
monitoringService.logQuestionSent(saved.getExternReferens(), saved.getInternReferens(), (saved.getIntygsReferens() == null) ? null : saved.getIntygsReferens().getIntygsId(), saved.getVardAktorHsaId(), saved.getAmne());
// Notify stakeholders
sendNotification(saved, NotificationEvent.NEW_QUESTION_FROM_CARE);
arendeDraftService.delete(intygId, null);
return saved;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson in project webcert by sklintyg.
the class FragaSvarRepositoryTest method buildFragaSvarFraga.
private FragaSvar buildFragaSvarFraga(String enhetsId, Status status, String hsaid, String hsaNamn) {
FragaSvar f = new FragaSvar();
f.setExternaKontakter(new HashSet<>(Arrays.asList("KONTAKT1", "KONTAKT2", "KONTAKT3")));
f.setAmne(Amne.AVSTAMNINGSMOTE);
f.setExternReferens("externReferens");
f.setFrageSigneringsDatum(FRAGA_SIGN_DATE);
f.setFrageSkickadDatum(FRAGA_SENT_DATE);
f.setFrageStallare("Olle");
Vardperson vardperson = new Vardperson();
vardperson.setEnhetsId(enhetsId);
vardperson.setEnhetsnamn(enhetsId + "-namnet");
vardperson.setHsaId(hsaid);
vardperson.setNamn(hsaNamn);
f.setVardperson(vardperson);
f.setFrageText("Detta var ju otydligt formulerat!");
f.setIntygsReferens(INTYGS_REFERENS);
f.setStatus(status);
return f;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson in project webcert by sklintyg.
the class FragaSvarRepositoryTest method buildFragaSvarFraga.
private FragaSvar buildFragaSvarFraga(String enhetsId, Status status, String frageStallare, boolean answered) {
FragaSvar f = new FragaSvar();
f.setExternaKontakter(new HashSet<>(Arrays.asList("KONTAKT1", "KONTAKT2", "KONTAKT3")));
f.setAmne(Amne.AVSTAMNINGSMOTE);
f.setExternReferens("externReferens");
f.setFrageSigneringsDatum(FRAGA_SIGN_DATE);
f.setFrageSkickadDatum(FRAGA_SENT_DATE);
f.setFrageStallare(frageStallare);
Vardperson vardperson = new Vardperson();
vardperson.setEnhetsId(enhetsId);
vardperson.setEnhetsnamn(enhetsId + "-namnet");
f.setVardperson(vardperson);
f.setFrageText("Detta var ju otydligt formulerat!");
f.setIntygsReferens(INTYGS_REFERENS);
f.setStatus(status);
if (answered) {
f.setSvarsText("Ett svar på frågan");
}
return f;
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.Vardperson in project webcert by sklintyg.
the class FragaSvarServiceImplTest method buildFraga.
private FragaSvar buildFraga(Long id, String frageText, Amne amne, LocalDateTime fragaSkickadDatum) {
FragaSvar f = new FragaSvar();
f.setStatus(Status.PENDING_INTERNAL_ACTION);
f.setAmne(amne);
f.setExternReferens("<fk-extern-referens>");
f.setInternReferens(id);
f.setFrageSkickadDatum(fragaSkickadDatum);
f.setFrageText(frageText);
f.setVardAktorHsaId("vardaktor-hsa-id");
IntygsReferens intygsReferens = new IntygsReferens();
intygsReferens.setIntygsId(INTYG_ID);
intygsReferens.setIntygsTyp("fk7263");
intygsReferens.setPatientId(PNR);
f.setIntygsReferens(intygsReferens);
f.setKompletteringar(new HashSet<>());
f.setVardperson(new Vardperson());
f.getVardperson().setEnhetsId("enhet");
return f;
}
Aggregations