Pourquoi la conformité documentaire ?

Vous souhaitez comprendre les enjeux de la conformité documentaire ?
Cet article détaille les différentes fonctionnalités liées à la conformité documentaire mais également comment l’intégrer au sein de FlowerDocs.
Pourquoi la conformité documentaire ?

24/09/2020

Pour quels usages ?

Au sein d’un système de GED, on retrouve souvent le besoin de valider le contenu d’un document ajouté manuellement par un utilisateur tant en termes de type de document, de contexte métier ou encore de validité du document.
La conformité documentaire consiste à vérifier dès l’ajout d’un document, si son contenu est bien celui attendu, s’il est cohérent avec les données métier ou les autres documents fournis, et s’il est valide.


Les deux buts majeurs sont de pouvoir :

  • éviter les erreurs manuelles
  • forcer les contrôles relatifs à la validité d’un document.


Voici les cas d’usage associés à la conformité documentaire :

  • Le document ajouté doit être une pièce d’identité. Le système vérifie que le document correspond bien à un carte d’identité, un passeport ou un titre de séjour.
  • Le document ajouté doit correspondre au client courant. Le système compare les informations extraites du contenu avec celles de FlowerDocs et bloque l’intégration du contenu si ce dernier ne concerne pas le client.
  • Le document ajouté doit être valide. Le système va vérifier la date de validité du document et peut bloquer l’intégration de ce contenu si la date est dépassée.

Cinématique

Le scénario illustré dans cet article est le suivant :

  • Lancement de la création d’un document : le formulaire d’indexation comporte des informations métier telles que le nom du client et le type du document attendu.

    Indexation du document
    Indexation du document
  • Ajout du contenu : le fichier est ajouté au formulaire d’indexation.

    Ajout du contenu
    Ajout du contenu
  • Contrôles des informations suivantes :

    • le type de document doit être conforme à l’attendu

      Non conformité du type de document
      Non conformité du type de document

    • le document doit être valide ( date de validité, informations requises présentes, date de validité non expirée …)

      Invalidité du document
      Invalidité du document

Intégration

Cette intégration dans FlowerDocs peut être faite côté client via un script en JavaScript. Il s’agit d’appeler un service de conformité externe au choix du client et en fonction des règles métier à définir.


Un script permettant d'appeler un service de conformité et d'afficher côté FlowerDocs le résultat sour forme de message d'erreur.
var SUPPORTED_MIME_TYPE = ["pdf", "jpeg", "jpg", "png", "gif", "tiff"];
var SUPPORTED_DOCUMENT_TYPE = ["PieceIdentite"];
var RAD_IDS = ["CNI", "TitreSejour"];

JSAPI.get().registerForComponentChange( function(formAPI, component, phase) { if (phase == PHASE_INSERT && OBJECT_TYPE_DOCUMENT == component.getCategory()) { setTimeout(function() { JSAPI.get().getLastComponentFormAPI().getActions().registerForActionConfirmation("footer", "create", function(value, executor) { executor.hold();
JSAPI.get().showLoadingPanel(); if (!callDocumentConformite(component, executor)) { JSAPI.get().hideLoadingPanel(); executor.resume(); } }); }, 500); } });

