1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
SaisieCREnLigneForm saisieCREnLigneFormulaire = (SaisieCREnLigneForm) vSession.getAttribute("SaisieCREnLigneForm");
String vIdDocument = saisieCREnLigneFormulaire.getIdDocument();
ValeurGeneraleFonctionnalite vValeurFonc = (ValeurGeneraleFonctionnalite) vSession.getAttribute(IDefine.DROIT_ACCES_SESSION);
final DocumentDelegateInterface vServiceDocument = (DocumentDelegateInterface) DelegateFactory.getInstance().createService(DocumentDelegateInterface.DELEGATE_INTERFACE_KEY);
DocumentVO docVO = vServiceDocument.getDocById(vIdDocument);
if(docVO != null)
{
if(!docVO.getType().equals(vForm.getType())) {
String vDroitAccessTousDocLibres = vValeurFonc.getAutorisationFonct(IDefine.ACCES_TOUT_DOC_LIB);
final TypeDocumentDelegateInterface vServiceTypeDoc = (TypeDocumentDelegateInterface) DelegateFactory.getInstance().createService(TypeDocumentDelegateInterface.DELEGATE_INTERFACE_KEY);
TypeDocumentVO vTypeDocVO = vServiceTypeDoc.getTypeDocumentVO(vForm.getType());
if (vTypeDocVO == null) {
sLogger.error("PostSaisieCREnLigneAction Type manquant -> forward erreur");
return retourneAvecErreur("","erreur.typeNonRenseigne",pRequest,pMapping,"erreurDocLibre");
} else {
if (IDefine.CODE_FLAG_TYPE_DOC_ACCES_TOUS_NON.equals(vTypeDocVO.getAccesTous())) {
if (!IDefine.AUTORISATION_OK.equals(vDroitAccessTousDocLibres)) {
sLogger.error("PostSaisieCREnLigneAction Droit insuffisant pour ce type -> forward erreur");
return retourneAvecErreur("","erreur.creationDoc",pRequest,pMapping,"erreurDocLibre");
}
}
if (IDefine.FLAG_LIAISON_PATIENT.equals(vTypeDocVO.getFlagLiaison()) || IDefine.FLAG_LIAISON_PATIENT_ET_VENUE.equals(vTypeDocVO.getFlagLiaison())) {
DocumentVO vTmpDocVO = vServiceDoc.getNotdeletedCurrentDocumentVOByType(vForm.getType(), vListEvtForm.getNip());
if (vTmpDocVO != null) {
pRequest.setAttribute(IDefine.DOC_EXISTANT_AVEC_TYPE_NON_LIE, vTmpDocVO);
return retourneAvecErreur("","warning.modifImpossible",pRequest,pMapping,"erreurDocLibre");
} else {
final EvenementDelegateInterface vServiceEvt = (EvenementDelegateInterface) DelegateFactory.getInstance().createService(EvenementDelegateInterface.DELEGATE_INTERFACE_KEY);
boolean bDroit = vServiceEvt.canCreateDocLibre(vValeurFonc);
if (!bDroit) {
return retourneAvecErreur("","erreur.droitsCreationDocLibre",pRequest,pMapping,"erreurDocLibre");
}
}
}
}
}
} |
Partager