<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>disability_once</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description/>
    <extended_description/>
    <pipeline_version/>
    <pipeline_type>Normal</pipeline_type>
    <parameters>
    </parameters>
    <capture_transform_performance>N</capture_transform_performance>
    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
    <created_user>-</created_user>
    <created_date>2024/08/15 14:02:51.713</created_date>
    <modified_user>-</modified_user>
    <modified_date>2024/08/15 14:02:51.713</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Table input</from>
      <to>Table output</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Table input 2</from>
      <to>Table output 2</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Table output 2</from>
      <to>Update 2</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Table output</from>
      <to>Update</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Table input</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>ervu_person_registry</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>select
    recruit_id,
    case when ri.info->'svedFL'->'svedInvalid'->'invalid'->>'gruppa'='1' then 'I группа'
         when ri.info->'svedFL'->'svedInvalid'->'invalid'->>'gruppa'='2' then 'II группа'
         when ri.info->'svedFL'->'svedInvalid'->'invalid'->>'gruppa'='3' then 'III группа'
         when ri.info->'svedFL'->'svedInvalid'->'invalid'->>'gruppa'='4' then 'ребенок-инвалид'
        end	disability_group,
    ri.info->'svedFL'->'svedInvalid'->'invalid'->>'ustanOrg' organization_name,
    to_date(ri.info->'svedFL'->'svedInvalid'->'invalid'->'ustanInvalid'->>'dataUstan', 'YYYY-MM-DD') start_date,
    to_date(ri.info->'svedFL'->'svedInvalid'->'invalid'->'ustanInvalid'->>'dataSnyat', 'YYYY-MM-DD') close_date,
    to_date(ri.info->'svedFL'->'svedInvalid'->'invalid'->'ustanInvalid'->>'dataPodtverzhdPlan', 'YYYY-MM-DD') confirmation_date,
    true disability
from public.recruits_info ri
         join public.recruits r
              ON r.id = ri.recruit_id
                  AND (r.target_recruitment_id = '${RCRT_C}' or
                       r.current_recruitment_id = '${RCRT_C}')
where ri.info->'svedFL'->'svedInvalid'->>'invalid' != 'null';</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>208</xloc>
      <yloc>208</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table input 2</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>ervu_person_registry</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>select
    recruit_id,
    ri.info->'svedNedeesp'->'nedeesposob'->>'naimOrg' organization_name,
    to_date(ri.info->'svedNedeesp'->'nedeesposob'->>'dataPrisv', 'YYYY-MM-DD') start_date,
    to_date(ri.info->'svedNedeesp'->'nedeesposob'->>'dataOtmeny', 'YYYY-MM-DD') close_date,
    false disability,
    true is_incompetent
from public.recruits_info ri
         join public.recruits r
              ON r.id = ri.recruit_id
                  AND (r.target_recruitment_id = '${RCRT_C}' or
                       r.current_recruitment_id = '${RCRT_C}')
where ri.info->'svedNedeesp'->>'nedeesposob' != 'null';</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>208</xloc>
      <yloc>304</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table output</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>20000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
      <field>
        <column_name>recruit_id</column_name>
        <stream_name>recruit_id</stream_name>
      </field>
      <field>
        <column_name>disability_group</column_name>
        <stream_name>disability_group</stream_name>
      </field>
      <field>
        <column_name>organization_name</column_name>
        <stream_name>organization_name</stream_name>
      </field>
      <field>
        <column_name>start_date</column_name>
        <stream_name>start_date</stream_name>
      </field>
      <field>
        <column_name>close_date</column_name>
        <stream_name>close_date</stream_name>
      </field>
      <field>
        <column_name>confirmation_date</column_name>
        <stream_name>confirmation_date</stream_name>
      </field>
      <field>
        <column_name>disability</column_name>
        <stream_name>disability</stream_name>
      </field>
    </fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_field/>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_field/>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>disability</table>
    <tablename_field/>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>416</xloc>
      <yloc>208</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table output 2</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>20000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
      <field>
        <column_name>recruit_id</column_name>
        <stream_name>recruit_id</stream_name>
      </field>
      <field>
        <column_name>organization_name</column_name>
        <stream_name>organization_name</stream_name>
      </field>
      <field>
        <column_name>start_date</column_name>
        <stream_name>start_date</stream_name>
      </field>
      <field>
        <column_name>close_date</column_name>
        <stream_name>close_date</stream_name>
      </field>
      <field>
        <column_name>disability</column_name>
        <stream_name>disability</stream_name>
      </field>
    </fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_field/>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_field/>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>disability</table>
    <tablename_field/>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>416</xloc>
      <yloc>304</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Update</name>
    <type>Update</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>1000</commit>
    <connection>ervu-dashboard</connection>
    <error_ignored>Y</error_ignored>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruit_id</field>
        <name>recruit_id</name>
      </key>
      <schema>ervu_dashboard</schema>
      <table>citizen</table>
      <value>
        <name>has_disability</name>
        <rename>disability</rename>
      </value>
    </lookup>
    <skip_lookup>N</skip_lookup>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>576</xloc>
      <yloc>208</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Update 2</name>
    <type>Update</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>1000</commit>
    <connection>ervu-dashboard</connection>
    <error_ignored>Y</error_ignored>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruit_id</field>
        <name>recruit_id</name>
      </key>
      <schema>ervu_dashboard</schema>
      <table>citizen</table>
      <value>
        <name>is_incompetent</name>
        <rename>is_incompetent</rename>
      </value>
    </lookup>
    <skip_lookup>N</skip_lookup>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>576</xloc>
      <yloc>304</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