function callDocumentConformite (component, executor) {

<span style="color:#00a8c8">var</span> <span style="color:#75af00">documentType</span> <span style="color:#f92672">=</span> <span style="color:#75af00">component</span><span style="color:#111">.</span><span style="color:#75af00">getTagValue</span><span style="color:#111">(</span><span style="color:#d88200">&#34;TypeDocument&#34;</span><span style="color:#111">);</span>
<span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#75af00">documentType</span> <span style="color:#f92672">!=</span> <span style="color:#d88200">&#34;&#34;</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#75af00">SUPPORTED_DOCUMENT_TYPE</span><span style="color:#111">.</span><span style="color:#75af00">indexOf</span><span style="color:#111">(</span><span style="color:#75af00">documentType</span><span style="color:#111">)</span> <span style="color:#f92672">!=</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span><span style="color:#111">)</span> <span style="color:#111">{</span>
    <span style="color:#00a8c8">var</span> <span style="color:#75af00">fileId</span> <span style="color:#f92672">=</span> <span style="color:#75af00">component</span><span style="color:#111">.</span><span style="color:#75af00">getDocumentFiles</span><span style="color:#111">()[</span><span style="color:#ae81ff">0</span><span style="color:#111">].</span><span style="color:#75af00">getId</span><span style="color:#111">();</span>
    <span style="color:#00a8c8">var</span> <span style="color:#75af00">fileType</span> <span style="color:#f92672">=</span> <span style="color:#75af00">component</span><span style="color:#111">.</span><span style="color:#75af00">getDocumentFiles</span><span style="color:#111">()[</span><span style="color:#ae81ff">0</span><span style="color:#111">].</span><span style="color:#75af00">getFormatCode</span><span style="color:#111">();</span>
    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#75af00">isSupportedFormat</span><span style="color:#111">(</span><span style="color:#75af00">fileType</span><span style="color:#111">))</span> <span style="color:#111">{</span>
        <span style="color:#00a8c8">var</span> <span style="color:#75af00">token</span> <span style="color:#f92672">=</span> <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getUserAPI</span><span style="color:#111">().</span><span style="color:#75af00">getUserToken</span><span style="color:#111">();</span>
         <span style="color:#75af00">$</span><span style="color:#111">.</span><span style="color:#75af00">ajax</span><span style="color:#111">({</span>
                <span style="color:#75af00">type</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#34;GET&#34;</span><span style="color:#111">,</span>
                <span style="color:#75af00">dataType</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#39;binary&#39;</span><span style="color:#111">,</span>
                <span style="color:#75af00">processData</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#39;false&#39;</span><span style="color:#111">,</span>
                <span style="color:#75af00">responseType</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#39;arraybuffer&#39;</span><span style="color:#111">,</span>
                <span style="color:#75af00">url</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#39;./../flower-docs-ws/rest/files/tmp/&#39;</span> <span style="color:#f92672">+</span> <span style="color:#75af00">fileId</span> <span style="color:#f92672">+</span> <span style="color:#d88200">&#39;?token=&#39;</span> <span style="color:#f92672">+</span> <span style="color:#75af00">token</span>
                <span style="color:#111">}).</span><span style="color:#75af00">then</span><span style="color:#111">(</span><span style="color:#00a8c8">function</span> <span style="color:#111">(</span><span style="color:#75af00">response</span><span style="color:#111">)</span> <span style="color:#111">{</span>
                    <span style="color:#75af00">callDocumentConformityService</span> <span style="color:#111">(</span><span style="color:#75af00">component</span><span style="color:#111">,</span> <span style="color:#75af00">response</span><span style="color:#111">,</span> <span style="color:#75af00">fileType</span><span style="color:#111">,</span> <span style="color:#75af00">documentType</span><span style="color:#111">,</span> <span style="color:#75af00">executor</span><span style="color:#111">);</span>
                <span style="color:#111">},</span> <span style="color:#00a8c8">function</span> <span style="color:#111">(</span><span style="color:#75af00">error</span><span style="color:#111">)</span> <span style="color:#111">{</span>
                    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
                    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;Impossible de transmettre le fichier pour l&#39;analyse de la conformité. Veuillez contacter votre administrateur technique.&#34;</span><span style="color:#111">);</span> 
                <span style="color:#111">});</span>

    <span style="color:#111">}</span> <span style="color:#00a8c8">else</span> <span style="color:#111">{</span>
        <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
        <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;Le format de fichier n&#39;est pas le format attendu : pdf, jpeg, jpg, png, gif, tiff&#34;</span><span style="color:#111">);</span> 
    <span style="color:#111">}</span>
    <span style="color:#00a8c8">return</span> <span style="color:#00a8c8">true</span><span style="color:#111">;</span>

<span style="color:#111">}</span>

