


PROC qcm$get_products, get_products, getpr (
  product_table, pt                    : file = $required
  pacs_catalog, pacc                   : file = $required
  licensed_products, licensed_product, ..
  lp                                   : list of name or key all = $optional
  include_subproducts, ..
  include_subproduct, is               : list of name = $optional
  exclude_subproducts, ..
  exclude_subproduct, es               : list of name = $optional
  intve_paths, ip                      : file = $optional
  alternate_intve_paths, aip           : file = $optional
  formats, f                           : file = $optional
  pacs_paths, pp                       : file = $optional
  pacs_commands, pc                    : file = $optional
  status                               : var of status = $optional
  )


  create_variable name=alternate_intve_paths_file kind=(string, $max_name) value=$unique
  create_variable name=compile_file kind=(string, $max_name) value=$unique
  create_variable name=formats_file kind=(string, $max_name) value=$unique
  create_variable name=get_all kind=boolean value=false
  create_variable name=get_alternate_intve_paths kind=boolean value=$specified(alternate_intve_paths)
  create_variable name=get_formats kind=boolean value=$specified(formats)
  create_variable name=get_intve_paths kind=boolean value=$specified(intve_paths)
  create_variable name=get_pacs_commands kind=boolean value=$specified(pacs_commands)
  create_variable name=get_pacs_paths kind=boolean value=$specified(pacs_paths)
  create_variable name=ignore_status kind=status
  create_variable name=intve_paths_file kind=(string, $max_name) value=$unique
  create_variable name=local_status kind=status
  create_variable name=pacs_commands_file kind=(string, $max_name) value=$unique
  create_variable name=pacs_paths_file kind=(string, $max_name) value=$unique
  create_variable name=selection_criteria_file kind=(string, $max_name) value=$unique
  create_variable name=wev$pacs_catalog kind=string value=$string($value(pacs_catalog))

getpti_block: ..
  BLOCK
        put_line line='include_group group=subproduct' ..
              output=$fname(selection_criteria_file//'.$eoi') status=local_status
        EXIT getpti_block WHEN NOT local_status.normal

IF $specified(include_subproducts) THEN
      FOR count = 1 TO $size(include_subproducts) DO
        put_line line='include_deck deck='//$string($value(include_subproducts, count)) ..
              output=$fname(selection_criteria_file//'.$eoi') status=local_status
        EXIT getpti_block WHEN NOT local_status.normal
      FOREND
IFEND

IF $specified(exclude_subproducts) THEN
      FOR count = 1 TO $size(exclude_subproducts) DO
        put_line line='exclude_deck deck='//$string($value(exclude_subproducts, count)) ..
              output=$fname(selection_criteria_file//'.$eoi') status=local_status
        EXIT getpti_block WHEN NOT local_status.normal
      FOREND
IFEND


    SCU
    scu_block: ..
      BLOCK
        use_library base=$value(product_table) result=$local.$null status=local_status
        EXIT scu_block WHEN NOT local_status.normal
        expand_deck deck=none compile=$fname(compile_file) ..
              selection_criteria=$fname(selection_criteria_file) status=local_status
      BLOCKEND scu_block
      include_command command='quit no' status=ignore_status
"$command=quit format=true

    EXIT getpti_block WHEN NOT local_status.normal
    include_file file=$fname(compile_file) status=local_status
    EXIT getpti_block WHEN NOT local_status.normal

      copy_file input=$fname(intve_paths_file) output=$value(intve_paths) status=local_status
      EXIT getpti_block WHEN NOT local_status.normal

      copy_file input=$fname(alternate_intve_paths_file) output=$value(alternate_intve_paths) status=local_status
      EXIT getpti_block WHEN NOT local_status.normal

      copy_file input=$fname(pacs_paths_file) output=$value(pacs_paths) status=local_status
      EXIT getpti_block WHEN NOT local_status.normal

      copy_file input=$fname(pacs_commands_file) output=$value(pacs_commands) status=local_status
      EXIT getpti_block WHEN NOT local_status.normal

      copy_file input=$fname(formats_file) output=$value(formats) status=local_status
      EXIT getpti_block WHEN NOT local_status.normal

  BLOCKEND getpti_block

  detach_file file=$fname(alternate_intve_paths_file) status=ignore_status
  detach_file file=$fname(compile_file) status=ignore_status
  detach_file file=$fname(formats_file) status=ignore_status
  detach_file file=$fname(intve_paths_file) status=ignore_status
  detach_file file=$fname(pacs_commands_file) status=ignore_status
  detach_file file=$fname(pacs_paths_file) status=ignore_status
  detach_file file=$fname(selection_criteria_file) status=ignore_status

  EXIT_PROC WITH local_status WHEN NOT local_status.normal

PROCEND qcm$get_products

