use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class IntygResource method deleteDraftsByPatient.
@DELETE
@Path("/patient/{patientId}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteDraftsByPatient(@PathParam("patientId") String patientId) {
Set<String> intygTyper = moduleRegistry.listAllModules().stream().map(IntygModule::getId).collect(Collectors.toSet());
List<Utkast> utkast = utkastRepository.findAllByPatientPersonnummerAndIntygsTypIn(patientId, intygTyper);
if (utkast != null) {
for (Utkast u : utkast) {
deleteDraftAndRelatedQAs(u);
}
}
return Response.ok().build();
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class IntygResource method updateUtkastForSign.
private void updateUtkastForSign(@PathParam("id") String id, String signeratAv) {
Utkast utkast = utkastRepository.findOne(id);
if (utkast != null) {
utkast.setStatus(UtkastStatus.SIGNED);
Signatur sig = new Signatur(LocalDateTime.now(), signeratAv != null ? signeratAv : "", id, "", "", "");
utkast.setSignatur(sig);
utkastRepository.save(utkast);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class CopyUtkastServiceImpl method checkIntegreradEnhet.
private void checkIntegreradEnhet(CopyUtkastBuilderResponse builderResponse) {
String orginalEnhetsId = builderResponse.getOrginalEnhetsId();
Utkast utkastCopy = builderResponse.getUtkastCopy();
IntegreradEnhetEntry newEntry = new IntegreradEnhetEntry(utkastCopy.getEnhetsId(), utkastCopy.getEnhetsNamn(), utkastCopy.getVardgivarId(), utkastCopy.getVardgivarNamn());
integreradeEnheterRegistry.addIfSameVardgivareButDifferentUnits(orginalEnhetsId, newEntry, utkastCopy.getIntygsTyp());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createReplacementCopy.
@Override
@Transactional("jpaTransactionManager")
public CreateReplacementCopyResponse createReplacementCopy(CreateReplacementCopyRequest replacementRequest) {
String originalIntygId = replacementRequest.getOriginalIntygId();
WebCertUser user = userService.getUser();
LOG.debug("Creating replacement copy of intyg '{}'", originalIntygId);
try {
if (intygService.isRevoked(replacementRequest.getOriginalIntygId(), replacementRequest.getTyp(), replacementRequest.isCoherentJournaling())) {
LOG.debug("Cannot create replacement certificate for id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Can not create replacement copy - Original certificate is revoked");
}
verifyNotReplaced(replacementRequest.getOriginalIntygId(), "create replacement");
verifyNotComplementedWithSigned(replacementRequest.getOriginalIntygId(), "create replacement");
CopyUtkastBuilderResponse builderResponse = buildReplacementUtkastBuilderResponse(replacementRequest, originalIntygId);
if (replacementRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedReplacement(savedUtkast.getIntygsId(), originalIntygId);
return new CreateReplacementCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createCompletion.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastService#createCopy(se.inera.intyg.webcert.web.service.utkast.
* dto.
* CreateNewDraftCopyRequest)
*/
@Override
public CreateCompletionCopyResponse createCompletion(CreateCompletionCopyRequest copyRequest) {
String originalIntygId = copyRequest.getOriginalIntygId();
LOG.debug("Creating completion to intyg '{}'", originalIntygId);
WebCertUser user = userService.getUser();
try {
if (intygService.isRevoked(copyRequest.getOriginalIntygId(), copyRequest.getTyp(), false)) {
LOG.debug("Cannot create completion copy of certificate with id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Original certificate is revoked");
}
CopyUtkastBuilderResponse builderResponse = buildCompletionUtkastBuilderResponse(copyRequest, originalIntygId, true);
if (copyRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedCompletion(savedUtkast.getIntygsId(), originalIntygId);
return new CreateCompletionCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
Aggregations