<span style="color:#00a8c8">return</span> <span style="color:#00a8c8">false</span><span style="color:#111">;</span>

}

function callDocumentConformityService (component, fileContent, fileType, documentType, executor) {

<span style="color:#75af00">$</span><span style="color:#111">.</span><span style="color:#75af00">ajax</span><span style="color:#111">({</span>
    <span style="color:#75af00">url</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#34;http://documentConfityServiceUrl&#34;</span><span style="color:#111">,</span>
    <span style="color:#75af00">headers</span><span style="color:#f92672">:</span> <span style="color:#111">{</span>
        <span style="color:#d88200">&#39;Content-Type&#39;</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#39;application/x-www-form-urlencoded&#39;</span>
    <span style="color:#111">},</span>
    <span style="color:#75af00">type</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#34;POST&#34;</span><span style="color:#111">,</span> 
    <span style="color:#75af00">dataType</span><span style="color:#f92672">:</span> <span style="color:#d88200">&#34;json&#34;</span><span style="color:#111">,</span>
    <span style="color:#75af00">complete</span><span style="color:#f92672">:</span> <span style="color:#00a8c8">function</span> <span style="color:#111">(</span><span style="color:#75af00">result</span><span style="color:#111">)</span> <span style="color:#111">{</span>
        <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">status</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">200</span><span style="color:#111">)</span> <span style="color:#111">{</span>
            <span style="color:#00a8c8">var</span> <span style="color:#75af00">token</span> <span style="color:#f92672">=</span> <span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">responseJSON</span><span style="color:#111">.</span><span style="color:#75af00">access_token</span><span style="color:#111">;</span>
            <span style="color:#75af00">extractJSONInformation</span> <span style="color:#111">(</span><span style="color:#75af00">component</span><span style="color:#111">,</span> <span style="color:#75af00">responseJSON</span><span style="color:#111">,</span> <span style="color:#75af00">documentType</span><span style="color:#111">,</span> <span style="color:#75af00">executor</span><span style="color:#111">)</span>
        <span style="color:#111">}</span> <span style="color:#00a8c8">else</span> <span style="color:#111">{</span>
            <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
            <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;Impossible de transmettre le fichier pour l&#39;analyse de la conformité. Veuillez contacter votre administrateur technique.&#34;</span><span style="color:#111">);</span> 
        <span style="color:#111">}</span>

    <span style="color:#111">}</span>
<span style="color:#111">});</span>

}

