Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created January 16, 2018 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrl-freak/88e50bf65f5b7009aa4493c5c57f72ee to your computer and use it in GitHub Desktop.
Save ctrl-freak/88e50bf65f5b7009aa4493c5c57f72ee to your computer and use it in GitHub Desktop.
Procura HACC MDS Statistical Linkage Key SQL SELECT
-- Government of Western Australia
-- Department of Health
-- HACC – Minimum Data Set
-- http://ww2.health.wa.gov.au/Articles/F_I/HACC-minimum-data-set
-- http://ww2.health.wa.gov.au/~/media/Files/Corporate/general%20documents/HACC/PDF/WA_MDS_User_Guide2014.pdf
SELECT
UPPER(CONCAT(
SUBSTRING(
LEFT(CONCAT(
REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
CLIENTS.LASTNAME
, ' ', ''), '''', ''),'(',''),')',''),'-','')
,' ','2')
,'22222'),5)
,2,2),
SUBSTRING(
LEFT(CONCAT(
REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
CLIENTS.LASTNAME
, ' ', ''), '''', ''),'(',''),')',''),'-','')
,' ','2')
,'22222'),5)
,5,1),
SUBSTRING(
LEFT(CONCAT(
REPLACE(
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
CLIENTS.FIRSTNAME
, ' ', ''), '''', ''),'(',''),')',''),'-','')
,' ','2')
,'22222'),5)
,2,2)
)) AS LettersOfName
FROM CLIENTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment