<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>citizen_kolledzh_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>2025/04/28 19:08:50.902</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/04/28 19:08:50.902</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Table input</from>
      <to>Table output</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Table output</from>
      <to>Dummy (do nothing)</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 ri.recruit_id,
       kolledzh_item->'svedOrg'->>'inn' as inn,
       kolledzh_item->'svedOrg'->>'kpp' as kpp,
       coalesce(kolledzh_item->'svedOrg'->>'ogrn', kolledzh_item->'svedOrg'->>'ogrnip') as ogrn,
       kolledzh_item->'svedOrg'->>'naimOrg' as educational_institution_name,
       kolledzh_item->'svedOrg'->>'adresOrg' as educational_institution_address,
       kolledzh_item->'svedOrg'->>'kodTipOrg' as educational_institution_type_code,
       kolledzh_item->>'kodStatus' as education_status_code,
       to_date(kolledzh_item->'svedVosst'->>'dataVosst', 'YYYY-MM-DD') as recovery_date,
       to_date(kolledzh_item->'svedVosst'->>'nomPrikazVosstnomPrikazVosst', 'YYYY-MM-DD') as recovery_order_date,
       kolledzh_item->'svedVosst'->>'nomPrikazVosst' recovery_order_number,
       kolledzh_item->>'kodUrovObr' as education_level_code,
       kolledzh_item->>'nomerKursa' as grade_number,
       to_date(kolledzh_item->'svedOtpusk'->0->>'dataNach', 'YYYY-MM-DD') as leave_start_date,
       to_date(kolledzh_item->'svedOtpusk'->0->>'dataOkonch', 'YYYY-MM-DD') as leave_end_date,
       kolledzh_item->'svedOtpusk'->0->>'kodPrichOtpusk' as leave_reason_code,
       to_date(kolledzh_item->>'dataZachisl', 'YYYY-MM-DD') as admission_date,
       kolledzh_item->>'prPervObuch' = '1' as first_education,
       kolledzh_item->'svedObrProg'->>'prVUSpecz' = '1' as vus_spec,
       to_date(kolledzh_item->'svedObrProg'->>'dataNachObuch', 'YYYY-MM-DD') as education_start_date,
       kolledzh_item->'svedObrProg'->>'kodFormaObuch' as education_form_code,
       to_date(kolledzh_item->'svedObrProg'->>'planDataOkonch', 'YYYY-MM-DD') as planned_education_end_date,
       kolledzh_item->'svedObrProg'->'svedSpeczMinobr'->>'kodSpecz' as minobr_spec_code,
       kolledzh_item->'svedObrProg'->'svedSpeczMinprosv'->>'kodSpecz' as minprosv_spec_code,
       to_date(kolledzh_item->'svedObrProg'->'svedOtchisl'->>'dataOtchisl', 'YYYY-MM-DD') as expulsion_date,
       to_date(kolledzh_item->'svedObrProg'->'svedOtchisl'->>'dataPrikazOtchisl', 'YYYY-MM-DD') as expulsion_order_date,
       kolledzh_item->'svedObrProg'->'svedOtchisl'->>'nomPrikazOtchisl' as expulsion_order_number,
       to_date(kolledzh_item->'svedVoenObuch'->>'dataNach', 'YYYY-MM-DD') as military_education_start_date,
       to_date(kolledzh_item->'svedVoenObuch'->>'dataOkonch', 'YYYY-MM-DD') as military_education_end_date,
       to_date(kolledzh_item->>'dataPrikazZachisl', 'YYYY-MM-DD') as admission_order_date,
       kolledzh_item->>'nomPrikazZachisl' as admission_order_number
from recruits_info ri
         join recruits r
              ON ri.recruit_id = r.id
                  and '${RCRT_C}' IN (r.target_recruitment_id, r.current_recruitment_id),
     jsonb_array_elements(info->'svedFL'->'svedKolledzh'->'kolledzh') as kolledzh_item