function extractJSONInformation (component, responseJSON, documentType, executor) {

<span style="color:#00a8c8">var</span> <span style="color:#75af00">customerName</span> <span style="color:#f92672">=</span> <span style="color:#75af00">component</span><span style="color:#111">.</span><span style="color:#75af00">getTagValue</span><span style="color:#111">(</span><span style="color:#d88200">&#34;NomClient&#34;</span><span style="color:#111">);</span>
<span style="color:#00a8c8">var</span> <span style="color:#111">document</span> <span style="color:#f92672">=</span> <span style="color:#75af00">responseJSON</span><span style="color:#111">.</span><span style="color:#111">document</span><span style="color:#111">;</span>
<span style="color:#00a8c8">var</span> <span style="color:#75af00">type</span> <span style="color:#f92672">=</span> <span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">type</span><span style="color:#111">;</span>
<span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#75af00">RAD_IDS</span><span style="color:#111">.</span><span style="color:#75af00">indexOf</span><span style="color:#111">(</span><span style="color:#75af00">type</span><span style="color:#111">)</span> <span style="color:#f92672">!=</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span><span style="color:#111">)</span> <span style="color:#111">{</span>
    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">errors</span> <span style="color:#f92672">!=</span> <span style="color:#00a8c8">undefined</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">errors</span><span style="color:#111">.</span><span style="color:#75af00">length</span> <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span><span style="color:#111">)</span> <span style="color:#111">{</span>
        <span style="color:#00a8c8">var</span> <span style="color:#75af00">errorMessage</span> <span style="color:#f92672">=</span> <span style="color:#d88200">&#34;Le document n&#39;est pas conforme. \n&#34;</span><span style="color:#111">;</span>
        <span style="color:#00a8c8">for</span> <span style="color:#111">(</span><span style="color:#00a8c8">var</span> <span style="color:#75af00">i</span> <span style="color:#00a8c8">in</span> <span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">errors</span><span style="color:#111">)</span> <span style="color:#111">{</span>
            <span style="color:#75af00">errorMessage</span> <span style="color:#f92672">+=</span> <span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">result</span><span style="color:#111">.</span><span style="color:#75af00">errors</span><span style="color:#111">[</span><span style="color:#75af00">i</span><span style="color:#111">].</span><span style="color:#75af00">shortDescription</span> <span style="color:#f92672">+</span> <span style="color:#d88200">&#34;\n&#34;</span><span style="color:#111">;</span>
        <span style="color:#111">}</span>
        <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
        <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#75af00">errorMessage</span><span style="color:#111">);</span>
        <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
    <span style="color:#111">}</span> <span style="color:#00a8c8">else</span> <span style="color:#111">{</span>
        <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#111">document</span><span style="color:#111">.</span><span style="color:#75af00">customerName</span> <span style="color:#f92672">==</span> <span style="color:#75af00">customerName</span><span style="color:#111">)</span> <span style="color:#111">{</span>
            <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
            <span style="color:#75af00">executor</span><span style="color:#111">.</span><span style="color:#75af00">resume</span><span style="color:#111">();</span>
            <span style="color:#00a8c8">return</span><span style="color:#111">;</span>
        <span style="color:#111">}</span>
    <span style="color:#111">}</span>
    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;Le document ne concerne pas le client &#34;</span> <span style="color:#f92672">+</span> <span style="color:#75af00">customerName</span><span style="color:#111">);</span>
<span style="color:#111">}</span> <span style="color:#00a8c8">else</span> <span style="color:#111">{</span>
    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">hideLoadingPanel</span><span style="color:#111">();</span>
    <span style="color:#75af00">JSAPI</span><span style="color:#111">.</span><span style="color:#75af00">get</span><span style="color:#111">().</span><span style="color:#75af00">getNotificationAPI</span><span style="color:#111">().</span><span style="color:#75af00">sendError</span><span style="color:#111">(</span><span style="color:#d88200">&#34;Le document n&#39;est pas une pièce d&#39;identité.&#34;</span><span style="color:#111">);</span>
<span style="color:#111">}</span>

}

function isSupportedFormat(fileType) {

<span style="color:#00a8c8">for</span> <span style="color:#111">(</span><span style="color:#00a8c8">var</span> <span style="color:#75af00">mimeType</span> <span style="color:#00a8c8">in</span> <span style="color:#75af00">SUPPORTED_MIME_TYPE</span><span style="color:#111">)</span> <span style="color:#111">{</span>
    <span style="color:#00a8c8">if</span> <span style="color:#111">(</span><span style="color:#75af00">fileType</span><span style="color:#111">.</span><span style="color:#75af00">indexOf</span><span style="color:#111">(</span><span style="color:#75af00">SUPPORTED_MIME_TYPE</span><span style="color:#111">[</span><span style="color:#75af00">mimeType</span><span style="color:#111">])</span> <span style="color:#f92672">!=</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span><span style="color:#111">)</span> <span style="color:#111">{</span>
        <span style="color:#00a8c8">return</span> <span style="color:#00a8c8">true</span><span style="color:#111">;</span>
    <span style="color:#111">}</span>
<span style="color:#111">}</span>
<span style="color:#00a8c8">return</span> <span style="color:#00a8c8">false</span><span style="color:#111">;</span>

}