<commit_before>#!/usr/bin/env python3

from reporter.core import SqlReport
from reporter.connections import RedcapInstance
from reporter.connections import DatabaseConnection
from reporter.emailing import (
    RECIPIENT_BRAVE_ADMIN as RECIPIENT_ADMIN,
    RECIPIENT_BRAVE_MANAGER as RECIPIENT_MANAGER,
)

REDCAP_PROJECT_ID = 18

# Abstract Reports


class RedcapInvalidNhsNumber(SqlReport):
    def __init__(
        self,
        redcap_instance,
        project_id,
        fields,
        recipients,
        schedule=None
    ):

        self._redcap_instance = redcap_instance
        super().__init__(
            introduction=("The following participants an invalid NHS Number "
                          "in REDCap"),
            recipients=recipients,
            schedule=schedule,
            conn=DatabaseConnection.uol_lamp,
            sql='''

SELECT
    e.project_id,
    e.record,
    md.element_label
FROM redcap_data e
JOIN redcap_metadata md
    ON md.project_id = e.project_id
    AND md.field_name = e.field_name
WHERE e.project_id = %s
    AND e.field_name IN ('nhs_num')

                ''',
            parameters=(project_id)
        )

    def get_report_line(self, row):
        return '- {}: {}\r\n'.format(
            self._redcap_instance()['link_generator'](
                row['record'], row['project_id'], row['record']),
            row['element_label']
        )
<commit_msg>Another test<commit_after>#!/usr/bin/env python3

from reporter.core import SqlReport
from reporter.connections import RedcapInstance
from reporter.connections import DatabaseConnection
from reporter.emailing import (
    RECIPIENT_BRAVE_ADMIN as RECIPIENT_ADMIN,
    RECIPIENT_BRAVE_MANAGER as RECIPIENT_MANAGER,
)

REDCAP_PROJECT_ID = 25

# Abstract Reports


class RedcapInvalidNhsNumber(SqlReport):
    def __init__(
        self,
        redcap_instance,
        project_id,
        fields,
        recipients,
        schedule=None
    ):

        self._redcap_instance = redcap_instance
        super().__init__(
            introduction=("The following participants an invalid NHS Number "
                          "in REDCap"),
            recipients=recipients,
            schedule=schedule,
            conn=DatabaseConnection.uol_lamp,
            sql='''

SELECT
    e.project_id,
    e.record,
    md.element_label
FROM redcap_data e
JOIN redcap_metadata md
    ON md.project_id = e.project_id
    AND md.field_name = e.field_name
WHERE e.project_id = %s
    AND e.field_name IN ('nhs_no')

                ''',
            parameters=(project_id)
        )

    def get_report_line(self, row):
        return '- {}: {}\r\n'.format(
            self._redcap_instance()['link_generator'](
                row['record'], row['project_id'], row['record']),
            row['element_label']
        )

{'fraction_non_alphanumeric': 0.08981612446958982, 'fraction_numerical': 0.0021216407355021216, 'mean_word_length': 2.3518957345971563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2133048', 'n_tokens_mistral': 875, 'n_tokens_neox': 831, 'n_words': 175}