https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37901

Pedro Amorim <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #181020|0                           |1
        is obsolete|                            |

--- Comment #55 from Pedro Amorim <[email protected]> ---
Created attachment 181708
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=181708&action=edit
Bug 37901: Add Tests

Example reports that can be written for ILL pseudonymized data:

--Total of requests of a given request type (article)--

SELECT
  COUNT(*) AS count
FROM
  pseudonymized_transactions pt
WHERE
  EXISTS (
    SELECT 1
    FROM pseudonymized_metadata_values pmv
    WHERE pmv.transaction_id = pt.id
    AND pmv.key = 'type'
    AND pmv.value = 'article'
  );

--Add backend info to listing--

SELECT
  pt.*,
  (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE
pmv.transaction_id = pt.id AND pmv.key = 'type') AS type,
  (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE
pmv.transaction_id = pt.id AND pmv.key = 'backend') AS backend
FROM
  pseudonymized_transactions pt;

--List all pseudonymized transactions and respective metadata values--

SELECT
  pt.*,
  table1.metadata AS borrower_attributes,
  table2.metadata AS illrequestattributes
FROM
  pseudonymized_transactions pt
  LEFT JOIN (
    SELECT
      transaction_id,
      GROUP_CONCAT(DISTINCT CONCAT(`key`, ':', value)) AS metadata
    FROM
      pseudonymized_metadata_values
    WHERE tablename = 'borrower_attributes'
    GROUP BY
      transaction_id
  ) table1 ON pt.id = table1.transaction_id
  LEFT JOIN (
    SELECT
      transaction_id,
      GROUP_CONCAT(DISTINCT CONCAT(`key`, ':', value)) AS metadata
    FROM
      pseudonymized_metadata_values
    WHERE tablename = 'illrequestattributes'
    GROUP BY
      transaction_id
  ) table2 ON pt.id = table2.transaction_id;

--ILL specific pseudonymized transactions report--

SELECT
  pt.hashed_borrowernumber as 'borrower',pt.transaction_type as 'Transaction
type', pt.datetime as 'Datetime', pt.branchcode as 'Patron branchcode',
pt.categorycode as 'Patron category',
  (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE
pmv.transaction_id = pt.id AND pmv.key = 'type') AS type,
  (SELECT pmv.value FROM pseudonymized_metadata_values pmv WHERE
pmv.transaction_id = pt.id AND pmv.key = 'backend') AS backend
FROM
  pseudonymized_transactions pt

Sponsored-by: UKHSA - UK Health Security Agency

Signed-off-by: Jeremy Evans <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to