def _upload_merge_file(self):
     print_message('Copy file to upload folder.')
     destination_folder = os.path.split(self.file_location)[0]
     merge_file_location = '{0}\Output\{1}'.format(self.merge_root_path,
                                                   self.file_name)
     file_utility.copy_file(
         merge_file_location,
         os.path.join(destination_folder, '{0}'.format(self.file_name)))
    def has_required_column(self):
        map_column_linked_claim_id = self.map_columns.where(lambda x: x['redshift_name'] == 'linked_claimid_medical_claims_header').first_or_default()
        map_column_cross_reference_number = self.map_columns.where(lambda x: x['redshift_name'] == 'reference_previous_claim_id_medical_claims_header').first_or_default()
        map_column_claim_process_status_code = self.map_columns.where(lambda x: x['redshift_name'] == 'record_status_medical_claims_header').first_or_default()
        map_column_system_assigned_number = self.map_columns.where(lambda x: x['redshift_name'] == 'previous_claim_number_medical_claims_header').first_or_default()

        if map_column_linked_claim_id is None:
            print_message('LinkedClaimIdPopulation pre-process service stopped because mandatory column "Linked Claim ID - From" is missing in the map. Please map the column and try again.')
            return False
        if map_column_cross_reference_number is None:
            print_message('LinkedClaimIdPopulation pre-process service stopped because mandatory column "Reference Previous Claim Id" is missing in the map. Please map the column and try again.')
            return False
        if map_column_claim_process_status_code is None:
            print_message('LinkedClaimIdPopulation pre-process service stopped because mandatory column "Claim Status Code" is missing in the map. Please map the column and try again.')
            return False
        if map_column_system_assigned_number is None:
            print_message('LinkedClaimIdPopulation pre-process service stopped because mandatory column "Previous Claim ID" is missing in the map. Please map the column and try again.')
            return False

        self.linked_claim_id_column_index = map_column_linked_claim_id['index']
        self.linked_claim_id_file_column_name = map_column_linked_claim_id['column_name']
        self.cross_reference_number_index = map_column_cross_reference_number['index']
        self.claim_process_status_code_index = map_column_claim_process_status_code['index']
        self.system_assigned_number_index = map_column_system_assigned_number['index']
        return True
    def prepare_data(self):
        data = redshift_provider.fetch_all(
            '''SELECT paid_date_medical_claims_header FROM medical_claims_header WHERE paid_date_medical_claims_header NOT SIMILAR TO  '[0-9]{8}' LIMIT 1;'''
        )
        if len(data) > 0:
            raise FileLoadException(
                'Different formats paid date has been found in claim database while executing loading weekly paid claims pre process.'
            )

        data = redshift_provider.fetch_all(
            'SELECT MAX(paid_date_medical_claims_header) FROM medical_claims_header;'
        )
        self.max_paid_date = parse_date(data[0][0])
        print_message('Max paid date for weekly paid claims is: {}'.format(
            self.max_paid_date))
 def __init__(self, args):
     print_message('Arguments are: {}'.format(args))
     self.pre_process_type = args.pre_process_type
     self.entity_type = args.entity_type
     self.delimiter = delimiters[args.delimiter]
     self.control_file_id = args.control_file_id
     self.map_id = args.map_id
     self.file_location = args.file_location
     self.file_name = os.path.basename(args.file_location)
     self.is_debug_mode = args.d
     self.merge_root_path = '{}/PreProcess_{}_{}_{}_{}'.format(
         dir_path, self.entity_type, self.pre_process_type,
         self.control_file_id, self.map_id).replace('-', '')
     self.pre_processes = eval('{}_policies'.format(args.pre_process_type))
     self._initialized()
Beispiel #5
0
 def _create_npi_json_file(self, sess, response):
     number = 0
     data = ''
     try:
         number = re.findall('.*number=([\d\w]*).*', response.url)[0]
         data = response.json()
         if 'results' in data and len(data['results']) > 0:
             with open('{}/NPIJsonFiles/Npi_{}.json'.format(
                     self.temp_folder, number),
                       'w',
                       encoding="utf-8") as json_file:
                 json.dump(data['results'][0], json_file, indent=2)
         else:
             print_message('NPI data not found for Id: {0}'.format(number))
     except:
         print_message(
             'Exception for NPI Number: {0}\n Data Object: {1} \n Following Exception: {2}'
             .format(number, data, sys.exc_info()))
    def execute_process(self):
        try:
            context = self._get_context_arguments()
            pre_process_scripts = self._get_pre_process_scripts(context)
            if len(pre_process_scripts) == 0:
                return

            pre_process_name = [
                PreProcessOrder(x.order).name for x in pre_process_scripts
            ]
            print_message(
                'Executing pre-process names: {}'.format(pre_process_name))
            self._prepare_base_data(context, pre_process_scripts)
            self._start_pre_process(context, pre_process_scripts)
            self._post_processing_tasks(pre_process_scripts)
            self._upload_merge_file()

        except FileLoadException as ex:
            logger.exception(ex.error_message)
        except Exception as ex:
            logger.exception(ex)
        finally:
            file_utility.delete_folder(self.merge_root_path)
    def has_required_column(self):
        frequency_code_field = self.map_columns.where(
            lambda x: x['redshift_name'] ==
            'frequency_code_medical_claims_header').first_or_default()
        type_of_bill_code_field = self.map_columns.where(
            lambda x: x['redshift_name'] ==
            'type_of_bill_code_medical_claims_header').first_or_default()
        claim_id_field = self.map_columns.where(
            lambda x: x['redshift_name'] == 'claim_id_medical_claim_header'
        ).first_or_default()
        link_claim_id_field = self.map_columns.where(
            lambda x: x['redshift_name'] ==
            'linked_claimid_medical_claims_header').first_or_default()

        if frequency_code_field is None:
            print_message(
                'LinkedClaimIdPopulationFromVersioned pre-process service stopped because mandatory column "frequency_code_medical_claims_header" is missing in the map.'
            )
            return False

        if type_of_bill_code_field is None:
            print_message(
                'LinkedClaimIdPopulationFromVersioned pre-process service stopped because mandatory column "type_of_bill_code_medical_claims_header" is missing in the map.'
            )
            return False

        if claim_id_field is None:
            print_message(
                'LinkedClaimIdPopulationFromVersioned pre-process service stopped because mandatory column "claim_id_medical_claim_header" is missing in the map.'
            )
            return False

        if link_claim_id_field is None:
            print_message(
                'LinkedClaimReplacement pre-process service stopped because mandatory column "linked_claimid_medical_claims_header" is missing in the map.'
            )
            return False

        self.frequency_code_index = frequency_code_field['index']
        self.type_of_bill_code_index = type_of_bill_code_field['index']
        self.claim_id_index = claim_id_field['index']
        self.link_claim_id_index = link_claim_id_field['index']

        return True