where info->'svedFL'->'svedKolledzh'->'kolledzh' != 'null';
</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>384</xloc>
      <yloc>192</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>inn</column_name>
        <stream_name>inn</stream_name>
      </field>
      <field>
        <column_name>kpp</column_name>
        <stream_name>kpp</stream_name>
      </field>
      <field>
        <column_name>ogrn</column_name>
        <stream_name>ogrn</stream_name>
      </field>
      <field>
        <column_name>educational_institution_name</column_name>
        <stream_name>educational_institution_name</stream_name>
      </field>
      <field>
        <column_name>educational_institution_address</column_name>
        <stream_name>educational_institution_address</stream_name>
      </field>
      <field>
        <column_name>educational_institution_type_code</column_name>
        <stream_name>educational_institution_type_code</stream_name>
      </field>
      <field>
        <column_name>education_status_code</column_name>
        <stream_name>education_status_code</stream_name>
      </field>
      <field>
        <column_name>recovery_date</column_name>
        <stream_name>recovery_date</stream_name>
      </field>
      <field>
        <column_name>recovery_order_date</column_name>
        <stream_name>recovery_order_date</stream_name>
      </field>
      <field>
        <column_name>recovery_order_number</column_name>
        <stream_name>recovery_order_number</stream_name>
      </field>
      <field>
        <column_name>education_level_code</column_name>
        <stream_name>education_level_code</stream_name>
      </field>
      <field>
        <column_name>grade_number</column_name>
        <stream_name>grade_number</stream_name>
      </field>
      <field>
        <column_name>leave_start_date</column_name>
        <stream_name>leave_start_date</stream_name>
      </field>
      <field>
        <column_name>leave_end_date</column_name>
        <stream_name>leave_end_date</stream_name>
      </field>
      <field>
        <column_name>leave_reason_code</column_name>
        <stream_name>leave_reason_code</stream_name>
      </field>
      <field>
        <column_name>admission_date</column_name>
        <stream_name>admission_date</stream_name>
      </field>
      <field>
        <column_name>first_education</column_name>
        <stream_name>first_education</stream_name>
      </field>
      <field>
        <column_name>vus_spec</column_name>
        <stream_name>vus_spec</stream_name>
      </field>
      <field>
        <column_name>education_start_date</column_name>
        <stream_name>education_start_date</stream_name>
      </field>
      <field>
        <column_name>education_form_code</column_name>
        <stream_name>education_form_code</stream_name>
      </field>
      <field>
        <column_name>planned_education_end_date</column_name>
        <stream_name>planned_education_end_date</stream_name>
      </field>
      <field>
        <column_name>minobr_spec_code</column_name>
        <stream_name>minobr_spec_code</stream_name>
      </field>
      <field>
        <column_name>minprosv_spec_code</column_name>
        <stream_name>minprosv_spec_code</stream_name>
      </field>
      <field>
        <column_name>expulsion_date</column_name>
        <stream_name>expulsion_date</stream_name>
      </field>
      <field>
        <column_name>expulsion_order_date</column_name>
        <stream_name>expulsion_order_date</stream_name>
      </field>
      <field>
        <column_name>expulsion_order_number</column_name>
        <stream_name>expulsion_order_number</stream_name>
      </field>
      <field>
        <column_name>military_education_start_date</column_name>
        <stream_name>military_education_start_date</stream_name>
      </field>
      <field>
        <column_name>military_education_end_date</column_name>
        <stream_name>military_education_end_date</stream_name>
      </field>
      <field>
        <column_name>admission_order_date</column_name>
        <stream_name>admission_order_date</stream_name>
      </field>
      <field>
        <column_name>admission_order_number</column_name>
        <stream_name>admission_order_number</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_monthly>Y</partitioning_monthly>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>citizen_education</table>
    <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>560</xloc>
      <yloc>192</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Dummy (do nothing)</name>
    <type>Dummy</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>656</xloc>
      <yloc>368</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
    <error>
      <source_transform>Table output</source_transform>
      <target_transform>Dummy (do nothing)</target_transform>
      <is_enabled>Y</is_enabled>
      <nr_valuename/>
      <descriptions_valuename/>
      <fields_valuename/>
      <codes_valuename/>
      <max_errors/>
      <max_pct_errors/>
      <min_pct_rows/>
    </error>
  </transform_error_handling>
  <attributes/>
</pipeline>
