use of se.inera.intyg.common.support.modules.support.api.dto.CreateNewDraftHolder in project webcert by sklintyg.
the class UtkastServiceImpl method createNewDraft.
@Override
public Utkast createNewDraft(CreateNewDraftRequest request) {
populateRequestWithIntygId(request);
request.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
String intygType = request.getIntygType();
CreateNewDraftHolder draftRequest = createModuleRequest(request);
String intygJsonModel = getPopulatedModelFromIntygModule(intygType, draftRequest);
Utkast savedUtkast = persistNewDraft(request, intygJsonModel);
// Persist the referens if supplied
if (!Strings.isNullOrEmpty(request.getReferens())) {
referensService.saveReferens(request.getIntygId(), request.getReferens());
}
monitoringService.logUtkastCreated(savedUtkast.getIntygsId(), savedUtkast.getIntygsTyp(), savedUtkast.getEnhetsId(), savedUtkast.getSkapadAv().getHsaId());
// Notify stakeholders when a draft has been created
sendNotification(savedUtkast, Event.CREATED);
// Create a PDL log for this action
LogUser logUser = createLogUser(request);
logCreateDraftPDL(savedUtkast, logUser);
return savedUtkast;
}
Aggregations