Skip to content

Instantly share code, notes, and snippets.

@sebbacon
Created March 30, 2022 11:30
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 sebbacon/bafbd61d8cc44c783bcc766ce93eca35 to your computer and use it in GitHub Desktop.
Save sebbacon/bafbd61d8cc44c783bcc766ce93eca35 to your computer and use it in GitHub Desktop.
-- Uploading file for patient_index_date
CREATE TABLE #tmp1_patient_index_date_file (
patient_id BIGINT,
patient_index_date DATE
)
GO
-- Query for patient_index_date
SELECT * INTO #patient_index_date FROM (
SELECT
patient_id,
patient_index_date
FROM
#tmp1_patient_index_date_file
) t
GO
-- Query for age
SELECT * INTO #age FROM (
SELECT
Patient.Patient_ID AS patient_id,
CASE WHEN
dateadd(year, datediff (year, DateOfBirth, '20200201'), DateOfBirth) > '20200201'
THEN
datediff(year, DateOfBirth, '20200201') - 1
ELSE
datediff(year, DateOfBirth, '20200201')
END AS value
FROM Patient
) t
GO
-- Query for sex
SELECT * INTO #sex FROM (
SELECT
Patient_ID AS patient_id,
Sex AS value
FROM Patient
) t
GO
-- Query for stp
SELECT * INTO #stp FROM (
SELECT
t.Patient_ID AS patient_id,
Organisation.STPCode AS stp_code
FROM (
SELECT RegistrationHistory.Patient_ID, Organisation_ID,
ROW_NUMBER() OVER (
PARTITION BY RegistrationHistory.Patient_ID
ORDER BY StartDate DESC, EndDate DESC, Registration_ID
) AS rownum
FROM RegistrationHistory
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = RegistrationHistory.patient_id
WHERE StartDate <= #patient_index_date.patient_index_date AND EndDate > #patient_index_date.patient_index_date
) t
LEFT JOIN Organisation
ON Organisation.Organisation_ID = t.Organisation_ID
WHERE t.rownum = 1
) t
GO
-- Query for dereg_date
SELECT * INTO #dereg_date FROM (
SELECT
t.Patient_id,
end_date AS value
FROM (
SELECT
Patient_ID AS patient_id,
MAX(EndDate) AS end_date
FROM
RegistrationHistory
GROUP BY
Patient_ID
) t
WHERE t.end_date BETWEEN '20200201' AND '30000101'
) t
GO
-- Query for ons_died_date
SELECT * INTO #ons_died_date FROM (
SELECT
ONS_Deaths.Patient_ID as patient_id,
MIN(dod) AS date_of_death
FROM ONS_Deaths
WHERE (1 = 1) AND dod >= '20200201'
GROUP BY ONS_Deaths.Patient_ID
) t
GO
-- Uploading codelist for Rx_Amikacin
CREATE TABLE #tmp2_Rx_Amikacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp2_Rx_Amikacin_codelist (code, category) VALUES
('35899811000001104', ''),
('35899911000001108', ''),
('9222111000001108', ''),
('11591311000001108', ''),
('39488711000001104', ''),
('4500411000001101', ''),
('4500111000001106', '')
GO
-- Query for Rx_Amikacin
SELECT * INTO #Rx_Amikacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp2_Rx_Amikacin_codelist
ON DMD_ID = #tmp2_Rx_Amikacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Amoxicillin
CREATE TABLE #tmp3_Rx_Amoxicillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp3_Rx_Amoxicillin_codelist (code, category) VALUES
('196111000001109', ''),
('29011000001102', ''),
('774011000001100', ''),
('644811000001100', ''),
('252511000001109', ''),
('121011000001106', ''),
('42011000001106', ''),
('500511000001107', ''),
('284811000001105', ''),
('19211000001104', ''),
('35368511000001108', ''),
('323732002', ''),
('634511000001102', ''),
('159311000001109', ''),
('200311000001108', ''),
('860211000001109', ''),
('143211000001100', ''),
('329011000001104', ''),
('856111000001107', ''),
('144711000001109', ''),
('549011000001104', ''),
('9786511000001104', ''),
('10426911000001104', ''),
('15984311000001100', ''),
('17781111000001106', ''),
('21766511000001108', ''),
('22609411000001108', ''),
('28943411000001108', ''),
('29769411000001104', ''),
('38785711000001104', ''),
('35901911000001104', ''),
('756511000001100', ''),
('623711000001108', ''),
('222511000001108', ''),
('311000001109', ''),
('69611000001101', ''),
('416211000001100', ''),
('264811000001108', ''),
('709111000001109', ''),
('9787111000001106', ''),
('10428011000001104', ''),
('15984711000001100', ''),
('17781911000001108', ''),
('21775811000001104', ''),
('22609611000001104', ''),
('29764511000001104', ''),
('29993911000001108', ''),
('35591711000001108', ''),
('35852611000001100', ''),
('38785511000001104', ''),
('38726811000001112', ''),
('38719511000001104', ''),
('38953811000001104', ''),
('38987311000001104', ''),
('323739006', ''),
('279111000001107', ''),
('144611000001100', ''),
('34748411000001104', ''),
('39732311000001104', ''),
('558111000001107', ''),
('739011000001101', ''),
('361711000001108', ''),
('413911000001103', ''),
('325811000001107', ''),
('833211000001107', ''),
('458811000001108', ''),
('145611000001104', ''),
('228311000001104', ''),
('9785311000001100', ''),
('10380511000001104', ''),
('12948011000001100', ''),
('15981611000001108', ''),
('17779911000001102', ''),
('18145411000001108', ''),
('19187411000001104', ''),
('19725711000001108', ''),
('21764811000001100', ''),
('22608411000001104', ''),
('23477711000001104', ''),
('29765011000001104', ''),
('29993011000001108', ''),
('33680711000001104', ''),
('35591111000001108', ''),
('36932811000001104', ''),
('38787311000001104', ''),
('323737008', ''),
('90411000001106', ''),
('283611000001108', ''),
('34748011000001100', ''),
('323733007', ''),
('819911000001107', ''),
('256911000001103', ''),
('830011000001107', ''),
('568411000001107', ''),
('555611000001105', ''),
('213311000001100', ''),
('828811000001100', ''),
('673011000001105', ''),
('767611000001107', ''),
('9786911000001106', ''),
('10427411000001100', ''),
('15065511000001104', ''),
('15984511000001106', ''),
('17781711000001108', ''),
('21776211000001104', ''),
('22609811000001108', ''),
('28943611000001108', ''),
('38787511000001104', ''),
('39021911000001104', ''),
('548011000001109', ''),
('328211000001104', ''),
('520311000001108', ''),
('930911000001103', ''),
('203311000001102', ''),
('693411000001108', ''),
('730511000001101', ''),
('88811000001107', ''),
('9787311000001108', ''),
('10428411000001100', ''),
('15984911000001104', ''),
('17782111000001100', ''),
('21776011000001108', ''),
('22610011000001108', ''),
('29765211000001108', ''),
('35591911000001104', ''),
('35852011000001108', ''),
('37033411000001104', ''),
('38787711000001104', ''),
('35902111000001108', ''),
('3241411000001109', ''),
('3243811000001105', ''),
('3246011000001107', ''),
('3246511000001104', ''),
('18081411000001108', ''),
('21766011000001100', ''),
('22609211000001108', ''),
('29765411000001108', ''),
('29993711000001104', ''),
('32496011000001108', ''),
('38788311000001104', ''),
('39732411000001104', ''),
('930411000001106', ''),
('406811000001101', ''),
('668411000001104', ''),
('816511000001105', ''),
('802011000001104', ''),
('13811000001100', ''),
('181511000001108', ''),
('116511000001101', ''),
('53711000001102', ''),
('268011000001106', ''),
('9785911000001104', ''),
('10381311000001104', ''),
('12948211000001106', ''),
('15981911000001102', ''),
('17780311000001104', ''),
('18146111000001108', ''),
('18458211000001104', ''),
('19187611000001108', ''),
('19726111000001104', ''),
('21765611000001104', ''),
('22608811000001104', ''),
('29769211000001108', ''),
('29993211000001104', ''),
('33680911000001100', ''),
('35591411000001104', ''),
('36693511000001104', ''),
('36933111000001104', ''),
('38787911000001104', ''),
('323738003', ''),
('834911000001101', ''),
('719311000001108', ''),
('34748211000001104', ''),
('769817000', ''),
('39339111000001112', ''),
('7339611000001107', ''),
('7339811000001106', ''),
('389311000001106', ''),
('234411000001104', ''),
('71111000001101', ''),
('388611000001105', ''),
('388911000001104', ''),
('689711000001103', ''),
('3243311000001101', ''),
('709311000001106', ''),
('120411000001106', ''),
('19374111000001108', ''),
('28922411000001104', ''),
('19374511000001104', ''),
('874611000001105', ''),
('2011000001104', ''),
('190111000001106', ''),
('130111000001103', ''),
('618111000001108', ''),
('451111000001109', ''),
('139811000001101', ''),
('57911000001109', ''),
('161011000001103', ''),
('14811000001102', '')
GO
-- Query for Rx_Amoxicillin
SELECT * INTO #Rx_Amoxicillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp3_Rx_Amoxicillin_codelist
ON DMD_ID = #tmp3_Rx_Amoxicillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ampicillin
CREATE TABLE #tmp4_Rx_Ampicillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp4_Rx_Ampicillin_codelist (code, category) VALUES
('323572009', ''),
('268411000001102', ''),
('531211000001109', ''),
('938511000001108', ''),
('352711000001107', ''),
('8169711000001108', ''),
('15065711000001108', ''),
('18081811000001104', ''),
('24024611000001104', ''),
('323570001', ''),
('875911000001100', ''),
('536211000001101', ''),
('305911000001106', ''),
('698211000001101', ''),
('529211000001107', ''),
('10382011000001104', ''),
('10565411000001108', ''),
('13575311000001108', ''),
('17782311000001104', ''),
('21776411000001104', ''),
('28944411000001108', ''),
('29769811000001108', ''),
('29994111000001104', ''),
('30976211000001104', ''),
('38788511000001104', ''),
('323573004', ''),
('310511000001106', ''),
('328611000001102', ''),
('649511000001104', ''),
('45311000001103', ''),
('8169911000001105', ''),
('15066011000001104', ''),
('18082611000001100', ''),
('28927211000001104', ''),
('323571002', ''),
('443811000001100', ''),
('578311000001106', ''),
('217411000001100', ''),
('755311000001101', ''),
('597311000001103', ''),
('10382211000001100', ''),
('10565611000001108', ''),
('15066311000001100', ''),
('17782711000001100', ''),
('28944611000001104', ''),
('29994311000001108', ''),
('30976411000001104', ''),
('38788711000001104', ''),
('323584006', ''),
('9505311000001100', ''),
('9725711000001104', ''),
('10355811000001100', ''),
('39732711000001104', ''),
('599611000001103', ''),
('34411000001105', ''),
('773911000001103', ''),
('908411000001104', ''),
('146111000001101', ''),
('382411000001105', ''),
('728111000001109', ''),
('4006211000001100', ''),
('9627311000001106', ''),
('10292811000001106', ''),
('17888511000001104', ''),
('19818211000001104', ''),
('21941711000001108', ''),
('23857311000001104', ''),
('28922811000001100', ''),
('29798411000001100', ''),
('30018311000001104', ''),
('38857911000001104', ''),
('323626004', ''),
('21710711000001104', ''),
('435911000001105', ''),
('473311000001105', ''),
('3098711000001105', ''),
('3347011000001101', ''),
('12778811000001104', ''),
('850311000001106', ''),
('9385411000001106', ''),
('414211000001105', ''),
('12778611000001102', '')
GO
-- Query for Rx_Ampicillin
SELECT * INTO #Rx_Ampicillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp4_Rx_Ampicillin_codelist
ON DMD_ID = #tmp4_Rx_Ampicillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Azithromycin
CREATE TABLE #tmp5_Rx_Azithromycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp5_Rx_Azithromycin_codelist (code, category) VALUES
('324253001', ''),
('13652511000001104', ''),
('14166911000001104', ''),
('15070811000001100', ''),
('17283411000001108', ''),
('20281711000001104', ''),
('21781011000001104', ''),
('22615611000001104', ''),
('37041811000001104', ''),
('38803511000001104', ''),
('29668711000001100', ''),
('29516411000001104', ''),
('324252006', ''),
('14789411000001104', ''),
('14968311000001104', ''),
('15017711000001104', ''),
('15071111000001102', ''),
('17791111000001104', ''),
('19706711000001108', ''),
('32395411000001104', ''),
('33932211000001100', ''),
('34554511000001100', ''),
('35727711000001104', ''),
('36465711000001104', ''),
('37041111000001104', ''),
('37893411000001104', ''),
('38802911000001104', ''),
('11034311000001100', ''),
('11028411000001100', ''),
('11252111000001104', ''),
('15071411000001108', ''),
('15472611000001108', ''),
('19474411000001108', ''),
('19544211000001104', ''),
('19707011000001108', ''),
('20282311000001104', ''),
('20942811000001100', ''),
('22202911000001108', ''),
('29998311000001104', ''),
('32395711000001104', ''),
('34642111000001108', ''),
('36445611000001104', ''),
('36907711000001104', ''),
('38006711000001104', ''),
('38710311000001104', ''),
('38803811000001104', ''),
('39733511000001104', ''),
('11028111000001104', ''),
('11252311000001102', ''),
('11579411000001106', ''),
('15051411000001104', ''),
('15472811000001108', ''),
('17791411000001100', ''),
('19474211000001108', ''),
('19543911000001108', ''),
('19707211000001104', ''),
('20943011000001104', ''),
('32395911000001108', ''),
('34642911000001104', ''),
('36420111000001104', ''),
('37042711000001104', ''),
('37857911000001104', ''),
('38006911000001104', ''),
('38710611000001104', ''),
('38810611000001104', ''),
('14759911000001104', ''),
('650911000001103', ''),
('85911000001108', ''),
('794511000001102', '')
GO
-- Query for Rx_Azithromycin
SELECT * INTO #Rx_Azithromycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp5_Rx_Azithromycin_codelist
ON DMD_ID = #tmp5_Rx_Azithromycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Aztreonam
CREATE TABLE #tmp6_Rx_Aztreonam_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp6_Rx_Aztreonam_codelist (code, category) VALUES
('4343611000001103', ''),
('4344011000001107', ''),
('4342911000001102', ''),
('323961007', ''),
('323962000', ''),
('323960008', '')
GO
-- Query for Rx_Aztreonam
SELECT * INTO #Rx_Aztreonam FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp6_Rx_Aztreonam_codelist
ON DMD_ID = #tmp6_Rx_Aztreonam_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Benzylpenicillin
CREATE TABLE #tmp7_Rx_Benzylpenicillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp7_Rx_Benzylpenicillin_codelist (code, category) VALUES
('323396003', ''),
('27732211000001104', ''),
('27872411000001100', ''),
('28035511000001100', ''),
('323398002', ''),
('27732411000001100', ''),
('27871711000001100', ''),
('28038711000001104', ''),
('4074311000001105', ''),
('3880811000001103', '')
GO
-- Query for Rx_Benzylpenicillin
SELECT * INTO #Rx_Benzylpenicillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp7_Rx_Benzylpenicillin_codelist
ON DMD_ID = #tmp7_Rx_Benzylpenicillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefaclor
CREATE TABLE #tmp8_Rx_Cefaclor_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp8_Rx_Cefaclor_codelist (code, category) VALUES
('869711000001109', ''),
('323792004', ''),
('612411000001100', ''),
('890411000001105', ''),
('171911000001109', ''),
('4113911000001107', ''),
('10348111000001104', ''),
('18085911000001104', ''),
('25833611000001104', ''),
('30008911000001108', ''),
('31564011000001108', ''),
('32201411000001108', ''),
('36134011000001104', ''),
('37011000001109', ''),
('576111000001105', ''),
('141511000001101', ''),
('10309911000001104', ''),
('17867211000001104', ''),
('39735011000001104', ''),
('275011000001109', ''),
('270911000001104', ''),
('636511000001108', ''),
('233911000001105', ''),
('813911000001109', ''),
('10290911000001100', ''),
('17826511000001100', ''),
('323793009', ''),
('647311000001100', ''),
('5311000001107', ''),
('400511000001101', ''),
('4114111000001106', ''),
('8825311000001105', ''),
('18086111000001108', ''),
('25834011000001104', ''),
('31564611000001104', ''),
('32201711000001104', ''),
('36134111000001104', ''),
('745411000001106', ''),
('248911000001101', ''),
('594511000001101', ''),
('9764411000001108', ''),
('10310111000001108', ''),
('17867411000001108', ''),
('36134211000001104', ''),
('168011000001109', ''),
('804411000001101', ''),
('3663611000001103', ''),
('4324111000001105', ''),
('39735111000001104', ''),
('744311000001103', ''),
('459111000001108', ''),
('923811000001104', ''),
('64011000001107', ''),
('4323911000001106', ''),
('10291411000001104', ''),
('15073011000001102', ''),
('17826711000001106', ''),
('793311000001106', ''),
('602211000001101', ''),
('252811000001107', ''),
('583511000001100', ''),
('531011000001104', ''),
('555211000001108', ''),
('318811000001107', ''),
('803611000001101', '')
GO
-- Query for Rx_Cefaclor
SELECT * INTO #Rx_Cefaclor FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp8_Rx_Cefaclor_codelist
ON DMD_ID = #tmp8_Rx_Cefaclor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefadroxil
CREATE TABLE #tmp9_Rx_Cefadroxil_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp9_Rx_Cefadroxil_codelist (code, category) VALUES
('912111000001109', ''),
('60011000001100', ''),
('674111000001108', ''),
('304211000001103', ''),
('323811004', ''),
('323812006', ''),
('39735211000001104', ''),
('4814611000001109', ''),
('5918311000001108', ''),
('7887711000001102', ''),
('8750411000001109', ''),
('15073211000001108', ''),
('17851711000001104', ''),
('19712411000001100', ''),
('21821711000001100', ''),
('30009111000001104', ''),
('38825011000001112', ''),
('323816009', '')
GO
-- Query for Rx_Cefadroxil
SELECT * INTO #Rx_Cefadroxil FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp9_Rx_Cefadroxil_codelist
ON DMD_ID = #tmp9_Rx_Cefadroxil_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefalexin
CREATE TABLE #tmp10_Rx_Cefalexin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp10_Rx_Cefalexin_codelist (code, category) VALUES
('323887008', ''),
('639611000001104', ''),
('640011000001104', ''),
('6211000001105', ''),
('560011000001100', ''),
('34311000001103', ''),
('233111000001107', ''),
('534211000001106', ''),
('10456111000001106', ''),
('15073911000001104', ''),
('18086311000001108', ''),
('21826411000001100', ''),
('22631711000001108', ''),
('30010411000001100', ''),
('37510911000001104', ''),
('38825611000001104', ''),
('4865011000001104', ''),
('4861711000001104', ''),
('11267111000001104', ''),
('19188211000001104', ''),
('35210711000001104', ''),
('35227111000001104', ''),
('39735311000001104', ''),
('716611000001106', ''),
('34811000001107', ''),
('758111000001108', ''),
('216811000001100', ''),
('3611000001101', ''),
('763611000001104', ''),
('612311000001107', ''),
('606011000001105', ''),
('9376611000001108', ''),
('10388711000001104', ''),
('17851911000001102', ''),
('19187811000001108', ''),
('21822811000001100', ''),
('22631111000001108', ''),
('27996311000001104', ''),
('29782311000001108', ''),
('30009611000001104', ''),
('37509711000001112', ''),
('38826011000001104', ''),
('39684111000001104', ''),
('719911000001109', ''),
('924811000001101', ''),
('362911000001104', ''),
('427011000001102', ''),
('360811000001108', ''),
('483611000001107', ''),
('232811000001108', ''),
('600911000001106', ''),
('10389111000001102', ''),
('11267511000001100', ''),
('15052511000001100', ''),
('17852311000001108', ''),
('21827211000001104', ''),
('22631911000001104', ''),
('37510511000001112', ''),
('39845511000001104', ''),
('323888003', ''),
('800711000001101', ''),
('707211000001109', ''),
('344611000001109', ''),
('887911000001102', ''),
('835511000001109', ''),
('728211000001103', ''),
('158511000001109', ''),
('10456311000001108', ''),
('15074111000001104', ''),
('18086511000001104', ''),
('21826611000001104', ''),
('30010611000001104', ''),
('30136211000001104', ''),
('37510711000001104', ''),
('38827711000001104', ''),
('4515811000001108', ''),
('4514011000001101', ''),
('11267311000001108', ''),
('19188411000001104', ''),
('35210911000001108', ''),
('35215211000001108', ''),
('39694811000001104', ''),
('660211000001101', ''),
('596511000001107', ''),
('587511000001105', ''),
('86911000001101', ''),
('648411000001106', ''),
('850211000001103', ''),
('305811000001101', ''),
('324911000001101', ''),
('9376411000001106', ''),
('10388911000001108', ''),
('17852111000001104', ''),
('19188011000001100', ''),
('21823311000001104', ''),
('22631511000001104', ''),
('27996611000001100', ''),
('29782711000001108', ''),
('30010111000001104', ''),
('37510111000001104', ''),
('38826411000001112', ''),
('39735911000001104', ''),
('652611000001105', ''),
('149411000001104', ''),
('199411000001106', ''),
('452411000001109', ''),
('887511000001109', ''),
('331411000001105', ''),
('687811000001103', ''),
('863911000001108', ''),
('10389411000001108', ''),
('11267711000001106', ''),
('17852511000001100', ''),
('21830211000001100', ''),
('22632111000001104', ''),
('29782911000001104', ''),
('37510311000001104', ''),
('38824911000001112', ''),
('36134311000001104', ''),
('8825611000001100', ''),
('15074311000001102', ''),
('21825911000001104', ''),
('30769411000001108', ''),
('31565211000001104', ''),
('32202211000001104', ''),
('96011000001104', ''),
('904711000001102', ''),
('474311000001107', ''),
('875311000001101', ''),
('343411000001108', ''),
('471811000001100', ''),
('3234011000001103', ''),
('691711000001103', ''),
('733011000001104', ''),
('91011000001106', ''),
('757911000001105', ''),
('362611000001105', ''),
('622911000001103', '')
GO
-- Query for Rx_Cefalexin
SELECT * INTO #Rx_Cefalexin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp10_Rx_Cefalexin_codelist
ON DMD_ID = #tmp10_Rx_Cefalexin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefamandole
CREATE TABLE #tmp11_Rx_Cefamandole_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp11_Rx_Cefamandole_codelist (code, category) VALUES
('4457111000001107', ''),
('4452211000001104', '')
GO
-- Query for Rx_Cefamandole
SELECT * INTO #Rx_Cefamandole FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp11_Rx_Cefamandole_codelist
ON DMD_ID = #tmp11_Rx_Cefamandole_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefazolin
CREATE TABLE #tmp12_Rx_Cefazolin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp12_Rx_Cefazolin_codelist (code, category) VALUES
('323936009', ''),
('37987711000001104', ''),
('33631211000001104', ''),
('33627411000001104', ''),
('34800611000001100', ''),
('36515811000001104', ''),
('37986811000001104', ''),
('323935008', ''),
('4981711000001108', ''),
('7654711000001109', '')
GO
-- Query for Rx_Cefazolin
SELECT * INTO #Rx_Cefazolin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp12_Rx_Cefazolin_codelist
ON DMD_ID = #tmp12_Rx_Cefazolin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefepime
CREATE TABLE #tmp13_Rx_Cefepime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp13_Rx_Cefepime_codelist (code, category) VALUES
('36458411000001104', ''),
('36458511000001112', ''),
('36456811000001104', ''),
('36457111000001104', '')
GO
-- Query for Rx_Cefepime
SELECT * INTO #Rx_Cefepime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp13_Rx_Cefepime_codelist
ON DMD_ID = #tmp13_Rx_Cefepime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefixime
CREATE TABLE #tmp14_Rx_Cefixime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp14_Rx_Cefixime_codelist (code, category) VALUES
('36134411000001104', ''),
('323973007', ''),
('370375008', ''),
('34762811000001104', ''),
('511411000001101', ''),
('3184511000001101', '')
GO
-- Query for Rx_Cefixime
SELECT * INTO #Rx_Cefixime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp14_Rx_Cefixime_codelist
ON DMD_ID = #tmp14_Rx_Cefixime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefotaxime
CREATE TABLE #tmp15_Rx_Cefotaxime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp15_Rx_Cefotaxime_codelist (code, category) VALUES
('323825003', ''),
('3940211000001103', ''),
('3940811000001102', ''),
('13611811000001104', ''),
('27969111000001104', ''),
('34749811000001100', ''),
('36516011000001104', ''),
('4558311000001100', ''),
('4533711000001108', ''),
('4533911000001105', ''),
('13612211000001106', ''),
('27969611000001104', ''),
('36516211000001104', ''),
('323824004', ''),
('4532411000001106', ''),
('4532811000001108', ''),
('13611511000001100', ''),
('27971011000001108', ''),
('34750011000001100', ''),
('3939811000001107', ''),
('4533411000001102', ''),
('4532011000001102', ''),
('37528311000001104', ''),
('37529711000001104', '')
GO
-- Query for Rx_Cefotaxime
SELECT * INTO #Rx_Cefotaxime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp15_Rx_Cefotaxime_codelist
ON DMD_ID = #tmp15_Rx_Cefotaxime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefoxitin
CREATE TABLE #tmp16_Rx_Cefoxitin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp16_Rx_Cefoxitin_codelist (code, category) VALUES
('323829009', ''),
('28788511000001104', ''),
('34800911000001108', ''),
('323830004', ''),
('28788811000001100', ''),
('34801211000001108', ''),
('4375311000001105', ''),
('4376311000001100', '')
GO
-- Query for Rx_Cefoxitin
SELECT * INTO #Rx_Cefoxitin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp16_Rx_Cefoxitin_codelist
ON DMD_ID = #tmp16_Rx_Cefoxitin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefpirome
CREATE TABLE #tmp17_Rx_Cefpirome_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp17_Rx_Cefpirome_codelist (code, category) VALUES
('323999000', ''),
('324000003', ''),
('4597311000001106', ''),
('4597911000001107', '')
GO
-- Query for Rx_Cefpirome
SELECT * INTO #Rx_Cefpirome FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp17_Rx_Cefpirome_codelist
ON DMD_ID = #tmp17_Rx_Cefpirome_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefpodoxime
CREATE TABLE #tmp18_Rx_Cefpodoxime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp18_Rx_Cefpodoxime_codelist (code, category) VALUES
('323982001', ''),
('35369711000001108', ''),
('3929911000001104', ''),
('3930911000001108', '')
GO
-- Query for Rx_Cefpodoxime
SELECT * INTO #Rx_Cefpodoxime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp18_Rx_Cefpodoxime_codelist
ON DMD_ID = #tmp18_Rx_Cefpodoxime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefprozil
CREATE TABLE #tmp19_Rx_Cefprozil_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp19_Rx_Cefprozil_codelist (code, category) VALUES
('324003001', ''),
('324005008', ''),
('324004007', ''),
('4626311000001109', ''),
('4627111000001105', ''),
('4626611000001104', '')
GO
-- Query for Rx_Cefprozil
SELECT * INTO #Rx_Cefprozil FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp19_Rx_Cefprozil_codelist
ON DMD_ID = #tmp19_Rx_Cefprozil_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefradine
CREATE TABLE #tmp20_Rx_Cefradine_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp20_Rx_Cefradine_codelist (code, category) VALUES
('323948007', ''),
('323944009', ''),
('441611000001103', ''),
('601211000001108', ''),
('141011000001109', ''),
('266111000001108', ''),
('821811000001106', ''),
('48711000001106', ''),
('231211000001100', ''),
('13576111000001100', ''),
('17852711000001106', ''),
('21830611000001104', ''),
('29783111000001100', ''),
('38825311000001104', ''),
('36134511000001104', ''),
('323945005', ''),
('810111000001104', ''),
('392711000001103', ''),
('688511000001102', ''),
('88011000001101', ''),
('332811000001103', ''),
('277711000001100', ''),
('750911000001109', ''),
('17852911000001108', ''),
('21831111000001100', ''),
('22632411000001108', ''),
('29783311000001104', ''),
('30010811000001104', ''),
('38825511000001104', ''),
('323947002', ''),
('435511000001103', ''),
('769211000001104', ''),
('14511000001100', ''),
('705811000001100', ''),
('3466111000001104', ''),
('8911000001102', ''),
('795711000001106', '')
GO
-- Query for Rx_Cefradine
SELECT * INTO #Rx_Cefradine FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp20_Rx_Cefradine_codelist
ON DMD_ID = #tmp20_Rx_Cefradine_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ceftazidime
CREATE TABLE #tmp21_Rx_Ceftazidime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp21_Rx_Ceftazidime_codelist (code, category) VALUES
('323854009', ''),
('8745211000001103', ''),
('9470311000001108', ''),
('10188111000001104', ''),
('19843211000001100', ''),
('23055511000001100', ''),
('32483811000001108', ''),
('34750411000001104', ''),
('36516411000001104', ''),
('36540611000001104', ''),
('36760611000001104', ''),
('323852008', ''),
('323855005', ''),
('8745411000001104', ''),
('9470511000001104', ''),
('10188311000001102', ''),
('19842311000001104', ''),
('23057711000001104', ''),
('32484011000001100', ''),
('34750611000001108', ''),
('36516611000001112', ''),
('36540811000001104', ''),
('36611411000001112', ''),
('323849000', ''),
('35798511000001104', ''),
('323853003', ''),
('8744311000001107', ''),
('10188511000001108', ''),
('19837811000001104', ''),
('32483611000001104', ''),
('34750211000001104', ''),
('36537311000001104', ''),
('3930311000001107', ''),
('4373011000001106', ''),
('4374611000001101', ''),
('4375711000001109', ''),
('4374011000001108', ''),
('10283311000001108', ''),
('3930711000001106', ''),
('4374911000001107', ''),
('4374311000001106', '')
GO
-- Query for Rx_Ceftazidime
SELECT * INTO #Rx_Ceftazidime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp21_Rx_Ceftazidime_codelist
ON DMD_ID = #tmp21_Rx_Ceftazidime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ceftriaxone
CREATE TABLE #tmp22_Rx_Ceftriaxone_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp22_Rx_Ceftriaxone_codelist (code, category) VALUES
('323990001', ''),
('3977811000001102', ''),
('3978011000001109', ''),
('3978511000001101', ''),
('11400311000001106', ''),
('20100211000001108', ''),
('22824911000001104', ''),
('32483211000001108', ''),
('34751011000001104', ''),
('36516811000001104', ''),
('36541011000001104', ''),
('37336711000001104', ''),
('38564411000001112', ''),
('39028111000001104', ''),
('323989005', ''),
('13612411000001104', ''),
('23047711000001100', ''),
('27971211000001104', ''),
('34750811000001108', ''),
('23414711000001104', ''),
('36517011000001104', ''),
('323991002', ''),
('4405611000001104', ''),
('4406011000001102', ''),
('4406311000001104', ''),
('20100411000001104', ''),
('32483411000001108', ''),
('34751211000001100', ''),
('36783811000001104', ''),
('39027911000001104', ''),
('3978911000001108', ''),
('4404611000001100', ''),
('4406611000001109', '')
GO
-- Query for Rx_Ceftriaxone
SELECT * INTO #Rx_Ceftriaxone FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp22_Rx_Ceftriaxone_codelist
ON DMD_ID = #tmp22_Rx_Ceftriaxone_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cefuroxime
CREATE TABLE #tmp23_Rx_Cefuroxime_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp23_Rx_Cefuroxime_codelist (code, category) VALUES
('11775611000001108', ''),
('11775211000001104', ''),
('11775411000001108', ''),
('4557611000001106', ''),
('4530611000001108', ''),
('11617611000001104', ''),
('36605311000001104', ''),
('36613311000001104', ''),
('36753811000001104', ''),
('323874002', ''),
('39684511000001104', ''),
('323872003', ''),
('323880005', ''),
('4740011000001101', ''),
('34751411000001100', ''),
('36754511000001104', ''),
('39694611000001104', ''),
('9547111000001104', ''),
('10096411000001100', ''),
('10271811000001104', ''),
('10885511000001106', ''),
('13743011000001108', ''),
('15074511000001108', ''),
('17853111000001104', ''),
('19712711000001104', ''),
('21831411000001104', ''),
('30011011000001100', ''),
('38826311000001104', ''),
('36134711000001104', ''),
('3939111000001100', ''),
('11617911000001108', ''),
('36605111000001104', ''),
('36613111000001104', ''),
('36754311000001104', ''),
('4530311000001103', ''),
('4740211000001106', ''),
('3939311000001103', ''),
('228011000001102', ''),
('238811000001105', ''),
('211911000001100', ''),
('3253511000001109', '')
GO
-- Query for Rx_Cefuroxime
SELECT * INTO #Rx_Cefuroxime FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp23_Rx_Cefuroxime_codelist
ON DMD_ID = #tmp23_Rx_Cefuroxime_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Chloramphenicol
CREATE TABLE #tmp24_Rx_Chloramphenicol_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp24_Rx_Chloramphenicol_codelist (code, category) VALUES
('324303009', ''),
('33582511000001100', ''),
('34327311000001100', ''),
('34340211000001108', ''),
('324298007', ''),
('3928511000001100', ''),
('3928911000001107', ''),
('3929711000001101', ''),
('4743111000001107', ''),
('11482411000001104', ''),
('14942611000001102', ''),
('4382311000001106', '')
GO
-- Query for Rx_Chloramphenicol
SELECT * INTO #Rx_Chloramphenicol FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp24_Rx_Chloramphenicol_codelist
ON DMD_ID = #tmp24_Rx_Chloramphenicol_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Cilastatin
CREATE TABLE #tmp25_Rx_Cilastatin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp25_Rx_Cilastatin_codelist (code, category) VALUES
('4396211000001103', ''),
('18852711000001100', ''),
('22980411000001104', ''),
('24200611000001108', ''),
('24416411000001104', ''),
('36568011000001104', ''),
('323970005', ''),
('4392111000001105', ''),
('4391611000001108', ''),
('4391811000001107', '')
GO
-- Query for Rx_Cilastatin
SELECT * INTO #Rx_Cilastatin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp25_Rx_Cilastatin_codelist
ON DMD_ID = #tmp25_Rx_Cilastatin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ciprofloxacin
CREATE TABLE #tmp26_Rx_Ciprofloxacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp26_Rx_Ciprofloxacin_codelist (code, category) VALUES
('39686211000001112', ''),
('227611000001105', ''),
('926611000001109', ''),
('671111000001105', ''),
('780711000001102', ''),
('130511000001107', ''),
('675411000001102', ''),
('799111000001107', ''),
('11017111000001100', ''),
('15076711000001108', ''),
('15988711000001108', ''),
('17858011000001108', ''),
('17964311000001102', ''),
('19713411000001108', ''),
('36575111000001104', ''),
('36839911000001104', ''),
('38834611000001104', ''),
('36140911000001104', ''),
('11546011000001108', ''),
('10892711000001106', ''),
('10889411000001104', ''),
('18756911000001104', ''),
('34532811000001104', ''),
('34648611000001104', ''),
('12019511000001104', ''),
('11975011000001108', ''),
('12019611000001100', ''),
('11975511000001100', ''),
('12019711000001108', ''),
('11976011000001100', ''),
('12019811000001100', ''),
('11976411000001108', ''),
('12019911000001106', ''),
('11977411000001106', ''),
('12020011000001108', ''),
('11978711000001104', ''),
('36141011000001104', ''),
('11761311000001108', ''),
('35515811000001104', ''),
('8967411000001108', ''),
('22982111000001104', ''),
('36570411000001104', ''),
('10892811000001104', ''),
('10889711000001104', ''),
('11528211000001100', ''),
('13793511000001104', ''),
('34533011000001108', ''),
('34648911000001108', ''),
('12020111000001108', ''),
('11979311000001108', ''),
('39687511000001112', ''),
('624611000001101', ''),
('826011000001107', ''),
('317211000001107', ''),
('485011000001104', ''),
('368511000001108', ''),
('170311000001103', ''),
('254711000001109', ''),
('211411000001108', ''),
('810711000001103', ''),
('370811000001102', ''),
('827711000001107', ''),
('7426211000001108', ''),
('9795711000001102', ''),
('10393211000001108', ''),
('10442211000001104', ''),
('11017911000001104', ''),
('11401111000001104', ''),
('13743811000001100', ''),
('15077111000001108', ''),
('15988911000001106', ''),
('17858211000001102', ''),
('18280611000001104', ''),
('18460011000001100', ''),
('19713611000001108', ''),
('19729511000001100', ''),
('19834111000001108', ''),
('21852511000001104', ''),
('36574211000001104', ''),
('36840911000001112', ''),
('38794711000001104', ''),
('38834811000001104', ''),
('324602005', ''),
('12020211000001104', ''),
('11980311000001108', ''),
('36141511000001104', ''),
('11761811000001104', ''),
('32775511000001108', ''),
('35516111000001104', ''),
('35831211000001108', ''),
('8973011000001101', ''),
('22983111000001100', ''),
('28040911000001104', ''),
('34611511000001104', ''),
('36570611000001104', ''),
('10892911000001108', ''),
('10890011000001104', ''),
('11528411000001102', ''),
('13793711000001100', ''),
('34649111000001104', ''),
('12020311000001106', ''),
('11980911000001104', ''),
('12020411000001104', ''),
('11971311000001104', ''),
('39687811000001104', ''),
('920811000001106', ''),
('648911000001103', ''),
('823711000001102', ''),
('327011000001108', ''),
('938011000001100', ''),
('625611000001100', ''),
('2511000001107', ''),
('238711000001102', ''),
('491511000001105', ''),
('62011000001101', ''),
('735711000001101', ''),
('7426411000001107', ''),
('9785111000001102', ''),
('10393511000001104', ''),
('11018811000001108', ''),
('11401511000001108', ''),
('13744011000001108', ''),
('15077911000001108', ''),
('15261211000001108', ''),
('15989111000001100', ''),
('17858511000001104', ''),
('18280811000001108', ''),
('18460411000001104', ''),
('19713911000001100', ''),
('19729711000001104', ''),
('19834311000001104', ''),
('21853011000001100', ''),
('36574711000001104', ''),
('36696711000001104', ''),
('36841511000001112', ''),
('38715111000001104', ''),
('38835111000001104', ''),
('12020511000001100', ''),
('11972111000001104', ''),
('12020611000001100', ''),
('11972711000001102', ''),
('12020711000001104', ''),
('11973311000001106', ''),
('39687011000001104', ''),
('469011000001100', ''),
('868011000001102', ''),
('630111000001102', ''),
('366711000001102', ''),
('271111000001108', ''),
('872511000001101', ''),
('849311000001100', ''),
('591811000001100', ''),
('935711000001105', ''),
('7426611000001105', ''),
('9207911000001104', ''),
('10393811000001108', ''),
('11019511000001104', ''),
('11402111000001108', ''),
('13744211000001104', ''),
('15078411000001100', ''),
('15989311000001104', ''),
('17858811000001100', ''),
('17964511000001108', ''),
('18281011000001108', ''),
('19714211000001108', ''),
('19730111000001104', ''),
('19833511000001104', ''),
('21853311000001104', ''),
('23483711000001104', ''),
('36574511000001104', ''),
('36841911000001104', ''),
('38715311000001104', ''),
('38835411000001104', ''),
('12020811000001102', ''),
('11973911000001108', ''),
('12020911000001108', ''),
('11974611000001104', ''),
('162511000001103', ''),
('902411000001101', ''),
('8951511000001108', ''),
('455911000001109', ''),
('3492511000001109', ''),
('8954311000001104', ''),
('417611000001101', ''),
('661311000001104', ''),
('785511000001102', ''),
('854011000001101', '')
GO
-- Query for Rx_Ciprofloxacin
SELECT * INTO #Rx_Ciprofloxacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp26_Rx_Ciprofloxacin_codelist
ON DMD_ID = #tmp26_Rx_Ciprofloxacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Clarithromycin
CREATE TABLE #tmp27_Rx_Clarithromycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp27_Rx_Clarithromycin_codelist (code, category) VALUES
('18149211000001104', ''),
('4977911000001105', ''),
('9742311000001104', ''),
('35368711000001104', ''),
('9042011000001104', ''),
('9155811000001104', ''),
('9157411000001102', ''),
('9252611000001100', ''),
('9547411000001108', ''),
('15080411000001108', ''),
('18101811000001104', ''),
('21854311000001100', ''),
('30031911000001104', ''),
('30761711000001104', ''),
('36621611000001104', ''),
('38840411000001104', ''),
('9742411000001104', ''),
('324248006', ''),
('9742511000001108', ''),
('324238009', ''),
('8818911000001106', ''),
('8825911000001106', ''),
('8914911000001107', ''),
('8927511000001103', ''),
('8993611000001100', ''),
('9033411000001104', ''),
('9038211000001104', ''),
('13745611000001100', ''),
('13765011000001104', ''),
('14694011000001106', ''),
('15080711000001102', ''),
('17522411000001102', ''),
('17859611000001108', ''),
('17965211000001106', ''),
('19715011000001104', ''),
('20096711000001104', ''),
('20165611000001104', ''),
('21854711000001104', ''),
('35140911000001104', ''),
('36846911000001104', ''),
('37402011000001104', ''),
('38836811000001104', ''),
('37083211000001104', ''),
('9042311000001100', ''),
('9156111000001108', ''),
('9157711000001108', ''),
('9253011000001104', ''),
('9547911000001100', ''),
('15080911000001100', ''),
('18103211000001100', ''),
('21854511000001108', ''),
('30041111000001108', ''),
('30761911000001100', ''),
('36621811000001104', ''),
('38840711000001104', ''),
('36142611000001104', ''),
('17648711000001102', ''),
('17997711000001108', ''),
('35555411000001108', ''),
('36635611000001104', ''),
('324242007', ''),
('13469711000001108', ''),
('13612911000001102', ''),
('34751611000001104', ''),
('324244008', ''),
('8819111000001101', ''),
('8826111000001102', ''),
('8915511000001104', ''),
('8928611000001100', ''),
('8993811000001101', ''),
('9033811000001100', ''),
('9038811000001106', ''),
('13745811000001102', ''),
('13765211000001108', ''),
('14694411000001102', ''),
('17522611000001104', ''),
('17859811000001108', ''),
('17965511000001108', ''),
('19715211000001108', ''),
('20097311000001108', ''),
('20165811000001104', ''),
('21854911000001100', ''),
('29789111000001104', ''),
('35141111000001104', ''),
('36847211000001104', ''),
('37402811000001104', ''),
('38837011000001104', ''),
('9739611000001100', ''),
('9739911000001106', ''),
('9740211000001104', ''),
('21708211000001104', ''),
('220811000001105', ''),
('463111000001102', ''),
('3253811000001107', ''),
('27011000001106', ''),
('4973711000001103', ''),
('917411000001101', ''),
('211000001101', ''),
('40811000001101', ''),
('21667211000001100', ''),
('33656011000001108', '')
GO
-- Query for Rx_Clarithromycin
SELECT * INTO #Rx_Clarithromycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp27_Rx_Clarithromycin_codelist
ON DMD_ID = #tmp27_Rx_Clarithromycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Clindamycin
CREATE TABLE #tmp28_Rx_Clindamycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp28_Rx_Clindamycin_codelist (code, category) VALUES
('36458611000001104', ''),
('36450611000001104', ''),
('12021311000001100', ''),
('11967411000001100', ''),
('324277007', ''),
('4329711000001107', ''),
('4919711000001105', ''),
('7845611000001105', ''),
('13704611000001104', ''),
('15081111000001108', ''),
('17860011000001100', ''),
('19213211000001104', ''),
('21858111000001108', ''),
('28693411000001100', ''),
('30041711000001104', ''),
('33041711000001108', ''),
('33634011000001104', ''),
('33933711000001104', ''),
('35019811000001104', ''),
('35638511000001104', ''),
('37053311000001104', ''),
('37342311000001104', ''),
('38320011000001104', ''),
('38841011000001104', ''),
('12021411000001108', ''),
('11967711000001108', ''),
('34376711000001104', ''),
('34355711000001108', ''),
('34818411000001104', ''),
('34810711000001108', ''),
('12021611000001106', ''),
('11968011000001106', ''),
('21711211000001104', ''),
('21669011000001100', ''),
('21732111000001108', ''),
('22164711000001104', ''),
('28693811000001104', ''),
('29789311000001100', ''),
('30042211000001104', ''),
('33041911000001104', ''),
('33634311000001100', ''),
('35774311000001104', ''),
('37053511000001104', ''),
('37343211000001112', ''),
('38322611000001104', ''),
('38841311000001104', ''),
('36087211000001112', ''),
('17664411000001104', ''),
('18031711000001108', ''),
('18275411000001108', ''),
('34751811000001104', ''),
('12021711000001102', ''),
('11969011000001100', ''),
('12021811000001104', ''),
('11969511000001108', ''),
('32748011000001108', ''),
('32705111000001104', ''),
('36458711000001104', ''),
('36450311000001104', ''),
('36087311000001104', ''),
('17664611000001108', ''),
('18031911000001104', ''),
('18275611000001108', ''),
('34752011000001104', ''),
('18519211000001104', ''),
('18513011000001104', ''),
('324276003', ''),
('36646511000001104', ''),
('37334911000001104', ''),
('27864611000001100', ''),
('8351711000001105', ''),
('8360611000001101', ''),
('8353211000001104', ''),
('3668311000001100', ''),
('3956511000001100', ''),
('4348911000001104', ''),
('7816711000001103', '')
GO
-- Query for Rx_Clindamycin
SELECT * INTO #Rx_Clindamycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp28_Rx_Clindamycin_codelist
ON DMD_ID = #tmp28_Rx_Clindamycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Co_amoxiclav
CREATE TABLE #tmp29_Rx_Co_amoxiclav_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp29_Rx_Co_amoxiclav_codelist (code, category) VALUES
('932211000001108', ''),
('866111000001100', ''),
('386811000001108', ''),
('94411000001100', ''),
('292511000001103', ''),
('871511000001109', ''),
('549911000001100', ''),
('169511000001107', ''),
('323568005', ''),
('5489611000001108', ''),
('10219211000001100', ''),
('10531011000001108', ''),
('19570811000001108', ''),
('30347811000001104', ''),
('34752411000001104', ''),
('36626911000001104', ''),
('37830211000001104', ''),
('7322211000001104', ''),
('7320111000001106', ''),
('13613111000001106', ''),
('22008011000001104', ''),
('23939811000001104', ''),
('24026411000001104', ''),
('24520711000001100', ''),
('28123611000001108', ''),
('29794511000001108', ''),
('31989511000001108', ''),
('38848811000001104', ''),
('36565811000001104', ''),
('829311000001103', ''),
('894611000001101', ''),
('575411000001109', ''),
('276811000001106', ''),
('193411000001109', ''),
('370711000001105', ''),
('4817111000001106', ''),
('6032711000001109', ''),
('9787711000001108', ''),
('15515811000001104', ''),
('17885411000001100', ''),
('22007211000001104', ''),
('22602311000001108', ''),
('38850811000001104', ''),
('39021311000001112', ''),
('39732111000001104', ''),
('38111000001106', ''),
('382811000001107', ''),
('771411000001107', ''),
('441311000001108', ''),
('760411000001105', ''),
('12511000001105', ''),
('882211000001108', ''),
('91211000001101', ''),
('380711000001103', ''),
('101911000001100', ''),
('9786711000001108', ''),
('10397411000001104', ''),
('17885811000001104', ''),
('19833711000001108', ''),
('22009111000001104', ''),
('23827411000001108', ''),
('29794911000001104', ''),
('30016311000001104', ''),
('32397711000001104', ''),
('34962611000001108', ''),
('35563511000001104', ''),
('35907111000001108', ''),
('36868011000001104', ''),
('38848311000001104', ''),
('7322311000001107', ''),
('7320411000001101', ''),
('11528611000001104', ''),
('22008411000001108', ''),
('23940311000001108', ''),
('24026611000001108', ''),
('24520911000001104', ''),
('28123911000001104', ''),
('29794711000001104', ''),
('31989811000001108', ''),
('38849111000001104', ''),
('37083611000001104', ''),
('732211000001103', ''),
('931011000001106', ''),
('353811000001107', ''),
('526211000001103', ''),
('22211000001104', ''),
('394111000001107', ''),
('3964011000001108', ''),
('4817311000001108', ''),
('6034811000001107', ''),
('9787911000001108', ''),
('15516011000001100', ''),
('17885611000001104', ''),
('22007711000001104', ''),
('22602511000001104', ''),
('30016111000001108', ''),
('36492911000001104', ''),
('38848111000001104', ''),
('37083711000001104', ''),
('11252711000001104', ''),
('15077811000001102', ''),
('19728111000001104', ''),
('19876911000001100', ''),
('22036711000001104', ''),
('23651411000001108', ''),
('30043911000001108', ''),
('32399111000001104', ''),
('32403711000001100', ''),
('38850411000001104', ''),
('323567000', ''),
('5488611000001104', ''),
('10219611000001104', ''),
('10530611000001104', ''),
('18757611000001104', ''),
('34752211000001108', ''),
('36626111000001104', ''),
('39732211000001104', ''),
('290311000001105', ''),
('934111000001105', ''),
('351311000001104', ''),
('785111000001106', ''),
('628011000001104', ''),
('680711000001105', ''),
('3964511000001100', ''),
('5629811000001102', ''),
('6036511000001103', ''),
('10397711000001104', ''),
('17668811000001104', ''),
('17886011000001100', ''),
('19199611000001104', ''),
('19728511000001108', ''),
('19833911000001108', ''),
('22009611000001104', ''),
('23828211000001108', ''),
('27959011000001104', ''),
('29795111000001100', ''),
('32399711000001108', ''),
('34679211000001108', ''),
('34962811000001108', ''),
('35563911000001104', ''),
('35907311000001104', ''),
('36695911000001104', ''),
('36870911000001104', ''),
('38848511000001104', ''),
('39732511000001104', ''),
('27959911000001108', ''),
('28039411000001100', ''),
('28873411000001104', ''),
('29795311000001104', ''),
('30016511000001100', ''),
('32400011000001108', '')
GO
-- Query for Rx_Co_amoxiclav
SELECT * INTO #Rx_Co_amoxiclav FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp29_Rx_Co_amoxiclav_codelist
ON DMD_ID = #tmp29_Rx_Co_amoxiclav_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Co_fluampicil
CREATE TABLE #tmp30_Rx_Co_fluampicil_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp30_Rx_Co_fluampicil_codelist (code, category) VALUES
('36090611000001104', ''),
('18421711000001100', ''),
('18446411000001104', ''),
('18542211000001108', ''),
('39732711000001104', ''),
('599611000001103', ''),
('34411000001105', ''),
('773911000001103', ''),
('908411000001104', ''),
('146111000001101', ''),
('382411000001105', ''),
('728111000001109', ''),
('4006211000001100', ''),
('9627311000001106', ''),
('10292811000001106', ''),
('17888511000001104', ''),
('19818211000001104', ''),
('21941711000001108', ''),
('23857311000001104', ''),
('28922811000001100', ''),
('29798411000001100', ''),
('30018311000001104', ''),
('38857911000001104', ''),
('323626004', ''),
('21710711000001104', '')
GO
-- Query for Rx_Co_fluampicil
SELECT * INTO #Rx_Co_fluampicil FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp30_Rx_Co_fluampicil_codelist
ON DMD_ID = #tmp30_Rx_Co_fluampicil_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Colistimethate
CREATE TABLE #tmp31_Rx_Colistimethate_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp31_Rx_Colistimethate_codelist (code, category) VALUES
('324311004', ''),
('17652211000001104', ''),
('18758011000001104', ''),
('32936911000001104', ''),
('4638311000001106', ''),
('324310003', ''),
('39707811000001104', ''),
('36091411000001104', ''),
('3964811000001102', ''),
('3108611000001108', ''),
('4352211000001109', ''),
('4621211000001109', ''),
('3109511000001103', ''),
('4658711000001106', '')
GO
-- Query for Rx_Colistimethate
SELECT * INTO #Rx_Colistimethate FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp31_Rx_Colistimethate_codelist
ON DMD_ID = #tmp31_Rx_Colistimethate_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Dalbavancin
CREATE TABLE #tmp32_Rx_Dalbavancin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp32_Rx_Dalbavancin_codelist (code, category) VALUES
('34376311000001104', '')
GO
-- Query for Rx_Dalbavancin
SELECT * INTO #Rx_Dalbavancin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp32_Rx_Dalbavancin_codelist
ON DMD_ID = #tmp32_Rx_Dalbavancin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Dalfopristin
CREATE TABLE #tmp33_Rx_Dalfopristin_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp33_Rx_Dalfopristin_codelist (code, category) VALUES
('324354009', ''),
('4408311000001100', '')
GO
-- Query for Rx_Dalfopristin
SELECT * INTO #Rx_Dalfopristin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp33_Rx_Dalfopristin_codelist
ON DMD_ID = #tmp33_Rx_Dalfopristin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Daptomycin
CREATE TABLE #tmp34_Rx_Daptomycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp34_Rx_Daptomycin_codelist (code, category) VALUES
('10140111000001108', ''),
('10961511000001102', ''),
('10140911000001104', ''),
('35047211000001104', ''),
('36531611000001104', ''),
('38972411000001104', ''),
('10961311000001108', ''),
('35047711000001108', ''),
('36531811000001112', ''),
('38973711000001104', '')
GO
-- Query for Rx_Daptomycin
SELECT * INTO #Rx_Daptomycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp34_Rx_Daptomycin_codelist
ON DMD_ID = #tmp34_Rx_Daptomycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Demeclocycline
CREATE TABLE #tmp35_Rx_Demeclocycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp35_Rx_Demeclocycline_codelist (code, category) VALUES
('324049005', ''),
('13385911000001100', ''),
('13479311000001102', ''),
('13613311000001108', ''),
('371595007', ''),
('27808811000001108', ''),
('34802411000001104', ''),
('11713311000001108', ''),
('11697011000001108', ''),
('11713411000001102', ''),
('11696711000001108', ''),
('11713511000001104', ''),
('11697611000001102', ''),
('11713611000001104', ''),
('11697311000001108', ''),
('11713711000001108', ''),
('11698211000001100', ''),
('11713811000001100', ''),
('11697911000001108', ''),
('3722011000001101', '')
GO
-- Query for Rx_Demeclocycline
SELECT * INTO #Rx_Demeclocycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp35_Rx_Demeclocycline_codelist
ON DMD_ID = #tmp35_Rx_Demeclocycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Doripenem
CREATE TABLE #tmp36_Rx_Doripenem_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp36_Rx_Doripenem_codelist (code, category) VALUES
('14236111000001106', ''),
('428353009', '')
GO
-- Query for Rx_Doripenem
SELECT * INTO #Rx_Doripenem FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp36_Rx_Doripenem_codelist
ON DMD_ID = #tmp36_Rx_Doripenem_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Doxycycline
CREATE TABLE #tmp37_Rx_Doxycycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp37_Rx_Doxycycline_codelist (code, category) VALUES
('2852111000001109', ''),
('2848211000001104', ''),
('324059006', ''),
('2850911000001108', ''),
('2851411000001109', ''),
('2851811000001106', ''),
('2852311000001106', ''),
('2852511000001100', ''),
('2852911000001107', ''),
('2853211000001109', ''),
('2854311000001104', ''),
('10405211000001104', ''),
('10724511000001104', ''),
('11404211000001106', ''),
('14161611000001104', ''),
('15083411000001100', ''),
('17894811000001104', ''),
('21933411000001100', ''),
('23880711000001108', ''),
('30123211000001108', ''),
('37896911000001104', ''),
('38877111000001104', ''),
('39710311000001104', ''),
('421341000', ''),
('38250911000001104', ''),
('32876211000001100', ''),
('32874411000001104', ''),
('36564611000001104', ''),
('324070004', ''),
('2847611000001101', ''),
('2847811000001102', ''),
('2848011000001109', ''),
('2848411000001100', ''),
('2848611000001102', ''),
('2849111000001103', ''),
('2849911000001100', ''),
('7432211000001109', ''),
('10405011000001108', ''),
('11403911000001104', ''),
('14201611000001100', ''),
('17894611000001104', ''),
('21933211000001100', ''),
('23881111000001104', ''),
('29836111000001100', ''),
('37071111000001104', ''),
('37897811000001104', ''),
('38877411000001104', ''),
('8485211000001101', ''),
('8458111000001109', ''),
('8485311000001109', ''),
('8459211000001108', ''),
('2853411000001108', ''),
('2849311000001101', ''),
('15656211000001108', ''),
('2854011000001102', ''),
('2849511000001107', ''),
('2849711000001102', ''),
('2847211000001103', ''),
('2853611000001106', '')
GO
-- Query for Rx_Doxycycline
SELECT * INTO #Rx_Doxycycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp37_Rx_Doxycycline_codelist
ON DMD_ID = #tmp37_Rx_Doxycycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ertapenem
CREATE TABLE #tmp38_Rx_Ertapenem_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp38_Rx_Ertapenem_codelist (code, category) VALUES
('36691911000001104', ''),
('38564211000001104', ''),
('4792411000001101', ''),
('4779811000001104', '')
GO
-- Query for Rx_Ertapenem
SELECT * INTO #Rx_Ertapenem FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp38_Rx_Ertapenem_codelist
ON DMD_ID = #tmp38_Rx_Ertapenem_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Erythromycin
CREATE TABLE #tmp39_Rx_Erythromycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp39_Rx_Erythromycin_codelist (code, category) VALUES
('759811000001108', ''),
('274611000001103', ''),
('30611000001101', ''),
('4693611000001103', ''),
('17628011000001100', ''),
('17627611000001108', ''),
('324215006', ''),
('4692411000001105', ''),
('4693011000001105', ''),
('4693311000001108', ''),
('29948711000001108', ''),
('33737411000001108', ''),
('36542711000001104', ''),
('36064711000001104', ''),
('258211000001108', ''),
('482311000001107', ''),
('9563611000001104', ''),
('10139811000001104', ''),
('10406211000001108', ''),
('20962611000001108', ''),
('324178009', ''),
('766711000001101', ''),
('89511000001103', ''),
('689511000001108', ''),
('919211000001106', ''),
('126311000001101', ''),
('654811000001103', ''),
('687011000001109', ''),
('789411000001103', ''),
('7211000001107', ''),
('4330011000001104', ''),
('9795911000001100', ''),
('10406411000001108', ''),
('11020911000001106', ''),
('17198711000001106', ''),
('17903711000001100', ''),
('18281911000001104', ''),
('19191611000001104', ''),
('19733011000001108', ''),
('21976211000001108', ''),
('23903911000001108', ''),
('24389111000001104', ''),
('29856311000001104', ''),
('30825911000001104', ''),
('32800711000001104', ''),
('35996611000001100', ''),
('38073211000001104', ''),
('38889811000001104', ''),
('324232005', ''),
('682211000001102', ''),
('838411000001100', ''),
('469911000001101', ''),
('231611000001103', ''),
('468911000001109', ''),
('10307311000001108', ''),
('13620311000001108', ''),
('17902311000001104', ''),
('21935211000001100', ''),
('23902711000001104', ''),
('29852211000001108', ''),
('38889611000001112', ''),
('36564711000001104', ''),
('481911000001102', ''),
('173511000001103', ''),
('549711000001102', ''),
('2411000001108', ''),
('840611000001104', ''),
('580111000001102', ''),
('10060511000001100', ''),
('10307511000001104', ''),
('13620911000001108', ''),
('17902611000001100', ''),
('21975611000001100', ''),
('23903311000001104', ''),
('29851811000001100', ''),
('30125811000001108', ''),
('38890211000001104', ''),
('324233000', ''),
('563411000001101', ''),
('398811000001108', ''),
('79111000001102', ''),
('103911000001104', ''),
('816211000001107', ''),
('10307711000001108', ''),
('13620511000001100', ''),
('17902811000001100', ''),
('21975211000001104', ''),
('23902911000001100', ''),
('29856111000001104', ''),
('38890011000001104', ''),
('39107311000001104', ''),
('177211000001105', ''),
('592611000001105', ''),
('784711000001108', ''),
('273611000001101', ''),
('506011000001101', ''),
('364011000001109', ''),
('10060711000001104', ''),
('10308011000001108', ''),
('13621111000001104', ''),
('17903011000001104', ''),
('21975811000001104', ''),
('23903511000001100', ''),
('29852611000001104', ''),
('30810111000001104', ''),
('38890411000001104', ''),
('324179001', ''),
('32163811000001104', ''),
('32506411000001108', ''),
('37149211000001104', ''),
('37376611000001104', ''),
('324234006', ''),
('348611000001104', ''),
('889511000001102', ''),
('237511000001108', ''),
('605811000001107', ''),
('845911000001101', ''),
('10308311000001104', ''),
('13620711000001106', ''),
('17903311000001100', ''),
('21975411000001104', ''),
('23903111000001108', ''),
('29856611000001108', ''),
('39107211000001104', ''),
('433911000001109', ''),
('848711000001105', ''),
('415511000001109', ''),
('364211000001104', ''),
('78611000001101', ''),
('626611000001105', ''),
('10060911000001108', ''),
('10308511000001104', ''),
('13621311000001102', ''),
('17903511000001106', ''),
('21976011000001104', ''),
('23903711000001104', ''),
('324180003', ''),
('37911311000001104', ''),
('38215511000001104', ''),
('324181004', ''),
('37911611000001104', ''),
('38215811000001104', ''),
('580811000001109', ''),
('178911000001100', ''),
('294211000001105', ''),
('108811000001104', ''),
('4227311000001109', ''),
('235411000001103', ''),
('165611000001108', '')
GO
-- Query for Rx_Erythromycin
SELECT * INTO #Rx_Erythromycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp39_Rx_Erythromycin_codelist
ON DMD_ID = #tmp39_Rx_Erythromycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Fidaxomicin
CREATE TABLE #tmp40_Rx_Fidaxomicin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp40_Rx_Fidaxomicin_codelist (code, category) VALUES
('20540311000001100', ''),
('703666002', '')
GO
-- Query for Rx_Fidaxomicin
SELECT * INTO #Rx_Fidaxomicin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp40_Rx_Fidaxomicin_codelist
ON DMD_ID = #tmp40_Rx_Fidaxomicin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Flucloxacillin
CREATE TABLE #tmp41_Rx_Flucloxacillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp41_Rx_Flucloxacillin_codelist (code, category) VALUES
('36090611000001104', ''),
('18421711000001100', ''),
('18446411000001104', ''),
('18542211000001108', ''),
('811111000001105', ''),
('419411000001108', ''),
('471111000001107', ''),
('865811000001104', ''),
('442211000001107', ''),
('888011000001100', ''),
('324711000001103', ''),
('251311000001107', ''),
('499611000001105', ''),
('323484009', ''),
('513711000001108', ''),
('103311000001100', ''),
('767311000001102', ''),
('337811000001100', ''),
('719411000001101', ''),
('138411000001106', ''),
('746511000001103', ''),
('207211000001101', ''),
('10454211000001104', ''),
('13578111000001100', ''),
('18107711000001104', ''),
('19193411000001104', ''),
('20136411000001100', ''),
('21997911000001104', ''),
('23189811000001104', ''),
('38914811000001104', ''),
('16089611000001104', ''),
('16086911000001100', ''),
('16247911000001104', ''),
('16443111000001108', ''),
('21997511000001104', ''),
('23979011000001104', ''),
('27126211000001104', ''),
('28096311000001108', ''),
('37732411000001104', ''),
('38619411000001104', ''),
('38915411000001104', ''),
('323496002', ''),
('323493005', ''),
('661411000001106', ''),
('858411000001101', ''),
('9143111000001102', ''),
('34752811000001108', ''),
('36921411000001104', ''),
('39692111000001104', ''),
('120711000001100', ''),
('699911000001102', ''),
('333211000001105', ''),
('850811000001102', ''),
('194111000001102', ''),
('627011000001100', ''),
('916911000001106', ''),
('135511000001102', ''),
('220311000001101', ''),
('9798411000001104', ''),
('10407811000001108', ''),
('15087311000001100', ''),
('16050611000001100', ''),
('17908511000001102', ''),
('19193011000001108', ''),
('19728911000001100', ''),
('21996911000001108', ''),
('23907811000001108', ''),
('30130811000001104', ''),
('37506211000001104', ''),
('38915011000001112', ''),
('323491007', ''),
('97911000001102', ''),
('231911000001109', ''),
('34753011000001104', ''),
('323485005', ''),
('4835611000001101', ''),
('11268511000001102', ''),
('13578311000001104', ''),
('16086311000001100', ''),
('18107911000001100', ''),
('18722811000001104', ''),
('20137211000001104', ''),
('21998111000001108', ''),
('38076711000001104', ''),
('38915611000001104', ''),
('16089711000001108', ''),
('16086611000001106', ''),
('16248111000001100', ''),
('16443611000001100', ''),
('21997711000001108', ''),
('23979211000001108', ''),
('27126411000001108', ''),
('28096511000001104', ''),
('37732211000001104', ''),
('38619611000001104', ''),
('38915811000001104', ''),
('323474008', ''),
('34769611000001108', ''),
('34753511000001104', ''),
('39692211000001104', ''),
('289411000001107', ''),
('3111000001109', ''),
('833311000001104', ''),
('401911000001101', ''),
('568111000001102', ''),
('590311000001104', ''),
('32611000001100', ''),
('770011000001107', ''),
('629811000001103', ''),
('9798911000001106', ''),
('10408011000001100', ''),
('15087511000001106', ''),
('16050911000001108', ''),
('17908811000001104', ''),
('19193211000001104', ''),
('19729111000001104', ''),
('21997211000001104', ''),
('23908511000001108', ''),
('30131011000001100', ''),
('36738011000001104', ''),
('38915211000001104', ''),
('323492000', ''),
('390611000001106', ''),
('256511000001105', ''),
('162711000001108', ''),
('9142811000001100', ''),
('34753211000001100', ''),
('36921811000001104', ''),
('748211000001100', ''),
('703911000001109', '')
GO
-- Query for Rx_Flucloxacillin
SELECT * INTO #Rx_Flucloxacillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp41_Rx_Flucloxacillin_codelist
ON DMD_ID = #tmp41_Rx_Flucloxacillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Fosfomycin
CREATE TABLE #tmp42_Rx_Fosfomycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp42_Rx_Fosfomycin_codelist (code, category) VALUES
('21259011000001104', ''),
('18162111000001104', ''),
('21393311000001104', ''),
('29934011000001104', ''),
('32746111000001104', ''),
('21258811000001108', ''),
('28691111000001108', ''),
('32982711000001104', '')
GO
-- Query for Rx_Fosfomycin
SELECT * INTO #Rx_Fosfomycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp42_Rx_Fosfomycin_codelist
ON DMD_ID = #tmp42_Rx_Fosfomycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Fusidate
CREATE TABLE #tmp43_Rx_Fusidate_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp43_Rx_Fusidate_codelist (code, category) VALUES
('3670711000001108', ''),
('3981111000001109', ''),
('4371711000001107', ''),
('324317000', ''),
('324316009', ''),
('35927411000001108', ''),
('8708411000001103', ''),
('9060611000001104', ''),
('27753611000001108', ''),
('29786111000001104', '')
GO
-- Query for Rx_Fusidate
SELECT * INTO #Rx_Fusidate FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp43_Rx_Fusidate_codelist
ON DMD_ID = #tmp43_Rx_Fusidate_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Gentamicin
CREATE TABLE #tmp44_Rx_Gentamicin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp44_Rx_Gentamicin_codelist (code, category) VALUES
('3845811000001100', ''),
('3997811000001108', ''),
('4609011000001105', ''),
('3983611000001102', ''),
('29903511000001104', ''),
('29861811000001108', ''),
('29934211000001108', ''),
('36063011000001104', ''),
('29951111000001100', ''),
('29942211000001104', ''),
('29942911000001104', ''),
('27800411000001108', ''),
('27690911000001108', ''),
('29827911000001104', ''),
('29793411000001108', ''),
('29951211000001104', ''),
('29942511000001104', ''),
('29943111000001104', ''),
('36050911000001104', ''),
('3999111000001107', ''),
('3999411000001102', ''),
('3999911000001105', ''),
('32749211000001108', ''),
('32743411000001104', ''),
('8523611000001103', ''),
('8494111000001107', ''),
('4615711000001107', ''),
('12089911000001108', ''),
('12075211000001108', ''),
('12090011000001100', ''),
('12076611000001100', ''),
('36051011000001104', ''),
('3845211000001101', ''),
('3846511000001105', ''),
('3847411000001108', ''),
('27334311000001100', ''),
('29862011000001104', ''),
('32334511000001108', ''),
('36051111000001104', ''),
('3997111000001101', ''),
('3998211000001106', ''),
('3998811000001107', ''),
('29951311000001104', ''),
('29941811000001104', ''),
('29942711000001108', ''),
('10967311000001102', ''),
('17330211000001102', ''),
('3847011000001104', '')
GO
-- Query for Rx_Gentamicin
SELECT * INTO #Rx_Gentamicin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp44_Rx_Gentamicin_codelist
ON DMD_ID = #tmp44_Rx_Gentamicin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Levofloxacin
CREATE TABLE #tmp45_Rx_Levofloxacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp45_Rx_Levofloxacin_codelist (code, category) VALUES
('39697411000001112', ''),
('19178611000001100', ''),
('19296611000001108', ''),
('19358511000001108', ''),
('19359511000001100', ''),
('19511711000001100', ''),
('19837211000001108', ''),
('21285711000001100', ''),
('22070311000001104', ''),
('24366211000001104', ''),
('29673211000001104', ''),
('29889711000001104', ''),
('37098711000001104', ''),
('324634001', ''),
('19178911000001108', ''),
('19298011000001104', ''),
('19359211000001104', ''),
('19359911000001108', ''),
('19512011000001104', ''),
('19837511000001108', ''),
('21286011000001108', ''),
('22070611000001100', ''),
('24366511000001100', ''),
('29673511000001108', ''),
('29890211000001100', ''),
('30220211000001100', ''),
('39015311000001104', ''),
('19448711000001104', ''),
('19447411000001104', ''),
('19447611000001100', ''),
('21660611000001104', ''),
('35831811000001104', ''),
('38236111000001104', ''),
('23108311000001100', ''),
('22985411000001108', ''),
('24416711000001100', ''),
('34611911000001108', ''),
('36571111000001104', ''),
('38745711000001104', ''),
('36038911000001104', ''),
('19359011000001108', ''),
('34754611000001100', ''),
('3077511000001109', ''),
('3078311000001102', ''),
('4602911000001104', '')
GO
-- Query for Rx_Levofloxacin
SELECT * INTO #Rx_Levofloxacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp45_Rx_Levofloxacin_codelist
ON DMD_ID = #tmp45_Rx_Levofloxacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Linezolid
CREATE TABLE #tmp46_Rx_Linezolid_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp46_Rx_Linezolid_codelist (code, category) VALUES
('39718111000001104', ''),
('134561001', ''),
('31153711000001108', ''),
('31203911000001104', ''),
('31279511000001100', ''),
('31684511000001104', ''),
('31800311000001104', ''),
('31896811000001104', ''),
('33627611000001100', ''),
('33746711000001100', ''),
('34943711000001100', ''),
('35165011000001104', ''),
('37267511000001104', ''),
('36040111000001104', ''),
('31153911000001108', ''),
('33737611000001104', ''),
('34574711000001108', ''),
('36615111000001104', ''),
('36441911000001104', ''),
('36096911000001104', ''),
('36886111000001104', ''),
('38675711000001104', ''),
('4946211000001104', ''),
('4450311000001108', ''),
('4827211000001109', '')
GO
-- Query for Rx_Linezolid
SELECT * INTO #Rx_Linezolid FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp46_Rx_Linezolid_codelist
ON DMD_ID = #tmp46_Rx_Linezolid_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Lymecycline
CREATE TABLE #tmp47_Rx_Lymecycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp47_Rx_Lymecycline_codelist (code, category) VALUES
('324076005', ''),
('21219611000001104', ''),
('21232111000001104', ''),
('21790011000001100', ''),
('23643111000001104', ''),
('24372611000001108', ''),
('29899911000001104', ''),
('30763011000001104', ''),
('32417211000001100', ''),
('34187111000001100', ''),
('37119611000001104', ''),
('37860011000001104', ''),
('39033111000001104', ''),
('396211000001106', '')
GO
-- Query for Rx_Lymecycline
SELECT * INTO #Rx_Lymecycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp47_Rx_Lymecycline_codelist
ON DMD_ID = #tmp47_Rx_Lymecycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Meropenem
CREATE TABLE #tmp48_Rx_Meropenem_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp48_Rx_Meropenem_codelist (code, category) VALUES
('4381711000001103', ''),
('4382011000001108', ''),
('324344005', ''),
('18486011000001100', ''),
('23049211000001104', ''),
('26812911000001104', ''),
('29714711000001100', ''),
('32391011000001104', ''),
('34711811000001104', ''),
('35246811000001104', ''),
('35306611000001104', ''),
('35829511000001104', ''),
('37656911000001104', ''),
('38009811000001104', ''),
('324343004', ''),
('18486711000001104', ''),
('23021211000001100', ''),
('26812711000001104', ''),
('28963111000001108', ''),
('34711611000001108', ''),
('35247011000001104', ''),
('35306811000001104', ''),
('35834011000001100', ''),
('37655611000001104', ''),
('38009511000001104', '')
GO
-- Query for Rx_Meropenem
SELECT * INTO #Rx_Meropenem FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp48_Rx_Meropenem_codelist
ON DMD_ID = #tmp48_Rx_Meropenem_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Methenamine
CREATE TABLE #tmp49_Rx_Methenamine_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp49_Rx_Methenamine_codelist (code, category) VALUES
('3691811000001100', ''),
('371616001', ''),
('37830711000001112', ''),
('37947311000001104', ''),
('38849511000001104', '')
GO
-- Query for Rx_Methenamine
SELECT * INTO #Rx_Methenamine FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp49_Rx_Methenamine_codelist
ON DMD_ID = #tmp49_Rx_Methenamine_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Metronidazole
CREATE TABLE #tmp50_Rx_Metronidazole_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp50_Rx_Metronidazole_codelist (code, category) VALUES
('3910511000001105', ''),
('838811000001103', ''),
('272211000001109', ''),
('3911811000001100', ''),
('3619811000001103', ''),
('3924811000001105', ''),
('453711000001106', ''),
('3910711000001100', ''),
('3912311000001100', ''),
('34194011000001108', ''),
('4969011000001107', ''),
('5099711000001109', ''),
('13007811000001104', ''),
('12961911000001102', ''),
('13007911000001108', ''),
('12960811000001104', ''),
('324518009', ''),
('34607211000001108', ''),
('34605411000001100', ''),
('324511003', ''),
('657311000001103', ''),
('703011000001105', ''),
('357811000001101', ''),
('786711000001104', ''),
('727811000001101', ''),
('461811000001105', ''),
('367011000001101', ''),
('494411000001108', ''),
('8826911000001104', ''),
('10394111000001104', ''),
('10690011000001102', ''),
('14162711000001100', ''),
('15110911000001108', ''),
('17941711000001106', ''),
('19193811000001100', ''),
('20189711000001104', ''),
('21800011000001100', ''),
('24384611000001108', ''),
('30830211000001108', ''),
('34612711000001100', ''),
('35843111000001100', ''),
('39045111000001104', ''),
('39118311000001104', ''),
('39503911000001104', ''),
('13008011000001104', ''),
('12962211000001104', ''),
('324520007', ''),
('271811000001101', ''),
('113911000001102', ''),
('341811000001106', ''),
('11599611000001102', ''),
('21309911000001104', ''),
('21799811000001104', ''),
('24384411000001108', ''),
('29920411000001104', ''),
('34745911000001108', ''),
('37149811000001104', ''),
('39045311000001112', ''),
('324512005', ''),
('791311000001105', ''),
('229911000001106', ''),
('585011000001109', ''),
('650511000001105', ''),
('723311000001103', ''),
('882111000001102', ''),
('406911000001106', ''),
('780111000001103', ''),
('239411000001100', ''),
('8827211000001105', ''),
('10394511000001108', ''),
('10690211000001108', ''),
('14162911000001104', ''),
('15111111000001104', ''),
('17941911000001108', ''),
('19194011000001108', ''),
('20189911000001108', ''),
('21800211000001104', ''),
('24384811000001104', ''),
('30830411000001104', ''),
('39045611000001104', ''),
('39809811000001104', ''),
('36035511000001104', ''),
('324517004', ''),
('324523009', ''),
('780211000001109', ''),
('310211000001108', ''),
('329811000001105', ''),
('15111311000001102', ''),
('24385011000001100', ''),
('36537511000001104', ''),
('39042411000001104', ''),
('36035611000001104', ''),
('3617511000001108', ''),
('3620311000001108', ''),
('13408411000001108', ''),
('34617211000001104', ''),
('34612511000001104', ''),
('36077111000001104', ''),
('32655011000001104', ''),
('32646011000001104', ''),
('13008111000001106', ''),
('12962811000001104', ''),
('13008211000001100', ''),
('12962511000001100', ''),
('3620111000001106', ''),
('471211000001101', '')
GO
-- Query for Rx_Metronidazole
SELECT * INTO #Rx_Metronidazole FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp50_Rx_Metronidazole_codelist
ON DMD_ID = #tmp50_Rx_Metronidazole_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Minocycline
CREATE TABLE #tmp51_Rx_Minocycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp51_Rx_Minocycline_codelist (code, category) VALUES
('9361611000001108', ''),
('18248711000001104', ''),
('147511000001107', ''),
('116911000001108', ''),
('926911000001103', ''),
('921111000001105', ''),
('621011000001105', ''),
('123211000001102', ''),
('820411000001100', ''),
('39700811000001104', ''),
('36565111000001104', ''),
('9330111000001102', ''),
('14781411000001108', ''),
('39700911000001112', ''),
('254511000001104', ''),
('754011000001103', ''),
('936711000001102', ''),
('7611000001109', ''),
('64211000001102', ''),
('165311000001103', ''),
('8819511000001105', ''),
('11408011000001104', ''),
('13758311000001100', ''),
('17942311000001104', ''),
('21801211000001100', ''),
('24385811000001108', ''),
('29923011000001100', ''),
('30831011000001104', ''),
('34019411000001108', ''),
('39044111000001104', ''),
('39700611000001104', ''),
('39700711000001104', ''),
('666311000001107', ''),
('679811000001102', ''),
('891511000001102', ''),
('238111000001103', ''),
('939411000001101', ''),
('514011000001108', ''),
('8819311000001104', ''),
('11408511000001102', ''),
('13758111000001102', ''),
('17942111000001100', ''),
('21801011000001104', ''),
('24386011000001104', ''),
('29923611000001108', ''),
('30831211000001100', ''),
('39044711000001112', ''),
('13010711000001108', ''),
('12979311000001104', ''),
('13010811000001100', ''),
('12979011000001108', ''),
('7393411000001103', ''),
('9891211000001108', '')
GO
-- Query for Rx_Minocycline
SELECT * INTO #Rx_Minocycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp51_Rx_Minocycline_codelist
ON DMD_ID = #tmp51_Rx_Minocycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Moxifloxacin
CREATE TABLE #tmp52_Rx_Moxifloxacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp52_Rx_Moxifloxacin_codelist (code, category) VALUES
('4360711000001109', ''),
('16751911000001104', ''),
('10496311000001104', ''),
('408015000', ''),
('24673211000001108', ''),
('24683911000001108', ''),
('24775911000001104', ''),
('24919311000001108', ''),
('28697411000001108', ''),
('29927511000001104', ''),
('30834211000001104', ''),
('37453311000001104', ''),
('38618511000001104', ''),
('39049711000001104', ''),
('39489811000001104', ''),
('36028511000001100', ''),
('16756911000001108', ''),
('25876211000001100', ''),
('36571311000001104', ''),
('36881911000001112', ''),
('36003311000001108', ''),
('35992311000001104', '')
GO
-- Query for Rx_Moxifloxacin
SELECT * INTO #Rx_Moxifloxacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp52_Rx_Moxifloxacin_codelist
ON DMD_ID = #tmp52_Rx_Moxifloxacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Nalidixic_acid
CREATE TABLE #tmp53_Rx_Nalidixic_acid_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp53_Rx_Nalidixic_acid_codelist (code, category) VALUES
('35445511000001100', ''),
('3852811000001105', ''),
('324579006', ''),
('19172111000001104', ''),
('19681911000001108', ''),
('26854011000001100', ''),
('36028911000001104', ''),
('324578003', ''),
('4058911000001101', ''),
('3683611000001101', ''),
('4059711000001107', '')
GO
-- Query for Rx_Nalidixic_acid
SELECT * INTO #Rx_Nalidixic_acid FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp53_Rx_Nalidixic_acid_codelist
ON DMD_ID = #tmp53_Rx_Nalidixic_acid_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Neomycin
CREATE TABLE #tmp54_Rx_Neomycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp54_Rx_Neomycin_codelist (code, category) VALUES
('12301911000001108', ''),
('12273311000001106', ''),
('324158001', ''),
('4055311000001106', ''),
('4055711000001105', ''),
('4208311000001104', ''),
('28932611000001104', ''),
('12302011000001102', ''),
('12274811000001104', ''),
('4055511000001100', '')
GO
-- Query for Rx_Neomycin
SELECT * INTO #Rx_Neomycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp54_Rx_Neomycin_codelist
ON DMD_ID = #tmp54_Rx_Neomycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Netilmicin
CREATE TABLE #tmp55_Rx_Netilmicin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp55_Rx_Netilmicin_codelist (code, category) VALUES
('4463311000001109', ''),
('4463611000001104', ''),
('4462711000001100', ''),
('4464611000001101', ''),
('4463011000001106', ''),
('36030911000001112', ''),
('36031011000001104', ''),
('36031111000001104', ''),
('36031211000001104', ''),
('36031311000001104', '')
GO
-- Query for Rx_Netilmicin
SELECT * INTO #Rx_Netilmicin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp55_Rx_Netilmicin_codelist
ON DMD_ID = #tmp55_Rx_Netilmicin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Nitazoxanid
CREATE TABLE #tmp56_Rx_Nitazoxanid_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp56_Rx_Nitazoxanid_codelist (code, category) VALUES
('409156007', ''),
('21626711000001104', ''),
('414851008', ''),
('20425111000001100', '')
GO
-- Query for Rx_Nitazoxanid
SELECT * INTO #Rx_Nitazoxanid FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp56_Rx_Nitazoxanid_codelist
ON DMD_ID = #tmp56_Rx_Nitazoxanid_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Nitrofurantoin
CREATE TABLE #tmp57_Rx_Nitrofurantoin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp57_Rx_Nitrofurantoin_codelist (code, category) VALUES
('758411000001103', ''),
('3606911000001102', ''),
('58211000001101', ''),
('32747111000001108', ''),
('32746911000001108', ''),
('517311000001102', ''),
('707311000001101', ''),
('623211000001101', ''),
('324572002', ''),
('24208911000001100', ''),
('24421811000001104', ''),
('24550111000001104', ''),
('35954211000001104', ''),
('36774511000001104', ''),
('37460611000001104', ''),
('37557111000001104', ''),
('39057411000001104', ''),
('39108511000001104', ''),
('324559003', ''),
('637211000001107', ''),
('626211000001108', ''),
('277011000001102', ''),
('405011000001103', ''),
('4221211000001106', ''),
('9555311000001108', ''),
('11015711000001106', ''),
('15111411000001108', ''),
('17946911000001104', ''),
('20326111000001104', ''),
('21821311000001100', ''),
('30763611000001104', ''),
('30851411000001100', ''),
('37461111000001104', ''),
('39060311000001104', ''),
('12862811000001106', ''),
('12820911000001108', ''),
('12862911000001100', ''),
('12820611000001102', ''),
('12863011000001108', ''),
('12821511000001108', ''),
('12863111000001104', ''),
('12821211000001104', ''),
('12863211000001104', ''),
('12822111000001108', ''),
('12863311000001108', ''),
('12821811000001106', ''),
('12863411000001100', ''),
('12822711000001104', ''),
('12863511000001100', ''),
('12822411000001104', ''),
('12863611000001102', ''),
('12823311000001100', ''),
('12863711000001106', ''),
('12823011000001104', ''),
('12863811000001104', ''),
('12823911000001100', ''),
('12863911000001108', ''),
('12823611000001106', ''),
('12864011000001106', ''),
('12824511000001104', ''),
('12864111000001108', ''),
('12824211000001108', ''),
('12864211000001100', ''),
('12825111000001102', ''),
('12864311000001108', ''),
('12824811000001108', ''),
('12864411000001102', ''),
('12828311000001108', ''),
('12864511000001104', ''),
('12827411000001100', ''),
('12864611000001104', ''),
('12829211000001106', ''),
('12864711000001108', ''),
('12828711000001108', ''),
('12864811000001100', ''),
('12830411000001104', ''),
('12864911000001104', ''),
('12829711000001104', ''),
('12893811000001100', ''),
('12889111000001106', ''),
('12894011000001108', ''),
('12888811000001106', ''),
('12894111000001108', ''),
('12889711000001108', ''),
('12894211000001104', ''),
('12889411000001100', ''),
('12894311000001106', ''),
('12890911000001102', ''),
('12894511000001100', ''),
('12890311000001104', ''),
('12894611000001100', ''),
('12892411000001106', ''),
('12894711000001104', ''),
('12891611000001104', ''),
('12895111000001108', ''),
('12894911000001108', ''),
('12894811000001102', ''),
('12893411000001102', ''),
('12904811000001104', ''),
('12898111000001104', ''),
('12904111000001104', ''),
('12897011000001100', ''),
('12904211000001108', ''),
('12899511000001100', ''),
('12904311000001100', ''),
('12898811000001104', ''),
('12904411000001108', ''),
('12901411000001106', ''),
('12904511000001108', ''),
('12901111000001100', ''),
('12904611000001106', ''),
('12902011000001104', ''),
('12904711000001102', ''),
('12901711000001100', ''),
('12904911000001100', ''),
('12902611000001104', ''),
('375489004', ''),
('12902311000001108', ''),
('36565611000001104', ''),
('3607611000001105', ''),
('5420911000001103', ''),
('24133311000001100', ''),
('38608611000001104', ''),
('39058211000001104', ''),
('12905011000001100', ''),
('12903211000001106', ''),
('12905111000001104', ''),
('12902911000001108', ''),
('12933911000001106', ''),
('12912911000001108', ''),
('12934011000001108', ''),
('12912611000001100', ''),
('12934111000001104', ''),
('12913611000001106', ''),
('12934211000001104', ''),
('12913211000001108', ''),
('12934311000001108', ''),
('12914211000001108', ''),
('12934411000001100', ''),
('12913911000001100', ''),
('12934511000001100', ''),
('12914811000001108', ''),
('12934611000001102', ''),
('12914511000001104', ''),
('12934711000001106', ''),
('12915411000001108', ''),
('12934811000001104', ''),
('12915111000001102', ''),
('12934911000001108', ''),
('12916011000001108', ''),
('12935011000001108', ''),
('12915711000001100', ''),
('12935111000001108', ''),
('12916611000001100', ''),
('12935211000001104', ''),
('12916311000001104', ''),
('324570005', ''),
('24209111000001104', ''),
('24421611000001108', ''),
('24549911000001108', ''),
('35952811000001108', ''),
('36774211000001112', ''),
('37460411000001104', ''),
('37556911000001104', ''),
('39237911000001112', ''),
('39498111000001104', ''),
('324558006', ''),
('180911000001108', ''),
('884111000001105', ''),
('537011000001109', ''),
('497811000001101', ''),
('4209111000001108', ''),
('9555111000001106', ''),
('11016111000001104', ''),
('17946711000001100', ''),
('20327411000001104', ''),
('21820711000001108', ''),
('29929911000001104', ''),
('30763811000001108', ''),
('30851211000001100', ''),
('37460811000001104', ''),
('39058411000001104', ''),
('12935311000001106', ''),
('12917211000001100', ''),
('12935411000001104', ''),
('12916911000001106', ''),
('12935511000001100', ''),
('12917811000001104', ''),
('12935611000001100', ''),
('12917511000001102', ''),
('12935711000001104', ''),
('12918411000001102', ''),
('12935811000001102', ''),
('12918111000001108', ''),
('12935911000001108', ''),
('12919011000001100', ''),
('12936011000001104', ''),
('12918711000001108', ''),
('12936111000001104', ''),
('12919611000001108', ''),
('12936211000001108', ''),
('12919311000001104', ''),
('12936311000001100', ''),
('12920211000001104', ''),
('12936411000001108', ''),
('12919911000001102', ''),
('12936511000001108', ''),
('12920811000001106', ''),
('12936611000001106', ''),
('12920511000001108', ''),
('12936711000001102', ''),
('12921411000001100', ''),
('12936811000001104', ''),
('12921111000001104', ''),
('12936911000001100', ''),
('12922011000001100', ''),
('12937011000001100', ''),
('12921711000001106', ''),
('12937111000001100', ''),
('12922611000001108', ''),
('12937211000001106', ''),
('12922311000001104', ''),
('12937311000001104', ''),
('12923211000001100', ''),
('12937411000001104', ''),
('12922911000001102', ''),
('32711000001109', ''),
('461311000001101', '')
GO
-- Query for Rx_Nitrofurantoin
SELECT * INTO #Rx_Nitrofurantoin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp57_Rx_Nitrofurantoin_codelist
ON DMD_ID = #tmp57_Rx_Nitrofurantoin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Norfloxacin
CREATE TABLE #tmp58_Rx_Norfloxacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp58_Rx_Norfloxacin_codelist (code, category) VALUES
('324621002', ''),
('822711000001105', ''),
('511511000001102', ''),
('739911000001102', ''),
('254211000001102', ''),
('17947511000001108', ''),
('18745111000001108', ''),
('21816311000001104', ''),
('35549811000001104', ''),
('866311000001103', '')
GO
-- Query for Rx_Norfloxacin
SELECT * INTO #Rx_Norfloxacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp58_Rx_Norfloxacin_codelist
ON DMD_ID = #tmp58_Rx_Norfloxacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ofloxacin
CREATE TABLE #tmp59_Rx_Ofloxacin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp59_Rx_Ofloxacin_codelist (code, category) VALUES
('12905211000001104', ''),
('12897211000001104', ''),
('12895811000001100', ''),
('12896211000001108', ''),
('324612003', ''),
('465511000001105', ''),
('792611000001106', ''),
('724511000001107', ''),
('319311000001109', ''),
('527011000001106', ''),
('4273411000001105', ''),
('7464011000001104', ''),
('15112111000001108', ''),
('16062011000001100', ''),
('21821611000001104', ''),
('30852711000001100', ''),
('37463211000001104', ''),
('39061711000001104', ''),
('38752711000001104', ''),
('12905311000001102', ''),
('12898411000001108', ''),
('12905411000001108', ''),
('12897811000001106', ''),
('324620001', ''),
('238911000001100', ''),
('339611000001109', ''),
('787111000001102', ''),
('525111000001103', ''),
('412511000001103', ''),
('4818111000001107', ''),
('7464911000001100', ''),
('15112411000001104', ''),
('16062211000001104', ''),
('30853111000001108', ''),
('37463811000001112', ''),
('39061911000001104', ''),
('362511000001106', ''),
('4415111000001109', ''),
('491611000001109', '')
GO
-- Query for Rx_Ofloxacin
SELECT * INTO #Rx_Ofloxacin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp59_Rx_Ofloxacin_codelist
ON DMD_ID = #tmp59_Rx_Ofloxacin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Oxytetracycline
CREATE TABLE #tmp60_Rx_Oxytetracycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp60_Rx_Oxytetracycline_codelist (code, category) VALUES
('3348411000001109', ''),
('13003711000001100', ''),
('12989211000001108', ''),
('13003811000001108', ''),
('12989611000001106', ''),
('324095003', ''),
('3345011000001108', ''),
('3345611000001101', ''),
('3346311000001101', ''),
('3347511000001109', ''),
('3347811000001107', ''),
('3349611000001103', ''),
('3350311000001102', ''),
('4331711000001105', ''),
('9802411000001100', ''),
('10436911000001108', ''),
('11013711000001104', ''),
('15114911000001104', ''),
('16062611000001108', ''),
('17951211000001102', ''),
('20326411000001108', ''),
('21829411000001108', ''),
('22473711000001108', ''),
('28918511000001104', ''),
('29006911000001104', ''),
('30071211000001104', ''),
('39070311000001104', ''),
('13003911000001104', ''),
('12990511000001100', ''),
('13004011000001100', ''),
('12991011000001104', '')
GO
-- Query for Rx_Oxytetracycline
SELECT * INTO #Rx_Oxytetracycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp60_Rx_Oxytetracycline_codelist
ON DMD_ID = #tmp60_Rx_Oxytetracycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Phenoxymethylpenicillin
CREATE TABLE #tmp61_Rx_Phenoxymethylpenicillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp61_Rx_Phenoxymethylpenicillin_codelist (code, category) VALUES
('22214211000001104', ''),
('22197411000001100', ''),
('323418000', ''),
('392411000001109', ''),
('683011000001103', ''),
('15311000001105', ''),
('808511000001109', ''),
('604211000001105', ''),
('610511000001102', ''),
('738911000001105', ''),
('10711000001104', ''),
('9804611000001104', ''),
('10452211000001100', ''),
('11144611000001104', ''),
('18719011000001104', ''),
('19736211000001104', ''),
('20129511000001108', ''),
('21038311000001108', ''),
('21532411000001100', ''),
('24410611000001108', ''),
('38081711000001104', ''),
('39177211000001104', ''),
('9215111000001108', ''),
('9209211000001100', ''),
('9253911000001104', ''),
('9308011000001108', ''),
('9842311000001100', ''),
('10452611000001104', ''),
('16165811000001108', ''),
('17954311000001108', ''),
('21038711000001108', ''),
('21844311000001104', ''),
('21863211000001104', ''),
('28097111000001104', ''),
('31058611000001104', ''),
('32490911000001108', ''),
('37772411000001104', ''),
('39177411000001104', ''),
('323416001', ''),
('765311000001105', ''),
('35211000001107', ''),
('799511000001103', ''),
('871611000001108', ''),
('482711000001106', ''),
('420411000001107', ''),
('78111000001109', ''),
('634711000001107', ''),
('839711000001102', ''),
('821311000001102', ''),
('9803511000001108', ''),
('10430511000001104', ''),
('16063111000001104', ''),
('17954711000001108', ''),
('19730711000001100', ''),
('21844711000001100', ''),
('28985911000001104', ''),
('29983311000001108', ''),
('30856411000001108', ''),
('32489211000001104', ''),
('37773011000001104', ''),
('39176911000001104', ''),
('323420002', ''),
('94811000001103', ''),
('209811000001108', ''),
('289911000001104', ''),
('770211000001102', ''),
('189311000001103', ''),
('887811000001107', ''),
('333711000001103', ''),
('322611000001104', ''),
('9805411000001108', ''),
('10452411000001102', ''),
('18719411000001108', ''),
('20129711000001104', ''),
('21038511000001104', ''),
('21532611000001104', ''),
('30856011000001104', ''),
('37772611000001104', ''),
('38081911000001104', ''),
('39177611000001104', ''),
('9215211000001100', ''),
('9209511000001104', ''),
('9254111000001100', ''),
('9308211000001104', ''),
('9842511000001106', ''),
('10452811000001100', ''),
('11533211000001108', ''),
('16166011000001106', ''),
('17954511000001102', ''),
('21038911000001104', ''),
('21834511000001104', ''),
('21844511000001104', ''),
('28097311000001108', ''),
('30856211000001108', ''),
('31058811000001100', ''),
('32492211000001104', ''),
('37772811000001104', ''),
('39177811000001104', ''),
('849911000001104', '')
GO
-- Query for Rx_Phenoxymethylpenicillin
SELECT * INTO #Rx_Phenoxymethylpenicillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp61_Rx_Phenoxymethylpenicillin_codelist
ON DMD_ID = #tmp61_Rx_Phenoxymethylpenicillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Piperacillin
CREATE TABLE #tmp62_Rx_Piperacillin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp62_Rx_Piperacillin_codelist (code, category) VALUES
('323673005', ''),
('15442611000001108', ''),
('34755211000001104', ''),
('36607511000001104', ''),
('36612211000001104', ''),
('38801411000001112', ''),
('15519011000001108', ''),
('16733411000001108', ''),
('18781411000001104', ''),
('19519511000001104', ''),
('22599711000001104', ''),
('24014211000001104', ''),
('4651611000001105', ''),
('323671007', ''),
('15442811000001106', ''),
('19518711000001104', ''),
('34680211000001108', ''),
('34755411000001104', ''),
('36607211000001104', ''),
('36611611000001104', ''),
('36798311000001104', ''),
('17899511000001104', ''),
('18166311000001100', ''),
('22599211000001104', ''),
('4437611000001103', ''),
('4641311000001103', ''),
('4437911000001109', '')
GO
-- Query for Rx_Piperacillin
SELECT * INTO #Rx_Piperacillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp62_Rx_Piperacillin_codelist
ON DMD_ID = #tmp62_Rx_Piperacillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Pivmecillinam
CREATE TABLE #tmp63_Rx_Pivmecillinam_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp63_Rx_Pivmecillinam_codelist (code, category) VALUES
('39702711000001104', ''),
('35175011000001108', ''),
('37305311000001104', ''),
('37775511000001112', ''),
('32750311000001104', ''),
('32744411000001108', ''),
('3685611000001102', '')
GO
-- Query for Rx_Pivmecillinam
SELECT * INTO #Rx_Pivmecillinam FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp63_Rx_Pivmecillinam_codelist
ON DMD_ID = #tmp63_Rx_Pivmecillinam_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Pristinamycin
CREATE TABLE #tmp64_Rx_Pristinamycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp64_Rx_Pristinamycin_codelist (code, category) VALUES
('16324411000001104', ''),
('20591911000001100', ''),
('16248411000001104', '')
GO
-- Query for Rx_Pristinamycin
SELECT * INTO #Rx_Pristinamycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp64_Rx_Pristinamycin_codelist
ON DMD_ID = #tmp64_Rx_Pristinamycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Rifaximin
CREATE TABLE #tmp65_Rx_Rifaximin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp65_Rx_Rifaximin_codelist (code, category) VALUES
('22175211000001100', ''),
('12556911000001106', ''),
('22192511000001100', ''),
('34604811000001100', ''),
('412555008', ''),
('15877511000001100', ''),
('445522003', ''),
('20442211000001104', ''),
('21874811000001108', ''),
('20441311000001104', ''),
('19475511000001108', '')
GO
-- Query for Rx_Rifaximin
SELECT * INTO #Rx_Rifaximin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp65_Rx_Rifaximin_codelist
ON DMD_ID = #tmp65_Rx_Rifaximin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Sulfadiazine
CREATE TABLE #tmp66_Rx_Sulfadiazine_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp66_Rx_Sulfadiazine_codelist (code, category) VALUES
('13454711000001102', ''),
('13449711000001104', ''),
('13454811000001104', ''),
('13450511000001104', ''),
('324411000', ''),
('4104011000001108', ''),
('4104411000001104', ''),
('4104611000001101', ''),
('4104911000001107', ''),
('21903611000001104', ''),
('26857011000001108', ''),
('13454911000001100', ''),
('13450011000001106', '')
GO
-- Query for Rx_Sulfadiazine
SELECT * INTO #Rx_Sulfadiazine FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp66_Rx_Sulfadiazine_codelist
ON DMD_ID = #tmp66_Rx_Sulfadiazine_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Sulfamethoxazole
CREATE TABLE #tmp67_Rx_Sulfamethoxazole_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp67_Rx_Sulfamethoxazole_codelist (code, category) VALUES
('5241611000001103', ''),
('13539611000001104', ''),
('27397711000001104', '')
GO
-- Query for Rx_Sulfamethoxazole
SELECT * INTO #Rx_Sulfamethoxazole FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp67_Rx_Sulfamethoxazole_codelist
ON DMD_ID = #tmp67_Rx_Sulfamethoxazole_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Sulfapyridine
CREATE TABLE #tmp68_Rx_Sulfapyridine_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp68_Rx_Sulfapyridine_codelist (code, category) VALUES
('15474111000001108', ''),
('21268011000001108', '')
GO
-- Query for Rx_Sulfapyridine
SELECT * INTO #Rx_Sulfapyridine FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp68_Rx_Sulfapyridine_codelist
ON DMD_ID = #tmp68_Rx_Sulfapyridine_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Taurolidin
CREATE TABLE #tmp69_Rx_Taurolidin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp69_Rx_Taurolidin_codelist (code, category) VALUES
('20151411000001108', ''),
('20177311000001108', ''),
('20151811000001108', ''),
('20152111000001108', '')
GO
-- Query for Rx_Taurolidin
SELECT * INTO #Rx_Taurolidin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp69_Rx_Taurolidin_codelist
ON DMD_ID = #tmp69_Rx_Taurolidin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Tedizolid
CREATE TABLE #tmp70_Rx_Tedizolid_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp70_Rx_Tedizolid_codelist (code, category) VALUES
('29722811000001108', ''),
('29723111000001104', ''),
('29734011000001108', ''),
('703915009', '')
GO
-- Query for Rx_Tedizolid
SELECT * INTO #Rx_Tedizolid FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp70_Rx_Tedizolid_codelist
ON DMD_ID = #tmp70_Rx_Tedizolid_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Teicoplanin
CREATE TABLE #tmp71_Rx_Teicoplanin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp71_Rx_Teicoplanin_codelist (code, category) VALUES
('4181011000001109', ''),
('4182311000001103', ''),
('35915111000001104', ''),
('36769311000001104', ''),
('35915211000001108', ''),
('36761811000001104', ''),
('39653611000001104', '')
GO
-- Query for Rx_Teicoplanin
SELECT * INTO #Rx_Teicoplanin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp71_Rx_Teicoplanin_codelist
ON DMD_ID = #tmp71_Rx_Teicoplanin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Telithromycin
CREATE TABLE #tmp72_Rx_Telithromycin_codelist (
code VARCHAR(14) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp72_Rx_Telithromycin_codelist (code, category) VALUES
('98311000001102', ''),
('407790000', '')
GO
-- Query for Rx_Telithromycin
SELECT * INTO #Rx_Telithromycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp72_Rx_Telithromycin_codelist
ON DMD_ID = #tmp72_Rx_Telithromycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Temocillin
CREATE TABLE #tmp73_Rx_Temocillin_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp73_Rx_Temocillin_codelist (code, category) VALUES
('9549311000001108', ''),
('9553611000001102', '')
GO
-- Query for Rx_Temocillin
SELECT * INTO #Rx_Temocillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp73_Rx_Temocillin_codelist
ON DMD_ID = #tmp73_Rx_Temocillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Tetracycline
CREATE TABLE #tmp74_Rx_Tetracycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp74_Rx_Tetracycline_codelist (code, category) VALUES
('4548811000001106', ''),
('917911000001109', ''),
('34819711000001100', ''),
('3348811000001106', ''),
('21407411000001104', ''),
('21406411000001100', ''),
('39704711000001104', ''),
('20291511000001104', ''),
('39704811000001112', ''),
('47611000001101', ''),
('205211000001109', ''),
('357111000001108', ''),
('625311000001105', ''),
('17875711000001104', ''),
('17962811000001100', ''),
('21787511000001108', ''),
('22473211000001100', ''),
('35593811000001104', ''),
('36074811000001104', ''),
('37824111000001104', '')
GO
-- Query for Rx_Tetracycline
SELECT * INTO #Rx_Tetracycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp74_Rx_Tetracycline_codelist
ON DMD_ID = #tmp74_Rx_Tetracycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Ticarcillin
CREATE TABLE #tmp75_Rx_Ticarcillin_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp75_Rx_Ticarcillin_codelist (code, category) VALUES
('323772006', ''),
('4413311000001105', '')
GO
-- Query for Rx_Ticarcillin
SELECT * INTO #Rx_Ticarcillin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp75_Rx_Ticarcillin_codelist
ON DMD_ID = #tmp75_Rx_Ticarcillin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Tigecycline
CREATE TABLE #tmp76_Rx_Tigecycline_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp76_Rx_Tigecycline_codelist (code, category) VALUES
('10328711000001100', ''),
('35204411000001108', ''),
('10321011000001108', '')
GO
-- Query for Rx_Tigecycline
SELECT * INTO #Rx_Tigecycline FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp76_Rx_Tigecycline_codelist
ON DMD_ID = #tmp76_Rx_Tigecycline_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Tinidazole
CREATE TABLE #tmp77_Rx_Tinidazole_codelist (
code VARCHAR(16) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp77_Rx_Tinidazole_codelist (code, category) VALUES
('3747511000001105', ''),
('324554008', '')
GO
-- Query for Rx_Tinidazole
SELECT * INTO #Rx_Tinidazole FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp77_Rx_Tinidazole_codelist
ON DMD_ID = #tmp77_Rx_Tinidazole_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Tobramycin
CREATE TABLE #tmp78_Rx_Tobramycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp78_Rx_Tobramycin_codelist (code, category) VALUES
('4514911000001102', ''),
('4128611000001102', ''),
('34194211000001104', ''),
('23676411000001104', ''),
('23671411000001108', ''),
('4516011000001106', ''),
('4514611000001108', ''),
('35777411000001100', ''),
('19544811000001100', ''),
('35919711000001100', ''),
('4514311000001103', ''),
('4957911000001108', ''),
('4944011000001104', ''),
('4944311000001101', ''),
('4944511000001107', ''),
('9187611000001104', ''),
('12949611000001104', ''),
('32656811000001108', ''),
('32645711000001104', ''),
('35919811000001108', ''),
('4158411000001104', ''),
('4145011000001103', ''),
('4127011000001108', ''),
('4128011000001109', ''),
('4129111000001103', ''),
('9187811000001108', ''),
('12949811000001100', ''),
('26857411000001100', ''),
('38027711000001104', '')
GO
-- Query for Rx_Tobramycin
SELECT * INTO #Rx_Tobramycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp78_Rx_Tobramycin_codelist
ON DMD_ID = #tmp78_Rx_Tobramycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Trimethoprim
CREATE TABLE #tmp79_Rx_Trimethoprim_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp79_Rx_Trimethoprim_codelist (code, category) VALUES
('324359004', ''),
('26777411000001104', ''),
('30994911000001108', ''),
('32278611000001104', ''),
('32506211000001108', ''),
('34958311000001104', ''),
('37232311000001104', ''),
('37896711000001104', ''),
('38859311000001104', ''),
('36091911000001104', ''),
('7817111000001101', ''),
('35313211000001104', ''),
('32431411000001104', ''),
('32501611000001104', ''),
('32505711000001104', ''),
('37232111000001104', ''),
('38859611000001104', ''),
('324357002', ''),
('688711000001107', ''),
('802611000001106', ''),
('517111000001104', ''),
('812711000001104', ''),
('14942811000001104', ''),
('17889311000001104', ''),
('21942611000001108', ''),
('23858211000001108', ''),
('26776811000001104', ''),
('28922511000001104', ''),
('29826011000001104', ''),
('32281711000001104', ''),
('34958511000001104', ''),
('38859111000001104', ''),
('324362001', ''),
('32280411000001100', ''),
('32501811000001100', ''),
('32507511000001108', ''),
('3653911000001100', ''),
('3625511000001107', ''),
('3625711000001102', ''),
('3626311000001106', ''),
('32519811000001100', ''),
('426411000001109', ''),
('735011000001103', ''),
('95811000001102', ''),
('789611000001100', ''),
('96711000001102', ''),
('3626011000001108', ''),
('764411000001104', ''),
('3757311000001102', ''),
('659211000001100', ''),
('324430000', ''),
('710811000001108', ''),
('897711000001103', ''),
('121511000001103', ''),
('426711000001103', ''),
('250811000001106', ''),
('46511000001102', ''),
('6038911000001109', ''),
('9800011000001104', ''),
('10414811000001100', ''),
('15199811000001106', ''),
('16070411000001100', ''),
('17865911000001106', ''),
('21906211000001104', ''),
('28917911000001104', ''),
('30106111000001104', ''),
('30942111000001104', ''),
('36144011000001104', ''),
('324431001', ''),
('15911000001106', ''),
('339211000001107', ''),
('187211000001100', ''),
('416811000001104', ''),
('112111000001106', ''),
('664011000001104', ''),
('490311000001109', ''),
('6039711000001103', ''),
('9799411000001106', ''),
('10415011000001104', ''),
('16071011000001100', ''),
('17866111000001102', ''),
('20170611000001104', ''),
('21906411000001104', ''),
('28988711000001104', ''),
('30106311000001100', ''),
('30942311000001108', ''),
('13374511000001100', ''),
('13363211000001108', ''),
('13374611000001102', ''),
('13361311000001100', ''),
('13374711000001106', ''),
('13363511000001106', ''),
('13374811000001104', ''),
('13361711000001102', ''),
('13374911000001108', ''),
('13363811000001108', ''),
('13375011000001108', ''),
('13362311000001104', ''),
('39022311000001104', ''),
('665011000001100', ''),
('733211000001109', ''),
('845811000001106', ''),
('543111000001101', ''),
('13627411000001100', ''),
('15200311000001106', ''),
('15861911000001104', ''),
('17865711000001108', ''),
('17962411000001102', ''),
('22387811000001108', ''),
('30835311000001104', ''),
('30941811000001108', ''),
('13375111000001108', ''),
('13364111000001100', ''),
('13375211000001104', ''),
('13362611000001100', ''),
('38080911000001104', ''),
('38081511000001104', ''),
('431211000001104', ''),
('329711000001102', '')
GO
-- Query for Rx_Trimethoprim
SELECT * INTO #Rx_Trimethoprim FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp79_Rx_Trimethoprim_codelist
ON DMD_ID = #tmp79_Rx_Trimethoprim_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for Rx_Vancomycin
CREATE TABLE #tmp80_Rx_Vancomycin_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp80_Rx_Vancomycin_codelist (code, category) VALUES
('34377311000001104', ''),
('4432611000001101', ''),
('4213311000001109', ''),
('4128511000001101', ''),
('4203811000001103', ''),
('324334008', ''),
('4126811000001104', ''),
('4127711000001105', ''),
('4128311000001107', ''),
('24566911000001108', ''),
('37436111000001104', ''),
('37832911000001104', ''),
('37877211000001104', ''),
('15453011000001108', ''),
('15445311000001108', ''),
('15453111000001108', ''),
('15445611000001104', ''),
('4432811000001102', ''),
('32895411000001100', ''),
('34758511000001108', ''),
('35829811000001108', ''),
('36759411000001104', ''),
('324333002', ''),
('4432211000001103', ''),
('4432411000001104', ''),
('4433011000001104', ''),
('15048611000001104', ''),
('19455111000001100', ''),
('24517611000001100', ''),
('26858511000001104', ''),
('36517611000001104', ''),
('324335009', ''),
('4202811000001106', ''),
('4203311000001107', ''),
('4203511000001101', ''),
('37725211000001104', ''),
('8818611000001100', ''),
('8815211000001109', ''),
('8818711000001109', ''),
('8815711000001102', ''),
('4213611000001104', ''),
('23872411000001108', ''),
('32895211000001100', ''),
('34758311000001100', ''),
('35830111000001108', ''),
('324337001', ''),
('4212611000001109', ''),
('4212911000001103', ''),
('4213811000001100', ''),
('15165911000001100', ''),
('19456211000001100', ''),
('24517411000001104', ''),
('36517311000001104', ''),
('12940811000001108', ''),
('12933111000001108', ''),
('13455811000001106', ''),
('13450811000001100', '')
GO
-- Query for Rx_Vancomycin
SELECT * INTO #Rx_Vancomycin FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp80_Rx_Vancomycin_codelist
ON DMD_ID = #tmp80_Rx_Vancomycin_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for ab_prescriptions
CREATE TABLE #tmp81_ab_prescriptions_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp81_ab_prescriptions_codelist (code, category) VALUES
('323398002', ''),
('27871711000001100', ''),
('28038711000001103', ''),
('27732411000001100', ''),
('323396003', ''),
('27872411000001101', ''),
('28035511000001100', ''),
('27732211000001104', ''),
('3880811000001103', ''),
('4074311000001105', ''),
('323418000', ''),
('392411000001109', ''),
('683011000001103', ''),
('10711000001104', ''),
('9804611000001105', ''),
('10452211000001101', ''),
('21038311000001109', ''),
('20129511000001108', ''),
('24410611000001107', ''),
('21532411000001101', ''),
('38081711000001100', ''),
('604211000001105', ''),
('11144611000001104', ''),
('610511000001102', ''),
('19736211000001105', ''),
('808511000001109', ''),
('738911000001105', ''),
('18719011000001104', ''),
('15311000001105', ''),
('323420002', ''),
('94811000001103', ''),
('209811000001108', ''),
('322611000001104', ''),
('9805411000001108', ''),
('10452411000001102', ''),
('21038511000001103', ''),
('20129711000001103', ''),
('37772611000001104', ''),
('21532611000001103', ''),
('38081911000001103', ''),
('189311000001103', ''),
('887811000001107', ''),
('30856011000001103', ''),
('770211000001102', ''),
('333711000001103', ''),
('18719411000001108', ''),
('289911000001104', ''),
('323416001', ''),
('765311000001105', ''),
('35211000001107', ''),
('821311000001102', ''),
('9803511000001108', ''),
('10430511000001103', ''),
('16063111000001105', ''),
('32489211000001105', ''),
('28985911000001106', ''),
('37773011000001102', ''),
('420411000001107', ''),
('78111000001109', ''),
('30856411000001107', ''),
('19730711000001101', ''),
('482711000001106', ''),
('17954711000001107', ''),
('839711000001102', ''),
('634711000001107', ''),
('29983311000001107', ''),
('799511000001103', ''),
('871611000001108', ''),
('21844711000001100', ''),
('9215111000001107', ''),
('9253911000001104', ''),
('31058611000001104', ''),
('16165811000001108', ''),
('28097111000001105', ''),
('10452611000001104', ''),
('21038711000001108', ''),
('32490911000001108', ''),
('21863211000001102', ''),
('37772411000001102', ''),
('9209211000001101', ''),
('9842311000001100', ''),
('17954311000001108', ''),
('9308011000001109', ''),
('21844311000001104', ''),
('9215211000001101', ''),
('9254111000001100', ''),
('31058811000001100', ''),
('16166011000001106', ''),
('28097311000001107', ''),
('10452811000001100', ''),
('21038911000001105', ''),
('32492211000001103', ''),
('21834511000001106', ''),
('37772811000001100', ''),
('9209511000001103', ''),
('30856211000001108', ''),
('9842511000001106', ''),
('17954511000001102', ''),
('11533211000001107', ''),
('9308211000001104', ''),
('21844511000001105', ''),
('22214211000001105', ''),
('22197411000001101', ''),
('849911000001104', ''),
('323464005', ''),
('120711000001100', ''),
('699911000001102', ''),
('916911000001106', ''),
('9798411000001103', ''),
('10407811000001107', ''),
('16050611000001101', ''),
('23907811000001108', ''),
('194111000001102', ''),
('627011000001100', ''),
('30130811000001104', ''),
('38915011000001109', ''),
('19728911000001100', ''),
('19193011000001107', ''),
('850811000001102', ''),
('37506211000001106', ''),
('17908511000001102', ''),
('220311000001101', ''),
('135511000001102', ''),
('15087311000001100', ''),
('333211000001105', ''),
('21996911000001108', ''),
('323465006', ''),
('289411000001107', ''),
('3111000001109', ''),
('32611000001100', ''),
('9798911000001106', ''),
('10408011000001100', ''),
('16050911000001107', ''),
('23908511000001109', ''),
('568111000001102', ''),
('590311000001104', ''),
('30131011000001101', ''),
('38915211000001104', ''),
('19729111000001105', ''),
('19193211000001102', ''),
('401911000001101', ''),
('36738011000001105', ''),
('17908811000001104', ''),
('629811000001103', ''),
('770011000001107', ''),
('15087511000001106', ''),
('833311000001104', ''),
('21997211000001102', ''),
('323491007', ''),
('97911000001102', ''),
('34753011000001106', ''),
('231911000001109', ''),
('323492000', ''),
('390611000001106', ''),
('162711000001108', ''),
('34753211000001101', ''),
('9142811000001101', ''),
('36921811000001102', ''),
('256511000001105', ''),
('323493005', ''),
('661411000001106', ''),
('34752811000001108', ''),
('9143111000001102', ''),
('36921411000001104', ''),
('858411000001101', ''),
('323484009', ''),
('513711000001108', ''),
('103311000001100', ''),
('207211000001101', ''),
('10454211000001105', ''),
('20136411000001100', ''),
('13578111000001101', ''),
('719411000001101', ''),
('138411000001106', ''),
('38914811000001104', ''),
('23189811000001102', ''),
('19193411000001103', ''),
('337811000001100', ''),
('18107711000001103', ''),
('746511000001103', ''),
('767311000001102', ''),
('21997911000001106', ''),
('323485005', ''),
('11268511000001102', ''),
('16086311000001101', ''),
('18722811000001105', ''),
('20137211000001102', ''),
('13578311000001104', ''),
('4835611000001101', ''),
('38915611000001102', ''),
('18107911000001101', ''),
('38076711000001103', ''),
('21998111000001109', ''),
('16089611000001103', ''),
('16443111000001108', ''),
('16086911000001100', ''),
('27126211000001105', ''),
('28096311000001109', ''),
('38619411000001101', ''),
('23979011000001102', ''),
('16247911000001103', ''),
('38915411000001100', ''),
('37732411000001104', ''),
('21997511000001104', ''),
('16089711000001107', ''),
('16443611000001100', ''),
('16086611000001106', ''),
('27126411000001109', ''),
('28096511000001103', ''),
('38619611000001103', ''),
('23979211000001107', ''),
('16248111000001100', ''),
('38915811000001103', ''),
('37732211000001103', ''),
('21997711000001109', ''),
('34769611000001109', ''),
('34753511000001103', ''),
('471111000001107', ''),
('888011000001100', ''),
('865811000001104', ''),
('324711000001103', ''),
('419411000001108', ''),
('748211000001100', ''),
('703911000001109', ''),
('251311000001107', ''),
('499611000001105', ''),
('323496002', ''),
('323474008', ''),
('811111000001105', ''),
('442211000001107', ''),
('9553611000001102', ''),
('9549311000001107', ''),
('323509004', ''),
('558111000001107', ''),
('23477711000001105', ''),
('739011000001101', ''),
('145611000001104', ''),
('9785311000001100', ''),
('10380511000001103', ''),
('12948011000001101', ''),
('15981611000001108', ''),
('33680711000001103', ''),
('22608411000001104', ''),
('36932811000001108', ''),
('325811000001107', ''),
('833211000001107', ''),
('29993011000001108', ''),
('38787311000001107', ''),
('19725711000001109', ''),
('19187411000001106', ''),
('413911000001103', ''),
('17779911000001102', ''),
('35591111000001108', ''),
('458811000001108', ''),
('228311000001104', ''),
('29765011000001104', ''),
('361711000001108', ''),
('21764811000001100', ''),
('18145411000001107', ''),
('323510009', ''),
('930411000001106', ''),
('18458211000001102', ''),
('406811000001101', ''),
('116511000001101', ''),
('9785911000001104', ''),
('10381311000001104', ''),
('12948211000001106', ''),
('15981911000001102', ''),
('33680911000001101', ''),
('22608811000001102', ''),
('36933111000001107', ''),
('802011000001104', ''),
('13811000001100', ''),
('29993211000001103', ''),
('38787911000001108', ''),
('19726111000001102', ''),
('19187611000001109', ''),
('816511000001105', ''),
('36693511000001106', ''),
('268011000001106', ''),
('17780311000001103', ''),
('35591411000001103', ''),
('181511000001108', ''),
('53711000001102', ''),
('29769211000001107', ''),
('668411000001104', ''),
('21765611000001103', ''),
('18146111000001108', ''),
('35902111000001107', ''),
('3241411000001109', ''),
('3246511000001104', ''),
('32496011000001107', ''),
('22609211000001108', ''),
('3246011000001107', ''),
('29993711000001105', ''),
('38788311000001108', ''),
('18081411000001108', ''),
('29765411000001108', ''),
('3243811000001105', ''),
('21766011000001101', ''),
('35368511000001109', ''),
('323732002', ''),
('634511000001102', ''),
('159311000001109', ''),
('549011000001104', ''),
('9786511000001104', ''),
('10426911000001105', ''),
('15984311000001100', ''),
('28943411000001109', ''),
('22609411000001107', ''),
('143211000001100', ''),
('329011000001104', ''),
('38785711000001100', ''),
('860211000001109', ''),
('17781111000001106', ''),
('144711000001109', ''),
('856111000001107', ''),
('29769411000001106', ''),
('200311000001108', ''),
('21766511000001109', ''),
('323733007', ''),
('819911000001107', ''),
('256911000001103', ''),
('767611000001107', ''),
('9786911000001106', ''),
('10427411000001100', ''),
('15984511000001106', ''),
('28943611000001107', ''),
('22609811000001109', ''),
('555611000001105', ''),
('213311000001100', ''),
('38787511000001101', ''),
('568411000001107', ''),
('17781711000001107', ''),
('673011000001105', ''),
('828811000001100', ''),
('15065511000001104', ''),
('830011000001107', ''),
('21776211000001103', ''),
('35901911000001104', ''),
('756511000001100', ''),
('623711000001108', ''),
('264811000001108', ''),
('9787111000001106', ''),
('10428011000001105', ''),
('15984711000001101', ''),
('22609611000001105', ''),
('69611000001101', ''),
('416211000001100', ''),
('29993911000001107', ''),
('38785511000001105', ''),
('35852611000001101', ''),
('311000001109', ''),
('17781911000001109', ''),
('35591711000001109', ''),
('709111000001109', ''),
('29764511000001106', ''),
('222511000001108', ''),
('21775811000001105', ''),
('548011000001109', ''),
('328211000001104', ''),
('730511000001101', ''),
('9787311000001108', ''),
('10428411000001101', ''),
('15984911000001104', ''),
('22610011000001109', ''),
('203311000001102', ''),
('693411000001108', ''),
('37033411000001105', ''),
('38787711000001106', ''),
('35852011000001108', ''),
('930911000001103', ''),
('17782111000001101', ''),
('35591911000001106', ''),
('88811000001107', ''),
('29765211000001109', ''),
('520311000001108', ''),
('21776011000001108', ''),
('38726811000001109', ''),
('38719511000001105', ''),
('388611000001105', ''),
('709311000001106', ''),
('234411000001104', ''),
('689711000001103', ''),
('389311000001106', ''),
('3243311000001101', ''),
('196111000001109', ''),
('644811000001100', ''),
('121011000001106', ''),
('774011000001100', ''),
('252511000001109', ''),
('500511000001107', ''),
('19211000001104', ''),
('42011000001106', ''),
('284811000001105', ''),
('2011000001104', ''),
('130111000001103', ''),
('874611000001105', ''),
('190111000001106', ''),
('161011000001103', ''),
('14811000001102', ''),
('7339611000001107', ''),
('7339811000001106', ''),
('323737008', ''),
('90411000001106', ''),
('34748011000001101', ''),
('283611000001108', ''),
('323738003', ''),
('834911000001101', ''),
('34748211000001106', ''),
('719311000001108', ''),
('323739006', ''),
('279111000001107', ''),
('34748411000001105', ''),
('144611000001100', ''),
('388911000001104', ''),
('120411000001106', ''),
('71111000001101', ''),
('323570001', ''),
('875911000001100', ''),
('536211000001101', ''),
('529211000001107', ''),
('10382011000001105', ''),
('28944411000001107', ''),
('13575311000001108', ''),
('30976211000001103', ''),
('698211000001101', ''),
('29994111000001106', ''),
('38788511000001102', ''),
('305911000001106', ''),
('17782311000001104', ''),
('10565411000001109', ''),
('29769811000001108', ''),
('21776411000001104', ''),
('323571002', ''),
('443811000001100', ''),
('578311000001106', ''),
('597311000001103', ''),
('10382211000001100', ''),
('28944611000001105', ''),
('30976411000001104', ''),
('755311000001101', ''),
('29994311000001108', ''),
('38788711000001107', ''),
('217411000001100', ''),
('17782711000001100', ''),
('10565611000001107', ''),
('15066311000001100', ''),
('323584006', ''),
('10355811000001100', ''),
('9725711000001105', ''),
('9505311000001100', ''),
('323572009', ''),
('8169711000001108', ''),
('268411000001102', ''),
('352711000001107', ''),
('24024611000001104', ''),
('938511000001108', ''),
('531211000001109', ''),
('18081811000001105', ''),
('15065711000001109', ''),
('323573004', ''),
('8169911000001105', ''),
('310511000001106', ''),
('45311000001103', ''),
('28927211000001104', ''),
('649511000001104', ''),
('328611000001102', ''),
('18082611000001100', ''),
('15066011000001103', ''),
('850311000001106', ''),
('9385411000001106', ''),
('12778811000001103', ''),
('12778611000001102', ''),
('414211000001105', ''),
('323563001', ''),
('38111000001106', ''),
('19833711000001107', ''),
('382811000001107', ''),
('101911000001100', ''),
('9786711000001109', ''),
('10397411000001104', ''),
('34962611000001109', ''),
('32397711000001104', ''),
('35907111000001109', ''),
('23827411000001108', ''),
('760411000001105', ''),
('12511000001105', ''),
('30016311000001106', ''),
('38848311000001101', ''),
('441311000001108', ''),
('17885811000001104', ''),
('91211000001101', ''),
('35563511000001103', ''),
('882211000001108', ''),
('29794911000001102', ''),
('771411000001107', ''),
('36868011000001101', ''),
('22009111000001105', ''),
('380711000001103', ''),
('36565811000001104', ''),
('829311000001103', ''),
('15515811000001104', ''),
('370711000001105', ''),
('9787711000001107', ''),
('22602311000001108', ''),
('575411000001109', ''),
('276811000001106', ''),
('38850811000001105', ''),
('4817111000001106', ''),
('17885411000001101', ''),
('193411000001109', ''),
('6032711000001109', ''),
('894611000001101', ''),
('22007211000001105', ''),
('323567000', ''),
('18757611000001105', ''),
('34752211000001107', ''),
('10219611000001104', ''),
('36626111000001101', ''),
('10530611000001105', ''),
('5488611000001104', ''),
('323568005', ''),
('19570811000001107', ''),
('34752411000001106', ''),
('37830211000001102', ''),
('10219211000001101', ''),
('30347811000001105', ''),
('36626911000001103', ''),
('10531011000001107', ''),
('5489611000001108', ''),
('37083611000001104', ''),
('732211000001103', ''),
('15516011000001101', ''),
('394111000001107', ''),
('9787911000001109', ''),
('22602511000001102', ''),
('353811000001107', ''),
('526211000001103', ''),
('30016111000001109', ''),
('38848111000001103', ''),
('36492911000001108', ''),
('4817311000001108', ''),
('17885611000001103', ''),
('22211000001104', ''),
('6034811000001107', ''),
('931011000001106', ''),
('22007711000001103', ''),
('3964011000001108', ''),
('7322211000001104', ''),
('13613111000001106', ''),
('24026411000001105', ''),
('23939811000001105', ''),
('31989511000001109', ''),
('24520711000001100', ''),
('38848811000001105', ''),
('7320111000001106', ''),
('28123611000001108', ''),
('29794511000001109', ''),
('22008011000001104', ''),
('7322311000001107', ''),
('11528611000001104', ''),
('24026611000001108', ''),
('23940311000001109', ''),
('31989811000001107', ''),
('24520911000001103', ''),
('38849111000001105', ''),
('7320411000001101', ''),
('28123911000001102', ''),
('29794711000001104', ''),
('22008411000001108', ''),
('323539009', ''),
('290311000001105', ''),
('19833911000001109', ''),
('17668811000001104', ''),
('680711000001105', ''),
('34679211000001108', ''),
('10397711000001105', ''),
('34962811000001108', ''),
('32399711000001107', ''),
('35907311000001106', ''),
('27959011000001105', ''),
('23828211000001108', ''),
('351311000001104', ''),
('785111000001106', ''),
('38848511000001107', ''),
('19728511000001107', ''),
('19199611000001103', ''),
('5629811000001102', ''),
('36695911000001103', ''),
('17886011000001101', ''),
('628011000001104', ''),
('35563911000001105', ''),
('6036511000001103', ''),
('29795111000001101', ''),
('934111000001105', ''),
('36870911000001108', ''),
('22009611000001102', ''),
('3964511000001100', ''),
('37083711000001108', ''),
('11252711000001103', ''),
('19876911000001100', ''),
('32403711000001100', ''),
('30043911000001108', ''),
('32399111000001106', ''),
('38850411000001108', ''),
('19728111000001103', ''),
('23651411000001107', ''),
('22036711000001105', ''),
('15077811000001102', ''),
('392259005', ''),
('28873411000001104', ''),
('28039411000001101', ''),
('32400011000001107', ''),
('27959911000001109', ''),
('30016511000001100', ''),
('29795311000001104', ''),
('94411000001100', ''),
('386811000001108', ''),
('549911000001100', ''),
('871511000001109', ''),
('932211000001108', ''),
('866111000001100', ''),
('292511000001103', ''),
('169511000001107', ''),
('29011000001102', ''),
('139811000001101', ''),
('57911000001109', ''),
('451111000001109', ''),
('618111000001108', ''),
('323624001', ''),
('599611000001103', ''),
('34411000001105', ''),
('728111000001109', ''),
('19818211000001104', ''),
('28922811000001101', ''),
('23857311000001102', ''),
('10292811000001106', ''),
('908411000001104', ''),
('146111000001101', ''),
('30018311000001105', ''),
('38857911000001104', ''),
('773911000001103', ''),
('17888511000001105', ''),
('382411000001105', ''),
('29798411000001101', ''),
('9627311000001106', ''),
('21941711000001107', ''),
('4006211000001100', ''),
('323626004', ''),
('21710711000001103', ''),
('36090611000001106', ''),
('18542211000001108', ''),
('18446411000001102', ''),
('18421711000001100', ''),
('435911000001105', ''),
('473311000001105', ''),
('3098711000001105', ''),
('323772006', ''),
('4413311000001105', ''),
('323673005', ''),
('34755211000001102', ''),
('36612211000001103', ''),
('38801411000001109', ''),
('36607511000001104', ''),
('15442611000001107', ''),
('16733411000001109', ''),
('18781411000001105', ''),
('15519011000001107', ''),
('19519511000001106', ''),
('22599711000001106', ''),
('24014211000001106', ''),
('323671007', ''),
('34755411000001103', ''),
('36611611000001107', ''),
('34680211000001108', ''),
('19518711000001105', ''),
('36798311000001102', ''),
('36607211000001102', ''),
('15442811000001106', ''),
('17899511000001103', ''),
('18166311000001101', ''),
('22599211000001104', ''),
('4651611000001105', ''),
('4437611000001103', ''),
('4437911000001109', ''),
('4641311000001103', ''),
('323786005', ''),
('37305311000001105', ''),
('37775511000001109', ''),
('35175011000001108', ''),
('32750311000001106', ''),
('32744411000001108', ''),
('3685611000001102', ''),
('323999000', ''),
('324000003', ''),
('4597311000001106', ''),
('4597911000001107', ''),
('324003001', ''),
('324004007', ''),
('324005008', ''),
('4626311000001109', ''),
('4626611000001104', ''),
('4627111000001105', ''),
('36458411000001105', ''),
('36458511000001109', ''),
('36456811000001106', ''),
('36457111000001101', ''),
('4457111000001107', ''),
('4452211000001104', ''),
('323935008', ''),
('323936009', ''),
('37987711000001105', ''),
('33631211000001106', ''),
('33627411000001104', ''),
('37986811000001104', ''),
('36515811000001100', ''),
('34800611000001101', ''),
('7654711000001109', ''),
('4981711000001108', ''),
('323791006', ''),
('275011000001109', ''),
('813911000001109', ''),
('10290911000001100', ''),
('636511000001108', ''),
('17826511000001101', ''),
('233911000001105', ''),
('270911000001104', ''),
('323792004', ''),
('4113911000001107', ''),
('10348111000001104', ''),
('25833611000001106', ''),
('31564011000001109', ''),
('890411000001105', ''),
('30008911000001108', ''),
('612411000001100', ''),
('32201411000001108', ''),
('18085911000001103', ''),
('171911000001109', ''),
('323793009', ''),
('4114111000001106', ''),
('8825311000001105', ''),
('25834011000001102', ''),
('31564611000001102', ''),
('5311000001107', ''),
('647311000001100', ''),
('32201711000001102', ''),
('18086111000001107', ''),
('400511000001101', ''),
('323795002', ''),
('744311000001103', ''),
('64011000001107', ''),
('10291411000001104', ''),
('4323911000001106', ''),
('17826711000001106', ''),
('923811000001104', ''),
('15073011000001102', ''),
('459111000001108', ''),
('36134211000001100', ''),
('3663611000001103', ''),
('804411000001101', ''),
('4324111000001105', ''),
('168011000001109', ''),
('36134011000001105', ''),
('37011000001109', ''),
('141511000001101', ''),
('10309911000001103', ''),
('17867211000001105', ''),
('576111000001105', ''),
('36134111000001106', ''),
('745411000001106', ''),
('594511000001101', ''),
('10310111000001109', ''),
('9764411000001109', ''),
('17867411000001109', ''),
('248911000001101', ''),
('793311000001106', ''),
('602211000001101', ''),
('252811000001107', ''),
('583511000001100', ''),
('555211000001108', ''),
('803611000001101', ''),
('531011000001104', ''),
('318811000001107', ''),
('869711000001109', ''),
('323813001', ''),
('7887711000001102', ''),
('5918311000001108', ''),
('19712411000001100', ''),
('30009111000001103', ''),
('38825011000001109', ''),
('17851711000001104', ''),
('8750411000001109', ''),
('4814611000001109', ''),
('15073211000001107', ''),
('21821711000001101', ''),
('323811004', ''),
('323812006', ''),
('323816009', ''),
('674111000001108', ''),
('912111000001109', ''),
('60011000001100', ''),
('304211000001103', ''),
('323973007', ''),
('36134411000001101', ''),
('370375008', ''),
('34762811000001103', ''),
('511411000001101', ''),
('3184511000001101', ''),
('323824004', ''),
('13611511000001101', ''),
('34750011000001101', ''),
('4532811000001108', ''),
('27971011000001109', ''),
('4532411000001106', ''),
('323825003', ''),
('13611811000001103', ''),
('34749811000001100', ''),
('3940811000001102', ''),
('27969111000001102', ''),
('36516011000001102', ''),
('3940211000001103', ''),
('4558311000001100', ''),
('13612211000001106', ''),
('4533911000001105', ''),
('27969611000001105', ''),
('36516211000001107', ''),
('4533711000001108', ''),
('4532011000001102', ''),
('3939811000001107', ''),
('4533411000001102', ''),
('323829009', ''),
('28788511000001103', ''),
('34800911000001107', ''),
('323830004', ''),
('28788811000001100', ''),
('34801211000001109', ''),
('4375311000001105', ''),
('4376311000001100', ''),
('37528311000001105', ''),
('37529711000001100', ''),
('323982001', ''),
('35369711000001108', ''),
('3929911000001104', ''),
('3930911000001108', ''),
('323989005', ''),
('13612411000001105', ''),
('34750811000001107', ''),
('23047711000001101', ''),
('27971211000001104', ''),
('323990001', ''),
('3977811000001102', ''),
('34751011000001105', ''),
('37336711000001105', ''),
('3978511000001101', ''),
('22824911000001102', ''),
('36516811000001108', ''),
('11400311000001106', ''),
('38564411000001109', ''),
('20100211000001107', ''),
('36541011000001102', ''),
('32483211000001108', ''),
('3978011000001109', ''),
('323991002', ''),
('23414711000001106', ''),
('36517011000001104', ''),
('4405611000001104', ''),
('34751211000001100', ''),
('4406311000001104', ''),
('20100411000001106', ''),
('36783811000001102', ''),
('32483411000001107', ''),
('4406011000001102', ''),
('4404611000001100', ''),
('3978911000001108', ''),
('4406611000001109', ''),
('323853003', ''),
('10188511000001108', ''),
('34750211000001106', ''),
('36537311000001106', ''),
('8744311000001107', ''),
('19837811000001105', ''),
('32483611000001105', ''),
('323854009', ''),
('10188111000001104', ''),
('34750411000001105', ''),
('36760611000001107', ''),
('8745211000001103', ''),
('23055511000001100', ''),
('36516411000001106', ''),
('19843211000001101', ''),
('36540611000001104', ''),
('32483811000001109', ''),
('9470311000001109', ''),
('323855005', ''),
('10188311000001102', ''),
('34750611000001108', ''),
('36611411000001109', ''),
('8745411000001104', ''),
('23057711000001104', ''),
('36516611000001109', ''),
('19842311000001104', ''),
('36540811000001100', ''),
('32484011000001101', ''),
('9470511000001103', ''),
('323852008', ''),
('323849000', ''),
('35798511000001105', ''),
('4373011000001106', ''),
('4374011000001108', ''),
('3930311000001107', ''),
('4374611000001101', ''),
('4375711000001109', ''),
('10283311000001108', ''),
('4374311000001106', ''),
('3930711000001106', ''),
('4374911000001107', ''),
('323880005', ''),
('4740011000001101', ''),
('34751411000001101', ''),
('36754511000001105', ''),
('36134711000001107', ''),
('3939111000001100', ''),
('11617911000001109', ''),
('36613111000001103', ''),
('36605111000001104', ''),
('36754311000001104', ''),
('4557611000001106', ''),
('4530611000001108', ''),
('11617611000001103', ''),
('36613311000001101', ''),
('36605311000001102', ''),
('36753811000001105', ''),
('4740211000001106', ''),
('3939311000001103', ''),
('4530311000001103', ''),
('11775211000001105', ''),
('11775411000001109', ''),
('11775611000001107', ''),
('323868002', ''),
('323869005', ''),
('10096411000001100', ''),
('10271811000001105', ''),
('19712711000001106', ''),
('30011011000001101', ''),
('38826311000001102', ''),
('17853111000001104', ''),
('9547111000001104', ''),
('15074511000001108', ''),
('10885511000001106', ''),
('13743011000001107', ''),
('21831411000001105', ''),
('323872003', ''),
('323874002', ''),
('228011000001102', ''),
('211911000001100', ''),
('238811000001105', ''),
('3253511000001109', ''),
('323883007', ''),
('716611000001106', ''),
('34811000001107', ''),
('606011000001105', ''),
('10388711000001105', ''),
('22631111000001107', ''),
('37509711000001109', ''),
('3611000001101', ''),
('763611000001104', ''),
('27996311000001105', ''),
('30009611000001106', ''),
('38826011000001100', ''),
('19187811000001108', ''),
('216811000001100', ''),
('9376611000001109', ''),
('17851911000001102', ''),
('612311000001107', ''),
('29782311000001109', ''),
('758111000001108', ''),
('21822811000001100', ''),
('323884001', ''),
('660211000001101', ''),
('596511000001107', ''),
('324911000001101', ''),
('10388911000001107', ''),
('22631511000001103', ''),
('37510111000001100', ''),
('648411000001106', ''),
('850211000001103', ''),
('27996611000001100', ''),
('30010111000001106', ''),
('38826411000001109', ''),
('19188011000001101', ''),
('86911000001101', ''),
('9376411000001106', ''),
('17852111000001105', ''),
('305811000001101', ''),
('29782711000001108', ''),
('587511000001105', ''),
('21823311000001104', ''),
('323887008', '')
GO
INSERT INTO #tmp81_ab_prescriptions_codelist (code, category) VALUES
('639611000001104', ''),
('640011000001104', ''),
('534211000001106', ''),
('10456111000001106', ''),
('22631711000001108', ''),
('37510911000001102', ''),
('34311000001103', ''),
('30010411000001101', ''),
('38825611000001102', ''),
('560011000001100', ''),
('18086311000001109', ''),
('233111000001107', ''),
('15073911000001103', ''),
('6211000001105', ''),
('21826411000001101', ''),
('323888003', ''),
('800711000001101', ''),
('707211000001109', ''),
('158511000001109', ''),
('10456311000001108', ''),
('30136211000001103', ''),
('37510711000001104', ''),
('835511000001109', ''),
('30010611000001103', ''),
('38827711000001100', ''),
('887911000001102', ''),
('18086511000001103', ''),
('728211000001103', ''),
('15074111000001104', ''),
('344611000001109', ''),
('21826611000001103', ''),
('36134311000001108', ''),
('30769411000001109', ''),
('31565211000001103', ''),
('8825611000001100', ''),
('32202211000001102', ''),
('15074311000001102', ''),
('21825911000001102', ''),
('323885000', ''),
('719911000001109', ''),
('924811000001101', ''),
('600911000001106', ''),
('10389111000001102', ''),
('22631911000001105', ''),
('37510511000001109', ''),
('360811000001108', ''),
('483611000001107', ''),
('427011000001102', ''),
('11267511000001101', ''),
('17852311000001107', ''),
('232811000001108', ''),
('15052511000001101', ''),
('362911000001104', ''),
('21827211000001103', ''),
('323886004', ''),
('652611000001105', ''),
('149411000001104', ''),
('863911000001108', ''),
('10389411000001107', ''),
('22632111000001102', ''),
('37510311000001103', ''),
('887511000001109', ''),
('331411000001105', ''),
('38824911000001109', ''),
('452411000001109', ''),
('11267711000001106', ''),
('17852511000001101', ''),
('687811000001103', ''),
('29782911000001105', ''),
('199411000001106', ''),
('21830211000001100', ''),
('4865011000001104', ''),
('35227111000001103', ''),
('35210711000001106', ''),
('19188211000001106', ''),
('11267111000001105', ''),
('4861711000001104', ''),
('4515811000001108', ''),
('35215211000001108', ''),
('35210911000001108', ''),
('19188411000001105', ''),
('11267311000001107', ''),
('4514011000001101', ''),
('904711000001102', ''),
('343411000001108', ''),
('474311000001107', ''),
('471811000001100', ''),
('96011000001104', ''),
('875311000001101', ''),
('3234011000001103', ''),
('733011000001104', ''),
('362611000001105', ''),
('91011000001106', ''),
('622911000001103', ''),
('691711000001103', ''),
('757911000001105', ''),
('323944009', ''),
('441611000001103', ''),
('48711000001106', ''),
('13576111000001100', ''),
('266111000001108', ''),
('821811000001106', ''),
('38825311000001107', ''),
('141011000001109', ''),
('17852711000001106', ''),
('231211000001100', ''),
('29783111000001101', ''),
('601211000001108', ''),
('21830611000001103', ''),
('323945005', ''),
('810111000001104', ''),
('277711000001100', ''),
('22632411000001107', ''),
('88011000001101', ''),
('332811000001103', ''),
('30010811000001104', ''),
('38825511000001101', ''),
('688511000001102', ''),
('17852911000001108', ''),
('750911000001109', ''),
('29783311000001104', ''),
('392711000001103', ''),
('21831111000001100', ''),
('323947002', ''),
('323948007', ''),
('36134511000001102', ''),
('705811000001100', ''),
('8911000001102', ''),
('3466111000001104', ''),
('795711000001106', ''),
('14511000001100', ''),
('435511000001103', ''),
('769211000001104', ''),
('324343004', ''),
('28963111000001109', ''),
('34711611000001107', ''),
('35306811000001105', ''),
('35834011000001101', ''),
('26812711000001104', ''),
('23021211000001100', ''),
('35247011000001102', ''),
('18486711000001104', ''),
('38009511000001105', ''),
('37655611000001101', ''),
('324344005', ''),
('29714711000001100', ''),
('34711811000001106', ''),
('35306611000001106', ''),
('35829511000001105', ''),
('26812911000001102', ''),
('23049211000001102', ''),
('35246811000001106', ''),
('18486011000001101', ''),
('38009811000001108', ''),
('37656911000001100', ''),
('32391011000001106', ''),
('4382011000001108', ''),
('4381711000001103', ''),
('4792411000001101', ''),
('36691911000001100', ''),
('38564211000001105', ''),
('4779811000001104', ''),
('428353009', ''),
('14236111000001106', ''),
('4396211000001103', ''),
('24416411000001106', ''),
('24200611000001109', ''),
('36568011000001102', ''),
('22980411000001102', ''),
('18852711000001100', ''),
('323970005', ''),
('4391811000001107', ''),
('4392111000001105', ''),
('4391611000001108', ''),
('323962000', ''),
('323961007', ''),
('323960008', ''),
('4344011000001107', ''),
('4343611000001103', ''),
('4342911000001102', ''),
('324049005', ''),
('13613311000001108', ''),
('13385911000001100', ''),
('13479311000001102', ''),
('11713511000001103', ''),
('11713611000001104', ''),
('11697611000001102', ''),
('11697311000001107', ''),
('11713311000001109', ''),
('11713411000001102', ''),
('11697011000001109', ''),
('11696711000001108', ''),
('11713711000001108', ''),
('11713811000001100', ''),
('11698211000001100', ''),
('11697911000001108', ''),
('371595007', ''),
('27808811000001108', ''),
('34802411000001103', ''),
('3722011000001101', ''),
('324070004', ''),
('2847611000001101', ''),
('2847811000001102', ''),
('2849911000001100', ''),
('11403911000001104', ''),
('10405011000001108', ''),
('23881111000001102', ''),
('37897811000001106', ''),
('14201611000001100', ''),
('2848611000001102', ''),
('2849111000001103', ''),
('37071111000001104', ''),
('38877411000001105', ''),
('7432211000001109', ''),
('17894611000001103', ''),
('29836111000001100', ''),
('2848011000001109', ''),
('2848411000001100', ''),
('21933211000001100', ''),
('324059006', ''),
('2850911000001108', ''),
('2851411000001109', ''),
('2854311000001104', ''),
('11404211000001106', ''),
('2851811000001106', ''),
('10405211000001103', ''),
('23880711000001109', ''),
('37896911000001104', ''),
('14161611000001103', ''),
('2852511000001100', ''),
('2853211000001109', ''),
('30123211000001107', ''),
('38877111000001100', ''),
('2852911000001107', ''),
('17894811000001104', ''),
('15083411000001100', ''),
('10724511000001104', ''),
('2852311000001106', ''),
('21933411000001101', ''),
('324072007', ''),
('8485211000001101', ''),
('8485311000001109', ''),
('8458111000001109', ''),
('8459211000001108', ''),
('32876211000001101', ''),
('32874411000001105', ''),
('421341000', ''),
('38250911000001106', ''),
('2853411000001108', ''),
('2849311000001101', ''),
('2849511000001107', ''),
('2854011000001102', ''),
('2847211000001103', ''),
('2849711000001102', ''),
('2852111000001109', ''),
('2848211000001104', ''),
('2853611000001106', ''),
('324076005', ''),
('21232111000001104', ''),
('23643111000001104', ''),
('30763011000001103', ''),
('24372611000001107', ''),
('32417211000001101', ''),
('37119611000001105', ''),
('34187111000001100', ''),
('29899911000001103', ''),
('37860011000001104', ''),
('21219611000001105', ''),
('21790011000001101', ''),
('396211000001106', ''),
('324092000', ''),
('666311000001107', ''),
('679811000001102', ''),
('514011000001108', ''),
('24386011000001105', ''),
('939411000001101', ''),
('30831211000001101', ''),
('238111000001103', ''),
('11408511000001102', ''),
('17942111000001100', ''),
('29923611000001108', ''),
('8819311000001104', ''),
('891511000001102', ''),
('13758111000001102', ''),
('21801011000001105', ''),
('324093005', ''),
('254511000001104', ''),
('754011000001103', ''),
('165311000001103', ''),
('34019411000001108', ''),
('24385811000001107', ''),
('64211000001102', ''),
('30831011000001106', ''),
('7611000001109', ''),
('11408011000001105', ''),
('17942311000001103', ''),
('29923011000001101', ''),
('8819511000001105', ''),
('936711000001102', ''),
('13758311000001100', ''),
('21801211000001100', ''),
('36565111000001106', ''),
('9330111000001102', ''),
('14781411000001109', ''),
('324090008', ''),
('324091007', ''),
('13010711000001108', ''),
('13010811000001100', ''),
('12979311000001105', ''),
('12979011000001107', ''),
('123211000001102', ''),
('621011000001105', ''),
('820411000001100', ''),
('921111000001105', ''),
('926911000001103', ''),
('116911000001108', ''),
('147511000001107', ''),
('7393411000001103', ''),
('9361611000001109', ''),
('18248711000001106', ''),
('9891211000001108', ''),
('324095003', ''),
('3345011000001108', ''),
('3345611000001101', ''),
('3350311000001102', ''),
('9802411000001100', ''),
('10436911000001108', ''),
('16062611000001107', ''),
('28918511000001105', ''),
('30071211000001104', ''),
('29006911000001106', ''),
('11013711000001105', ''),
('20326411000001109', ''),
('3347511000001109', ''),
('22473711000001108', ''),
('3347811000001107', ''),
('17951211000001102', ''),
('4331711000001105', ''),
('15114911000001103', ''),
('3349611000001103', ''),
('3346311000001101', ''),
('21829411000001108', ''),
('13003811000001109', ''),
('12989611000001106', ''),
('13003911000001104', ''),
('12990511000001100', ''),
('13004011000001101', ''),
('12991011000001104', ''),
('13003711000001101', ''),
('12989211000001109', ''),
('3348411000001109', ''),
('3348811000001106', ''),
('3347011000001101', ''),
('324011006', ''),
('20291511000001104', ''),
('324012004', ''),
('47611000001101', ''),
('205211000001109', ''),
('625311000001105', ''),
('17962811000001100', ''),
('37824111000001101', ''),
('36074811000001107', ''),
('22473211000001101', ''),
('357111000001108', ''),
('35593811000001102', ''),
('17875711000001104', ''),
('21787511000001109', ''),
('21407411000001104', ''),
('21406411000001101', ''),
('4548811000001106', ''),
('34819711000001101', ''),
('917911000001109', ''),
('10328711000001100', ''),
('35204411000001108', ''),
('10321011000001108', ''),
('36564611000001104', ''),
('15656211000001107', ''),
('35899911000001109', ''),
('9222111000001109', ''),
('11591311000001108', ''),
('35899811000001104', ''),
('4500111000001106', ''),
('4500411000001101', ''),
('36051011000001102', ''),
('3845211000001101', ''),
('27334311000001101', ''),
('3847411000001108', ''),
('32334511000001109', ''),
('3846511000001105', ''),
('29862011000001106', ''),
('36063011000001107', ''),
('4615711000001107', ''),
('36051111000001101', ''),
('3997111000001101', ''),
('3998811000001107', ''),
('3998211000001106', ''),
('36050911000001105', ''),
('3999111000001107', ''),
('3999911000001105', ''),
('3999411000001102', ''),
('8523611000001103', ''),
('8494111000001107', ''),
('12089911000001108', ''),
('12075211000001108', ''),
('12090011000001100', ''),
('12076611000001100', ''),
('27800411000001108', ''),
('27690911000001109', ''),
('29827911000001102', ''),
('29793411000001107', ''),
('29903511000001102', ''),
('29934211000001107', ''),
('29861811000001109', ''),
('29951311000001103', ''),
('29941811000001105', ''),
('29942711000001109', ''),
('29951111000001100', ''),
('29942211000001102', ''),
('29942911000001106', ''),
('29951211000001106', ''),
('29942511000001104', ''),
('29943111000001102', ''),
('32749211000001108', ''),
('32743411000001105', ''),
('3845811000001100', ''),
('3983611000001102', ''),
('4609011000001105', ''),
('3997811000001108', ''),
('3847011000001104', ''),
('17330211000001102', ''),
('10967311000001102', ''),
('324158001', ''),
('4055311000001106', ''),
('28932611000001103', ''),
('4055711000001105', ''),
('4208311000001104', ''),
('12302011000001102', ''),
('12274811000001104', ''),
('12301911000001109', ''),
('12273311000001106', ''),
('4055511000001100', ''),
('36031111000001100', ''),
('36031311000001103', ''),
('36030911000001109', ''),
('36031011000001101', ''),
('36031211000001106', ''),
('4463011000001106', ''),
('4463311000001109', ''),
('4463611000001104', ''),
('4464611000001101', ''),
('4462711000001100', ''),
('34194211000001103', ''),
('4957911000001108', ''),
('4944011000001104', ''),
('9187611000001105', ''),
('4944511000001107', ''),
('4944311000001101', ''),
('12949611000001104', ''),
('4145011000001103', ''),
('4127011000001108', ''),
('9187811000001109', ''),
('4129111000001103', ''),
('26857411000001100', ''),
('38027711000001101', ''),
('4128011000001109', ''),
('12949811000001100', ''),
('35919711000001100', ''),
('4514311000001103', ''),
('35919811000001108', ''),
('4158411000001104', ''),
('32656811000001108', ''),
('32645711000001105', ''),
('4516011000001106', ''),
('35777411000001100', ''),
('4514611000001108', ''),
('19544811000001101', ''),
('23676411000001103', ''),
('23671411000001109', ''),
('4514911000001102', ''),
('4128611000001102', ''),
('324252006', ''),
('14968311000001103', ''),
('15017711000001104', ''),
('36465711000001104', ''),
('19706711000001107', ''),
('37893411000001102', ''),
('32395411000001104', ''),
('37041111000001100', ''),
('38802911000001107', ''),
('35727711000001105', ''),
('17791111000001105', ''),
('15071111000001102', ''),
('33932211000001100', ''),
('14789411000001105', ''),
('34554511000001101', ''),
('324253001', ''),
('13652511000001104', ''),
('17283411000001107', ''),
('22615611000001105', ''),
('37041811000001107', ''),
('38803511000001107', ''),
('20281711000001105', ''),
('15070811000001101', ''),
('14166911000001104', ''),
('21781011000001106', ''),
('324258005', ''),
('11252311000001102', ''),
('38006911000001107', ''),
('20943011000001102', ''),
('15472811000001107', ''),
('34642911000001105', ''),
('19543911000001109', ''),
('36420111000001101', ''),
('19707211000001103', ''),
('32395911000001107', ''),
('37042711000001106', ''),
('38810611000001100', ''),
('38710611000001103', ''),
('19474211000001108', ''),
('17791411000001100', ''),
('11579411000001106', ''),
('15051411000001105', ''),
('37857911000001108', ''),
('11028111000001105', ''),
('11034311000001100', ''),
('11252111000001104', ''),
('38006711000001105', ''),
('20942811000001100', ''),
('15472611000001108', ''),
('34642111000001107', ''),
('19544211000001102', ''),
('36445611000001104', ''),
('19707011000001108', ''),
('32395711000001105', ''),
('29998311000001103', ''),
('38803811000001105', ''),
('38710311000001108', ''),
('19474411000001107', ''),
('22202911000001107', ''),
('20282311000001102', ''),
('15071411000001107', ''),
('36907711000001108', ''),
('11028411000001100', ''),
('29668711000001101', ''),
('29516411000001104', ''),
('85911000001108', ''),
('650911000001103', ''),
('794511000001102', ''),
('14759911000001105', ''),
('324238009', ''),
('8927511000001103', ''),
('20165611000001102', ''),
('14694011000001106', ''),
('9033411000001103', ''),
('17965211000001106', ''),
('13765011000001103', ''),
('19715011000001104', ''),
('37402011000001108', ''),
('8825911000001106', ''),
('38836811000001108', ''),
('35140911000001102', ''),
('8914911000001107', ''),
('17859611000001109', ''),
('9038211000001105', ''),
('8993611000001100', ''),
('15080711000001102', ''),
('17522411000001102', ''),
('8818911000001106', ''),
('13745611000001101', ''),
('36846911000001107', ''),
('21854711000001102', ''),
('20096711000001105', ''),
('35368711000001104', ''),
('9252611000001100', ''),
('36621611000001102', ''),
('9157411000001102', ''),
('30761711000001102', ''),
('30031911000001106', ''),
('9155811000001105', ''),
('38840411000001105', ''),
('18101811000001104', ''),
('9042011000001104', ''),
('9547411000001109', ''),
('15080411000001108', ''),
('21854311000001101', ''),
('324242007', ''),
('36635611000001101', ''),
('17648711000001102', ''),
('17997711000001108', ''),
('35555411000001108', ''),
('13612911000001102', ''),
('34751611000001103', ''),
('13469711000001107', ''),
('324244008', ''),
('8928611000001100', ''),
('20165811000001103', ''),
('14694411000001102', ''),
('9033811000001101', ''),
('17965511000001109', ''),
('13765211000001108', ''),
('19715211000001109', ''),
('37402811000001102', ''),
('8826111000001102', ''),
('38837011000001104', ''),
('35141111000001106', ''),
('8915511000001104', ''),
('17859811000001108', ''),
('9038811000001106', ''),
('8993811000001101', ''),
('29789111000001103', ''),
('17522611000001104', ''),
('8819111000001101', ''),
('13745811000001102', ''),
('36847211000001101', ''),
('21854911000001100', ''),
('20097311000001109', ''),
('36142611000001107', ''),
('324248006', ''),
('4977911000001105', ''),
('37083211000001101', ''),
('9253011000001103', ''),
('36621811000001103', ''),
('9157711000001108', ''),
('30761911000001100', ''),
('30041111000001109', ''),
('9156111000001109', ''),
('38840711000001104', ''),
('18103211000001101', ''),
('9042311000001101', ''),
('9547911000001101', ''),
('15080911000001100', ''),
('21854511000001107', ''),
('9742311000001103', ''),
('9742411000001105', ''),
('9742511000001109', ''),
('220811000001105', ''),
('917411000001101', ''),
('27011000001106', ''),
('463111000001102', ''),
('40811000001101', ''),
('3253811000001107', ''),
('4973711000001103', ''),
('211000001101', ''),
('9739611000001100', ''),
('9739911000001106', ''),
('9740211000001105', ''),
('18149211000001106', ''),
('21667211000001100', ''),
('21708211000001106', ''),
('33656011000001109', ''),
('324178009', ''),
('766711000001101', ''),
('89511000001103', ''),
('689511000001108', ''),
('789411000001103', ''),
('9795911000001100', ''),
('10406411000001108', ''),
('24389111000001103', ''),
('23903911000001107', ''),
('11020911000001106', ''),
('35996611000001100', ''),
('32800711000001104', ''),
('654811000001103', ''),
('687011000001109', ''),
('30825911000001105', ''),
('38889811000001108', ''),
('19733011000001108', ''),
('19191611000001104', ''),
('126311000001101', ''),
('38073211000001103', ''),
('17903711000001101', ''),
('7211000001107', ''),
('4330011000001104', ''),
('29856311000001102', ''),
('17198711000001106', ''),
('18281911000001106', ''),
('919211000001106', ''),
('21976211000001109', ''),
('36064711000001106', ''),
('482311000001107', ''),
('20962611000001108', ''),
('258211000001108', ''),
('10406211000001109', ''),
('10139811000001105', ''),
('9563611000001105', ''),
('759811000001108', ''),
('235411000001103', ''),
('165611000001108', ''),
('4227311000001109', ''),
('324232005', ''),
('682211000001102', ''),
('838411000001100', ''),
('468911000001109', ''),
('23902711000001102', ''),
('10307311000001109', ''),
('469911000001101', ''),
('38889611000001109', ''),
('17902311000001105', ''),
('13620311000001107', ''),
('231611000001103', ''),
('29852211000001109', ''),
('21935211000001101', ''),
('324233000', ''),
('563411000001101', ''),
('398811000001108', ''),
('816211000001107', ''),
('23902911000001100', ''),
('10307711000001108', ''),
('79111000001102', ''),
('38890011000001106', ''),
('17902811000001101', ''),
('13620511000001101', ''),
('103911000001104', ''),
('29856111000001104', ''),
('21975211000001103', ''),
('324234006', ''),
('348611000001104', ''),
('889511000001102', ''),
('845911000001101', ''),
('23903111000001109', ''),
('10308311000001105', ''),
('237511000001108', ''),
('17903311000001100', ''),
('13620711000001106', ''),
('605811000001107', ''),
('29856611000001107', ''),
('21975411000001104', ''),
('324179001', ''),
('32506411000001108', ''),
('37376611000001104', ''),
('32163811000001106', ''),
('37149211000001103', ''),
('36564711000001108', ''),
('481911000001102', ''),
('10060511000001100', ''),
('580111000001102', ''),
('23903311000001106', ''),
('10307511000001103', ''),
('2411000001108', ''),
('840611000001104', ''),
('30125811000001107', ''),
('38890211000001101', ''),
('549711000001102', ''),
('17902611000001100', ''),
('13620911000001108', ''),
('29851811000001101', ''),
('173511000001103', ''),
('21975611000001101', ''),
('177211000001105', ''),
('10060711000001105', ''),
('364011000001109', ''),
('23903511000001100', ''),
('10308011000001107', ''),
('273611000001101', ''),
('506011000001101', ''),
('30810111000001105', ''),
('38890411000001102', ''),
('784711000001108', ''),
('17903011000001103', ''),
('13621111000001104', ''),
('29852611000001106', ''),
('592611000001105', ''),
('21975811000001102', ''),
('433911000001109', ''),
('10060911000001107', ''),
('626611000001105', ''),
('23903711000001105', ''),
('10308511000001104', ''),
('364211000001104', ''),
('78611000001101', ''),
('415511000001109', ''),
('17903511000001106', ''),
('13621311000001102', ''),
('848711000001105', ''),
('21976011000001104', ''),
('580811000001109', ''),
('108811000001104', ''),
('294211000001105', ''),
('178911000001100', ''),
('324215006', ''),
('4692411000001105', ''),
('29948711000001107', ''),
('4693311000001108', ''),
('4693011000001105', ''),
('33737411000001107', ''),
('36542711000001107', ''),
('4693611000001103', ''),
('324180003', ''),
('38215511000001102', ''),
('37911311000001102', ''),
('324181004', ''),
('38215811000001104', ''),
('37911611000001107', ''),
('274611000001103', ''),
('30611000001101', ''),
('17628011000001101', ''),
('17627611000001109', ''),
('407790000', ''),
('98311000001102', ''),
('324276003', ''),
('36646511000001108', ''),
('37334911000001104', ''),
('324277007', ''),
('4919711000001105', ''),
('33634011000001103', ''),
('7845611000001105', ''),
('37342311000001106', ''),
('30041711000001105', ''),
('35019811000001102', ''),
('13704611000001105', ''),
('37053311000001104', ''),
('38841011000001105', ''),
('38320011000001100', ''),
('35638511000001105', ''),
('17860011000001101', ''),
('28693411000001100', ''),
('4329711000001107', ''),
('15081111000001109', ''),
('33933711000001104', ''),
('33041711000001109', ''),
('21858111000001109', ''),
('19213211000001104', ''),
('27864611000001100', ''),
('8351711000001105', ''),
('12021611000001106', ''),
('11968011000001106', ''),
('12021711000001102', ''),
('11969011000001101', ''),
('12021411000001108', ''),
('11967711000001107', ''),
('12021811000001105', ''),
('11969511000001109', ''),
('12021311000001101', ''),
('11967411000001101', ''),
('18519211000001105', ''),
('18513011000001103', ''),
('21711211000001104', ''),
('21732111000001107', ''),
('33634311000001100', ''),
('22164711000001102', ''),
('37343211000001109', ''),
('21669011000001101', ''),
('30042211000001105', ''),
('37053511000001105', ''),
('38841311000001108', ''),
('38322611000001108', ''),
('35774311000001103', ''),
('28693811000001103', ''),
('29789311000001101', ''),
('33041911000001106', ''),
('8360611000001101', ''),
('8353211000001104', ''),
('32748011000001108', ''),
('32705111000001105', ''),
('34376711000001103', ''),
('34355711000001108', ''),
('34818411000001104', ''),
('34810711000001108', ''),
('36458711000001104', ''),
('36450311000001100', ''),
('36458611000001108', ''),
('36450611000001105', ''),
('3956511000001100', ''),
('3668311000001100', ''),
('36087211000001109', ''),
('18275411000001109', ''),
('17664411000001105', ''),
('18031711000001109', ''),
('34751811000001104', ''),
('36087311000001101', ''),
('18275611000001107', ''),
('17664611000001108', ''),
('18031911000001106', ''),
('34752011000001102', ''),
('4348911000001104', ''),
('7816711000001103', ''),
('20151411000001107', ''),
('20177311000001108', ''),
('20151811000001109', ''),
('20152111000001107', ''),
('414851008', ''),
('20425111000001100', ''),
('409156007', ''),
('21626711000001104', ''),
('703666002', ''),
('20540311000001100', ''),
('29734011000001109', ''),
('703915009', ''),
('29722811000001107', ''),
('29723111000001106', ''),
('18162111000001102', ''),
('29934011000001102', ''),
('32746111000001105', ''),
('21393311000001105', ''),
('32982711000001106', ''),
('34377311000001104', ''),
('34376311000001102', ''),
('324298007', ''),
('3928511000001100', ''),
('3929711000001101', ''),
('14942611000001102', ''),
('4743111000001107', ''),
('11482411000001104', ''),
('3928911000001107', ''),
('324303009', ''),
('34327311000001100', ''),
('34340211000001107', ''),
('33582511000001101', ''),
('4382311000001106', ''),
('36091411000001104', ''),
('324308000', ''),
('3964811000001102', ''),
('4352211000001109', ''),
('324310003', ''),
('324311004', ''),
('18758011000001102', ''),
('17652211000001105', ''),
('4638311000001106', ''),
('32936911000001103', ''),
('3109511000001103', ''),
('3108611000001108', ''),
('4621211000001109', ''),
('4658711000001106', ''),
('324317000', ''),
('3981111000001109', ''),
('35927411000001109', ''),
('29786111000001106', ''),
('9060611000001103', ''),
('27753611000001108', ''),
('8708411000001103', ''),
('324316009', ''),
('3670711000001108', ''),
('4371711000001107', ''),
('35915211000001109', ''),
('36761811000001103', ''),
('35915111000001103', ''),
('36769311000001106', ''),
('4182311000001103', ''),
('4181011000001109', ''),
('324334008', ''),
('4126811000001104', ''),
('4127711000001105', ''),
('4128311000001107', ''),
('37832911000001105', ''),
('24566911000001109', ''),
('37877211000001101', ''),
('37436111000001101', ''),
('324335009', ''),
('4202811000001106', ''),
('4203311000001107', ''),
('4203511000001101', ''),
('37725211000001105', ''),
('324337001', ''),
('34758311000001101', ''),
('35830111000001109', ''),
('32895211000001100', ''),
('23872411000001109', ''),
('4213611000001104', ''),
('4212611000001109', ''),
('4212911000001103', ''),
('4213811000001100', ''),
('36517311000001101', ''),
('19456211000001101', ''),
('24517411000001103', ''),
('15165911000001100', ''),
('324333002', ''),
('34758511000001107', ''),
('35829811000001108', ''),
('32895411000001101', ''),
('36759411000001105', ''),
('4432811000001102', ''),
('4432211000001103', ''),
('4432411000001104', ''),
('4433011000001104', ''),
('26858511000001102', ''),
('36517611000001106', ''),
('19455111000001101', ''),
('24517611000001100', ''),
('15048611000001103', ''),
('12940811000001109', ''),
('12933111000001108', ''),
('8818611000001100', ''),
('8818711000001109', ''),
('8815211000001109', ''),
('8815711000001102', ''),
('15453011000001107', ''),
('15453111000001108', ''),
('15445311000001108', ''),
('15445611000001103', ''),
('13455811000001106', ''),
('13450811000001100', ''),
('4128511000001101', ''),
('4203811000001103', ''),
('4213311000001109', ''),
('4432611000001101', ''),
('324354009', ''),
('4408311000001100', ''),
('134561001', ''),
('31800311000001102', '')
GO
INSERT INTO #tmp81_ab_prescriptions_codelist (code, category) VALUES
('34943711000001101', ''),
('31203911000001103', ''),
('31896811000001106', ''),
('31279511000001100', ''),
('37267511000001102', ''),
('35165011000001102', ''),
('33627611000001101', ''),
('31153711000001107', ''),
('31684511000001106', ''),
('33746711000001100', ''),
('407899006', ''),
('36040111000001105', ''),
('34574711000001109', ''),
('36615111000001102', ''),
('33737611000001105', ''),
('31153911000001109', ''),
('36441911000001108', ''),
('38675711000001104', ''),
('36096911000001102', ''),
('36886111000001102', ''),
('4450311000001108', ''),
('4946211000001104', ''),
('4827211000001109', ''),
('412555008', ''),
('15877511000001101', ''),
('445522003', ''),
('20442211000001103', ''),
('22192511000001100', ''),
('34604811000001100', ''),
('12556911000001106', ''),
('22175211000001101', ''),
('19475511000001107', ''),
('20441311000001102', ''),
('21874811000001107', ''),
('10140911000001105', ''),
('35047211000001102', ''),
('36531611000001105', ''),
('10961311000001108', ''),
('35047711000001109', ''),
('36531811000001109', ''),
('10140111000001107', ''),
('10961511000001102', ''),
('16324411000001105', ''),
('20591911000001100', ''),
('16248411000001105', ''),
('3653911000001100', ''),
('3625511000001107', ''),
('3626311000001106', ''),
('32519811000001101', ''),
('3625711000001102', ''),
('35313211000001104', ''),
('32501611000001104', ''),
('32505711000001105', ''),
('32431411000001103', ''),
('37232111000001101', ''),
('38859611000001100', ''),
('324362001', ''),
('32501811000001100', ''),
('32507511000001109', ''),
('32280411000001100', ''),
('324357002', ''),
('812711000001104', ''),
('688711000001107', ''),
('517111000001104', ''),
('32281711000001103', ''),
('28922511000001104', ''),
('23858211000001109', ''),
('14942811000001103', ''),
('34958511000001104', ''),
('802611000001106', ''),
('38859111000001108', ''),
('17889311000001105', ''),
('29826011000001104', ''),
('26776811000001104', ''),
('21942611000001109', ''),
('324359004', ''),
('30994911000001107', ''),
('32506211000001109', ''),
('32278611000001106', ''),
('37232311000001104', ''),
('37896711000001101', ''),
('34958311000001105', ''),
('38859311000001105', ''),
('26777411000001104', ''),
('36091911000001107', ''),
('7817111000001101', ''),
('659211000001100', ''),
('764411000001104', ''),
('96711000001102', ''),
('3757311000001102', ''),
('3626011000001108', ''),
('324411000', ''),
('4104011000001108', ''),
('4104911000001107', ''),
('26857011000001109', ''),
('4104611000001101', ''),
('21903611000001106', ''),
('4104411000001104', ''),
('13454711000001102', ''),
('13449711000001104', ''),
('13454911000001100', ''),
('13450011000001106', ''),
('13454811000001105', ''),
('13450511000001103', ''),
('5241611000001103', ''),
('13539611000001103', ''),
('27397711000001102', ''),
('15474111000001108', ''),
('21268011000001109', ''),
('36144011000001106', ''),
('324430000', ''),
('710811000001108', ''),
('897711000001103', ''),
('250811000001106', ''),
('9800011000001105', ''),
('10414811000001100', ''),
('16070411000001101', ''),
('28917911000001104', ''),
('30106111000001102', ''),
('426711000001103', ''),
('30942111000001106', ''),
('17865911000001106', ''),
('46511000001102', ''),
('6038911000001109', ''),
('15199811000001106', ''),
('121511000001103', ''),
('21906211000001102', ''),
('324431001', ''),
('339211000001107', ''),
('20170611000001102', ''),
('15911000001106', ''),
('112111000001106', ''),
('9799411000001106', ''),
('10415011000001105', ''),
('16071011000001101', ''),
('28988711000001102', ''),
('30106311000001100', ''),
('664011000001104', ''),
('416811000001104', ''),
('30942311000001108', ''),
('17866111000001102', ''),
('490311000001109', ''),
('6039711000001103', ''),
('187211000001100', ''),
('21906411000001103', ''),
('665011000001100', ''),
('15861911000001105', ''),
('543111000001101', ''),
('17962411000001102', ''),
('30835311000001106', ''),
('845811000001106', ''),
('30941811000001108', ''),
('17865711000001109', ''),
('13627411000001101', ''),
('15200311000001106', ''),
('733211000001109', ''),
('22387811000001109', ''),
('13374511000001101', ''),
('13374611000001102', ''),
('13363211000001108', ''),
('13361311000001101', ''),
('13374711000001106', ''),
('13374811000001103', ''),
('13363511000001106', ''),
('13361711000001102', ''),
('13374911000001108', ''),
('13375011000001108', ''),
('13363811000001109', ''),
('13362311000001105', ''),
('13375111000001109', ''),
('13375211000001103', ''),
('13364111000001100', ''),
('13362611000001100', ''),
('426411000001109', ''),
('95811000001102', ''),
('789611000001100', ''),
('735011000001103', ''),
('431211000001104', ''),
('329711000001102', ''),
('38080911000001105', ''),
('38081511000001105', ''),
('36035511000001107', ''),
('34194011000001108', ''),
('4969011000001107', ''),
('5099711000001109', ''),
('324520007', ''),
('271811000001101', ''),
('341811000001106', ''),
('24384411000001109', ''),
('34745911000001108', ''),
('113911000001102', ''),
('37149811000001102', ''),
('11599611000001102', ''),
('29920411000001102', ''),
('21799811000001103', ''),
('21309911000001106', ''),
('324517004', ''),
('324518009', ''),
('324511003', ''),
('657311000001103', ''),
('703011000001105', ''),
('367011000001101', ''),
('10690011000001102', ''),
('10394111000001104', ''),
('20189711000001106', ''),
('24384611000001107', ''),
('14162711000001100', ''),
('727811000001101', ''),
('35843111000001101', ''),
('461811000001105', ''),
('30830211000001107', ''),
('19193811000001101', ''),
('786711000001104', ''),
('34612711000001100', ''),
('17941711000001106', ''),
('494411000001108', ''),
('8826911000001104', ''),
('15110911000001108', ''),
('357811000001101', ''),
('21800011000001101', ''),
('324512005', ''),
('791311000001105', ''),
('229911000001106', ''),
('780111000001103', ''),
('10690211000001107', ''),
('10394511000001108', ''),
('20189911000001108', ''),
('24384811000001106', ''),
('14162911000001103', ''),
('882111000001102', ''),
('406911000001106', ''),
('30830411000001106', ''),
('19194011000001109', ''),
('723311000001103', ''),
('17941911000001108', ''),
('239411000001100', ''),
('8827211000001105', ''),
('15111111000001104', ''),
('585011000001109', ''),
('650511000001105', ''),
('21800211000001106', ''),
('34617211000001105', ''),
('36077111000001105', ''),
('34612511000001105', ''),
('36035611000001106', ''),
('13408411000001108', ''),
('3617511000001108', ''),
('3620311000001108', ''),
('324523009', ''),
('780211000001109', ''),
('310211000001108', ''),
('329811000001105', ''),
('24385011000001101', ''),
('15111311000001102', ''),
('36537511000001100', ''),
('34607211000001108', ''),
('34605411000001101', ''),
('13007811000001103', ''),
('12961911000001102', ''),
('13008011000001105', ''),
('12962211000001104', ''),
('13008111000001106', ''),
('12962811000001103', ''),
('32655011000001106', ''),
('32646011000001104', ''),
('13007911000001108', ''),
('12960811000001104', ''),
('13008211000001100', ''),
('12962511000001101', ''),
('838811000001103', ''),
('272211000001109', ''),
('3911811000001100', ''),
('3910511000001105', ''),
('453711000001106', ''),
('3924811000001105', ''),
('3619811000001103', ''),
('3912311000001100', ''),
('3910711000001100', ''),
('471211000001101', ''),
('3620111000001106', ''),
('324554008', ''),
('3747511000001105', ''),
('324607004', ''),
('170311000001103', ''),
('19834111000001108', ''),
('18460011000001101', ''),
('624611000001101', ''),
('211411000001108', ''),
('9795711000001102', ''),
('10393211000001107', ''),
('15988911000001106', ''),
('19713611000001107', ''),
('11017911000001103', ''),
('7426211000001108', ''),
('810711000001103', ''),
('254711000001109', ''),
('38834811000001101', ''),
('19729511000001101', ''),
('38794711000001100', ''),
('317211000001107', ''),
('36574211000001108', ''),
('10442211000001104', ''),
('11401111000001103', ''),
('17858211000001102', ''),
('827711000001107', ''),
('485011000001104', ''),
('15077111000001109', ''),
('368511000001108', ''),
('18280611000001105', ''),
('370811000001102', ''),
('13743811000001101', ''),
('36840911000001109', ''),
('21852511000001102', ''),
('826011000001107', ''),
('36140911000001100', ''),
('11546011000001109', ''),
('8967411000001108', ''),
('36570411000001101', ''),
('22982111000001106', ''),
('324606008', ''),
('625611000001100', ''),
('19834311000001105', ''),
('18460411000001105', ''),
('920811000001106', ''),
('238711000001102', ''),
('9785111000001102', ''),
('10393511000001105', ''),
('15989111000001101', ''),
('648911000001103', ''),
('19713911000001101', ''),
('11018811000001107', ''),
('7426411000001107', ''),
('491511000001105', ''),
('2511000001107', ''),
('38835111000001107', ''),
('19729711000001106', ''),
('38715111000001103', ''),
('823711000001102', ''),
('36574711000001101', ''),
('36696711000001108', ''),
('11401511000001107', ''),
('17858511000001104', ''),
('735711000001101', ''),
('327011000001108', ''),
('15077911000001107', ''),
('938011000001100', ''),
('18280811000001109', ''),
('62011000001101', ''),
('13744011000001109', ''),
('36841511000001109', ''),
('21853011000001101', ''),
('15261211000001108', ''),
('324600002', ''),
('675411000001102', ''),
('227611000001105', ''),
('130511000001107', ''),
('17964311000001102', ''),
('15988711000001109', ''),
('19713411000001109', ''),
('11017111000001101', ''),
('780711000001102', ''),
('38834611000001100', ''),
('36575111000001103', ''),
('17858011000001107', ''),
('926611000001109', ''),
('15076711000001107', ''),
('671111000001105', ''),
('799111000001107', ''),
('36839911000001104', ''),
('324605007', ''),
('366711000001102', ''),
('19833511000001102', ''),
('23483711000001106', ''),
('469011000001100', ''),
('872511000001101', ''),
('17964511000001108', ''),
('10393811000001108', ''),
('15989311000001104', ''),
('19714211000001108', ''),
('11019511000001103', ''),
('7426611000001105', ''),
('849311000001100', ''),
('271111000001108', ''),
('38835411000001102', ''),
('19730111000001102', ''),
('38715311000001101', ''),
('36574511000001106', ''),
('11402111000001108', ''),
('17858811000001101', ''),
('935711000001105', ''),
('868011000001102', ''),
('15078411000001100', ''),
('630111000001102', ''),
('18281011000001107', ''),
('591811000001100', ''),
('13744211000001104', ''),
('36841911000001102', ''),
('21853311000001103', ''),
('9207911000001103', ''),
('12020311000001106', ''),
('11980911000001105', ''),
('12019511000001104', ''),
('11975011000001109', ''),
('12020511000001100', ''),
('11972111000001103', ''),
('12019611000001100', ''),
('11975511000001101', ''),
('12020611000001101', ''),
('11972711000001102', ''),
('12020811000001102', ''),
('11973911000001107', ''),
('12020711000001105', ''),
('11973311000001106', ''),
('12019911000001106', ''),
('11977411000001106', ''),
('8973011000001101', ''),
('28040911000001104', ''),
('36570611000001103', ''),
('22983111000001100', ''),
('34611511000001102', ''),
('12020211000001103', ''),
('11980311000001109', ''),
('12020011000001108', ''),
('11978711000001104', ''),
('12020911000001107', ''),
('11974611000001103', ''),
('36141011000001108', ''),
('35515811000001102', ''),
('11761311000001107', ''),
('36141511000001100', ''),
('32775511000001107', ''),
('35516111000001103', ''),
('35831211000001109', ''),
('11761811000001103', ''),
('324602005', ''),
('12020411000001104', ''),
('11971311000001105', ''),
('12019711000001109', ''),
('11976011000001100', ''),
('12019811000001101', ''),
('11976411000001109', ''),
('12020111000001109', ''),
('11979311000001109', ''),
('10892711000001106', ''),
('18756911000001102', ''),
('34648611000001102', ''),
('34532811000001105', ''),
('10889411000001105', ''),
('10892811000001103', ''),
('11528211000001101', ''),
('13793511000001105', ''),
('34648911000001108', ''),
('34533011000001108', ''),
('10889711000001104', ''),
('10892911000001108', ''),
('11528411000001102', ''),
('13793711000001100', ''),
('34649111000001103', ''),
('10890011000001105', ''),
('455911000001109', ''),
('417611000001101', ''),
('162511000001103', ''),
('661311000001104', ''),
('902411000001101', ''),
('8951511000001108', ''),
('8954311000001104', ''),
('785511000001102', ''),
('854011000001101', ''),
('3492511000001109', ''),
('324579006', ''),
('19681911000001107', ''),
('26854011000001101', ''),
('19172111000001106', ''),
('324578003', ''),
('35445511000001100', ''),
('36028911000001108', ''),
('3683611000001101', ''),
('4058911000001101', ''),
('4059711000001107', ''),
('3852811000001105', ''),
('324612003', ''),
('465511000001105', ''),
('527011000001106', ''),
('16062011000001100', ''),
('37463211000001108', ''),
('724511000001107', ''),
('30852711000001100', ''),
('4273411000001105', ''),
('7464011000001104', ''),
('319311000001109', ''),
('15112111000001109', ''),
('792611000001106', ''),
('21821611000001105', ''),
('324620001', ''),
('238911000001100', ''),
('412511000001103', ''),
('16062211000001105', ''),
('37463811000001109', ''),
('787111000001102', ''),
('30853111000001107', ''),
('4818111000001107', ''),
('7464911000001100', ''),
('525111000001103', ''),
('15112411000001104', ''),
('339611000001109', ''),
('38752711000001101', ''),
('12905211000001105', ''),
('12895811000001101', ''),
('12897211000001105', ''),
('12896211000001108', ''),
('12905311000001102', ''),
('12905411000001109', ''),
('12898411000001108', ''),
('12897811000001106', ''),
('362511000001106', ''),
('491611000001109', ''),
('4415111000001109', ''),
('324621002', ''),
('822711000001105', ''),
('254211000001102', ''),
('511511000001102', ''),
('739911000001102', ''),
('17947511000001107', ''),
('35549811000001106', ''),
('18745111000001108', ''),
('21816311000001102', ''),
('866311000001103', ''),
('324634001', ''),
('19359911000001108', ''),
('21286011000001107', ''),
('19298011000001103', ''),
('19359211000001104', ''),
('24366511000001100', ''),
('19512011000001105', ''),
('29673511000001109', ''),
('30220211000001100', ''),
('19837511000001107', ''),
('29890211000001100', ''),
('19178911000001107', ''),
('22070611000001101', ''),
('324633007', ''),
('19359511000001101', ''),
('21285711000001101', ''),
('19296611000001109', ''),
('19358511000001107', ''),
('24366211000001103', ''),
('19511711000001100', ''),
('29673211000001106', ''),
('37098711000001101', ''),
('19837211000001109', ''),
('29889711000001104', ''),
('19178611000001101', ''),
('22070311000001106', ''),
('36038911000001106', ''),
('19359011000001109', ''),
('34754611000001101', ''),
('19448711000001105', ''),
('19447411000001103', ''),
('19447611000001100', ''),
('38236111000001105', ''),
('35831811000001105', ''),
('21660611000001102', ''),
('23108311000001101', ''),
('24416711000001100', ''),
('38745711000001107', ''),
('36571111000001100', ''),
('22985411000001109', ''),
('34611911000001109', ''),
('3078311000001102', ''),
('3077511000001109', ''),
('4602911000001104', ''),
('19374111000001107', ''),
('19374511000001103', ''),
('28922411000001103', ''),
('408015000', ''),
('24919311000001109', ''),
('24683911000001108', ''),
('24775911000001105', ''),
('38618511000001108', ''),
('37453311000001107', ''),
('30834211000001104', ''),
('28697411000001107', ''),
('29927511000001104', ''),
('24673211000001107', ''),
('16756911000001108', ''),
('25876211000001100', ''),
('36571311000001103', ''),
('36881911000001109', ''),
('36028511000001101', ''),
('36003311000001109', ''),
('35992311000001106', ''),
('4360711000001109', ''),
('16751911000001103', ''),
('10496311000001104', ''),
('371616001', ''),
('37947311000001104', ''),
('37830711000001109', ''),
('38849511000001101', ''),
('3691811000001100', ''),
('324570005', ''),
('24549911000001107', ''),
('37556911000001106', ''),
('24209111000001106', ''),
('24421611000001107', ''),
('37460411000001104', ''),
('35952811000001109', ''),
('36774211000001109', ''),
('324572002', ''),
('24550111000001102', ''),
('37557111000001106', ''),
('24208911000001101', ''),
('24421811000001106', ''),
('37460611000001101', ''),
('35954211000001104', ''),
('36774511000001107', ''),
('36565611000001103', ''),
('24133311000001100', ''),
('5420911000001103', ''),
('3607611000001105', ''),
('38608611000001105', ''),
('324558006', ''),
('180911000001108', ''),
('884111000001105', ''),
('497811000001101', ''),
('30763811000001109', ''),
('37460811000001102', ''),
('11016111000001104', ''),
('20327411000001106', ''),
('537011000001109', ''),
('30851211000001100', ''),
('9555111000001106', ''),
('17946711000001100', ''),
('29929911000001104', ''),
('4209111000001108', ''),
('21820711000001109', ''),
('324559003', ''),
('637211000001107', ''),
('626211000001108', ''),
('405011000001103', ''),
('30763611000001105', ''),
('37461111000001103', ''),
('11015711000001106', ''),
('20326111000001104', ''),
('277011000001102', ''),
('30851411000001101', ''),
('9555311000001108', ''),
('17946911000001103', ''),
('15111411000001109', ''),
('4221211000001106', ''),
('21821311000001100', ''),
('12862811000001106', ''),
('12862911000001101', ''),
('12820911000001108', ''),
('12820611000001102', ''),
('12864611000001104', ''),
('12864711000001108', ''),
('12829211000001106', ''),
('12828711000001108', ''),
('12904911000001100', ''),
('375489004', ''),
('12902611000001103', ''),
('12902311000001108', ''),
('12935311000001106', ''),
('12935411000001104', ''),
('12917211000001100', ''),
('12916911000001106', ''),
('12934511000001101', ''),
('12934611000001102', ''),
('12914811000001108', ''),
('12914511000001105', ''),
('12894611000001101', ''),
('12894711000001105', ''),
('12892411000001106', ''),
('12891611000001103', ''),
('12935511000001100', ''),
('12935611000001101', ''),
('12917811000001104', ''),
('12917511000001102', ''),
('12864211000001101', ''),
('12864311000001109', ''),
('12825111000001102', ''),
('12824811000001108', ''),
('12863011000001109', ''),
('12863111000001105', ''),
('12821511000001108', ''),
('12821211000001105', ''),
('12863811000001103', ''),
('12863911000001108', ''),
('12823911000001100', ''),
('12823611000001106', ''),
('12904211000001109', ''),
('12904311000001101', ''),
('12899511000001101', ''),
('12898811000001105', ''),
('12935711000001105', ''),
('12935811000001102', ''),
('12918411000001102', ''),
('12918111000001107', ''),
('12936111000001103', ''),
('12936211000001109', ''),
('12919611000001108', ''),
('12919311000001103', ''),
('12933911000001106', ''),
('12934011000001109', ''),
('12912911000001107', ''),
('12912611000001101', ''),
('12937311000001103', ''),
('12937411000001105', ''),
('12923211000001100', ''),
('12922911000001102', ''),
('12936711000001102', ''),
('12936811000001105', ''),
('12921411000001100', ''),
('12921111000001105', ''),
('12905011000001100', ''),
('12905111000001104', ''),
('12903211000001106', ''),
('12902911000001109', ''),
('12904811000001105', ''),
('12904111000001103', ''),
('12898111000001103', ''),
('12897011000001100', ''),
('12863411000001100', ''),
('12863511000001101', ''),
('12822711000001105', ''),
('12822411000001104', ''),
('12904411000001108', ''),
('12904511000001107', ''),
('12901411000001106', ''),
('12901111000001101', ''),
('12894111000001109', ''),
('12894211000001103', ''),
('12889711000001107', ''),
('12889411000001101', ''),
('12864811000001100', ''),
('12864911000001105', ''),
('12830411000001103', ''),
('12829711000001104', ''),
('12936511000001107', ''),
('12936611000001106', ''),
('12920811000001106', ''),
('12920511000001108', ''),
('12936911000001100', ''),
('12937011000001101', ''),
('12922011000001101', ''),
('12921711000001106', ''),
('12935111000001109', ''),
('12935211000001103', ''),
('12916611000001100', ''),
('12916311000001105', ''),
('12934311000001107', ''),
('12934411000001100', ''),
('12914211000001107', ''),
('12913911000001100', ''),
('12894311000001106', ''),
('12894511000001100', ''),
('12890911000001102', ''),
('12890311000001103', ''),
('12935911000001107', ''),
('12936011000001104', ''),
('12919011000001101', ''),
('12918711000001108', ''),
('12863611000001102', ''),
('12863711000001106', ''),
('12823311000001101', ''),
('12823011000001104', ''),
('12937111000001100', ''),
('12937211000001106', ''),
('12922611000001108', ''),
('12922311000001103', ''),
('12934111000001105', ''),
('12934211000001104', ''),
('12913611000001106', ''),
('12913211000001109', ''),
('12934911000001108', ''),
('12935011000001108', ''),
('12916011000001107', ''),
('12915711000001101', ''),
('12864411000001102', ''),
('12864511000001103', ''),
('12828311000001109', ''),
('12827411000001101', ''),
('12934711000001106', ''),
('12934811000001103', ''),
('12915411000001107', ''),
('12915111000001102', ''),
('12904611000001106', ''),
('12904711000001102', ''),
('12902011000001105', ''),
('12901711000001100', ''),
('12895111000001108', ''),
('12894811000001102', ''),
('12894911000001107', ''),
('12893411000001102', ''),
('12864011000001106', ''),
('12864111000001107', ''),
('12824511000001105', ''),
('12824211000001107', ''),
('12863211000001104', ''),
('12863311000001107', ''),
('12822111000001109', ''),
('12821811000001106', ''),
('12893811000001100', ''),
('12894011000001108', ''),
('12889111000001106', ''),
('12888811000001106', ''),
('12936311000001101', ''),
('12936411000001108', ''),
('12920211000001105', ''),
('12919911000001102', ''),
('58211000001101', ''),
('758411000001103', ''),
('3606911000001102', ''),
('623211000001101', ''),
('707311000001101', ''),
('461311000001101', ''),
('32711000001109', ''),
('517311000001102', ''),
('32747111000001108', ''),
('32746911000001108', ''),
('21258811000001107', ''),
('28691111000001109', ''),
('21259011000001106', '')
GO
-- Query for ab_prescriptions
SELECT * INTO #ab_prescriptions FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp81_ab_prescriptions_codelist
ON DMD_ID = #tmp81_ab_prescriptions_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for ab_first_date
CREATE TABLE #tmp82_ab_first_date_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp82_ab_first_date_codelist (code, category) VALUES
('323398002', ''),
('27871711000001100', ''),
('28038711000001103', ''),
('27732411000001100', ''),
('323396003', ''),
('27872411000001101', ''),
('28035511000001100', ''),
('27732211000001104', ''),
('3880811000001103', ''),
('4074311000001105', ''),
('323418000', ''),
('392411000001109', ''),
('683011000001103', ''),
('10711000001104', ''),
('9804611000001105', ''),
('10452211000001101', ''),
('21038311000001109', ''),
('20129511000001108', ''),
('24410611000001107', ''),
('21532411000001101', ''),
('38081711000001100', ''),
('604211000001105', ''),
('11144611000001104', ''),
('610511000001102', ''),
('19736211000001105', ''),
('808511000001109', ''),
('738911000001105', ''),
('18719011000001104', ''),
('15311000001105', ''),
('323420002', ''),
('94811000001103', ''),
('209811000001108', ''),
('322611000001104', ''),
('9805411000001108', ''),
('10452411000001102', ''),
('21038511000001103', ''),
('20129711000001103', ''),
('37772611000001104', ''),
('21532611000001103', ''),
('38081911000001103', ''),
('189311000001103', ''),
('887811000001107', ''),
('30856011000001103', ''),
('770211000001102', ''),
('333711000001103', ''),
('18719411000001108', ''),
('289911000001104', ''),
('323416001', ''),
('765311000001105', ''),
('35211000001107', ''),
('821311000001102', ''),
('9803511000001108', ''),
('10430511000001103', ''),
('16063111000001105', ''),
('32489211000001105', ''),
('28985911000001106', ''),
('37773011000001102', ''),
('420411000001107', ''),
('78111000001109', ''),
('30856411000001107', ''),
('19730711000001101', ''),
('482711000001106', ''),
('17954711000001107', ''),
('839711000001102', ''),
('634711000001107', ''),
('29983311000001107', ''),
('799511000001103', ''),
('871611000001108', ''),
('21844711000001100', ''),
('9215111000001107', ''),
('9253911000001104', ''),
('31058611000001104', ''),
('16165811000001108', ''),
('28097111000001105', ''),
('10452611000001104', ''),
('21038711000001108', ''),
('32490911000001108', ''),
('21863211000001102', ''),
('37772411000001102', ''),
('9209211000001101', ''),
('9842311000001100', ''),
('17954311000001108', ''),
('9308011000001109', ''),
('21844311000001104', ''),
('9215211000001101', ''),
('9254111000001100', ''),
('31058811000001100', ''),
('16166011000001106', ''),
('28097311000001107', ''),
('10452811000001100', ''),
('21038911000001105', ''),
('32492211000001103', ''),
('21834511000001106', ''),
('37772811000001100', ''),
('9209511000001103', ''),
('30856211000001108', ''),
('9842511000001106', ''),
('17954511000001102', ''),
('11533211000001107', ''),
('9308211000001104', ''),
('21844511000001105', ''),
('22214211000001105', ''),
('22197411000001101', ''),
('849911000001104', ''),
('323464005', ''),
('120711000001100', ''),
('699911000001102', ''),
('916911000001106', ''),
('9798411000001103', ''),
('10407811000001107', ''),
('16050611000001101', ''),
('23907811000001108', ''),
('194111000001102', ''),
('627011000001100', ''),
('30130811000001104', ''),
('38915011000001109', ''),
('19728911000001100', ''),
('19193011000001107', ''),
('850811000001102', ''),
('37506211000001106', ''),
('17908511000001102', ''),
('220311000001101', ''),
('135511000001102', ''),
('15087311000001100', ''),
('333211000001105', ''),
('21996911000001108', ''),
('323465006', ''),
('289411000001107', ''),
('3111000001109', ''),
('32611000001100', ''),
('9798911000001106', ''),
('10408011000001100', ''),
('16050911000001107', ''),
('23908511000001109', ''),
('568111000001102', ''),
('590311000001104', ''),
('30131011000001101', ''),
('38915211000001104', ''),
('19729111000001105', ''),
('19193211000001102', ''),
('401911000001101', ''),
('36738011000001105', ''),
('17908811000001104', ''),
('629811000001103', ''),
('770011000001107', ''),
('15087511000001106', ''),
('833311000001104', ''),
('21997211000001102', ''),
('323491007', ''),
('97911000001102', ''),
('34753011000001106', ''),
('231911000001109', ''),
('323492000', ''),
('390611000001106', ''),
('162711000001108', ''),
('34753211000001101', ''),
('9142811000001101', ''),
('36921811000001102', ''),
('256511000001105', ''),
('323493005', ''),
('661411000001106', ''),
('34752811000001108', ''),
('9143111000001102', ''),
('36921411000001104', ''),
('858411000001101', ''),
('323484009', ''),
('513711000001108', ''),
('103311000001100', ''),
('207211000001101', ''),
('10454211000001105', ''),
('20136411000001100', ''),
('13578111000001101', ''),
('719411000001101', ''),
('138411000001106', ''),
('38914811000001104', ''),
('23189811000001102', ''),
('19193411000001103', ''),
('337811000001100', ''),
('18107711000001103', ''),
('746511000001103', ''),
('767311000001102', ''),
('21997911000001106', ''),
('323485005', ''),
('11268511000001102', ''),
('16086311000001101', ''),
('18722811000001105', ''),
('20137211000001102', ''),
('13578311000001104', ''),
('4835611000001101', ''),
('38915611000001102', ''),
('18107911000001101', ''),
('38076711000001103', ''),
('21998111000001109', ''),
('16089611000001103', ''),
('16443111000001108', ''),
('16086911000001100', ''),
('27126211000001105', ''),
('28096311000001109', ''),
('38619411000001101', ''),
('23979011000001102', ''),
('16247911000001103', ''),
('38915411000001100', ''),
('37732411000001104', ''),
('21997511000001104', ''),
('16089711000001107', ''),
('16443611000001100', ''),
('16086611000001106', ''),
('27126411000001109', ''),
('28096511000001103', ''),
('38619611000001103', ''),
('23979211000001107', ''),
('16248111000001100', ''),
('38915811000001103', ''),
('37732211000001103', ''),
('21997711000001109', ''),
('34769611000001109', ''),
('34753511000001103', ''),
('471111000001107', ''),
('888011000001100', ''),
('865811000001104', ''),
('324711000001103', ''),
('419411000001108', ''),
('748211000001100', ''),
('703911000001109', ''),
('251311000001107', ''),
('499611000001105', ''),
('323496002', ''),
('323474008', ''),
('811111000001105', ''),
('442211000001107', ''),
('9553611000001102', ''),
('9549311000001107', ''),
('323509004', ''),
('558111000001107', ''),
('23477711000001105', ''),
('739011000001101', ''),
('145611000001104', ''),
('9785311000001100', ''),
('10380511000001103', ''),
('12948011000001101', ''),
('15981611000001108', ''),
('33680711000001103', ''),
('22608411000001104', ''),
('36932811000001108', ''),
('325811000001107', ''),
('833211000001107', ''),
('29993011000001108', ''),
('38787311000001107', ''),
('19725711000001109', ''),
('19187411000001106', ''),
('413911000001103', ''),
('17779911000001102', ''),
('35591111000001108', ''),
('458811000001108', ''),
('228311000001104', ''),
('29765011000001104', ''),
('361711000001108', ''),
('21764811000001100', ''),
('18145411000001107', ''),
('323510009', ''),
('930411000001106', ''),
('18458211000001102', ''),
('406811000001101', ''),
('116511000001101', ''),
('9785911000001104', ''),
('10381311000001104', ''),
('12948211000001106', ''),
('15981911000001102', ''),
('33680911000001101', ''),
('22608811000001102', ''),
('36933111000001107', ''),
('802011000001104', ''),
('13811000001100', ''),
('29993211000001103', ''),
('38787911000001108', ''),
('19726111000001102', ''),
('19187611000001109', ''),
('816511000001105', ''),
('36693511000001106', ''),
('268011000001106', ''),
('17780311000001103', ''),
('35591411000001103', ''),
('181511000001108', ''),
('53711000001102', ''),
('29769211000001107', ''),
('668411000001104', ''),
('21765611000001103', ''),
('18146111000001108', ''),
('35902111000001107', ''),
('3241411000001109', ''),
('3246511000001104', ''),
('32496011000001107', ''),
('22609211000001108', ''),
('3246011000001107', ''),
('29993711000001105', ''),
('38788311000001108', ''),
('18081411000001108', ''),
('29765411000001108', ''),
('3243811000001105', ''),
('21766011000001101', ''),
('35368511000001109', ''),
('323732002', ''),
('634511000001102', ''),
('159311000001109', ''),
('549011000001104', ''),
('9786511000001104', ''),
('10426911000001105', ''),
('15984311000001100', ''),
('28943411000001109', ''),
('22609411000001107', ''),
('143211000001100', ''),
('329011000001104', ''),
('38785711000001100', ''),
('860211000001109', ''),
('17781111000001106', ''),
('144711000001109', ''),
('856111000001107', ''),
('29769411000001106', ''),
('200311000001108', ''),
('21766511000001109', ''),
('323733007', ''),
('819911000001107', ''),
('256911000001103', ''),
('767611000001107', ''),
('9786911000001106', ''),
('10427411000001100', ''),
('15984511000001106', ''),
('28943611000001107', ''),
('22609811000001109', ''),
('555611000001105', ''),
('213311000001100', ''),
('38787511000001101', ''),
('568411000001107', ''),
('17781711000001107', ''),
('673011000001105', ''),
('828811000001100', ''),
('15065511000001104', ''),
('830011000001107', ''),
('21776211000001103', ''),
('35901911000001104', ''),
('756511000001100', ''),
('623711000001108', ''),
('264811000001108', ''),
('9787111000001106', ''),
('10428011000001105', ''),
('15984711000001101', ''),
('22609611000001105', ''),
('69611000001101', ''),
('416211000001100', ''),
('29993911000001107', ''),
('38785511000001105', ''),
('35852611000001101', ''),
('311000001109', ''),
('17781911000001109', ''),
('35591711000001109', ''),
('709111000001109', ''),
('29764511000001106', ''),
('222511000001108', ''),
('21775811000001105', ''),
('548011000001109', ''),
('328211000001104', ''),
('730511000001101', ''),
('9787311000001108', ''),
('10428411000001101', ''),
('15984911000001104', ''),
('22610011000001109', ''),
('203311000001102', ''),
('693411000001108', ''),
('37033411000001105', ''),
('38787711000001106', ''),
('35852011000001108', ''),
('930911000001103', ''),
('17782111000001101', ''),
('35591911000001106', ''),
('88811000001107', ''),
('29765211000001109', ''),
('520311000001108', ''),
('21776011000001108', ''),
('38726811000001109', ''),
('38719511000001105', ''),
('388611000001105', ''),
('709311000001106', ''),
('234411000001104', ''),
('689711000001103', ''),
('389311000001106', ''),
('3243311000001101', ''),
('196111000001109', ''),
('644811000001100', ''),
('121011000001106', ''),
('774011000001100', ''),
('252511000001109', ''),
('500511000001107', ''),
('19211000001104', ''),
('42011000001106', ''),
('284811000001105', ''),
('2011000001104', ''),
('130111000001103', ''),
('874611000001105', ''),
('190111000001106', ''),
('161011000001103', ''),
('14811000001102', ''),
('7339611000001107', ''),
('7339811000001106', ''),
('323737008', ''),
('90411000001106', ''),
('34748011000001101', ''),
('283611000001108', ''),
('323738003', ''),
('834911000001101', ''),
('34748211000001106', ''),
('719311000001108', ''),
('323739006', ''),
('279111000001107', ''),
('34748411000001105', ''),
('144611000001100', ''),
('388911000001104', ''),
('120411000001106', ''),
('71111000001101', ''),
('323570001', ''),
('875911000001100', ''),
('536211000001101', ''),
('529211000001107', ''),
('10382011000001105', ''),
('28944411000001107', ''),
('13575311000001108', ''),
('30976211000001103', ''),
('698211000001101', ''),
('29994111000001106', ''),
('38788511000001102', ''),
('305911000001106', ''),
('17782311000001104', ''),
('10565411000001109', ''),
('29769811000001108', ''),
('21776411000001104', ''),
('323571002', ''),
('443811000001100', ''),
('578311000001106', ''),
('597311000001103', ''),
('10382211000001100', ''),
('28944611000001105', ''),
('30976411000001104', ''),
('755311000001101', ''),
('29994311000001108', ''),
('38788711000001107', ''),
('217411000001100', ''),
('17782711000001100', ''),
('10565611000001107', ''),
('15066311000001100', ''),
('323584006', ''),
('10355811000001100', ''),
('9725711000001105', ''),
('9505311000001100', ''),
('323572009', ''),
('8169711000001108', ''),
('268411000001102', ''),
('352711000001107', ''),
('24024611000001104', ''),
('938511000001108', ''),
('531211000001109', ''),
('18081811000001105', ''),
('15065711000001109', ''),
('323573004', ''),
('8169911000001105', ''),
('310511000001106', ''),
('45311000001103', ''),
('28927211000001104', ''),
('649511000001104', ''),
('328611000001102', ''),
('18082611000001100', ''),
('15066011000001103', ''),
('850311000001106', ''),
('9385411000001106', ''),
('12778811000001103', ''),
('12778611000001102', ''),
('414211000001105', ''),
('323563001', ''),
('38111000001106', ''),
('19833711000001107', ''),
('382811000001107', ''),
('101911000001100', ''),
('9786711000001109', ''),
('10397411000001104', ''),
('34962611000001109', ''),
('32397711000001104', ''),
('35907111000001109', ''),
('23827411000001108', ''),
('760411000001105', ''),
('12511000001105', ''),
('30016311000001106', ''),
('38848311000001101', ''),
('441311000001108', ''),
('17885811000001104', ''),
('91211000001101', ''),
('35563511000001103', ''),
('882211000001108', ''),
('29794911000001102', ''),
('771411000001107', ''),
('36868011000001101', ''),
('22009111000001105', ''),
('380711000001103', ''),
('36565811000001104', ''),
('829311000001103', ''),
('15515811000001104', ''),
('370711000001105', ''),
('9787711000001107', ''),
('22602311000001108', ''),
('575411000001109', ''),
('276811000001106', ''),
('38850811000001105', ''),
('4817111000001106', ''),
('17885411000001101', ''),
('193411000001109', ''),
('6032711000001109', ''),
('894611000001101', ''),
('22007211000001105', ''),
('323567000', ''),
('18757611000001105', ''),
('34752211000001107', ''),
('10219611000001104', ''),
('36626111000001101', ''),
('10530611000001105', ''),
('5488611000001104', ''),
('323568005', ''),
('19570811000001107', ''),
('34752411000001106', ''),
('37830211000001102', ''),
('10219211000001101', ''),
('30347811000001105', ''),
('36626911000001103', ''),
('10531011000001107', ''),
('5489611000001108', ''),
('37083611000001104', ''),
('732211000001103', ''),
('15516011000001101', ''),
('394111000001107', ''),
('9787911000001109', ''),
('22602511000001102', ''),
('353811000001107', ''),
('526211000001103', ''),
('30016111000001109', ''),
('38848111000001103', ''),
('36492911000001108', ''),
('4817311000001108', ''),
('17885611000001103', ''),
('22211000001104', ''),
('6034811000001107', ''),
('931011000001106', ''),
('22007711000001103', ''),
('3964011000001108', ''),
('7322211000001104', ''),
('13613111000001106', ''),
('24026411000001105', ''),
('23939811000001105', ''),
('31989511000001109', ''),
('24520711000001100', ''),
('38848811000001105', ''),
('7320111000001106', ''),
('28123611000001108', ''),
('29794511000001109', ''),
('22008011000001104', ''),
('7322311000001107', ''),
('11528611000001104', ''),
('24026611000001108', ''),
('23940311000001109', ''),
('31989811000001107', ''),
('24520911000001103', ''),
('38849111000001105', ''),
('7320411000001101', ''),
('28123911000001102', ''),
('29794711000001104', ''),
('22008411000001108', ''),
('323539009', ''),
('290311000001105', ''),
('19833911000001109', ''),
('17668811000001104', ''),
('680711000001105', ''),
('34679211000001108', ''),
('10397711000001105', ''),
('34962811000001108', ''),
('32399711000001107', ''),
('35907311000001106', ''),
('27959011000001105', ''),
('23828211000001108', ''),
('351311000001104', ''),
('785111000001106', ''),
('38848511000001107', ''),
('19728511000001107', ''),
('19199611000001103', ''),
('5629811000001102', ''),
('36695911000001103', ''),
('17886011000001101', ''),
('628011000001104', ''),
('35563911000001105', ''),
('6036511000001103', ''),
('29795111000001101', ''),
('934111000001105', ''),
('36870911000001108', ''),
('22009611000001102', ''),
('3964511000001100', ''),
('37083711000001108', ''),
('11252711000001103', ''),
('19876911000001100', ''),
('32403711000001100', ''),
('30043911000001108', ''),
('32399111000001106', ''),
('38850411000001108', ''),
('19728111000001103', ''),
('23651411000001107', ''),
('22036711000001105', ''),
('15077811000001102', ''),
('392259005', ''),
('28873411000001104', ''),
('28039411000001101', ''),
('32400011000001107', ''),
('27959911000001109', ''),
('30016511000001100', ''),
('29795311000001104', ''),
('94411000001100', ''),
('386811000001108', ''),
('549911000001100', ''),
('871511000001109', ''),
('932211000001108', ''),
('866111000001100', ''),
('292511000001103', ''),
('169511000001107', ''),
('29011000001102', ''),
('139811000001101', ''),
('57911000001109', ''),
('451111000001109', ''),
('618111000001108', ''),
('323624001', ''),
('599611000001103', ''),
('34411000001105', ''),
('728111000001109', ''),
('19818211000001104', ''),
('28922811000001101', ''),
('23857311000001102', ''),
('10292811000001106', ''),
('908411000001104', ''),
('146111000001101', ''),
('30018311000001105', ''),
('38857911000001104', ''),
('773911000001103', ''),
('17888511000001105', ''),
('382411000001105', ''),
('29798411000001101', ''),
('9627311000001106', ''),
('21941711000001107', ''),
('4006211000001100', ''),
('323626004', ''),
('21710711000001103', ''),
('36090611000001106', ''),
('18542211000001108', ''),
('18446411000001102', ''),
('18421711000001100', ''),
('435911000001105', ''),
('473311000001105', ''),
('3098711000001105', ''),
('323772006', ''),
('4413311000001105', ''),
('323673005', ''),
('34755211000001102', ''),
('36612211000001103', ''),
('38801411000001109', ''),
('36607511000001104', ''),
('15442611000001107', ''),
('16733411000001109', ''),
('18781411000001105', ''),
('15519011000001107', ''),
('19519511000001106', ''),
('22599711000001106', ''),
('24014211000001106', ''),
('323671007', ''),
('34755411000001103', ''),
('36611611000001107', ''),
('34680211000001108', ''),
('19518711000001105', ''),
('36798311000001102', ''),
('36607211000001102', ''),
('15442811000001106', ''),
('17899511000001103', ''),
('18166311000001101', ''),
('22599211000001104', ''),
('4651611000001105', ''),
('4437611000001103', ''),
('4437911000001109', ''),
('4641311000001103', ''),
('323786005', ''),
('37305311000001105', ''),
('37775511000001109', ''),
('35175011000001108', ''),
('32750311000001106', ''),
('32744411000001108', ''),
('3685611000001102', ''),
('323999000', ''),
('324000003', ''),
('4597311000001106', ''),
('4597911000001107', ''),
('324003001', ''),
('324004007', ''),
('324005008', ''),
('4626311000001109', ''),
('4626611000001104', ''),
('4627111000001105', ''),
('36458411000001105', ''),
('36458511000001109', ''),
('36456811000001106', ''),
('36457111000001101', ''),
('4457111000001107', ''),
('4452211000001104', ''),
('323935008', ''),
('323936009', ''),
('37987711000001105', ''),
('33631211000001106', ''),
('33627411000001104', ''),
('37986811000001104', ''),
('36515811000001100', ''),
('34800611000001101', ''),
('7654711000001109', ''),
('4981711000001108', ''),
('323791006', ''),
('275011000001109', ''),
('813911000001109', ''),
('10290911000001100', ''),
('636511000001108', ''),
('17826511000001101', ''),
('233911000001105', ''),
('270911000001104', ''),
('323792004', ''),
('4113911000001107', ''),
('10348111000001104', ''),
('25833611000001106', ''),
('31564011000001109', ''),
('890411000001105', ''),
('30008911000001108', ''),
('612411000001100', ''),
('32201411000001108', ''),
('18085911000001103', ''),
('171911000001109', ''),
('323793009', ''),
('4114111000001106', ''),
('8825311000001105', ''),
('25834011000001102', ''),
('31564611000001102', ''),
('5311000001107', ''),
('647311000001100', ''),
('32201711000001102', ''),
('18086111000001107', ''),
('400511000001101', ''),
('323795002', ''),
('744311000001103', ''),
('64011000001107', ''),
('10291411000001104', ''),
('4323911000001106', ''),
('17826711000001106', ''),
('923811000001104', ''),
('15073011000001102', ''),
('459111000001108', ''),
('36134211000001100', ''),
('3663611000001103', ''),
('804411000001101', ''),
('4324111000001105', ''),
('168011000001109', ''),
('36134011000001105', ''),
('37011000001109', ''),
('141511000001101', ''),
('10309911000001103', ''),
('17867211000001105', ''),
('576111000001105', ''),
('36134111000001106', ''),
('745411000001106', ''),
('594511000001101', ''),
('10310111000001109', ''),
('9764411000001109', ''),
('17867411000001109', ''),
('248911000001101', ''),
('793311000001106', ''),
('602211000001101', ''),
('252811000001107', ''),
('583511000001100', ''),
('555211000001108', ''),
('803611000001101', ''),
('531011000001104', ''),
('318811000001107', ''),
('869711000001109', ''),
('323813001', ''),
('7887711000001102', ''),
('5918311000001108', ''),
('19712411000001100', ''),
('30009111000001103', ''),
('38825011000001109', ''),
('17851711000001104', ''),
('8750411000001109', ''),
('4814611000001109', ''),
('15073211000001107', ''),
('21821711000001101', ''),
('323811004', ''),
('323812006', ''),
('323816009', ''),
('674111000001108', ''),
('912111000001109', ''),
('60011000001100', ''),
('304211000001103', ''),
('323973007', ''),
('36134411000001101', ''),
('370375008', ''),
('34762811000001103', ''),
('511411000001101', ''),
('3184511000001101', ''),
('323824004', ''),
('13611511000001101', ''),
('34750011000001101', ''),
('4532811000001108', ''),
('27971011000001109', ''),
('4532411000001106', ''),
('323825003', ''),
('13611811000001103', ''),
('34749811000001100', ''),
('3940811000001102', ''),
('27969111000001102', ''),
('36516011000001102', ''),
('3940211000001103', ''),
('4558311000001100', ''),
('13612211000001106', ''),
('4533911000001105', ''),
('27969611000001105', ''),
('36516211000001107', ''),
('4533711000001108', ''),
('4532011000001102', ''),
('3939811000001107', ''),
('4533411000001102', ''),
('323829009', ''),
('28788511000001103', ''),
('34800911000001107', ''),
('323830004', ''),
('28788811000001100', ''),
('34801211000001109', ''),
('4375311000001105', ''),
('4376311000001100', ''),
('37528311000001105', ''),
('37529711000001100', ''),
('323982001', ''),
('35369711000001108', ''),
('3929911000001104', ''),
('3930911000001108', ''),
('323989005', ''),
('13612411000001105', ''),
('34750811000001107', ''),
('23047711000001101', ''),
('27971211000001104', ''),
('323990001', ''),
('3977811000001102', ''),
('34751011000001105', ''),
('37336711000001105', ''),
('3978511000001101', ''),
('22824911000001102', ''),
('36516811000001108', ''),
('11400311000001106', ''),
('38564411000001109', ''),
('20100211000001107', ''),
('36541011000001102', ''),
('32483211000001108', ''),
('3978011000001109', ''),
('323991002', ''),
('23414711000001106', ''),
('36517011000001104', ''),
('4405611000001104', ''),
('34751211000001100', ''),
('4406311000001104', ''),
('20100411000001106', ''),
('36783811000001102', ''),
('32483411000001107', ''),
('4406011000001102', ''),
('4404611000001100', ''),
('3978911000001108', ''),
('4406611000001109', ''),
('323853003', ''),
('10188511000001108', ''),
('34750211000001106', ''),
('36537311000001106', ''),
('8744311000001107', ''),
('19837811000001105', ''),
('32483611000001105', ''),
('323854009', ''),
('10188111000001104', ''),
('34750411000001105', ''),
('36760611000001107', ''),
('8745211000001103', ''),
('23055511000001100', ''),
('36516411000001106', ''),
('19843211000001101', ''),
('36540611000001104', ''),
('32483811000001109', ''),
('9470311000001109', ''),
('323855005', ''),
('10188311000001102', ''),
('34750611000001108', ''),
('36611411000001109', ''),
('8745411000001104', ''),
('23057711000001104', ''),
('36516611000001109', ''),
('19842311000001104', ''),
('36540811000001100', ''),
('32484011000001101', ''),
('9470511000001103', ''),
('323852008', ''),
('323849000', ''),
('35798511000001105', ''),
('4373011000001106', ''),
('4374011000001108', ''),
('3930311000001107', ''),
('4374611000001101', ''),
('4375711000001109', ''),
('10283311000001108', ''),
('4374311000001106', ''),
('3930711000001106', ''),
('4374911000001107', ''),
('323880005', ''),
('4740011000001101', ''),
('34751411000001101', ''),
('36754511000001105', ''),
('36134711000001107', ''),
('3939111000001100', ''),
('11617911000001109', ''),
('36613111000001103', ''),
('36605111000001104', ''),
('36754311000001104', ''),
('4557611000001106', ''),
('4530611000001108', ''),
('11617611000001103', ''),
('36613311000001101', ''),
('36605311000001102', ''),
('36753811000001105', ''),
('4740211000001106', ''),
('3939311000001103', ''),
('4530311000001103', ''),
('11775211000001105', ''),
('11775411000001109', ''),
('11775611000001107', ''),
('323868002', ''),
('323869005', ''),
('10096411000001100', ''),
('10271811000001105', ''),
('19712711000001106', ''),
('30011011000001101', ''),
('38826311000001102', ''),
('17853111000001104', ''),
('9547111000001104', ''),
('15074511000001108', ''),
('10885511000001106', ''),
('13743011000001107', ''),
('21831411000001105', ''),
('323872003', ''),
('323874002', ''),
('228011000001102', ''),
('211911000001100', ''),
('238811000001105', ''),
('3253511000001109', ''),
('323883007', ''),
('716611000001106', ''),
('34811000001107', ''),
('606011000001105', ''),
('10388711000001105', ''),
('22631111000001107', ''),
('37509711000001109', ''),
('3611000001101', ''),
('763611000001104', ''),
('27996311000001105', ''),
('30009611000001106', ''),
('38826011000001100', ''),
('19187811000001108', ''),
('216811000001100', ''),
('9376611000001109', ''),
('17851911000001102', ''),
('612311000001107', ''),
('29782311000001109', ''),
('758111000001108', ''),
('21822811000001100', ''),
('323884001', ''),
('660211000001101', ''),
('596511000001107', ''),
('324911000001101', ''),
('10388911000001107', ''),
('22631511000001103', ''),
('37510111000001100', ''),
('648411000001106', ''),
('850211000001103', ''),
('27996611000001100', ''),
('30010111000001106', ''),
('38826411000001109', ''),
('19188011000001101', ''),
('86911000001101', ''),
('9376411000001106', ''),
('17852111000001105', ''),
('305811000001101', ''),
('29782711000001108', ''),
('587511000001105', ''),
('21823311000001104', ''),
('323887008', '')
GO
INSERT INTO #tmp82_ab_first_date_codelist (code, category) VALUES
('639611000001104', ''),
('640011000001104', ''),
('534211000001106', ''),
('10456111000001106', ''),
('22631711000001108', ''),
('37510911000001102', ''),
('34311000001103', ''),
('30010411000001101', ''),
('38825611000001102', ''),
('560011000001100', ''),
('18086311000001109', ''),
('233111000001107', ''),
('15073911000001103', ''),
('6211000001105', ''),
('21826411000001101', ''),
('323888003', ''),
('800711000001101', ''),
('707211000001109', ''),
('158511000001109', ''),
('10456311000001108', ''),
('30136211000001103', ''),
('37510711000001104', ''),
('835511000001109', ''),
('30010611000001103', ''),
('38827711000001100', ''),
('887911000001102', ''),
('18086511000001103', ''),
('728211000001103', ''),
('15074111000001104', ''),
('344611000001109', ''),
('21826611000001103', ''),
('36134311000001108', ''),
('30769411000001109', ''),
('31565211000001103', ''),
('8825611000001100', ''),
('32202211000001102', ''),
('15074311000001102', ''),
('21825911000001102', ''),
('323885000', ''),
('719911000001109', ''),
('924811000001101', ''),
('600911000001106', ''),
('10389111000001102', ''),
('22631911000001105', ''),
('37510511000001109', ''),
('360811000001108', ''),
('483611000001107', ''),
('427011000001102', ''),
('11267511000001101', ''),
('17852311000001107', ''),
('232811000001108', ''),
('15052511000001101', ''),
('362911000001104', ''),
('21827211000001103', ''),
('323886004', ''),
('652611000001105', ''),
('149411000001104', ''),
('863911000001108', ''),
('10389411000001107', ''),
('22632111000001102', ''),
('37510311000001103', ''),
('887511000001109', ''),
('331411000001105', ''),
('38824911000001109', ''),
('452411000001109', ''),
('11267711000001106', ''),
('17852511000001101', ''),
('687811000001103', ''),
('29782911000001105', ''),
('199411000001106', ''),
('21830211000001100', ''),
('4865011000001104', ''),
('35227111000001103', ''),
('35210711000001106', ''),
('19188211000001106', ''),
('11267111000001105', ''),
('4861711000001104', ''),
('4515811000001108', ''),
('35215211000001108', ''),
('35210911000001108', ''),
('19188411000001105', ''),
('11267311000001107', ''),
('4514011000001101', ''),
('904711000001102', ''),
('343411000001108', ''),
('474311000001107', ''),
('471811000001100', ''),
('96011000001104', ''),
('875311000001101', ''),
('3234011000001103', ''),
('733011000001104', ''),
('362611000001105', ''),
('91011000001106', ''),
('622911000001103', ''),
('691711000001103', ''),
('757911000001105', ''),
('323944009', ''),
('441611000001103', ''),
('48711000001106', ''),
('13576111000001100', ''),
('266111000001108', ''),
('821811000001106', ''),
('38825311000001107', ''),
('141011000001109', ''),
('17852711000001106', ''),
('231211000001100', ''),
('29783111000001101', ''),
('601211000001108', ''),
('21830611000001103', ''),
('323945005', ''),
('810111000001104', ''),
('277711000001100', ''),
('22632411000001107', ''),
('88011000001101', ''),
('332811000001103', ''),
('30010811000001104', ''),
('38825511000001101', ''),
('688511000001102', ''),
('17852911000001108', ''),
('750911000001109', ''),
('29783311000001104', ''),
('392711000001103', ''),
('21831111000001100', ''),
('323947002', ''),
('323948007', ''),
('36134511000001102', ''),
('705811000001100', ''),
('8911000001102', ''),
('3466111000001104', ''),
('795711000001106', ''),
('14511000001100', ''),
('435511000001103', ''),
('769211000001104', ''),
('324343004', ''),
('28963111000001109', ''),
('34711611000001107', ''),
('35306811000001105', ''),
('35834011000001101', ''),
('26812711000001104', ''),
('23021211000001100', ''),
('35247011000001102', ''),
('18486711000001104', ''),
('38009511000001105', ''),
('37655611000001101', ''),
('324344005', ''),
('29714711000001100', ''),
('34711811000001106', ''),
('35306611000001106', ''),
('35829511000001105', ''),
('26812911000001102', ''),
('23049211000001102', ''),
('35246811000001106', ''),
('18486011000001101', ''),
('38009811000001108', ''),
('37656911000001100', ''),
('32391011000001106', ''),
('4382011000001108', ''),
('4381711000001103', ''),
('4792411000001101', ''),
('36691911000001100', ''),
('38564211000001105', ''),
('4779811000001104', ''),
('428353009', ''),
('14236111000001106', ''),
('4396211000001103', ''),
('24416411000001106', ''),
('24200611000001109', ''),
('36568011000001102', ''),
('22980411000001102', ''),
('18852711000001100', ''),
('323970005', ''),
('4391811000001107', ''),
('4392111000001105', ''),
('4391611000001108', ''),
('323962000', ''),
('323961007', ''),
('323960008', ''),
('4344011000001107', ''),
('4343611000001103', ''),
('4342911000001102', ''),
('324049005', ''),
('13613311000001108', ''),
('13385911000001100', ''),
('13479311000001102', ''),
('11713511000001103', ''),
('11713611000001104', ''),
('11697611000001102', ''),
('11697311000001107', ''),
('11713311000001109', ''),
('11713411000001102', ''),
('11697011000001109', ''),
('11696711000001108', ''),
('11713711000001108', ''),
('11713811000001100', ''),
('11698211000001100', ''),
('11697911000001108', ''),
('371595007', ''),
('27808811000001108', ''),
('34802411000001103', ''),
('3722011000001101', ''),
('324070004', ''),
('2847611000001101', ''),
('2847811000001102', ''),
('2849911000001100', ''),
('11403911000001104', ''),
('10405011000001108', ''),
('23881111000001102', ''),
('37897811000001106', ''),
('14201611000001100', ''),
('2848611000001102', ''),
('2849111000001103', ''),
('37071111000001104', ''),
('38877411000001105', ''),
('7432211000001109', ''),
('17894611000001103', ''),
('29836111000001100', ''),
('2848011000001109', ''),
('2848411000001100', ''),
('21933211000001100', ''),
('324059006', ''),
('2850911000001108', ''),
('2851411000001109', ''),
('2854311000001104', ''),
('11404211000001106', ''),
('2851811000001106', ''),
('10405211000001103', ''),
('23880711000001109', ''),
('37896911000001104', ''),
('14161611000001103', ''),
('2852511000001100', ''),
('2853211000001109', ''),
('30123211000001107', ''),
('38877111000001100', ''),
('2852911000001107', ''),
('17894811000001104', ''),
('15083411000001100', ''),
('10724511000001104', ''),
('2852311000001106', ''),
('21933411000001101', ''),
('324072007', ''),
('8485211000001101', ''),
('8485311000001109', ''),
('8458111000001109', ''),
('8459211000001108', ''),
('32876211000001101', ''),
('32874411000001105', ''),
('421341000', ''),
('38250911000001106', ''),
('2853411000001108', ''),
('2849311000001101', ''),
('2849511000001107', ''),
('2854011000001102', ''),
('2847211000001103', ''),
('2849711000001102', ''),
('2852111000001109', ''),
('2848211000001104', ''),
('2853611000001106', ''),
('324076005', ''),
('21232111000001104', ''),
('23643111000001104', ''),
('30763011000001103', ''),
('24372611000001107', ''),
('32417211000001101', ''),
('37119611000001105', ''),
('34187111000001100', ''),
('29899911000001103', ''),
('37860011000001104', ''),
('21219611000001105', ''),
('21790011000001101', ''),
('396211000001106', ''),
('324092000', ''),
('666311000001107', ''),
('679811000001102', ''),
('514011000001108', ''),
('24386011000001105', ''),
('939411000001101', ''),
('30831211000001101', ''),
('238111000001103', ''),
('11408511000001102', ''),
('17942111000001100', ''),
('29923611000001108', ''),
('8819311000001104', ''),
('891511000001102', ''),
('13758111000001102', ''),
('21801011000001105', ''),
('324093005', ''),
('254511000001104', ''),
('754011000001103', ''),
('165311000001103', ''),
('34019411000001108', ''),
('24385811000001107', ''),
('64211000001102', ''),
('30831011000001106', ''),
('7611000001109', ''),
('11408011000001105', ''),
('17942311000001103', ''),
('29923011000001101', ''),
('8819511000001105', ''),
('936711000001102', ''),
('13758311000001100', ''),
('21801211000001100', ''),
('36565111000001106', ''),
('9330111000001102', ''),
('14781411000001109', ''),
('324090008', ''),
('324091007', ''),
('13010711000001108', ''),
('13010811000001100', ''),
('12979311000001105', ''),
('12979011000001107', ''),
('123211000001102', ''),
('621011000001105', ''),
('820411000001100', ''),
('921111000001105', ''),
('926911000001103', ''),
('116911000001108', ''),
('147511000001107', ''),
('7393411000001103', ''),
('9361611000001109', ''),
('18248711000001106', ''),
('9891211000001108', ''),
('324095003', ''),
('3345011000001108', ''),
('3345611000001101', ''),
('3350311000001102', ''),
('9802411000001100', ''),
('10436911000001108', ''),
('16062611000001107', ''),
('28918511000001105', ''),
('30071211000001104', ''),
('29006911000001106', ''),
('11013711000001105', ''),
('20326411000001109', ''),
('3347511000001109', ''),
('22473711000001108', ''),
('3347811000001107', ''),
('17951211000001102', ''),
('4331711000001105', ''),
('15114911000001103', ''),
('3349611000001103', ''),
('3346311000001101', ''),
('21829411000001108', ''),
('13003811000001109', ''),
('12989611000001106', ''),
('13003911000001104', ''),
('12990511000001100', ''),
('13004011000001101', ''),
('12991011000001104', ''),
('13003711000001101', ''),
('12989211000001109', ''),
('3348411000001109', ''),
('3348811000001106', ''),
('3347011000001101', ''),
('324011006', ''),
('20291511000001104', ''),
('324012004', ''),
('47611000001101', ''),
('205211000001109', ''),
('625311000001105', ''),
('17962811000001100', ''),
('37824111000001101', ''),
('36074811000001107', ''),
('22473211000001101', ''),
('357111000001108', ''),
('35593811000001102', ''),
('17875711000001104', ''),
('21787511000001109', ''),
('21407411000001104', ''),
('21406411000001101', ''),
('4548811000001106', ''),
('34819711000001101', ''),
('917911000001109', ''),
('10328711000001100', ''),
('35204411000001108', ''),
('10321011000001108', ''),
('36564611000001104', ''),
('15656211000001107', ''),
('35899911000001109', ''),
('9222111000001109', ''),
('11591311000001108', ''),
('35899811000001104', ''),
('4500111000001106', ''),
('4500411000001101', ''),
('36051011000001102', ''),
('3845211000001101', ''),
('27334311000001101', ''),
('3847411000001108', ''),
('32334511000001109', ''),
('3846511000001105', ''),
('29862011000001106', ''),
('36063011000001107', ''),
('4615711000001107', ''),
('36051111000001101', ''),
('3997111000001101', ''),
('3998811000001107', ''),
('3998211000001106', ''),
('36050911000001105', ''),
('3999111000001107', ''),
('3999911000001105', ''),
('3999411000001102', ''),
('8523611000001103', ''),
('8494111000001107', ''),
('12089911000001108', ''),
('12075211000001108', ''),
('12090011000001100', ''),
('12076611000001100', ''),
('27800411000001108', ''),
('27690911000001109', ''),
('29827911000001102', ''),
('29793411000001107', ''),
('29903511000001102', ''),
('29934211000001107', ''),
('29861811000001109', ''),
('29951311000001103', ''),
('29941811000001105', ''),
('29942711000001109', ''),
('29951111000001100', ''),
('29942211000001102', ''),
('29942911000001106', ''),
('29951211000001106', ''),
('29942511000001104', ''),
('29943111000001102', ''),
('32749211000001108', ''),
('32743411000001105', ''),
('3845811000001100', ''),
('3983611000001102', ''),
('4609011000001105', ''),
('3997811000001108', ''),
('3847011000001104', ''),
('17330211000001102', ''),
('10967311000001102', ''),
('324158001', ''),
('4055311000001106', ''),
('28932611000001103', ''),
('4055711000001105', ''),
('4208311000001104', ''),
('12302011000001102', ''),
('12274811000001104', ''),
('12301911000001109', ''),
('12273311000001106', ''),
('4055511000001100', ''),
('36031111000001100', ''),
('36031311000001103', ''),
('36030911000001109', ''),
('36031011000001101', ''),
('36031211000001106', ''),
('4463011000001106', ''),
('4463311000001109', ''),
('4463611000001104', ''),
('4464611000001101', ''),
('4462711000001100', ''),
('34194211000001103', ''),
('4957911000001108', ''),
('4944011000001104', ''),
('9187611000001105', ''),
('4944511000001107', ''),
('4944311000001101', ''),
('12949611000001104', ''),
('4145011000001103', ''),
('4127011000001108', ''),
('9187811000001109', ''),
('4129111000001103', ''),
('26857411000001100', ''),
('38027711000001101', ''),
('4128011000001109', ''),
('12949811000001100', ''),
('35919711000001100', ''),
('4514311000001103', ''),
('35919811000001108', ''),
('4158411000001104', ''),
('32656811000001108', ''),
('32645711000001105', ''),
('4516011000001106', ''),
('35777411000001100', ''),
('4514611000001108', ''),
('19544811000001101', ''),
('23676411000001103', ''),
('23671411000001109', ''),
('4514911000001102', ''),
('4128611000001102', ''),
('324252006', ''),
('14968311000001103', ''),
('15017711000001104', ''),
('36465711000001104', ''),
('19706711000001107', ''),
('37893411000001102', ''),
('32395411000001104', ''),
('37041111000001100', ''),
('38802911000001107', ''),
('35727711000001105', ''),
('17791111000001105', ''),
('15071111000001102', ''),
('33932211000001100', ''),
('14789411000001105', ''),
('34554511000001101', ''),
('324253001', ''),
('13652511000001104', ''),
('17283411000001107', ''),
('22615611000001105', ''),
('37041811000001107', ''),
('38803511000001107', ''),
('20281711000001105', ''),
('15070811000001101', ''),
('14166911000001104', ''),
('21781011000001106', ''),
('324258005', ''),
('11252311000001102', ''),
('38006911000001107', ''),
('20943011000001102', ''),
('15472811000001107', ''),
('34642911000001105', ''),
('19543911000001109', ''),
('36420111000001101', ''),
('19707211000001103', ''),
('32395911000001107', ''),
('37042711000001106', ''),
('38810611000001100', ''),
('38710611000001103', ''),
('19474211000001108', ''),
('17791411000001100', ''),
('11579411000001106', ''),
('15051411000001105', ''),
('37857911000001108', ''),
('11028111000001105', ''),
('11034311000001100', ''),
('11252111000001104', ''),
('38006711000001105', ''),
('20942811000001100', ''),
('15472611000001108', ''),
('34642111000001107', ''),
('19544211000001102', ''),
('36445611000001104', ''),
('19707011000001108', ''),
('32395711000001105', ''),
('29998311000001103', ''),
('38803811000001105', ''),
('38710311000001108', ''),
('19474411000001107', ''),
('22202911000001107', ''),
('20282311000001102', ''),
('15071411000001107', ''),
('36907711000001108', ''),
('11028411000001100', ''),
('29668711000001101', ''),
('29516411000001104', ''),
('85911000001108', ''),
('650911000001103', ''),
('794511000001102', ''),
('14759911000001105', ''),
('324238009', ''),
('8927511000001103', ''),
('20165611000001102', ''),
('14694011000001106', ''),
('9033411000001103', ''),
('17965211000001106', ''),
('13765011000001103', ''),
('19715011000001104', ''),
('37402011000001108', ''),
('8825911000001106', ''),
('38836811000001108', ''),
('35140911000001102', ''),
('8914911000001107', ''),
('17859611000001109', ''),
('9038211000001105', ''),
('8993611000001100', ''),
('15080711000001102', ''),
('17522411000001102', ''),
('8818911000001106', ''),
('13745611000001101', ''),
('36846911000001107', ''),
('21854711000001102', ''),
('20096711000001105', ''),
('35368711000001104', ''),
('9252611000001100', ''),
('36621611000001102', ''),
('9157411000001102', ''),
('30761711000001102', ''),
('30031911000001106', ''),
('9155811000001105', ''),
('38840411000001105', ''),
('18101811000001104', ''),
('9042011000001104', ''),
('9547411000001109', ''),
('15080411000001108', ''),
('21854311000001101', ''),
('324242007', ''),
('36635611000001101', ''),
('17648711000001102', ''),
('17997711000001108', ''),
('35555411000001108', ''),
('13612911000001102', ''),
('34751611000001103', ''),
('13469711000001107', ''),
('324244008', ''),
('8928611000001100', ''),
('20165811000001103', ''),
('14694411000001102', ''),
('9033811000001101', ''),
('17965511000001109', ''),
('13765211000001108', ''),
('19715211000001109', ''),
('37402811000001102', ''),
('8826111000001102', ''),
('38837011000001104', ''),
('35141111000001106', ''),
('8915511000001104', ''),
('17859811000001108', ''),
('9038811000001106', ''),
('8993811000001101', ''),
('29789111000001103', ''),
('17522611000001104', ''),
('8819111000001101', ''),
('13745811000001102', ''),
('36847211000001101', ''),
('21854911000001100', ''),
('20097311000001109', ''),
('36142611000001107', ''),
('324248006', ''),
('4977911000001105', ''),
('37083211000001101', ''),
('9253011000001103', ''),
('36621811000001103', ''),
('9157711000001108', ''),
('30761911000001100', ''),
('30041111000001109', ''),
('9156111000001109', ''),
('38840711000001104', ''),
('18103211000001101', ''),
('9042311000001101', ''),
('9547911000001101', ''),
('15080911000001100', ''),
('21854511000001107', ''),
('9742311000001103', ''),
('9742411000001105', ''),
('9742511000001109', ''),
('220811000001105', ''),
('917411000001101', ''),
('27011000001106', ''),
('463111000001102', ''),
('40811000001101', ''),
('3253811000001107', ''),
('4973711000001103', ''),
('211000001101', ''),
('9739611000001100', ''),
('9739911000001106', ''),
('9740211000001105', ''),
('18149211000001106', ''),
('21667211000001100', ''),
('21708211000001106', ''),
('33656011000001109', ''),
('324178009', ''),
('766711000001101', ''),
('89511000001103', ''),
('689511000001108', ''),
('789411000001103', ''),
('9795911000001100', ''),
('10406411000001108', ''),
('24389111000001103', ''),
('23903911000001107', ''),
('11020911000001106', ''),
('35996611000001100', ''),
('32800711000001104', ''),
('654811000001103', ''),
('687011000001109', ''),
('30825911000001105', ''),
('38889811000001108', ''),
('19733011000001108', ''),
('19191611000001104', ''),
('126311000001101', ''),
('38073211000001103', ''),
('17903711000001101', ''),
('7211000001107', ''),
('4330011000001104', ''),
('29856311000001102', ''),
('17198711000001106', ''),
('18281911000001106', ''),
('919211000001106', ''),
('21976211000001109', ''),
('36064711000001106', ''),
('482311000001107', ''),
('20962611000001108', ''),
('258211000001108', ''),
('10406211000001109', ''),
('10139811000001105', ''),
('9563611000001105', ''),
('759811000001108', ''),
('235411000001103', ''),
('165611000001108', ''),
('4227311000001109', ''),
('324232005', ''),
('682211000001102', ''),
('838411000001100', ''),
('468911000001109', ''),
('23902711000001102', ''),
('10307311000001109', ''),
('469911000001101', ''),
('38889611000001109', ''),
('17902311000001105', ''),
('13620311000001107', ''),
('231611000001103', ''),
('29852211000001109', ''),
('21935211000001101', ''),
('324233000', ''),
('563411000001101', ''),
('398811000001108', ''),
('816211000001107', ''),
('23902911000001100', ''),
('10307711000001108', ''),
('79111000001102', ''),
('38890011000001106', ''),
('17902811000001101', ''),
('13620511000001101', ''),
('103911000001104', ''),
('29856111000001104', ''),
('21975211000001103', ''),
('324234006', ''),
('348611000001104', ''),
('889511000001102', ''),
('845911000001101', ''),
('23903111000001109', ''),
('10308311000001105', ''),
('237511000001108', ''),
('17903311000001100', ''),
('13620711000001106', ''),
('605811000001107', ''),
('29856611000001107', ''),
('21975411000001104', ''),
('324179001', ''),
('32506411000001108', ''),
('37376611000001104', ''),
('32163811000001106', ''),
('37149211000001103', ''),
('36564711000001108', ''),
('481911000001102', ''),
('10060511000001100', ''),
('580111000001102', ''),
('23903311000001106', ''),
('10307511000001103', ''),
('2411000001108', ''),
('840611000001104', ''),
('30125811000001107', ''),
('38890211000001101', ''),
('549711000001102', ''),
('17902611000001100', ''),
('13620911000001108', ''),
('29851811000001101', ''),
('173511000001103', ''),
('21975611000001101', ''),
('177211000001105', ''),
('10060711000001105', ''),
('364011000001109', ''),
('23903511000001100', ''),
('10308011000001107', ''),
('273611000001101', ''),
('506011000001101', ''),
('30810111000001105', ''),
('38890411000001102', ''),
('784711000001108', ''),
('17903011000001103', ''),
('13621111000001104', ''),
('29852611000001106', ''),
('592611000001105', ''),
('21975811000001102', ''),
('433911000001109', ''),
('10060911000001107', ''),
('626611000001105', ''),
('23903711000001105', ''),
('10308511000001104', ''),
('364211000001104', ''),
('78611000001101', ''),
('415511000001109', ''),
('17903511000001106', ''),
('13621311000001102', ''),
('848711000001105', ''),
('21976011000001104', ''),
('580811000001109', ''),
('108811000001104', ''),
('294211000001105', ''),
('178911000001100', ''),
('324215006', ''),
('4692411000001105', ''),
('29948711000001107', ''),
('4693311000001108', ''),
('4693011000001105', ''),
('33737411000001107', ''),
('36542711000001107', ''),
('4693611000001103', ''),
('324180003', ''),
('38215511000001102', ''),
('37911311000001102', ''),
('324181004', ''),
('38215811000001104', ''),
('37911611000001107', ''),
('274611000001103', ''),
('30611000001101', ''),
('17628011000001101', ''),
('17627611000001109', ''),
('407790000', ''),
('98311000001102', ''),
('324276003', ''),
('36646511000001108', ''),
('37334911000001104', ''),
('324277007', ''),
('4919711000001105', ''),
('33634011000001103', ''),
('7845611000001105', ''),
('37342311000001106', ''),
('30041711000001105', ''),
('35019811000001102', ''),
('13704611000001105', ''),
('37053311000001104', ''),
('38841011000001105', ''),
('38320011000001100', ''),
('35638511000001105', ''),
('17860011000001101', ''),
('28693411000001100', ''),
('4329711000001107', ''),
('15081111000001109', ''),
('33933711000001104', ''),
('33041711000001109', ''),
('21858111000001109', ''),
('19213211000001104', ''),
('27864611000001100', ''),
('8351711000001105', ''),
('12021611000001106', ''),
('11968011000001106', ''),
('12021711000001102', ''),
('11969011000001101', ''),
('12021411000001108', ''),
('11967711000001107', ''),
('12021811000001105', ''),
('11969511000001109', ''),
('12021311000001101', ''),
('11967411000001101', ''),
('18519211000001105', ''),
('18513011000001103', ''),
('21711211000001104', ''),
('21732111000001107', ''),
('33634311000001100', ''),
('22164711000001102', ''),
('37343211000001109', ''),
('21669011000001101', ''),
('30042211000001105', ''),
('37053511000001105', ''),
('38841311000001108', ''),
('38322611000001108', ''),
('35774311000001103', ''),
('28693811000001103', ''),
('29789311000001101', ''),
('33041911000001106', ''),
('8360611000001101', ''),
('8353211000001104', ''),
('32748011000001108', ''),
('32705111000001105', ''),
('34376711000001103', ''),
('34355711000001108', ''),
('34818411000001104', ''),
('34810711000001108', ''),
('36458711000001104', ''),
('36450311000001100', ''),
('36458611000001108', ''),
('36450611000001105', ''),
('3956511000001100', ''),
('3668311000001100', ''),
('36087211000001109', ''),
('18275411000001109', ''),
('17664411000001105', ''),
('18031711000001109', ''),
('34751811000001104', ''),
('36087311000001101', ''),
('18275611000001107', ''),
('17664611000001108', ''),
('18031911000001106', ''),
('34752011000001102', ''),
('4348911000001104', ''),
('7816711000001103', ''),
('20151411000001107', ''),
('20177311000001108', ''),
('20151811000001109', ''),
('20152111000001107', ''),
('414851008', ''),
('20425111000001100', ''),
('409156007', ''),
('21626711000001104', ''),
('703666002', ''),
('20540311000001100', ''),
('29734011000001109', ''),
('703915009', ''),
('29722811000001107', ''),
('29723111000001106', ''),
('18162111000001102', ''),
('29934011000001102', ''),
('32746111000001105', ''),
('21393311000001105', ''),
('32982711000001106', ''),
('34377311000001104', ''),
('34376311000001102', ''),
('324298007', ''),
('3928511000001100', ''),
('3929711000001101', ''),
('14942611000001102', ''),
('4743111000001107', ''),
('11482411000001104', ''),
('3928911000001107', ''),
('324303009', ''),
('34327311000001100', ''),
('34340211000001107', ''),
('33582511000001101', ''),
('4382311000001106', ''),
('36091411000001104', ''),
('324308000', ''),
('3964811000001102', ''),
('4352211000001109', ''),
('324310003', ''),
('324311004', ''),
('18758011000001102', ''),
('17652211000001105', ''),
('4638311000001106', ''),
('32936911000001103', ''),
('3109511000001103', ''),
('3108611000001108', ''),
('4621211000001109', ''),
('4658711000001106', ''),
('324317000', ''),
('3981111000001109', ''),
('35927411000001109', ''),
('29786111000001106', ''),
('9060611000001103', ''),
('27753611000001108', ''),
('8708411000001103', ''),
('324316009', ''),
('3670711000001108', ''),
('4371711000001107', ''),
('35915211000001109', ''),
('36761811000001103', ''),
('35915111000001103', ''),
('36769311000001106', ''),
('4182311000001103', ''),
('4181011000001109', ''),
('324334008', ''),
('4126811000001104', ''),
('4127711000001105', ''),
('4128311000001107', ''),
('37832911000001105', ''),
('24566911000001109', ''),
('37877211000001101', ''),
('37436111000001101', ''),
('324335009', ''),
('4202811000001106', ''),
('4203311000001107', ''),
('4203511000001101', ''),
('37725211000001105', ''),
('324337001', ''),
('34758311000001101', ''),
('35830111000001109', ''),
('32895211000001100', ''),
('23872411000001109', ''),
('4213611000001104', ''),
('4212611000001109', ''),
('4212911000001103', ''),
('4213811000001100', ''),
('36517311000001101', ''),
('19456211000001101', ''),
('24517411000001103', ''),
('15165911000001100', ''),
('324333002', ''),
('34758511000001107', ''),
('35829811000001108', ''),
('32895411000001101', ''),
('36759411000001105', ''),
('4432811000001102', ''),
('4432211000001103', ''),
('4432411000001104', ''),
('4433011000001104', ''),
('26858511000001102', ''),
('36517611000001106', ''),
('19455111000001101', ''),
('24517611000001100', ''),
('15048611000001103', ''),
('12940811000001109', ''),
('12933111000001108', ''),
('8818611000001100', ''),
('8818711000001109', ''),
('8815211000001109', ''),
('8815711000001102', ''),
('15453011000001107', ''),
('15453111000001108', ''),
('15445311000001108', ''),
('15445611000001103', ''),
('13455811000001106', ''),
('13450811000001100', ''),
('4128511000001101', ''),
('4203811000001103', ''),
('4213311000001109', ''),
('4432611000001101', ''),
('324354009', ''),
('4408311000001100', ''),
('134561001', ''),
('31800311000001102', '')
GO
INSERT INTO #tmp82_ab_first_date_codelist (code, category) VALUES
('34943711000001101', ''),
('31203911000001103', ''),
('31896811000001106', ''),
('31279511000001100', ''),
('37267511000001102', ''),
('35165011000001102', ''),
('33627611000001101', ''),
('31153711000001107', ''),
('31684511000001106', ''),
('33746711000001100', ''),
('407899006', ''),
('36040111000001105', ''),
('34574711000001109', ''),
('36615111000001102', ''),
('33737611000001105', ''),
('31153911000001109', ''),
('36441911000001108', ''),
('38675711000001104', ''),
('36096911000001102', ''),
('36886111000001102', ''),
('4450311000001108', ''),
('4946211000001104', ''),
('4827211000001109', ''),
('412555008', ''),
('15877511000001101', ''),
('445522003', ''),
('20442211000001103', ''),
('22192511000001100', ''),
('34604811000001100', ''),
('12556911000001106', ''),
('22175211000001101', ''),
('19475511000001107', ''),
('20441311000001102', ''),
('21874811000001107', ''),
('10140911000001105', ''),
('35047211000001102', ''),
('36531611000001105', ''),
('10961311000001108', ''),
('35047711000001109', ''),
('36531811000001109', ''),
('10140111000001107', ''),
('10961511000001102', ''),
('16324411000001105', ''),
('20591911000001100', ''),
('16248411000001105', ''),
('3653911000001100', ''),
('3625511000001107', ''),
('3626311000001106', ''),
('32519811000001101', ''),
('3625711000001102', ''),
('35313211000001104', ''),
('32501611000001104', ''),
('32505711000001105', ''),
('32431411000001103', ''),
('37232111000001101', ''),
('38859611000001100', ''),
('324362001', ''),
('32501811000001100', ''),
('32507511000001109', ''),
('32280411000001100', ''),
('324357002', ''),
('812711000001104', ''),
('688711000001107', ''),
('517111000001104', ''),
('32281711000001103', ''),
('28922511000001104', ''),
('23858211000001109', ''),
('14942811000001103', ''),
('34958511000001104', ''),
('802611000001106', ''),
('38859111000001108', ''),
('17889311000001105', ''),
('29826011000001104', ''),
('26776811000001104', ''),
('21942611000001109', ''),
('324359004', ''),
('30994911000001107', ''),
('32506211000001109', ''),
('32278611000001106', ''),
('37232311000001104', ''),
('37896711000001101', ''),
('34958311000001105', ''),
('38859311000001105', ''),
('26777411000001104', ''),
('36091911000001107', ''),
('7817111000001101', ''),
('659211000001100', ''),
('764411000001104', ''),
('96711000001102', ''),
('3757311000001102', ''),
('3626011000001108', ''),
('324411000', ''),
('4104011000001108', ''),
('4104911000001107', ''),
('26857011000001109', ''),
('4104611000001101', ''),
('21903611000001106', ''),
('4104411000001104', ''),
('13454711000001102', ''),
('13449711000001104', ''),
('13454911000001100', ''),
('13450011000001106', ''),
('13454811000001105', ''),
('13450511000001103', ''),
('5241611000001103', ''),
('13539611000001103', ''),
('27397711000001102', ''),
('15474111000001108', ''),
('21268011000001109', ''),
('36144011000001106', ''),
('324430000', ''),
('710811000001108', ''),
('897711000001103', ''),
('250811000001106', ''),
('9800011000001105', ''),
('10414811000001100', ''),
('16070411000001101', ''),
('28917911000001104', ''),
('30106111000001102', ''),
('426711000001103', ''),
('30942111000001106', ''),
('17865911000001106', ''),
('46511000001102', ''),
('6038911000001109', ''),
('15199811000001106', ''),
('121511000001103', ''),
('21906211000001102', ''),
('324431001', ''),
('339211000001107', ''),
('20170611000001102', ''),
('15911000001106', ''),
('112111000001106', ''),
('9799411000001106', ''),
('10415011000001105', ''),
('16071011000001101', ''),
('28988711000001102', ''),
('30106311000001100', ''),
('664011000001104', ''),
('416811000001104', ''),
('30942311000001108', ''),
('17866111000001102', ''),
('490311000001109', ''),
('6039711000001103', ''),
('187211000001100', ''),
('21906411000001103', ''),
('665011000001100', ''),
('15861911000001105', ''),
('543111000001101', ''),
('17962411000001102', ''),
('30835311000001106', ''),
('845811000001106', ''),
('30941811000001108', ''),
('17865711000001109', ''),
('13627411000001101', ''),
('15200311000001106', ''),
('733211000001109', ''),
('22387811000001109', ''),
('13374511000001101', ''),
('13374611000001102', ''),
('13363211000001108', ''),
('13361311000001101', ''),
('13374711000001106', ''),
('13374811000001103', ''),
('13363511000001106', ''),
('13361711000001102', ''),
('13374911000001108', ''),
('13375011000001108', ''),
('13363811000001109', ''),
('13362311000001105', ''),
('13375111000001109', ''),
('13375211000001103', ''),
('13364111000001100', ''),
('13362611000001100', ''),
('426411000001109', ''),
('95811000001102', ''),
('789611000001100', ''),
('735011000001103', ''),
('431211000001104', ''),
('329711000001102', ''),
('38080911000001105', ''),
('38081511000001105', ''),
('36035511000001107', ''),
('34194011000001108', ''),
('4969011000001107', ''),
('5099711000001109', ''),
('324520007', ''),
('271811000001101', ''),
('341811000001106', ''),
('24384411000001109', ''),
('34745911000001108', ''),
('113911000001102', ''),
('37149811000001102', ''),
('11599611000001102', ''),
('29920411000001102', ''),
('21799811000001103', ''),
('21309911000001106', ''),
('324517004', ''),
('324518009', ''),
('324511003', ''),
('657311000001103', ''),
('703011000001105', ''),
('367011000001101', ''),
('10690011000001102', ''),
('10394111000001104', ''),
('20189711000001106', ''),
('24384611000001107', ''),
('14162711000001100', ''),
('727811000001101', ''),
('35843111000001101', ''),
('461811000001105', ''),
('30830211000001107', ''),
('19193811000001101', ''),
('786711000001104', ''),
('34612711000001100', ''),
('17941711000001106', ''),
('494411000001108', ''),
('8826911000001104', ''),
('15110911000001108', ''),
('357811000001101', ''),
('21800011000001101', ''),
('324512005', ''),
('791311000001105', ''),
('229911000001106', ''),
('780111000001103', ''),
('10690211000001107', ''),
('10394511000001108', ''),
('20189911000001108', ''),
('24384811000001106', ''),
('14162911000001103', ''),
('882111000001102', ''),
('406911000001106', ''),
('30830411000001106', ''),
('19194011000001109', ''),
('723311000001103', ''),
('17941911000001108', ''),
('239411000001100', ''),
('8827211000001105', ''),
('15111111000001104', ''),
('585011000001109', ''),
('650511000001105', ''),
('21800211000001106', ''),
('34617211000001105', ''),
('36077111000001105', ''),
('34612511000001105', ''),
('36035611000001106', ''),
('13408411000001108', ''),
('3617511000001108', ''),
('3620311000001108', ''),
('324523009', ''),
('780211000001109', ''),
('310211000001108', ''),
('329811000001105', ''),
('24385011000001101', ''),
('15111311000001102', ''),
('36537511000001100', ''),
('34607211000001108', ''),
('34605411000001101', ''),
('13007811000001103', ''),
('12961911000001102', ''),
('13008011000001105', ''),
('12962211000001104', ''),
('13008111000001106', ''),
('12962811000001103', ''),
('32655011000001106', ''),
('32646011000001104', ''),
('13007911000001108', ''),
('12960811000001104', ''),
('13008211000001100', ''),
('12962511000001101', ''),
('838811000001103', ''),
('272211000001109', ''),
('3911811000001100', ''),
('3910511000001105', ''),
('453711000001106', ''),
('3924811000001105', ''),
('3619811000001103', ''),
('3912311000001100', ''),
('3910711000001100', ''),
('471211000001101', ''),
('3620111000001106', ''),
('324554008', ''),
('3747511000001105', ''),
('324607004', ''),
('170311000001103', ''),
('19834111000001108', ''),
('18460011000001101', ''),
('624611000001101', ''),
('211411000001108', ''),
('9795711000001102', ''),
('10393211000001107', ''),
('15988911000001106', ''),
('19713611000001107', ''),
('11017911000001103', ''),
('7426211000001108', ''),
('810711000001103', ''),
('254711000001109', ''),
('38834811000001101', ''),
('19729511000001101', ''),
('38794711000001100', ''),
('317211000001107', ''),
('36574211000001108', ''),
('10442211000001104', ''),
('11401111000001103', ''),
('17858211000001102', ''),
('827711000001107', ''),
('485011000001104', ''),
('15077111000001109', ''),
('368511000001108', ''),
('18280611000001105', ''),
('370811000001102', ''),
('13743811000001101', ''),
('36840911000001109', ''),
('21852511000001102', ''),
('826011000001107', ''),
('36140911000001100', ''),
('11546011000001109', ''),
('8967411000001108', ''),
('36570411000001101', ''),
('22982111000001106', ''),
('324606008', ''),
('625611000001100', ''),
('19834311000001105', ''),
('18460411000001105', ''),
('920811000001106', ''),
('238711000001102', ''),
('9785111000001102', ''),
('10393511000001105', ''),
('15989111000001101', ''),
('648911000001103', ''),
('19713911000001101', ''),
('11018811000001107', ''),
('7426411000001107', ''),
('491511000001105', ''),
('2511000001107', ''),
('38835111000001107', ''),
('19729711000001106', ''),
('38715111000001103', ''),
('823711000001102', ''),
('36574711000001101', ''),
('36696711000001108', ''),
('11401511000001107', ''),
('17858511000001104', ''),
('735711000001101', ''),
('327011000001108', ''),
('15077911000001107', ''),
('938011000001100', ''),
('18280811000001109', ''),
('62011000001101', ''),
('13744011000001109', ''),
('36841511000001109', ''),
('21853011000001101', ''),
('15261211000001108', ''),
('324600002', ''),
('675411000001102', ''),
('227611000001105', ''),
('130511000001107', ''),
('17964311000001102', ''),
('15988711000001109', ''),
('19713411000001109', ''),
('11017111000001101', ''),
('780711000001102', ''),
('38834611000001100', ''),
('36575111000001103', ''),
('17858011000001107', ''),
('926611000001109', ''),
('15076711000001107', ''),
('671111000001105', ''),
('799111000001107', ''),
('36839911000001104', ''),
('324605007', ''),
('366711000001102', ''),
('19833511000001102', ''),
('23483711000001106', ''),
('469011000001100', ''),
('872511000001101', ''),
('17964511000001108', ''),
('10393811000001108', ''),
('15989311000001104', ''),
('19714211000001108', ''),
('11019511000001103', ''),
('7426611000001105', ''),
('849311000001100', ''),
('271111000001108', ''),
('38835411000001102', ''),
('19730111000001102', ''),
('38715311000001101', ''),
('36574511000001106', ''),
('11402111000001108', ''),
('17858811000001101', ''),
('935711000001105', ''),
('868011000001102', ''),
('15078411000001100', ''),
('630111000001102', ''),
('18281011000001107', ''),
('591811000001100', ''),
('13744211000001104', ''),
('36841911000001102', ''),
('21853311000001103', ''),
('9207911000001103', ''),
('12020311000001106', ''),
('11980911000001105', ''),
('12019511000001104', ''),
('11975011000001109', ''),
('12020511000001100', ''),
('11972111000001103', ''),
('12019611000001100', ''),
('11975511000001101', ''),
('12020611000001101', ''),
('11972711000001102', ''),
('12020811000001102', ''),
('11973911000001107', ''),
('12020711000001105', ''),
('11973311000001106', ''),
('12019911000001106', ''),
('11977411000001106', ''),
('8973011000001101', ''),
('28040911000001104', ''),
('36570611000001103', ''),
('22983111000001100', ''),
('34611511000001102', ''),
('12020211000001103', ''),
('11980311000001109', ''),
('12020011000001108', ''),
('11978711000001104', ''),
('12020911000001107', ''),
('11974611000001103', ''),
('36141011000001108', ''),
('35515811000001102', ''),
('11761311000001107', ''),
('36141511000001100', ''),
('32775511000001107', ''),
('35516111000001103', ''),
('35831211000001109', ''),
('11761811000001103', ''),
('324602005', ''),
('12020411000001104', ''),
('11971311000001105', ''),
('12019711000001109', ''),
('11976011000001100', ''),
('12019811000001101', ''),
('11976411000001109', ''),
('12020111000001109', ''),
('11979311000001109', ''),
('10892711000001106', ''),
('18756911000001102', ''),
('34648611000001102', ''),
('34532811000001105', ''),
('10889411000001105', ''),
('10892811000001103', ''),
('11528211000001101', ''),
('13793511000001105', ''),
('34648911000001108', ''),
('34533011000001108', ''),
('10889711000001104', ''),
('10892911000001108', ''),
('11528411000001102', ''),
('13793711000001100', ''),
('34649111000001103', ''),
('10890011000001105', ''),
('455911000001109', ''),
('417611000001101', ''),
('162511000001103', ''),
('661311000001104', ''),
('902411000001101', ''),
('8951511000001108', ''),
('8954311000001104', ''),
('785511000001102', ''),
('854011000001101', ''),
('3492511000001109', ''),
('324579006', ''),
('19681911000001107', ''),
('26854011000001101', ''),
('19172111000001106', ''),
('324578003', ''),
('35445511000001100', ''),
('36028911000001108', ''),
('3683611000001101', ''),
('4058911000001101', ''),
('4059711000001107', ''),
('3852811000001105', ''),
('324612003', ''),
('465511000001105', ''),
('527011000001106', ''),
('16062011000001100', ''),
('37463211000001108', ''),
('724511000001107', ''),
('30852711000001100', ''),
('4273411000001105', ''),
('7464011000001104', ''),
('319311000001109', ''),
('15112111000001109', ''),
('792611000001106', ''),
('21821611000001105', ''),
('324620001', ''),
('238911000001100', ''),
('412511000001103', ''),
('16062211000001105', ''),
('37463811000001109', ''),
('787111000001102', ''),
('30853111000001107', ''),
('4818111000001107', ''),
('7464911000001100', ''),
('525111000001103', ''),
('15112411000001104', ''),
('339611000001109', ''),
('38752711000001101', ''),
('12905211000001105', ''),
('12895811000001101', ''),
('12897211000001105', ''),
('12896211000001108', ''),
('12905311000001102', ''),
('12905411000001109', ''),
('12898411000001108', ''),
('12897811000001106', ''),
('362511000001106', ''),
('491611000001109', ''),
('4415111000001109', ''),
('324621002', ''),
('822711000001105', ''),
('254211000001102', ''),
('511511000001102', ''),
('739911000001102', ''),
('17947511000001107', ''),
('35549811000001106', ''),
('18745111000001108', ''),
('21816311000001102', ''),
('866311000001103', ''),
('324634001', ''),
('19359911000001108', ''),
('21286011000001107', ''),
('19298011000001103', ''),
('19359211000001104', ''),
('24366511000001100', ''),
('19512011000001105', ''),
('29673511000001109', ''),
('30220211000001100', ''),
('19837511000001107', ''),
('29890211000001100', ''),
('19178911000001107', ''),
('22070611000001101', ''),
('324633007', ''),
('19359511000001101', ''),
('21285711000001101', ''),
('19296611000001109', ''),
('19358511000001107', ''),
('24366211000001103', ''),
('19511711000001100', ''),
('29673211000001106', ''),
('37098711000001101', ''),
('19837211000001109', ''),
('29889711000001104', ''),
('19178611000001101', ''),
('22070311000001106', ''),
('36038911000001106', ''),
('19359011000001109', ''),
('34754611000001101', ''),
('19448711000001105', ''),
('19447411000001103', ''),
('19447611000001100', ''),
('38236111000001105', ''),
('35831811000001105', ''),
('21660611000001102', ''),
('23108311000001101', ''),
('24416711000001100', ''),
('38745711000001107', ''),
('36571111000001100', ''),
('22985411000001109', ''),
('34611911000001109', ''),
('3078311000001102', ''),
('3077511000001109', ''),
('4602911000001104', ''),
('19374111000001107', ''),
('19374511000001103', ''),
('28922411000001103', ''),
('408015000', ''),
('24919311000001109', ''),
('24683911000001108', ''),
('24775911000001105', ''),
('38618511000001108', ''),
('37453311000001107', ''),
('30834211000001104', ''),
('28697411000001107', ''),
('29927511000001104', ''),
('24673211000001107', ''),
('16756911000001108', ''),
('25876211000001100', ''),
('36571311000001103', ''),
('36881911000001109', ''),
('36028511000001101', ''),
('36003311000001109', ''),
('35992311000001106', ''),
('4360711000001109', ''),
('16751911000001103', ''),
('10496311000001104', ''),
('371616001', ''),
('37947311000001104', ''),
('37830711000001109', ''),
('38849511000001101', ''),
('3691811000001100', ''),
('324570005', ''),
('24549911000001107', ''),
('37556911000001106', ''),
('24209111000001106', ''),
('24421611000001107', ''),
('37460411000001104', ''),
('35952811000001109', ''),
('36774211000001109', ''),
('324572002', ''),
('24550111000001102', ''),
('37557111000001106', ''),
('24208911000001101', ''),
('24421811000001106', ''),
('37460611000001101', ''),
('35954211000001104', ''),
('36774511000001107', ''),
('36565611000001103', ''),
('24133311000001100', ''),
('5420911000001103', ''),
('3607611000001105', ''),
('38608611000001105', ''),
('324558006', ''),
('180911000001108', ''),
('884111000001105', ''),
('497811000001101', ''),
('30763811000001109', ''),
('37460811000001102', ''),
('11016111000001104', ''),
('20327411000001106', ''),
('537011000001109', ''),
('30851211000001100', ''),
('9555111000001106', ''),
('17946711000001100', ''),
('29929911000001104', ''),
('4209111000001108', ''),
('21820711000001109', ''),
('324559003', ''),
('637211000001107', ''),
('626211000001108', ''),
('405011000001103', ''),
('30763611000001105', ''),
('37461111000001103', ''),
('11015711000001106', ''),
('20326111000001104', ''),
('277011000001102', ''),
('30851411000001101', ''),
('9555311000001108', ''),
('17946911000001103', ''),
('15111411000001109', ''),
('4221211000001106', ''),
('21821311000001100', ''),
('12862811000001106', ''),
('12862911000001101', ''),
('12820911000001108', ''),
('12820611000001102', ''),
('12864611000001104', ''),
('12864711000001108', ''),
('12829211000001106', ''),
('12828711000001108', ''),
('12904911000001100', ''),
('375489004', ''),
('12902611000001103', ''),
('12902311000001108', ''),
('12935311000001106', ''),
('12935411000001104', ''),
('12917211000001100', ''),
('12916911000001106', ''),
('12934511000001101', ''),
('12934611000001102', ''),
('12914811000001108', ''),
('12914511000001105', ''),
('12894611000001101', ''),
('12894711000001105', ''),
('12892411000001106', ''),
('12891611000001103', ''),
('12935511000001100', ''),
('12935611000001101', ''),
('12917811000001104', ''),
('12917511000001102', ''),
('12864211000001101', ''),
('12864311000001109', ''),
('12825111000001102', ''),
('12824811000001108', ''),
('12863011000001109', ''),
('12863111000001105', ''),
('12821511000001108', ''),
('12821211000001105', ''),
('12863811000001103', ''),
('12863911000001108', ''),
('12823911000001100', ''),
('12823611000001106', ''),
('12904211000001109', ''),
('12904311000001101', ''),
('12899511000001101', ''),
('12898811000001105', ''),
('12935711000001105', ''),
('12935811000001102', ''),
('12918411000001102', ''),
('12918111000001107', ''),
('12936111000001103', ''),
('12936211000001109', ''),
('12919611000001108', ''),
('12919311000001103', ''),
('12933911000001106', ''),
('12934011000001109', ''),
('12912911000001107', ''),
('12912611000001101', ''),
('12937311000001103', ''),
('12937411000001105', ''),
('12923211000001100', ''),
('12922911000001102', ''),
('12936711000001102', ''),
('12936811000001105', ''),
('12921411000001100', ''),
('12921111000001105', ''),
('12905011000001100', ''),
('12905111000001104', ''),
('12903211000001106', ''),
('12902911000001109', ''),
('12904811000001105', ''),
('12904111000001103', ''),
('12898111000001103', ''),
('12897011000001100', ''),
('12863411000001100', ''),
('12863511000001101', ''),
('12822711000001105', ''),
('12822411000001104', ''),
('12904411000001108', ''),
('12904511000001107', ''),
('12901411000001106', ''),
('12901111000001101', ''),
('12894111000001109', ''),
('12894211000001103', ''),
('12889711000001107', ''),
('12889411000001101', ''),
('12864811000001100', ''),
('12864911000001105', ''),
('12830411000001103', ''),
('12829711000001104', ''),
('12936511000001107', ''),
('12936611000001106', ''),
('12920811000001106', ''),
('12920511000001108', ''),
('12936911000001100', ''),
('12937011000001101', ''),
('12922011000001101', ''),
('12921711000001106', ''),
('12935111000001109', ''),
('12935211000001103', ''),
('12916611000001100', ''),
('12916311000001105', ''),
('12934311000001107', ''),
('12934411000001100', ''),
('12914211000001107', ''),
('12913911000001100', ''),
('12894311000001106', ''),
('12894511000001100', ''),
('12890911000001102', ''),
('12890311000001103', ''),
('12935911000001107', ''),
('12936011000001104', ''),
('12919011000001101', ''),
('12918711000001108', ''),
('12863611000001102', ''),
('12863711000001106', ''),
('12823311000001101', ''),
('12823011000001104', ''),
('12937111000001100', ''),
('12937211000001106', ''),
('12922611000001108', ''),
('12922311000001103', ''),
('12934111000001105', ''),
('12934211000001104', ''),
('12913611000001106', ''),
('12913211000001109', ''),
('12934911000001108', ''),
('12935011000001108', ''),
('12916011000001107', ''),
('12915711000001101', ''),
('12864411000001102', ''),
('12864511000001103', ''),
('12828311000001109', ''),
('12827411000001101', ''),
('12934711000001106', ''),
('12934811000001103', ''),
('12915411000001107', ''),
('12915111000001102', ''),
('12904611000001106', ''),
('12904711000001102', ''),
('12902011000001105', ''),
('12901711000001100', ''),
('12895111000001108', ''),
('12894811000001102', ''),
('12894911000001107', ''),
('12893411000001102', ''),
('12864011000001106', ''),
('12864111000001107', ''),
('12824511000001105', ''),
('12824211000001107', ''),
('12863211000001104', ''),
('12863311000001107', ''),
('12822111000001109', ''),
('12821811000001106', ''),
('12893811000001100', ''),
('12894011000001108', ''),
('12889111000001106', ''),
('12888811000001106', ''),
('12936311000001101', ''),
('12936411000001108', ''),
('12920211000001105', ''),
('12919911000001102', ''),
('58211000001101', ''),
('758411000001103', ''),
('3606911000001102', ''),
('623211000001101', ''),
('707311000001101', ''),
('461311000001101', ''),
('32711000001109', ''),
('517311000001102', ''),
('32747111000001108', ''),
('32746911000001108', ''),
('21258811000001107', ''),
('28691111000001109', ''),
('21259011000001106', '')
GO
-- Query for ab_first_date
SELECT * INTO #ab_first_date FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
1 AS binary_flag,
MIN(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp82_ab_first_date_codelist
ON DMD_ID = #tmp82_ab_first_date_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for ab_last_date
CREATE TABLE #tmp83_ab_last_date_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp83_ab_last_date_codelist (code, category) VALUES
('323398002', ''),
('27871711000001100', ''),
('28038711000001103', ''),
('27732411000001100', ''),
('323396003', ''),
('27872411000001101', ''),
('28035511000001100', ''),
('27732211000001104', ''),
('3880811000001103', ''),
('4074311000001105', ''),
('323418000', ''),
('392411000001109', ''),
('683011000001103', ''),
('10711000001104', ''),
('9804611000001105', ''),
('10452211000001101', ''),
('21038311000001109', ''),
('20129511000001108', ''),
('24410611000001107', ''),
('21532411000001101', ''),
('38081711000001100', ''),
('604211000001105', ''),
('11144611000001104', ''),
('610511000001102', ''),
('19736211000001105', ''),
('808511000001109', ''),
('738911000001105', ''),
('18719011000001104', ''),
('15311000001105', ''),
('323420002', ''),
('94811000001103', ''),
('209811000001108', ''),
('322611000001104', ''),
('9805411000001108', ''),
('10452411000001102', ''),
('21038511000001103', ''),
('20129711000001103', ''),
('37772611000001104', ''),
('21532611000001103', ''),
('38081911000001103', ''),
('189311000001103', ''),
('887811000001107', ''),
('30856011000001103', ''),
('770211000001102', ''),
('333711000001103', ''),
('18719411000001108', ''),
('289911000001104', ''),
('323416001', ''),
('765311000001105', ''),
('35211000001107', ''),
('821311000001102', ''),
('9803511000001108', ''),
('10430511000001103', ''),
('16063111000001105', ''),
('32489211000001105', ''),
('28985911000001106', ''),
('37773011000001102', ''),
('420411000001107', ''),
('78111000001109', ''),
('30856411000001107', ''),
('19730711000001101', ''),
('482711000001106', ''),
('17954711000001107', ''),
('839711000001102', ''),
('634711000001107', ''),
('29983311000001107', ''),
('799511000001103', ''),
('871611000001108', ''),
('21844711000001100', ''),
('9215111000001107', ''),
('9253911000001104', ''),
('31058611000001104', ''),
('16165811000001108', ''),
('28097111000001105', ''),
('10452611000001104', ''),
('21038711000001108', ''),
('32490911000001108', ''),
('21863211000001102', ''),
('37772411000001102', ''),
('9209211000001101', ''),
('9842311000001100', ''),
('17954311000001108', ''),
('9308011000001109', ''),
('21844311000001104', ''),
('9215211000001101', ''),
('9254111000001100', ''),
('31058811000001100', ''),
('16166011000001106', ''),
('28097311000001107', ''),
('10452811000001100', ''),
('21038911000001105', ''),
('32492211000001103', ''),
('21834511000001106', ''),
('37772811000001100', ''),
('9209511000001103', ''),
('30856211000001108', ''),
('9842511000001106', ''),
('17954511000001102', ''),
('11533211000001107', ''),
('9308211000001104', ''),
('21844511000001105', ''),
('22214211000001105', ''),
('22197411000001101', ''),
('849911000001104', ''),
('323464005', ''),
('120711000001100', ''),
('699911000001102', ''),
('916911000001106', ''),
('9798411000001103', ''),
('10407811000001107', ''),
('16050611000001101', ''),
('23907811000001108', ''),
('194111000001102', ''),
('627011000001100', ''),
('30130811000001104', ''),
('38915011000001109', ''),
('19728911000001100', ''),
('19193011000001107', ''),
('850811000001102', ''),
('37506211000001106', ''),
('17908511000001102', ''),
('220311000001101', ''),
('135511000001102', ''),
('15087311000001100', ''),
('333211000001105', ''),
('21996911000001108', ''),
('323465006', ''),
('289411000001107', ''),
('3111000001109', ''),
('32611000001100', ''),
('9798911000001106', ''),
('10408011000001100', ''),
('16050911000001107', ''),
('23908511000001109', ''),
('568111000001102', ''),
('590311000001104', ''),
('30131011000001101', ''),
('38915211000001104', ''),
('19729111000001105', ''),
('19193211000001102', ''),
('401911000001101', ''),
('36738011000001105', ''),
('17908811000001104', ''),
('629811000001103', ''),
('770011000001107', ''),
('15087511000001106', ''),
('833311000001104', ''),
('21997211000001102', ''),
('323491007', ''),
('97911000001102', ''),
('34753011000001106', ''),
('231911000001109', ''),
('323492000', ''),
('390611000001106', ''),
('162711000001108', ''),
('34753211000001101', ''),
('9142811000001101', ''),
('36921811000001102', ''),
('256511000001105', ''),
('323493005', ''),
('661411000001106', ''),
('34752811000001108', ''),
('9143111000001102', ''),
('36921411000001104', ''),
('858411000001101', ''),
('323484009', ''),
('513711000001108', ''),
('103311000001100', ''),
('207211000001101', ''),
('10454211000001105', ''),
('20136411000001100', ''),
('13578111000001101', ''),
('719411000001101', ''),
('138411000001106', ''),
('38914811000001104', ''),
('23189811000001102', ''),
('19193411000001103', ''),
('337811000001100', ''),
('18107711000001103', ''),
('746511000001103', ''),
('767311000001102', ''),
('21997911000001106', ''),
('323485005', ''),
('11268511000001102', ''),
('16086311000001101', ''),
('18722811000001105', ''),
('20137211000001102', ''),
('13578311000001104', ''),
('4835611000001101', ''),
('38915611000001102', ''),
('18107911000001101', ''),
('38076711000001103', ''),
('21998111000001109', ''),
('16089611000001103', ''),
('16443111000001108', ''),
('16086911000001100', ''),
('27126211000001105', ''),
('28096311000001109', ''),
('38619411000001101', ''),
('23979011000001102', ''),
('16247911000001103', ''),
('38915411000001100', ''),
('37732411000001104', ''),
('21997511000001104', ''),
('16089711000001107', ''),
('16443611000001100', ''),
('16086611000001106', ''),
('27126411000001109', ''),
('28096511000001103', ''),
('38619611000001103', ''),
('23979211000001107', ''),
('16248111000001100', ''),
('38915811000001103', ''),
('37732211000001103', ''),
('21997711000001109', ''),
('34769611000001109', ''),
('34753511000001103', ''),
('471111000001107', ''),
('888011000001100', ''),
('865811000001104', ''),
('324711000001103', ''),
('419411000001108', ''),
('748211000001100', ''),
('703911000001109', ''),
('251311000001107', ''),
('499611000001105', ''),
('323496002', ''),
('323474008', ''),
('811111000001105', ''),
('442211000001107', ''),
('9553611000001102', ''),
('9549311000001107', ''),
('323509004', ''),
('558111000001107', ''),
('23477711000001105', ''),
('739011000001101', ''),
('145611000001104', ''),
('9785311000001100', ''),
('10380511000001103', ''),
('12948011000001101', ''),
('15981611000001108', ''),
('33680711000001103', ''),
('22608411000001104', ''),
('36932811000001108', ''),
('325811000001107', ''),
('833211000001107', ''),
('29993011000001108', ''),
('38787311000001107', ''),
('19725711000001109', ''),
('19187411000001106', ''),
('413911000001103', ''),
('17779911000001102', ''),
('35591111000001108', ''),
('458811000001108', ''),
('228311000001104', ''),
('29765011000001104', ''),
('361711000001108', ''),
('21764811000001100', ''),
('18145411000001107', ''),
('323510009', ''),
('930411000001106', ''),
('18458211000001102', ''),
('406811000001101', ''),
('116511000001101', ''),
('9785911000001104', ''),
('10381311000001104', ''),
('12948211000001106', ''),
('15981911000001102', ''),
('33680911000001101', ''),
('22608811000001102', ''),
('36933111000001107', ''),
('802011000001104', ''),
('13811000001100', ''),
('29993211000001103', ''),
('38787911000001108', ''),
('19726111000001102', ''),
('19187611000001109', ''),
('816511000001105', ''),
('36693511000001106', ''),
('268011000001106', ''),
('17780311000001103', ''),
('35591411000001103', ''),
('181511000001108', ''),
('53711000001102', ''),
('29769211000001107', ''),
('668411000001104', ''),
('21765611000001103', ''),
('18146111000001108', ''),
('35902111000001107', ''),
('3241411000001109', ''),
('3246511000001104', ''),
('32496011000001107', ''),
('22609211000001108', ''),
('3246011000001107', ''),
('29993711000001105', ''),
('38788311000001108', ''),
('18081411000001108', ''),
('29765411000001108', ''),
('3243811000001105', ''),
('21766011000001101', ''),
('35368511000001109', ''),
('323732002', ''),
('634511000001102', ''),
('159311000001109', ''),
('549011000001104', ''),
('9786511000001104', ''),
('10426911000001105', ''),
('15984311000001100', ''),
('28943411000001109', ''),
('22609411000001107', ''),
('143211000001100', ''),
('329011000001104', ''),
('38785711000001100', ''),
('860211000001109', ''),
('17781111000001106', ''),
('144711000001109', ''),
('856111000001107', ''),
('29769411000001106', ''),
('200311000001108', ''),
('21766511000001109', ''),
('323733007', ''),
('819911000001107', ''),
('256911000001103', ''),
('767611000001107', ''),
('9786911000001106', ''),
('10427411000001100', ''),
('15984511000001106', ''),
('28943611000001107', ''),
('22609811000001109', ''),
('555611000001105', ''),
('213311000001100', ''),
('38787511000001101', ''),
('568411000001107', ''),
('17781711000001107', ''),
('673011000001105', ''),
('828811000001100', ''),
('15065511000001104', ''),
('830011000001107', ''),
('21776211000001103', ''),
('35901911000001104', ''),
('756511000001100', ''),
('623711000001108', ''),
('264811000001108', ''),
('9787111000001106', ''),
('10428011000001105', ''),
('15984711000001101', ''),
('22609611000001105', ''),
('69611000001101', ''),
('416211000001100', ''),
('29993911000001107', ''),
('38785511000001105', ''),
('35852611000001101', ''),
('311000001109', ''),
('17781911000001109', ''),
('35591711000001109', ''),
('709111000001109', ''),
('29764511000001106', ''),
('222511000001108', ''),
('21775811000001105', ''),
('548011000001109', ''),
('328211000001104', ''),
('730511000001101', ''),
('9787311000001108', ''),
('10428411000001101', ''),
('15984911000001104', ''),
('22610011000001109', ''),
('203311000001102', ''),
('693411000001108', ''),
('37033411000001105', ''),
('38787711000001106', ''),
('35852011000001108', ''),
('930911000001103', ''),
('17782111000001101', ''),
('35591911000001106', ''),
('88811000001107', ''),
('29765211000001109', ''),
('520311000001108', ''),
('21776011000001108', ''),
('38726811000001109', ''),
('38719511000001105', ''),
('388611000001105', ''),
('709311000001106', ''),
('234411000001104', ''),
('689711000001103', ''),
('389311000001106', ''),
('3243311000001101', ''),
('196111000001109', ''),
('644811000001100', ''),
('121011000001106', ''),
('774011000001100', ''),
('252511000001109', ''),
('500511000001107', ''),
('19211000001104', ''),
('42011000001106', ''),
('284811000001105', ''),
('2011000001104', ''),
('130111000001103', ''),
('874611000001105', ''),
('190111000001106', ''),
('161011000001103', ''),
('14811000001102', ''),
('7339611000001107', ''),
('7339811000001106', ''),
('323737008', ''),
('90411000001106', ''),
('34748011000001101', ''),
('283611000001108', ''),
('323738003', ''),
('834911000001101', ''),
('34748211000001106', ''),
('719311000001108', ''),
('323739006', ''),
('279111000001107', ''),
('34748411000001105', ''),
('144611000001100', ''),
('388911000001104', ''),
('120411000001106', ''),
('71111000001101', ''),
('323570001', ''),
('875911000001100', ''),
('536211000001101', ''),
('529211000001107', ''),
('10382011000001105', ''),
('28944411000001107', ''),
('13575311000001108', ''),
('30976211000001103', ''),
('698211000001101', ''),
('29994111000001106', ''),
('38788511000001102', ''),
('305911000001106', ''),
('17782311000001104', ''),
('10565411000001109', ''),
('29769811000001108', ''),
('21776411000001104', ''),
('323571002', ''),
('443811000001100', ''),
('578311000001106', ''),
('597311000001103', ''),
('10382211000001100', ''),
('28944611000001105', ''),
('30976411000001104', ''),
('755311000001101', ''),
('29994311000001108', ''),
('38788711000001107', ''),
('217411000001100', ''),
('17782711000001100', ''),
('10565611000001107', ''),
('15066311000001100', ''),
('323584006', ''),
('10355811000001100', ''),
('9725711000001105', ''),
('9505311000001100', ''),
('323572009', ''),
('8169711000001108', ''),
('268411000001102', ''),
('352711000001107', ''),
('24024611000001104', ''),
('938511000001108', ''),
('531211000001109', ''),
('18081811000001105', ''),
('15065711000001109', ''),
('323573004', ''),
('8169911000001105', ''),
('310511000001106', ''),
('45311000001103', ''),
('28927211000001104', ''),
('649511000001104', ''),
('328611000001102', ''),
('18082611000001100', ''),
('15066011000001103', ''),
('850311000001106', ''),
('9385411000001106', ''),
('12778811000001103', ''),
('12778611000001102', ''),
('414211000001105', ''),
('323563001', ''),
('38111000001106', ''),
('19833711000001107', ''),
('382811000001107', ''),
('101911000001100', ''),
('9786711000001109', ''),
('10397411000001104', ''),
('34962611000001109', ''),
('32397711000001104', ''),
('35907111000001109', ''),
('23827411000001108', ''),
('760411000001105', ''),
('12511000001105', ''),
('30016311000001106', ''),
('38848311000001101', ''),
('441311000001108', ''),
('17885811000001104', ''),
('91211000001101', ''),
('35563511000001103', ''),
('882211000001108', ''),
('29794911000001102', ''),
('771411000001107', ''),
('36868011000001101', ''),
('22009111000001105', ''),
('380711000001103', ''),
('36565811000001104', ''),
('829311000001103', ''),
('15515811000001104', ''),
('370711000001105', ''),
('9787711000001107', ''),
('22602311000001108', ''),
('575411000001109', ''),
('276811000001106', ''),
('38850811000001105', ''),
('4817111000001106', ''),
('17885411000001101', ''),
('193411000001109', ''),
('6032711000001109', ''),
('894611000001101', ''),
('22007211000001105', ''),
('323567000', ''),
('18757611000001105', ''),
('34752211000001107', ''),
('10219611000001104', ''),
('36626111000001101', ''),
('10530611000001105', ''),
('5488611000001104', ''),
('323568005', ''),
('19570811000001107', ''),
('34752411000001106', ''),
('37830211000001102', ''),
('10219211000001101', ''),
('30347811000001105', ''),
('36626911000001103', ''),
('10531011000001107', ''),
('5489611000001108', ''),
('37083611000001104', ''),
('732211000001103', ''),
('15516011000001101', ''),
('394111000001107', ''),
('9787911000001109', ''),
('22602511000001102', ''),
('353811000001107', ''),
('526211000001103', ''),
('30016111000001109', ''),
('38848111000001103', ''),
('36492911000001108', ''),
('4817311000001108', ''),
('17885611000001103', ''),
('22211000001104', ''),
('6034811000001107', ''),
('931011000001106', ''),
('22007711000001103', ''),
('3964011000001108', ''),
('7322211000001104', ''),
('13613111000001106', ''),
('24026411000001105', ''),
('23939811000001105', ''),
('31989511000001109', ''),
('24520711000001100', ''),
('38848811000001105', ''),
('7320111000001106', ''),
('28123611000001108', ''),
('29794511000001109', ''),
('22008011000001104', ''),
('7322311000001107', ''),
('11528611000001104', ''),
('24026611000001108', ''),
('23940311000001109', ''),
('31989811000001107', ''),
('24520911000001103', ''),
('38849111000001105', ''),
('7320411000001101', ''),
('28123911000001102', ''),
('29794711000001104', ''),
('22008411000001108', ''),
('323539009', ''),
('290311000001105', ''),
('19833911000001109', ''),
('17668811000001104', ''),
('680711000001105', ''),
('34679211000001108', ''),
('10397711000001105', ''),
('34962811000001108', ''),
('32399711000001107', ''),
('35907311000001106', ''),
('27959011000001105', ''),
('23828211000001108', ''),
('351311000001104', ''),
('785111000001106', ''),
('38848511000001107', ''),
('19728511000001107', ''),
('19199611000001103', ''),
('5629811000001102', ''),
('36695911000001103', ''),
('17886011000001101', ''),
('628011000001104', ''),
('35563911000001105', ''),
('6036511000001103', ''),
('29795111000001101', ''),
('934111000001105', ''),
('36870911000001108', ''),
('22009611000001102', ''),
('3964511000001100', ''),
('37083711000001108', ''),
('11252711000001103', ''),
('19876911000001100', ''),
('32403711000001100', ''),
('30043911000001108', ''),
('32399111000001106', ''),
('38850411000001108', ''),
('19728111000001103', ''),
('23651411000001107', ''),
('22036711000001105', ''),
('15077811000001102', ''),
('392259005', ''),
('28873411000001104', ''),
('28039411000001101', ''),
('32400011000001107', ''),
('27959911000001109', ''),
('30016511000001100', ''),
('29795311000001104', ''),
('94411000001100', ''),
('386811000001108', ''),
('549911000001100', ''),
('871511000001109', ''),
('932211000001108', ''),
('866111000001100', ''),
('292511000001103', ''),
('169511000001107', ''),
('29011000001102', ''),
('139811000001101', ''),
('57911000001109', ''),
('451111000001109', ''),
('618111000001108', ''),
('323624001', ''),
('599611000001103', ''),
('34411000001105', ''),
('728111000001109', ''),
('19818211000001104', ''),
('28922811000001101', ''),
('23857311000001102', ''),
('10292811000001106', ''),
('908411000001104', ''),
('146111000001101', ''),
('30018311000001105', ''),
('38857911000001104', ''),
('773911000001103', ''),
('17888511000001105', ''),
('382411000001105', ''),
('29798411000001101', ''),
('9627311000001106', ''),
('21941711000001107', ''),
('4006211000001100', ''),
('323626004', ''),
('21710711000001103', ''),
('36090611000001106', ''),
('18542211000001108', ''),
('18446411000001102', ''),
('18421711000001100', ''),
('435911000001105', ''),
('473311000001105', ''),
('3098711000001105', ''),
('323772006', ''),
('4413311000001105', ''),
('323673005', ''),
('34755211000001102', ''),
('36612211000001103', ''),
('38801411000001109', ''),
('36607511000001104', ''),
('15442611000001107', ''),
('16733411000001109', ''),
('18781411000001105', ''),
('15519011000001107', ''),
('19519511000001106', ''),
('22599711000001106', ''),
('24014211000001106', ''),
('323671007', ''),
('34755411000001103', ''),
('36611611000001107', ''),
('34680211000001108', ''),
('19518711000001105', ''),
('36798311000001102', ''),
('36607211000001102', ''),
('15442811000001106', ''),
('17899511000001103', ''),
('18166311000001101', ''),
('22599211000001104', ''),
('4651611000001105', ''),
('4437611000001103', ''),
('4437911000001109', ''),
('4641311000001103', ''),
('323786005', ''),
('37305311000001105', ''),
('37775511000001109', ''),
('35175011000001108', ''),
('32750311000001106', ''),
('32744411000001108', ''),
('3685611000001102', ''),
('323999000', ''),
('324000003', ''),
('4597311000001106', ''),
('4597911000001107', ''),
('324003001', ''),
('324004007', ''),
('324005008', ''),
('4626311000001109', ''),
('4626611000001104', ''),
('4627111000001105', ''),
('36458411000001105', ''),
('36458511000001109', ''),
('36456811000001106', ''),
('36457111000001101', ''),
('4457111000001107', ''),
('4452211000001104', ''),
('323935008', ''),
('323936009', ''),
('37987711000001105', ''),
('33631211000001106', ''),
('33627411000001104', ''),
('37986811000001104', ''),
('36515811000001100', ''),
('34800611000001101', ''),
('7654711000001109', ''),
('4981711000001108', ''),
('323791006', ''),
('275011000001109', ''),
('813911000001109', ''),
('10290911000001100', ''),
('636511000001108', ''),
('17826511000001101', ''),
('233911000001105', ''),
('270911000001104', ''),
('323792004', ''),
('4113911000001107', ''),
('10348111000001104', ''),
('25833611000001106', ''),
('31564011000001109', ''),
('890411000001105', ''),
('30008911000001108', ''),
('612411000001100', ''),
('32201411000001108', ''),
('18085911000001103', ''),
('171911000001109', ''),
('323793009', ''),
('4114111000001106', ''),
('8825311000001105', ''),
('25834011000001102', ''),
('31564611000001102', ''),
('5311000001107', ''),
('647311000001100', ''),
('32201711000001102', ''),
('18086111000001107', ''),
('400511000001101', ''),
('323795002', ''),
('744311000001103', ''),
('64011000001107', ''),
('10291411000001104', ''),
('4323911000001106', ''),
('17826711000001106', ''),
('923811000001104', ''),
('15073011000001102', ''),
('459111000001108', ''),
('36134211000001100', ''),
('3663611000001103', ''),
('804411000001101', ''),
('4324111000001105', ''),
('168011000001109', ''),
('36134011000001105', ''),
('37011000001109', ''),
('141511000001101', ''),
('10309911000001103', ''),
('17867211000001105', ''),
('576111000001105', ''),
('36134111000001106', ''),
('745411000001106', ''),
('594511000001101', ''),
('10310111000001109', ''),
('9764411000001109', ''),
('17867411000001109', ''),
('248911000001101', ''),
('793311000001106', ''),
('602211000001101', ''),
('252811000001107', ''),
('583511000001100', ''),
('555211000001108', ''),
('803611000001101', ''),
('531011000001104', ''),
('318811000001107', ''),
('869711000001109', ''),
('323813001', ''),
('7887711000001102', ''),
('5918311000001108', ''),
('19712411000001100', ''),
('30009111000001103', ''),
('38825011000001109', ''),
('17851711000001104', ''),
('8750411000001109', ''),
('4814611000001109', ''),
('15073211000001107', ''),
('21821711000001101', ''),
('323811004', ''),
('323812006', ''),
('323816009', ''),
('674111000001108', ''),
('912111000001109', ''),
('60011000001100', ''),
('304211000001103', ''),
('323973007', ''),
('36134411000001101', ''),
('370375008', ''),
('34762811000001103', ''),
('511411000001101', ''),
('3184511000001101', ''),
('323824004', ''),
('13611511000001101', ''),
('34750011000001101', ''),
('4532811000001108', ''),
('27971011000001109', ''),
('4532411000001106', ''),
('323825003', ''),
('13611811000001103', ''),
('34749811000001100', ''),
('3940811000001102', ''),
('27969111000001102', ''),
('36516011000001102', ''),
('3940211000001103', ''),
('4558311000001100', ''),
('13612211000001106', ''),
('4533911000001105', ''),
('27969611000001105', ''),
('36516211000001107', ''),
('4533711000001108', ''),
('4532011000001102', ''),
('3939811000001107', ''),
('4533411000001102', ''),
('323829009', ''),
('28788511000001103', ''),
('34800911000001107', ''),
('323830004', ''),
('28788811000001100', ''),
('34801211000001109', ''),
('4375311000001105', ''),
('4376311000001100', ''),
('37528311000001105', ''),
('37529711000001100', ''),
('323982001', ''),
('35369711000001108', ''),
('3929911000001104', ''),
('3930911000001108', ''),
('323989005', ''),
('13612411000001105', ''),
('34750811000001107', ''),
('23047711000001101', ''),
('27971211000001104', ''),
('323990001', ''),
('3977811000001102', ''),
('34751011000001105', ''),
('37336711000001105', ''),
('3978511000001101', ''),
('22824911000001102', ''),
('36516811000001108', ''),
('11400311000001106', ''),
('38564411000001109', ''),
('20100211000001107', ''),
('36541011000001102', ''),
('32483211000001108', ''),
('3978011000001109', ''),
('323991002', ''),
('23414711000001106', ''),
('36517011000001104', ''),
('4405611000001104', ''),
('34751211000001100', ''),
('4406311000001104', ''),
('20100411000001106', ''),
('36783811000001102', ''),
('32483411000001107', ''),
('4406011000001102', ''),
('4404611000001100', ''),
('3978911000001108', ''),
('4406611000001109', ''),
('323853003', ''),
('10188511000001108', ''),
('34750211000001106', ''),
('36537311000001106', ''),
('8744311000001107', ''),
('19837811000001105', ''),
('32483611000001105', ''),
('323854009', ''),
('10188111000001104', ''),
('34750411000001105', ''),
('36760611000001107', ''),
('8745211000001103', ''),
('23055511000001100', ''),
('36516411000001106', ''),
('19843211000001101', ''),
('36540611000001104', ''),
('32483811000001109', ''),
('9470311000001109', ''),
('323855005', ''),
('10188311000001102', ''),
('34750611000001108', ''),
('36611411000001109', ''),
('8745411000001104', ''),
('23057711000001104', ''),
('36516611000001109', ''),
('19842311000001104', ''),
('36540811000001100', ''),
('32484011000001101', ''),
('9470511000001103', ''),
('323852008', ''),
('323849000', ''),
('35798511000001105', ''),
('4373011000001106', ''),
('4374011000001108', ''),
('3930311000001107', ''),
('4374611000001101', ''),
('4375711000001109', ''),
('10283311000001108', ''),
('4374311000001106', ''),
('3930711000001106', ''),
('4374911000001107', ''),
('323880005', ''),
('4740011000001101', ''),
('34751411000001101', ''),
('36754511000001105', ''),
('36134711000001107', ''),
('3939111000001100', ''),
('11617911000001109', ''),
('36613111000001103', ''),
('36605111000001104', ''),
('36754311000001104', ''),
('4557611000001106', ''),
('4530611000001108', ''),
('11617611000001103', ''),
('36613311000001101', ''),
('36605311000001102', ''),
('36753811000001105', ''),
('4740211000001106', ''),
('3939311000001103', ''),
('4530311000001103', ''),
('11775211000001105', ''),
('11775411000001109', ''),
('11775611000001107', ''),
('323868002', ''),
('323869005', ''),
('10096411000001100', ''),
('10271811000001105', ''),
('19712711000001106', ''),
('30011011000001101', ''),
('38826311000001102', ''),
('17853111000001104', ''),
('9547111000001104', ''),
('15074511000001108', ''),
('10885511000001106', ''),
('13743011000001107', ''),
('21831411000001105', ''),
('323872003', ''),
('323874002', ''),
('228011000001102', ''),
('211911000001100', ''),
('238811000001105', ''),
('3253511000001109', ''),
('323883007', ''),
('716611000001106', ''),
('34811000001107', ''),
('606011000001105', ''),
('10388711000001105', ''),
('22631111000001107', ''),
('37509711000001109', ''),
('3611000001101', ''),
('763611000001104', ''),
('27996311000001105', ''),
('30009611000001106', ''),
('38826011000001100', ''),
('19187811000001108', ''),
('216811000001100', ''),
('9376611000001109', ''),
('17851911000001102', ''),
('612311000001107', ''),
('29782311000001109', ''),
('758111000001108', ''),
('21822811000001100', ''),
('323884001', ''),
('660211000001101', ''),
('596511000001107', ''),
('324911000001101', ''),
('10388911000001107', ''),
('22631511000001103', ''),
('37510111000001100', ''),
('648411000001106', ''),
('850211000001103', ''),
('27996611000001100', ''),
('30010111000001106', ''),
('38826411000001109', ''),
('19188011000001101', ''),
('86911000001101', ''),
('9376411000001106', ''),
('17852111000001105', ''),
('305811000001101', ''),
('29782711000001108', ''),
('587511000001105', ''),
('21823311000001104', ''),
('323887008', '')
GO
INSERT INTO #tmp83_ab_last_date_codelist (code, category) VALUES
('639611000001104', ''),
('640011000001104', ''),
('534211000001106', ''),
('10456111000001106', ''),
('22631711000001108', ''),
('37510911000001102', ''),
('34311000001103', ''),
('30010411000001101', ''),
('38825611000001102', ''),
('560011000001100', ''),
('18086311000001109', ''),
('233111000001107', ''),
('15073911000001103', ''),
('6211000001105', ''),
('21826411000001101', ''),
('323888003', ''),
('800711000001101', ''),
('707211000001109', ''),
('158511000001109', ''),
('10456311000001108', ''),
('30136211000001103', ''),
('37510711000001104', ''),
('835511000001109', ''),
('30010611000001103', ''),
('38827711000001100', ''),
('887911000001102', ''),
('18086511000001103', ''),
('728211000001103', ''),
('15074111000001104', ''),
('344611000001109', ''),
('21826611000001103', ''),
('36134311000001108', ''),
('30769411000001109', ''),
('31565211000001103', ''),
('8825611000001100', ''),
('32202211000001102', ''),
('15074311000001102', ''),
('21825911000001102', ''),
('323885000', ''),
('719911000001109', ''),
('924811000001101', ''),
('600911000001106', ''),
('10389111000001102', ''),
('22631911000001105', ''),
('37510511000001109', ''),
('360811000001108', ''),
('483611000001107', ''),
('427011000001102', ''),
('11267511000001101', ''),
('17852311000001107', ''),
('232811000001108', ''),
('15052511000001101', ''),
('362911000001104', ''),
('21827211000001103', ''),
('323886004', ''),
('652611000001105', ''),
('149411000001104', ''),
('863911000001108', ''),
('10389411000001107', ''),
('22632111000001102', ''),
('37510311000001103', ''),
('887511000001109', ''),
('331411000001105', ''),
('38824911000001109', ''),
('452411000001109', ''),
('11267711000001106', ''),
('17852511000001101', ''),
('687811000001103', ''),
('29782911000001105', ''),
('199411000001106', ''),
('21830211000001100', ''),
('4865011000001104', ''),
('35227111000001103', ''),
('35210711000001106', ''),
('19188211000001106', ''),
('11267111000001105', ''),
('4861711000001104', ''),
('4515811000001108', ''),
('35215211000001108', ''),
('35210911000001108', ''),
('19188411000001105', ''),
('11267311000001107', ''),
('4514011000001101', ''),
('904711000001102', ''),
('343411000001108', ''),
('474311000001107', ''),
('471811000001100', ''),
('96011000001104', ''),
('875311000001101', ''),
('3234011000001103', ''),
('733011000001104', ''),
('362611000001105', ''),
('91011000001106', ''),
('622911000001103', ''),
('691711000001103', ''),
('757911000001105', ''),
('323944009', ''),
('441611000001103', ''),
('48711000001106', ''),
('13576111000001100', ''),
('266111000001108', ''),
('821811000001106', ''),
('38825311000001107', ''),
('141011000001109', ''),
('17852711000001106', ''),
('231211000001100', ''),
('29783111000001101', ''),
('601211000001108', ''),
('21830611000001103', ''),
('323945005', ''),
('810111000001104', ''),
('277711000001100', ''),
('22632411000001107', ''),
('88011000001101', ''),
('332811000001103', ''),
('30010811000001104', ''),
('38825511000001101', ''),
('688511000001102', ''),
('17852911000001108', ''),
('750911000001109', ''),
('29783311000001104', ''),
('392711000001103', ''),
('21831111000001100', ''),
('323947002', ''),
('323948007', ''),
('36134511000001102', ''),
('705811000001100', ''),
('8911000001102', ''),
('3466111000001104', ''),
('795711000001106', ''),
('14511000001100', ''),
('435511000001103', ''),
('769211000001104', ''),
('324343004', ''),
('28963111000001109', ''),
('34711611000001107', ''),
('35306811000001105', ''),
('35834011000001101', ''),
('26812711000001104', ''),
('23021211000001100', ''),
('35247011000001102', ''),
('18486711000001104', ''),
('38009511000001105', ''),
('37655611000001101', ''),
('324344005', ''),
('29714711000001100', ''),
('34711811000001106', ''),
('35306611000001106', ''),
('35829511000001105', ''),
('26812911000001102', ''),
('23049211000001102', ''),
('35246811000001106', ''),
('18486011000001101', ''),
('38009811000001108', ''),
('37656911000001100', ''),
('32391011000001106', ''),
('4382011000001108', ''),
('4381711000001103', ''),
('4792411000001101', ''),
('36691911000001100', ''),
('38564211000001105', ''),
('4779811000001104', ''),
('428353009', ''),
('14236111000001106', ''),
('4396211000001103', ''),
('24416411000001106', ''),
('24200611000001109', ''),
('36568011000001102', ''),
('22980411000001102', ''),
('18852711000001100', ''),
('323970005', ''),
('4391811000001107', ''),
('4392111000001105', ''),
('4391611000001108', ''),
('323962000', ''),
('323961007', ''),
('323960008', ''),
('4344011000001107', ''),
('4343611000001103', ''),
('4342911000001102', ''),
('324049005', ''),
('13613311000001108', ''),
('13385911000001100', ''),
('13479311000001102', ''),
('11713511000001103', ''),
('11713611000001104', ''),
('11697611000001102', ''),
('11697311000001107', ''),
('11713311000001109', ''),
('11713411000001102', ''),
('11697011000001109', ''),
('11696711000001108', ''),
('11713711000001108', ''),
('11713811000001100', ''),
('11698211000001100', ''),
('11697911000001108', ''),
('371595007', ''),
('27808811000001108', ''),
('34802411000001103', ''),
('3722011000001101', ''),
('324070004', ''),
('2847611000001101', ''),
('2847811000001102', ''),
('2849911000001100', ''),
('11403911000001104', ''),
('10405011000001108', ''),
('23881111000001102', ''),
('37897811000001106', ''),
('14201611000001100', ''),
('2848611000001102', ''),
('2849111000001103', ''),
('37071111000001104', ''),
('38877411000001105', ''),
('7432211000001109', ''),
('17894611000001103', ''),
('29836111000001100', ''),
('2848011000001109', ''),
('2848411000001100', ''),
('21933211000001100', ''),
('324059006', ''),
('2850911000001108', ''),
('2851411000001109', ''),
('2854311000001104', ''),
('11404211000001106', ''),
('2851811000001106', ''),
('10405211000001103', ''),
('23880711000001109', ''),
('37896911000001104', ''),
('14161611000001103', ''),
('2852511000001100', ''),
('2853211000001109', ''),
('30123211000001107', ''),
('38877111000001100', ''),
('2852911000001107', ''),
('17894811000001104', ''),
('15083411000001100', ''),
('10724511000001104', ''),
('2852311000001106', ''),
('21933411000001101', ''),
('324072007', ''),
('8485211000001101', ''),
('8485311000001109', ''),
('8458111000001109', ''),
('8459211000001108', ''),
('32876211000001101', ''),
('32874411000001105', ''),
('421341000', ''),
('38250911000001106', ''),
('2853411000001108', ''),
('2849311000001101', ''),
('2849511000001107', ''),
('2854011000001102', ''),
('2847211000001103', ''),
('2849711000001102', ''),
('2852111000001109', ''),
('2848211000001104', ''),
('2853611000001106', ''),
('324076005', ''),
('21232111000001104', ''),
('23643111000001104', ''),
('30763011000001103', ''),
('24372611000001107', ''),
('32417211000001101', ''),
('37119611000001105', ''),
('34187111000001100', ''),
('29899911000001103', ''),
('37860011000001104', ''),
('21219611000001105', ''),
('21790011000001101', ''),
('396211000001106', ''),
('324092000', ''),
('666311000001107', ''),
('679811000001102', ''),
('514011000001108', ''),
('24386011000001105', ''),
('939411000001101', ''),
('30831211000001101', ''),
('238111000001103', ''),
('11408511000001102', ''),
('17942111000001100', ''),
('29923611000001108', ''),
('8819311000001104', ''),
('891511000001102', ''),
('13758111000001102', ''),
('21801011000001105', ''),
('324093005', ''),
('254511000001104', ''),
('754011000001103', ''),
('165311000001103', ''),
('34019411000001108', ''),
('24385811000001107', ''),
('64211000001102', ''),
('30831011000001106', ''),
('7611000001109', ''),
('11408011000001105', ''),
('17942311000001103', ''),
('29923011000001101', ''),
('8819511000001105', ''),
('936711000001102', ''),
('13758311000001100', ''),
('21801211000001100', ''),
('36565111000001106', ''),
('9330111000001102', ''),
('14781411000001109', ''),
('324090008', ''),
('324091007', ''),
('13010711000001108', ''),
('13010811000001100', ''),
('12979311000001105', ''),
('12979011000001107', ''),
('123211000001102', ''),
('621011000001105', ''),
('820411000001100', ''),
('921111000001105', ''),
('926911000001103', ''),
('116911000001108', ''),
('147511000001107', ''),
('7393411000001103', ''),
('9361611000001109', ''),
('18248711000001106', ''),
('9891211000001108', ''),
('324095003', ''),
('3345011000001108', ''),
('3345611000001101', ''),
('3350311000001102', ''),
('9802411000001100', ''),
('10436911000001108', ''),
('16062611000001107', ''),
('28918511000001105', ''),
('30071211000001104', ''),
('29006911000001106', ''),
('11013711000001105', ''),
('20326411000001109', ''),
('3347511000001109', ''),
('22473711000001108', ''),
('3347811000001107', ''),
('17951211000001102', ''),
('4331711000001105', ''),
('15114911000001103', ''),
('3349611000001103', ''),
('3346311000001101', ''),
('21829411000001108', ''),
('13003811000001109', ''),
('12989611000001106', ''),
('13003911000001104', ''),
('12990511000001100', ''),
('13004011000001101', ''),
('12991011000001104', ''),
('13003711000001101', ''),
('12989211000001109', ''),
('3348411000001109', ''),
('3348811000001106', ''),
('3347011000001101', ''),
('324011006', ''),
('20291511000001104', ''),
('324012004', ''),
('47611000001101', ''),
('205211000001109', ''),
('625311000001105', ''),
('17962811000001100', ''),
('37824111000001101', ''),
('36074811000001107', ''),
('22473211000001101', ''),
('357111000001108', ''),
('35593811000001102', ''),
('17875711000001104', ''),
('21787511000001109', ''),
('21407411000001104', ''),
('21406411000001101', ''),
('4548811000001106', ''),
('34819711000001101', ''),
('917911000001109', ''),
('10328711000001100', ''),
('35204411000001108', ''),
('10321011000001108', ''),
('36564611000001104', ''),
('15656211000001107', ''),
('35899911000001109', ''),
('9222111000001109', ''),
('11591311000001108', ''),
('35899811000001104', ''),
('4500111000001106', ''),
('4500411000001101', ''),
('36051011000001102', ''),
('3845211000001101', ''),
('27334311000001101', ''),
('3847411000001108', ''),
('32334511000001109', ''),
('3846511000001105', ''),
('29862011000001106', ''),
('36063011000001107', ''),
('4615711000001107', ''),
('36051111000001101', ''),
('3997111000001101', ''),
('3998811000001107', ''),
('3998211000001106', ''),
('36050911000001105', ''),
('3999111000001107', ''),
('3999911000001105', ''),
('3999411000001102', ''),
('8523611000001103', ''),
('8494111000001107', ''),
('12089911000001108', ''),
('12075211000001108', ''),
('12090011000001100', ''),
('12076611000001100', ''),
('27800411000001108', ''),
('27690911000001109', ''),
('29827911000001102', ''),
('29793411000001107', ''),
('29903511000001102', ''),
('29934211000001107', ''),
('29861811000001109', ''),
('29951311000001103', ''),
('29941811000001105', ''),
('29942711000001109', ''),
('29951111000001100', ''),
('29942211000001102', ''),
('29942911000001106', ''),
('29951211000001106', ''),
('29942511000001104', ''),
('29943111000001102', ''),
('32749211000001108', ''),
('32743411000001105', ''),
('3845811000001100', ''),
('3983611000001102', ''),
('4609011000001105', ''),
('3997811000001108', ''),
('3847011000001104', ''),
('17330211000001102', ''),
('10967311000001102', ''),
('324158001', ''),
('4055311000001106', ''),
('28932611000001103', ''),
('4055711000001105', ''),
('4208311000001104', ''),
('12302011000001102', ''),
('12274811000001104', ''),
('12301911000001109', ''),
('12273311000001106', ''),
('4055511000001100', ''),
('36031111000001100', ''),
('36031311000001103', ''),
('36030911000001109', ''),
('36031011000001101', ''),
('36031211000001106', ''),
('4463011000001106', ''),
('4463311000001109', ''),
('4463611000001104', ''),
('4464611000001101', ''),
('4462711000001100', ''),
('34194211000001103', ''),
('4957911000001108', ''),
('4944011000001104', ''),
('9187611000001105', ''),
('4944511000001107', ''),
('4944311000001101', ''),
('12949611000001104', ''),
('4145011000001103', ''),
('4127011000001108', ''),
('9187811000001109', ''),
('4129111000001103', ''),
('26857411000001100', ''),
('38027711000001101', ''),
('4128011000001109', ''),
('12949811000001100', ''),
('35919711000001100', ''),
('4514311000001103', ''),
('35919811000001108', ''),
('4158411000001104', ''),
('32656811000001108', ''),
('32645711000001105', ''),
('4516011000001106', ''),
('35777411000001100', ''),
('4514611000001108', ''),
('19544811000001101', ''),
('23676411000001103', ''),
('23671411000001109', ''),
('4514911000001102', ''),
('4128611000001102', ''),
('324252006', ''),
('14968311000001103', ''),
('15017711000001104', ''),
('36465711000001104', ''),
('19706711000001107', ''),
('37893411000001102', ''),
('32395411000001104', ''),
('37041111000001100', ''),
('38802911000001107', ''),
('35727711000001105', ''),
('17791111000001105', ''),
('15071111000001102', ''),
('33932211000001100', ''),
('14789411000001105', ''),
('34554511000001101', ''),
('324253001', ''),
('13652511000001104', ''),
('17283411000001107', ''),
('22615611000001105', ''),
('37041811000001107', ''),
('38803511000001107', ''),
('20281711000001105', ''),
('15070811000001101', ''),
('14166911000001104', ''),
('21781011000001106', ''),
('324258005', ''),
('11252311000001102', ''),
('38006911000001107', ''),
('20943011000001102', ''),
('15472811000001107', ''),
('34642911000001105', ''),
('19543911000001109', ''),
('36420111000001101', ''),
('19707211000001103', ''),
('32395911000001107', ''),
('37042711000001106', ''),
('38810611000001100', ''),
('38710611000001103', ''),
('19474211000001108', ''),
('17791411000001100', ''),
('11579411000001106', ''),
('15051411000001105', ''),
('37857911000001108', ''),
('11028111000001105', ''),
('11034311000001100', ''),
('11252111000001104', ''),
('38006711000001105', ''),
('20942811000001100', ''),
('15472611000001108', ''),
('34642111000001107', ''),
('19544211000001102', ''),
('36445611000001104', ''),
('19707011000001108', ''),
('32395711000001105', ''),
('29998311000001103', ''),
('38803811000001105', ''),
('38710311000001108', ''),
('19474411000001107', ''),
('22202911000001107', ''),
('20282311000001102', ''),
('15071411000001107', ''),
('36907711000001108', ''),
('11028411000001100', ''),
('29668711000001101', ''),
('29516411000001104', ''),
('85911000001108', ''),
('650911000001103', ''),
('794511000001102', ''),
('14759911000001105', ''),
('324238009', ''),
('8927511000001103', ''),
('20165611000001102', ''),
('14694011000001106', ''),
('9033411000001103', ''),
('17965211000001106', ''),
('13765011000001103', ''),
('19715011000001104', ''),
('37402011000001108', ''),
('8825911000001106', ''),
('38836811000001108', ''),
('35140911000001102', ''),
('8914911000001107', ''),
('17859611000001109', ''),
('9038211000001105', ''),
('8993611000001100', ''),
('15080711000001102', ''),
('17522411000001102', ''),
('8818911000001106', ''),
('13745611000001101', ''),
('36846911000001107', ''),
('21854711000001102', ''),
('20096711000001105', ''),
('35368711000001104', ''),
('9252611000001100', ''),
('36621611000001102', ''),
('9157411000001102', ''),
('30761711000001102', ''),
('30031911000001106', ''),
('9155811000001105', ''),
('38840411000001105', ''),
('18101811000001104', ''),
('9042011000001104', ''),
('9547411000001109', ''),
('15080411000001108', ''),
('21854311000001101', ''),
('324242007', ''),
('36635611000001101', ''),
('17648711000001102', ''),
('17997711000001108', ''),
('35555411000001108', ''),
('13612911000001102', ''),
('34751611000001103', ''),
('13469711000001107', ''),
('324244008', ''),
('8928611000001100', ''),
('20165811000001103', ''),
('14694411000001102', ''),
('9033811000001101', ''),
('17965511000001109', ''),
('13765211000001108', ''),
('19715211000001109', ''),
('37402811000001102', ''),
('8826111000001102', ''),
('38837011000001104', ''),
('35141111000001106', ''),
('8915511000001104', ''),
('17859811000001108', ''),
('9038811000001106', ''),
('8993811000001101', ''),
('29789111000001103', ''),
('17522611000001104', ''),
('8819111000001101', ''),
('13745811000001102', ''),
('36847211000001101', ''),
('21854911000001100', ''),
('20097311000001109', ''),
('36142611000001107', ''),
('324248006', ''),
('4977911000001105', ''),
('37083211000001101', ''),
('9253011000001103', ''),
('36621811000001103', ''),
('9157711000001108', ''),
('30761911000001100', ''),
('30041111000001109', ''),
('9156111000001109', ''),
('38840711000001104', ''),
('18103211000001101', ''),
('9042311000001101', ''),
('9547911000001101', ''),
('15080911000001100', ''),
('21854511000001107', ''),
('9742311000001103', ''),
('9742411000001105', ''),
('9742511000001109', ''),
('220811000001105', ''),
('917411000001101', ''),
('27011000001106', ''),
('463111000001102', ''),
('40811000001101', ''),
('3253811000001107', ''),
('4973711000001103', ''),
('211000001101', ''),
('9739611000001100', ''),
('9739911000001106', ''),
('9740211000001105', ''),
('18149211000001106', ''),
('21667211000001100', ''),
('21708211000001106', ''),
('33656011000001109', ''),
('324178009', ''),
('766711000001101', ''),
('89511000001103', ''),
('689511000001108', ''),
('789411000001103', ''),
('9795911000001100', ''),
('10406411000001108', ''),
('24389111000001103', ''),
('23903911000001107', ''),
('11020911000001106', ''),
('35996611000001100', ''),
('32800711000001104', ''),
('654811000001103', ''),
('687011000001109', ''),
('30825911000001105', ''),
('38889811000001108', ''),
('19733011000001108', ''),
('19191611000001104', ''),
('126311000001101', ''),
('38073211000001103', ''),
('17903711000001101', ''),
('7211000001107', ''),
('4330011000001104', ''),
('29856311000001102', ''),
('17198711000001106', ''),
('18281911000001106', ''),
('919211000001106', ''),
('21976211000001109', ''),
('36064711000001106', ''),
('482311000001107', ''),
('20962611000001108', ''),
('258211000001108', ''),
('10406211000001109', ''),
('10139811000001105', ''),
('9563611000001105', ''),
('759811000001108', ''),
('235411000001103', ''),
('165611000001108', ''),
('4227311000001109', ''),
('324232005', ''),
('682211000001102', ''),
('838411000001100', ''),
('468911000001109', ''),
('23902711000001102', ''),
('10307311000001109', ''),
('469911000001101', ''),
('38889611000001109', ''),
('17902311000001105', ''),
('13620311000001107', ''),
('231611000001103', ''),
('29852211000001109', ''),
('21935211000001101', ''),
('324233000', ''),
('563411000001101', ''),
('398811000001108', ''),
('816211000001107', ''),
('23902911000001100', ''),
('10307711000001108', ''),
('79111000001102', ''),
('38890011000001106', ''),
('17902811000001101', ''),
('13620511000001101', ''),
('103911000001104', ''),
('29856111000001104', ''),
('21975211000001103', ''),
('324234006', ''),
('348611000001104', ''),
('889511000001102', ''),
('845911000001101', ''),
('23903111000001109', ''),
('10308311000001105', ''),
('237511000001108', ''),
('17903311000001100', ''),
('13620711000001106', ''),
('605811000001107', ''),
('29856611000001107', ''),
('21975411000001104', ''),
('324179001', ''),
('32506411000001108', ''),
('37376611000001104', ''),
('32163811000001106', ''),
('37149211000001103', ''),
('36564711000001108', ''),
('481911000001102', ''),
('10060511000001100', ''),
('580111000001102', ''),
('23903311000001106', ''),
('10307511000001103', ''),
('2411000001108', ''),
('840611000001104', ''),
('30125811000001107', ''),
('38890211000001101', ''),
('549711000001102', ''),
('17902611000001100', ''),
('13620911000001108', ''),
('29851811000001101', ''),
('173511000001103', ''),
('21975611000001101', ''),
('177211000001105', ''),
('10060711000001105', ''),
('364011000001109', ''),
('23903511000001100', ''),
('10308011000001107', ''),
('273611000001101', ''),
('506011000001101', ''),
('30810111000001105', ''),
('38890411000001102', ''),
('784711000001108', ''),
('17903011000001103', ''),
('13621111000001104', ''),
('29852611000001106', ''),
('592611000001105', ''),
('21975811000001102', ''),
('433911000001109', ''),
('10060911000001107', ''),
('626611000001105', ''),
('23903711000001105', ''),
('10308511000001104', ''),
('364211000001104', ''),
('78611000001101', ''),
('415511000001109', ''),
('17903511000001106', ''),
('13621311000001102', ''),
('848711000001105', ''),
('21976011000001104', ''),
('580811000001109', ''),
('108811000001104', ''),
('294211000001105', ''),
('178911000001100', ''),
('324215006', ''),
('4692411000001105', ''),
('29948711000001107', ''),
('4693311000001108', ''),
('4693011000001105', ''),
('33737411000001107', ''),
('36542711000001107', ''),
('4693611000001103', ''),
('324180003', ''),
('38215511000001102', ''),
('37911311000001102', ''),
('324181004', ''),
('38215811000001104', ''),
('37911611000001107', ''),
('274611000001103', ''),
('30611000001101', ''),
('17628011000001101', ''),
('17627611000001109', ''),
('407790000', ''),
('98311000001102', ''),
('324276003', ''),
('36646511000001108', ''),
('37334911000001104', ''),
('324277007', ''),
('4919711000001105', ''),
('33634011000001103', ''),
('7845611000001105', ''),
('37342311000001106', ''),
('30041711000001105', ''),
('35019811000001102', ''),
('13704611000001105', ''),
('37053311000001104', ''),
('38841011000001105', ''),
('38320011000001100', ''),
('35638511000001105', ''),
('17860011000001101', ''),
('28693411000001100', ''),
('4329711000001107', ''),
('15081111000001109', ''),
('33933711000001104', ''),
('33041711000001109', ''),
('21858111000001109', ''),
('19213211000001104', ''),
('27864611000001100', ''),
('8351711000001105', ''),
('12021611000001106', ''),
('11968011000001106', ''),
('12021711000001102', ''),
('11969011000001101', ''),
('12021411000001108', ''),
('11967711000001107', ''),
('12021811000001105', ''),
('11969511000001109', ''),
('12021311000001101', ''),
('11967411000001101', ''),
('18519211000001105', ''),
('18513011000001103', ''),
('21711211000001104', ''),
('21732111000001107', ''),
('33634311000001100', ''),
('22164711000001102', ''),
('37343211000001109', ''),
('21669011000001101', ''),
('30042211000001105', ''),
('37053511000001105', ''),
('38841311000001108', ''),
('38322611000001108', ''),
('35774311000001103', ''),
('28693811000001103', ''),
('29789311000001101', ''),
('33041911000001106', ''),
('8360611000001101', ''),
('8353211000001104', ''),
('32748011000001108', ''),
('32705111000001105', ''),
('34376711000001103', ''),
('34355711000001108', ''),
('34818411000001104', ''),
('34810711000001108', ''),
('36458711000001104', ''),
('36450311000001100', ''),
('36458611000001108', ''),
('36450611000001105', ''),
('3956511000001100', ''),
('3668311000001100', ''),
('36087211000001109', ''),
('18275411000001109', ''),
('17664411000001105', ''),
('18031711000001109', ''),
('34751811000001104', ''),
('36087311000001101', ''),
('18275611000001107', ''),
('17664611000001108', ''),
('18031911000001106', ''),
('34752011000001102', ''),
('4348911000001104', ''),
('7816711000001103', ''),
('20151411000001107', ''),
('20177311000001108', ''),
('20151811000001109', ''),
('20152111000001107', ''),
('414851008', ''),
('20425111000001100', ''),
('409156007', ''),
('21626711000001104', ''),
('703666002', ''),
('20540311000001100', ''),
('29734011000001109', ''),
('703915009', ''),
('29722811000001107', ''),
('29723111000001106', ''),
('18162111000001102', ''),
('29934011000001102', ''),
('32746111000001105', ''),
('21393311000001105', ''),
('32982711000001106', ''),
('34377311000001104', ''),
('34376311000001102', ''),
('324298007', ''),
('3928511000001100', ''),
('3929711000001101', ''),
('14942611000001102', ''),
('4743111000001107', ''),
('11482411000001104', ''),
('3928911000001107', ''),
('324303009', ''),
('34327311000001100', ''),
('34340211000001107', ''),
('33582511000001101', ''),
('4382311000001106', ''),
('36091411000001104', ''),
('324308000', ''),
('3964811000001102', ''),
('4352211000001109', ''),
('324310003', ''),
('324311004', ''),
('18758011000001102', ''),
('17652211000001105', ''),
('4638311000001106', ''),
('32936911000001103', ''),
('3109511000001103', ''),
('3108611000001108', ''),
('4621211000001109', ''),
('4658711000001106', ''),
('324317000', ''),
('3981111000001109', ''),
('35927411000001109', ''),
('29786111000001106', ''),
('9060611000001103', ''),
('27753611000001108', ''),
('8708411000001103', ''),
('324316009', ''),
('3670711000001108', ''),
('4371711000001107', ''),
('35915211000001109', ''),
('36761811000001103', ''),
('35915111000001103', ''),
('36769311000001106', ''),
('4182311000001103', ''),
('4181011000001109', ''),
('324334008', ''),
('4126811000001104', ''),
('4127711000001105', ''),
('4128311000001107', ''),
('37832911000001105', ''),
('24566911000001109', ''),
('37877211000001101', ''),
('37436111000001101', ''),
('324335009', ''),
('4202811000001106', ''),
('4203311000001107', ''),
('4203511000001101', ''),
('37725211000001105', ''),
('324337001', ''),
('34758311000001101', ''),
('35830111000001109', ''),
('32895211000001100', ''),
('23872411000001109', ''),
('4213611000001104', ''),
('4212611000001109', ''),
('4212911000001103', ''),
('4213811000001100', ''),
('36517311000001101', ''),
('19456211000001101', ''),
('24517411000001103', ''),
('15165911000001100', ''),
('324333002', ''),
('34758511000001107', ''),
('35829811000001108', ''),
('32895411000001101', ''),
('36759411000001105', ''),
('4432811000001102', ''),
('4432211000001103', ''),
('4432411000001104', ''),
('4433011000001104', ''),
('26858511000001102', ''),
('36517611000001106', ''),
('19455111000001101', ''),
('24517611000001100', ''),
('15048611000001103', ''),
('12940811000001109', ''),
('12933111000001108', ''),
('8818611000001100', ''),
('8818711000001109', ''),
('8815211000001109', ''),
('8815711000001102', ''),
('15453011000001107', ''),
('15453111000001108', ''),
('15445311000001108', ''),
('15445611000001103', ''),
('13455811000001106', ''),
('13450811000001100', ''),
('4128511000001101', ''),
('4203811000001103', ''),
('4213311000001109', ''),
('4432611000001101', ''),
('324354009', ''),
('4408311000001100', ''),
('134561001', ''),
('31800311000001102', '')
GO
INSERT INTO #tmp83_ab_last_date_codelist (code, category) VALUES
('34943711000001101', ''),
('31203911000001103', ''),
('31896811000001106', ''),
('31279511000001100', ''),
('37267511000001102', ''),
('35165011000001102', ''),
('33627611000001101', ''),
('31153711000001107', ''),
('31684511000001106', ''),
('33746711000001100', ''),
('407899006', ''),
('36040111000001105', ''),
('34574711000001109', ''),
('36615111000001102', ''),
('33737611000001105', ''),
('31153911000001109', ''),
('36441911000001108', ''),
('38675711000001104', ''),
('36096911000001102', ''),
('36886111000001102', ''),
('4450311000001108', ''),
('4946211000001104', ''),
('4827211000001109', ''),
('412555008', ''),
('15877511000001101', ''),
('445522003', ''),
('20442211000001103', ''),
('22192511000001100', ''),
('34604811000001100', ''),
('12556911000001106', ''),
('22175211000001101', ''),
('19475511000001107', ''),
('20441311000001102', ''),
('21874811000001107', ''),
('10140911000001105', ''),
('35047211000001102', ''),
('36531611000001105', ''),
('10961311000001108', ''),
('35047711000001109', ''),
('36531811000001109', ''),
('10140111000001107', ''),
('10961511000001102', ''),
('16324411000001105', ''),
('20591911000001100', ''),
('16248411000001105', ''),
('3653911000001100', ''),
('3625511000001107', ''),
('3626311000001106', ''),
('32519811000001101', ''),
('3625711000001102', ''),
('35313211000001104', ''),
('32501611000001104', ''),
('32505711000001105', ''),
('32431411000001103', ''),
('37232111000001101', ''),
('38859611000001100', ''),
('324362001', ''),
('32501811000001100', ''),
('32507511000001109', ''),
('32280411000001100', ''),
('324357002', ''),
('812711000001104', ''),
('688711000001107', ''),
('517111000001104', ''),
('32281711000001103', ''),
('28922511000001104', ''),
('23858211000001109', ''),
('14942811000001103', ''),
('34958511000001104', ''),
('802611000001106', ''),
('38859111000001108', ''),
('17889311000001105', ''),
('29826011000001104', ''),
('26776811000001104', ''),
('21942611000001109', ''),
('324359004', ''),
('30994911000001107', ''),
('32506211000001109', ''),
('32278611000001106', ''),
('37232311000001104', ''),
('37896711000001101', ''),
('34958311000001105', ''),
('38859311000001105', ''),
('26777411000001104', ''),
('36091911000001107', ''),
('7817111000001101', ''),
('659211000001100', ''),
('764411000001104', ''),
('96711000001102', ''),
('3757311000001102', ''),
('3626011000001108', ''),
('324411000', ''),
('4104011000001108', ''),
('4104911000001107', ''),
('26857011000001109', ''),
('4104611000001101', ''),
('21903611000001106', ''),
('4104411000001104', ''),
('13454711000001102', ''),
('13449711000001104', ''),
('13454911000001100', ''),
('13450011000001106', ''),
('13454811000001105', ''),
('13450511000001103', ''),
('5241611000001103', ''),
('13539611000001103', ''),
('27397711000001102', ''),
('15474111000001108', ''),
('21268011000001109', ''),
('36144011000001106', ''),
('324430000', ''),
('710811000001108', ''),
('897711000001103', ''),
('250811000001106', ''),
('9800011000001105', ''),
('10414811000001100', ''),
('16070411000001101', ''),
('28917911000001104', ''),
('30106111000001102', ''),
('426711000001103', ''),
('30942111000001106', ''),
('17865911000001106', ''),
('46511000001102', ''),
('6038911000001109', ''),
('15199811000001106', ''),
('121511000001103', ''),
('21906211000001102', ''),
('324431001', ''),
('339211000001107', ''),
('20170611000001102', ''),
('15911000001106', ''),
('112111000001106', ''),
('9799411000001106', ''),
('10415011000001105', ''),
('16071011000001101', ''),
('28988711000001102', ''),
('30106311000001100', ''),
('664011000001104', ''),
('416811000001104', ''),
('30942311000001108', ''),
('17866111000001102', ''),
('490311000001109', ''),
('6039711000001103', ''),
('187211000001100', ''),
('21906411000001103', ''),
('665011000001100', ''),
('15861911000001105', ''),
('543111000001101', ''),
('17962411000001102', ''),
('30835311000001106', ''),
('845811000001106', ''),
('30941811000001108', ''),
('17865711000001109', ''),
('13627411000001101', ''),
('15200311000001106', ''),
('733211000001109', ''),
('22387811000001109', ''),
('13374511000001101', ''),
('13374611000001102', ''),
('13363211000001108', ''),
('13361311000001101', ''),
('13374711000001106', ''),
('13374811000001103', ''),
('13363511000001106', ''),
('13361711000001102', ''),
('13374911000001108', ''),
('13375011000001108', ''),
('13363811000001109', ''),
('13362311000001105', ''),
('13375111000001109', ''),
('13375211000001103', ''),
('13364111000001100', ''),
('13362611000001100', ''),
('426411000001109', ''),
('95811000001102', ''),
('789611000001100', ''),
('735011000001103', ''),
('431211000001104', ''),
('329711000001102', ''),
('38080911000001105', ''),
('38081511000001105', ''),
('36035511000001107', ''),
('34194011000001108', ''),
('4969011000001107', ''),
('5099711000001109', ''),
('324520007', ''),
('271811000001101', ''),
('341811000001106', ''),
('24384411000001109', ''),
('34745911000001108', ''),
('113911000001102', ''),
('37149811000001102', ''),
('11599611000001102', ''),
('29920411000001102', ''),
('21799811000001103', ''),
('21309911000001106', ''),
('324517004', ''),
('324518009', ''),
('324511003', ''),
('657311000001103', ''),
('703011000001105', ''),
('367011000001101', ''),
('10690011000001102', ''),
('10394111000001104', ''),
('20189711000001106', ''),
('24384611000001107', ''),
('14162711000001100', ''),
('727811000001101', ''),
('35843111000001101', ''),
('461811000001105', ''),
('30830211000001107', ''),
('19193811000001101', ''),
('786711000001104', ''),
('34612711000001100', ''),
('17941711000001106', ''),
('494411000001108', ''),
('8826911000001104', ''),
('15110911000001108', ''),
('357811000001101', ''),
('21800011000001101', ''),
('324512005', ''),
('791311000001105', ''),
('229911000001106', ''),
('780111000001103', ''),
('10690211000001107', ''),
('10394511000001108', ''),
('20189911000001108', ''),
('24384811000001106', ''),
('14162911000001103', ''),
('882111000001102', ''),
('406911000001106', ''),
('30830411000001106', ''),
('19194011000001109', ''),
('723311000001103', ''),
('17941911000001108', ''),
('239411000001100', ''),
('8827211000001105', ''),
('15111111000001104', ''),
('585011000001109', ''),
('650511000001105', ''),
('21800211000001106', ''),
('34617211000001105', ''),
('36077111000001105', ''),
('34612511000001105', ''),
('36035611000001106', ''),
('13408411000001108', ''),
('3617511000001108', ''),
('3620311000001108', ''),
('324523009', ''),
('780211000001109', ''),
('310211000001108', ''),
('329811000001105', ''),
('24385011000001101', ''),
('15111311000001102', ''),
('36537511000001100', ''),
('34607211000001108', ''),
('34605411000001101', ''),
('13007811000001103', ''),
('12961911000001102', ''),
('13008011000001105', ''),
('12962211000001104', ''),
('13008111000001106', ''),
('12962811000001103', ''),
('32655011000001106', ''),
('32646011000001104', ''),
('13007911000001108', ''),
('12960811000001104', ''),
('13008211000001100', ''),
('12962511000001101', ''),
('838811000001103', ''),
('272211000001109', ''),
('3911811000001100', ''),
('3910511000001105', ''),
('453711000001106', ''),
('3924811000001105', ''),
('3619811000001103', ''),
('3912311000001100', ''),
('3910711000001100', ''),
('471211000001101', ''),
('3620111000001106', ''),
('324554008', ''),
('3747511000001105', ''),
('324607004', ''),
('170311000001103', ''),
('19834111000001108', ''),
('18460011000001101', ''),
('624611000001101', ''),
('211411000001108', ''),
('9795711000001102', ''),
('10393211000001107', ''),
('15988911000001106', ''),
('19713611000001107', ''),
('11017911000001103', ''),
('7426211000001108', ''),
('810711000001103', ''),
('254711000001109', ''),
('38834811000001101', ''),
('19729511000001101', ''),
('38794711000001100', ''),
('317211000001107', ''),
('36574211000001108', ''),
('10442211000001104', ''),
('11401111000001103', ''),
('17858211000001102', ''),
('827711000001107', ''),
('485011000001104', ''),
('15077111000001109', ''),
('368511000001108', ''),
('18280611000001105', ''),
('370811000001102', ''),
('13743811000001101', ''),
('36840911000001109', ''),
('21852511000001102', ''),
('826011000001107', ''),
('36140911000001100', ''),
('11546011000001109', ''),
('8967411000001108', ''),
('36570411000001101', ''),
('22982111000001106', ''),
('324606008', ''),
('625611000001100', ''),
('19834311000001105', ''),
('18460411000001105', ''),
('920811000001106', ''),
('238711000001102', ''),
('9785111000001102', ''),
('10393511000001105', ''),
('15989111000001101', ''),
('648911000001103', ''),
('19713911000001101', ''),
('11018811000001107', ''),
('7426411000001107', ''),
('491511000001105', ''),
('2511000001107', ''),
('38835111000001107', ''),
('19729711000001106', ''),
('38715111000001103', ''),
('823711000001102', ''),
('36574711000001101', ''),
('36696711000001108', ''),
('11401511000001107', ''),
('17858511000001104', ''),
('735711000001101', ''),
('327011000001108', ''),
('15077911000001107', ''),
('938011000001100', ''),
('18280811000001109', ''),
('62011000001101', ''),
('13744011000001109', ''),
('36841511000001109', ''),
('21853011000001101', ''),
('15261211000001108', ''),
('324600002', ''),
('675411000001102', ''),
('227611000001105', ''),
('130511000001107', ''),
('17964311000001102', ''),
('15988711000001109', ''),
('19713411000001109', ''),
('11017111000001101', ''),
('780711000001102', ''),
('38834611000001100', ''),
('36575111000001103', ''),
('17858011000001107', ''),
('926611000001109', ''),
('15076711000001107', ''),
('671111000001105', ''),
('799111000001107', ''),
('36839911000001104', ''),
('324605007', ''),
('366711000001102', ''),
('19833511000001102', ''),
('23483711000001106', ''),
('469011000001100', ''),
('872511000001101', ''),
('17964511000001108', ''),
('10393811000001108', ''),
('15989311000001104', ''),
('19714211000001108', ''),
('11019511000001103', ''),
('7426611000001105', ''),
('849311000001100', ''),
('271111000001108', ''),
('38835411000001102', ''),
('19730111000001102', ''),
('38715311000001101', ''),
('36574511000001106', ''),
('11402111000001108', ''),
('17858811000001101', ''),
('935711000001105', ''),
('868011000001102', ''),
('15078411000001100', ''),
('630111000001102', ''),
('18281011000001107', ''),
('591811000001100', ''),
('13744211000001104', ''),
('36841911000001102', ''),
('21853311000001103', ''),
('9207911000001103', ''),
('12020311000001106', ''),
('11980911000001105', ''),
('12019511000001104', ''),
('11975011000001109', ''),
('12020511000001100', ''),
('11972111000001103', ''),
('12019611000001100', ''),
('11975511000001101', ''),
('12020611000001101', ''),
('11972711000001102', ''),
('12020811000001102', ''),
('11973911000001107', ''),
('12020711000001105', ''),
('11973311000001106', ''),
('12019911000001106', ''),
('11977411000001106', ''),
('8973011000001101', ''),
('28040911000001104', ''),
('36570611000001103', ''),
('22983111000001100', ''),
('34611511000001102', ''),
('12020211000001103', ''),
('11980311000001109', ''),
('12020011000001108', ''),
('11978711000001104', ''),
('12020911000001107', ''),
('11974611000001103', ''),
('36141011000001108', ''),
('35515811000001102', ''),
('11761311000001107', ''),
('36141511000001100', ''),
('32775511000001107', ''),
('35516111000001103', ''),
('35831211000001109', ''),
('11761811000001103', ''),
('324602005', ''),
('12020411000001104', ''),
('11971311000001105', ''),
('12019711000001109', ''),
('11976011000001100', ''),
('12019811000001101', ''),
('11976411000001109', ''),
('12020111000001109', ''),
('11979311000001109', ''),
('10892711000001106', ''),
('18756911000001102', ''),
('34648611000001102', ''),
('34532811000001105', ''),
('10889411000001105', ''),
('10892811000001103', ''),
('11528211000001101', ''),
('13793511000001105', ''),
('34648911000001108', ''),
('34533011000001108', ''),
('10889711000001104', ''),
('10892911000001108', ''),
('11528411000001102', ''),
('13793711000001100', ''),
('34649111000001103', ''),
('10890011000001105', ''),
('455911000001109', ''),
('417611000001101', ''),
('162511000001103', ''),
('661311000001104', ''),
('902411000001101', ''),
('8951511000001108', ''),
('8954311000001104', ''),
('785511000001102', ''),
('854011000001101', ''),
('3492511000001109', ''),
('324579006', ''),
('19681911000001107', ''),
('26854011000001101', ''),
('19172111000001106', ''),
('324578003', ''),
('35445511000001100', ''),
('36028911000001108', ''),
('3683611000001101', ''),
('4058911000001101', ''),
('4059711000001107', ''),
('3852811000001105', ''),
('324612003', ''),
('465511000001105', ''),
('527011000001106', ''),
('16062011000001100', ''),
('37463211000001108', ''),
('724511000001107', ''),
('30852711000001100', ''),
('4273411000001105', ''),
('7464011000001104', ''),
('319311000001109', ''),
('15112111000001109', ''),
('792611000001106', ''),
('21821611000001105', ''),
('324620001', ''),
('238911000001100', ''),
('412511000001103', ''),
('16062211000001105', ''),
('37463811000001109', ''),
('787111000001102', ''),
('30853111000001107', ''),
('4818111000001107', ''),
('7464911000001100', ''),
('525111000001103', ''),
('15112411000001104', ''),
('339611000001109', ''),
('38752711000001101', ''),
('12905211000001105', ''),
('12895811000001101', ''),
('12897211000001105', ''),
('12896211000001108', ''),
('12905311000001102', ''),
('12905411000001109', ''),
('12898411000001108', ''),
('12897811000001106', ''),
('362511000001106', ''),
('491611000001109', ''),
('4415111000001109', ''),
('324621002', ''),
('822711000001105', ''),
('254211000001102', ''),
('511511000001102', ''),
('739911000001102', ''),
('17947511000001107', ''),
('35549811000001106', ''),
('18745111000001108', ''),
('21816311000001102', ''),
('866311000001103', ''),
('324634001', ''),
('19359911000001108', ''),
('21286011000001107', ''),
('19298011000001103', ''),
('19359211000001104', ''),
('24366511000001100', ''),
('19512011000001105', ''),
('29673511000001109', ''),
('30220211000001100', ''),
('19837511000001107', ''),
('29890211000001100', ''),
('19178911000001107', ''),
('22070611000001101', ''),
('324633007', ''),
('19359511000001101', ''),
('21285711000001101', ''),
('19296611000001109', ''),
('19358511000001107', ''),
('24366211000001103', ''),
('19511711000001100', ''),
('29673211000001106', ''),
('37098711000001101', ''),
('19837211000001109', ''),
('29889711000001104', ''),
('19178611000001101', ''),
('22070311000001106', ''),
('36038911000001106', ''),
('19359011000001109', ''),
('34754611000001101', ''),
('19448711000001105', ''),
('19447411000001103', ''),
('19447611000001100', ''),
('38236111000001105', ''),
('35831811000001105', ''),
('21660611000001102', ''),
('23108311000001101', ''),
('24416711000001100', ''),
('38745711000001107', ''),
('36571111000001100', ''),
('22985411000001109', ''),
('34611911000001109', ''),
('3078311000001102', ''),
('3077511000001109', ''),
('4602911000001104', ''),
('19374111000001107', ''),
('19374511000001103', ''),
('28922411000001103', ''),
('408015000', ''),
('24919311000001109', ''),
('24683911000001108', ''),
('24775911000001105', ''),
('38618511000001108', ''),
('37453311000001107', ''),
('30834211000001104', ''),
('28697411000001107', ''),
('29927511000001104', ''),
('24673211000001107', ''),
('16756911000001108', ''),
('25876211000001100', ''),
('36571311000001103', ''),
('36881911000001109', ''),
('36028511000001101', ''),
('36003311000001109', ''),
('35992311000001106', ''),
('4360711000001109', ''),
('16751911000001103', ''),
('10496311000001104', ''),
('371616001', ''),
('37947311000001104', ''),
('37830711000001109', ''),
('38849511000001101', ''),
('3691811000001100', ''),
('324570005', ''),
('24549911000001107', ''),
('37556911000001106', ''),
('24209111000001106', ''),
('24421611000001107', ''),
('37460411000001104', ''),
('35952811000001109', ''),
('36774211000001109', ''),
('324572002', ''),
('24550111000001102', ''),
('37557111000001106', ''),
('24208911000001101', ''),
('24421811000001106', ''),
('37460611000001101', ''),
('35954211000001104', ''),
('36774511000001107', ''),
('36565611000001103', ''),
('24133311000001100', ''),
('5420911000001103', ''),
('3607611000001105', ''),
('38608611000001105', ''),
('324558006', ''),
('180911000001108', ''),
('884111000001105', ''),
('497811000001101', ''),
('30763811000001109', ''),
('37460811000001102', ''),
('11016111000001104', ''),
('20327411000001106', ''),
('537011000001109', ''),
('30851211000001100', ''),
('9555111000001106', ''),
('17946711000001100', ''),
('29929911000001104', ''),
('4209111000001108', ''),
('21820711000001109', ''),
('324559003', ''),
('637211000001107', ''),
('626211000001108', ''),
('405011000001103', ''),
('30763611000001105', ''),
('37461111000001103', ''),
('11015711000001106', ''),
('20326111000001104', ''),
('277011000001102', ''),
('30851411000001101', ''),
('9555311000001108', ''),
('17946911000001103', ''),
('15111411000001109', ''),
('4221211000001106', ''),
('21821311000001100', ''),
('12862811000001106', ''),
('12862911000001101', ''),
('12820911000001108', ''),
('12820611000001102', ''),
('12864611000001104', ''),
('12864711000001108', ''),
('12829211000001106', ''),
('12828711000001108', ''),
('12904911000001100', ''),
('375489004', ''),
('12902611000001103', ''),
('12902311000001108', ''),
('12935311000001106', ''),
('12935411000001104', ''),
('12917211000001100', ''),
('12916911000001106', ''),
('12934511000001101', ''),
('12934611000001102', ''),
('12914811000001108', ''),
('12914511000001105', ''),
('12894611000001101', ''),
('12894711000001105', ''),
('12892411000001106', ''),
('12891611000001103', ''),
('12935511000001100', ''),
('12935611000001101', ''),
('12917811000001104', ''),
('12917511000001102', ''),
('12864211000001101', ''),
('12864311000001109', ''),
('12825111000001102', ''),
('12824811000001108', ''),
('12863011000001109', ''),
('12863111000001105', ''),
('12821511000001108', ''),
('12821211000001105', ''),
('12863811000001103', ''),
('12863911000001108', ''),
('12823911000001100', ''),
('12823611000001106', ''),
('12904211000001109', ''),
('12904311000001101', ''),
('12899511000001101', ''),
('12898811000001105', ''),
('12935711000001105', ''),
('12935811000001102', ''),
('12918411000001102', ''),
('12918111000001107', ''),
('12936111000001103', ''),
('12936211000001109', ''),
('12919611000001108', ''),
('12919311000001103', ''),
('12933911000001106', ''),
('12934011000001109', ''),
('12912911000001107', ''),
('12912611000001101', ''),
('12937311000001103', ''),
('12937411000001105', ''),
('12923211000001100', ''),
('12922911000001102', ''),
('12936711000001102', ''),
('12936811000001105', ''),
('12921411000001100', ''),
('12921111000001105', ''),
('12905011000001100', ''),
('12905111000001104', ''),
('12903211000001106', ''),
('12902911000001109', ''),
('12904811000001105', ''),
('12904111000001103', ''),
('12898111000001103', ''),
('12897011000001100', ''),
('12863411000001100', ''),
('12863511000001101', ''),
('12822711000001105', ''),
('12822411000001104', ''),
('12904411000001108', ''),
('12904511000001107', ''),
('12901411000001106', ''),
('12901111000001101', ''),
('12894111000001109', ''),
('12894211000001103', ''),
('12889711000001107', ''),
('12889411000001101', ''),
('12864811000001100', ''),
('12864911000001105', ''),
('12830411000001103', ''),
('12829711000001104', ''),
('12936511000001107', ''),
('12936611000001106', ''),
('12920811000001106', ''),
('12920511000001108', ''),
('12936911000001100', ''),
('12937011000001101', ''),
('12922011000001101', ''),
('12921711000001106', ''),
('12935111000001109', ''),
('12935211000001103', ''),
('12916611000001100', ''),
('12916311000001105', ''),
('12934311000001107', ''),
('12934411000001100', ''),
('12914211000001107', ''),
('12913911000001100', ''),
('12894311000001106', ''),
('12894511000001100', ''),
('12890911000001102', ''),
('12890311000001103', ''),
('12935911000001107', ''),
('12936011000001104', ''),
('12919011000001101', ''),
('12918711000001108', ''),
('12863611000001102', ''),
('12863711000001106', ''),
('12823311000001101', ''),
('12823011000001104', ''),
('12937111000001100', ''),
('12937211000001106', ''),
('12922611000001108', ''),
('12922311000001103', ''),
('12934111000001105', ''),
('12934211000001104', ''),
('12913611000001106', ''),
('12913211000001109', ''),
('12934911000001108', ''),
('12935011000001108', ''),
('12916011000001107', ''),
('12915711000001101', ''),
('12864411000001102', ''),
('12864511000001103', ''),
('12828311000001109', ''),
('12827411000001101', ''),
('12934711000001106', ''),
('12934811000001103', ''),
('12915411000001107', ''),
('12915111000001102', ''),
('12904611000001106', ''),
('12904711000001102', ''),
('12902011000001105', ''),
('12901711000001100', ''),
('12895111000001108', ''),
('12894811000001102', ''),
('12894911000001107', ''),
('12893411000001102', ''),
('12864011000001106', ''),
('12864111000001107', ''),
('12824511000001105', ''),
('12824211000001107', ''),
('12863211000001104', ''),
('12863311000001107', ''),
('12822111000001109', ''),
('12821811000001106', ''),
('12893811000001100', ''),
('12894011000001108', ''),
('12889111000001106', ''),
('12888811000001106', ''),
('12936311000001101', ''),
('12936411000001108', ''),
('12920211000001105', ''),
('12919911000001102', ''),
('58211000001101', ''),
('758411000001103', ''),
('3606911000001102', ''),
('623211000001101', ''),
('707311000001101', ''),
('461311000001101', ''),
('32711000001109', ''),
('517311000001102', ''),
('32747111000001108', ''),
('32746911000001108', ''),
('21258811000001107', ''),
('28691111000001109', ''),
('21259011000001106', '')
GO
-- Query for ab_last_date
SELECT * INTO #ab_last_date FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp83_ab_last_date_codelist
ON DMD_ID = #tmp83_ab_last_date_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for broad_ab_prescriptions
CREATE TABLE #tmp84_broad_ab_prescriptions_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp84_broad_ab_prescriptions_codelist (code, category) VALUES
('323509004', ''),
('558111000001107', ''),
('23477711000001105', ''),
('739011000001101', ''),
('145611000001104', ''),
('9785311000001100', ''),
('10380511000001103', ''),
('12948011000001101', ''),
('15981611000001108', ''),
('33680711000001103', ''),
('22608411000001104', ''),
('36932811000001108', ''),
('325811000001107', ''),
('833211000001107', ''),
('29993011000001108', ''),
('38787311000001107', ''),
('19725711000001109', ''),
('19187411000001106', ''),
('413911000001103', ''),
('17779911000001102', ''),
('35591111000001108', ''),
('458811000001108', ''),
('228311000001104', ''),
('29765011000001104', ''),
('361711000001108', ''),
('21764811000001100', ''),
('18145411000001107', ''),
('323510009', ''),
('930411000001106', ''),
('18458211000001102', ''),
('406811000001101', ''),
('116511000001101', ''),
('9785911000001104', ''),
('10381311000001104', ''),
('12948211000001106', ''),
('15981911000001102', ''),
('33680911000001101', ''),
('22608811000001102', ''),
('36933111000001107', ''),
('802011000001104', ''),
('13811000001100', ''),
('29993211000001103', ''),
('38787911000001108', ''),
('19726111000001102', ''),
('19187611000001109', ''),
('816511000001105', ''),
('36693511000001106', ''),
('268011000001106', ''),
('17780311000001103', ''),
('35591411000001103', ''),
('181511000001108', ''),
('53711000001102', ''),
('29769211000001107', ''),
('668411000001104', ''),
('21765611000001103', ''),
('18146111000001108', ''),
('35902111000001107', ''),
('3241411000001109', ''),
('3246511000001104', ''),
('32496011000001107', ''),
('22609211000001108', ''),
('3246011000001107', ''),
('29993711000001105', ''),
('38788311000001108', ''),
('18081411000001108', ''),
('29765411000001108', ''),
('3243811000001105', ''),
('21766011000001101', ''),
('35368511000001109', ''),
('323732002', ''),
('634511000001102', ''),
('159311000001109', ''),
('549011000001104', ''),
('9786511000001104', ''),
('10426911000001105', ''),
('15984311000001100', ''),
('28943411000001109', ''),
('22609411000001107', ''),
('143211000001100', ''),
('329011000001104', ''),
('38785711000001100', ''),
('860211000001109', ''),
('17781111000001106', ''),
('144711000001109', ''),
('856111000001107', ''),
('29769411000001106', ''),
('200311000001108', ''),
('21766511000001109', ''),
('323733007', ''),
('819911000001107', ''),
('256911000001103', ''),
('767611000001107', ''),
('9786911000001106', ''),
('10427411000001100', ''),
('15984511000001106', ''),
('28943611000001107', ''),
('22609811000001109', ''),
('555611000001105', ''),
('213311000001100', ''),
('38787511000001101', ''),
('568411000001107', ''),
('17781711000001107', ''),
('673011000001105', ''),
('828811000001100', ''),
('15065511000001104', ''),
('830011000001107', ''),
('21776211000001103', ''),
('35901911000001104', ''),
('756511000001100', ''),
('623711000001108', ''),
('264811000001108', ''),
('9787111000001106', ''),
('10428011000001105', ''),
('15984711000001101', ''),
('22609611000001105', ''),
('69611000001101', ''),
('416211000001100', ''),
('29993911000001107', ''),
('38785511000001105', ''),
('35852611000001101', ''),
('311000001109', ''),
('17781911000001109', ''),
('35591711000001109', ''),
('709111000001109', ''),
('29764511000001106', ''),
('222511000001108', ''),
('21775811000001105', ''),
('548011000001109', ''),
('328211000001104', ''),
('730511000001101', ''),
('9787311000001108', ''),
('10428411000001101', ''),
('15984911000001104', ''),
('22610011000001109', ''),
('203311000001102', ''),
('693411000001108', ''),
('37033411000001105', ''),
('38787711000001106', ''),
('35852011000001108', ''),
('930911000001103', ''),
('17782111000001101', ''),
('35591911000001106', ''),
('88811000001107', ''),
('29765211000001109', ''),
('520311000001108', ''),
('21776011000001108', ''),
('38726811000001109', ''),
('38719511000001105', ''),
('388611000001105', ''),
('709311000001106', ''),
('234411000001104', ''),
('689711000001103', ''),
('389311000001106', ''),
('3243311000001101', ''),
('196111000001109', ''),
('644811000001100', ''),
('121011000001106', ''),
('774011000001100', ''),
('252511000001109', ''),
('500511000001107', ''),
('19211000001104', ''),
('42011000001106', ''),
('284811000001105', ''),
('2011000001104', ''),
('130111000001103', ''),
('874611000001105', ''),
('190111000001106', ''),
('161011000001103', ''),
('14811000001102', ''),
('7339611000001107', ''),
('7339811000001106', ''),
('323737008', ''),
('90411000001106', ''),
('34748011000001101', ''),
('283611000001108', ''),
('323738003', ''),
('834911000001101', ''),
('34748211000001106', ''),
('719311000001108', ''),
('323739006', ''),
('279111000001107', ''),
('34748411000001105', ''),
('144611000001100', ''),
('388911000001104', ''),
('120411000001106', ''),
('71111000001101', ''),
('323570001', ''),
('875911000001100', ''),
('536211000001101', ''),
('529211000001107', ''),
('10382011000001105', ''),
('28944411000001107', ''),
('13575311000001108', ''),
('30976211000001103', ''),
('698211000001101', ''),
('29994111000001106', ''),
('38788511000001102', ''),
('305911000001106', ''),
('17782311000001104', ''),
('10565411000001109', ''),
('29769811000001108', ''),
('21776411000001104', ''),
('323571002', ''),
('443811000001100', ''),
('578311000001106', ''),
('597311000001103', ''),
('10382211000001100', ''),
('28944611000001105', ''),
('30976411000001104', ''),
('755311000001101', ''),
('29994311000001108', ''),
('38788711000001107', ''),
('217411000001100', ''),
('17782711000001100', ''),
('10565611000001107', ''),
('15066311000001100', ''),
('323584006', ''),
('10355811000001100', ''),
('9725711000001105', ''),
('9505311000001100', ''),
('323572009', ''),
('8169711000001108', ''),
('268411000001102', ''),
('352711000001107', ''),
('24024611000001104', ''),
('938511000001108', ''),
('531211000001109', ''),
('18081811000001105', ''),
('15065711000001109', ''),
('323573004', ''),
('8169911000001105', ''),
('310511000001106', ''),
('45311000001103', ''),
('28927211000001104', ''),
('649511000001104', ''),
('328611000001102', ''),
('18082611000001100', ''),
('15066011000001103', ''),
('850311000001106', ''),
('9385411000001106', ''),
('12778811000001103', ''),
('12778611000001102', ''),
('414211000001105', ''),
('323563001', ''),
('38111000001106', ''),
('19833711000001107', ''),
('382811000001107', ''),
('101911000001100', ''),
('9786711000001109', ''),
('10397411000001104', ''),
('34962611000001109', ''),
('32397711000001104', ''),
('35907111000001109', ''),
('23827411000001108', ''),
('760411000001105', ''),
('12511000001105', ''),
('30016311000001106', ''),
('38848311000001101', ''),
('441311000001108', ''),
('17885811000001104', ''),
('91211000001101', ''),
('35563511000001103', ''),
('882211000001108', ''),
('29794911000001102', ''),
('771411000001107', ''),
('36868011000001101', ''),
('22009111000001105', ''),
('380711000001103', ''),
('36565811000001104', ''),
('829311000001103', ''),
('15515811000001104', ''),
('370711000001105', ''),
('9787711000001107', ''),
('22602311000001108', ''),
('575411000001109', ''),
('276811000001106', ''),
('38850811000001105', ''),
('4817111000001106', ''),
('17885411000001101', ''),
('193411000001109', ''),
('6032711000001109', ''),
('894611000001101', ''),
('22007211000001105', ''),
('323567000', ''),
('18757611000001105', ''),
('34752211000001107', ''),
('10219611000001104', ''),
('36626111000001101', ''),
('10530611000001105', ''),
('5488611000001104', ''),
('323568005', ''),
('19570811000001107', ''),
('34752411000001106', ''),
('37830211000001102', ''),
('10219211000001101', ''),
('30347811000001105', ''),
('36626911000001103', ''),
('10531011000001107', ''),
('5489611000001108', ''),
('37083611000001104', ''),
('732211000001103', ''),
('15516011000001101', ''),
('394111000001107', ''),
('9787911000001109', ''),
('22602511000001102', ''),
('353811000001107', ''),
('526211000001103', ''),
('30016111000001109', ''),
('38848111000001103', ''),
('36492911000001108', ''),
('4817311000001108', ''),
('17885611000001103', ''),
('22211000001104', ''),
('6034811000001107', ''),
('931011000001106', ''),
('22007711000001103', ''),
('3964011000001108', ''),
('7322211000001104', ''),
('13613111000001106', ''),
('24026411000001105', ''),
('23939811000001105', ''),
('31989511000001109', ''),
('24520711000001100', ''),
('38848811000001105', ''),
('7320111000001106', ''),
('28123611000001108', ''),
('29794511000001109', ''),
('22008011000001104', ''),
('7322311000001107', ''),
('11528611000001104', ''),
('24026611000001108', ''),
('23940311000001109', ''),
('31989811000001107', ''),
('24520911000001103', ''),
('38849111000001105', ''),
('7320411000001101', ''),
('28123911000001102', ''),
('29794711000001104', ''),
('22008411000001108', ''),
('323539009', ''),
('290311000001105', ''),
('19833911000001109', ''),
('17668811000001104', ''),
('680711000001105', ''),
('34679211000001108', ''),
('10397711000001105', ''),
('34962811000001108', ''),
('32399711000001107', ''),
('35907311000001106', ''),
('27959011000001105', ''),
('23828211000001108', ''),
('351311000001104', ''),
('785111000001106', ''),
('38848511000001107', ''),
('19728511000001107', ''),
('19199611000001103', ''),
('5629811000001102', ''),
('36695911000001103', ''),
('17886011000001101', ''),
('628011000001104', ''),
('35563911000001105', ''),
('6036511000001103', ''),
('29795111000001101', ''),
('934111000001105', ''),
('36870911000001108', ''),
('22009611000001102', ''),
('3964511000001100', ''),
('37083711000001108', ''),
('11252711000001103', ''),
('19876911000001100', ''),
('32403711000001100', ''),
('30043911000001108', ''),
('32399111000001106', ''),
('38850411000001108', ''),
('19728111000001103', ''),
('23651411000001107', ''),
('22036711000001105', ''),
('15077811000001102', ''),
('392259005', ''),
('28873411000001104', ''),
('28039411000001101', ''),
('32400011000001107', ''),
('27959911000001109', ''),
('30016511000001100', ''),
('29795311000001104', ''),
('94411000001100', ''),
('386811000001108', ''),
('549911000001100', ''),
('871511000001109', ''),
('932211000001108', ''),
('866111000001100', ''),
('292511000001103', ''),
('169511000001107', ''),
('29011000001102', ''),
('139811000001101', ''),
('57911000001109', ''),
('451111000001109', ''),
('618111000001108', ''),
('323624001', ''),
('599611000001103', ''),
('34411000001105', ''),
('728111000001109', ''),
('19818211000001104', ''),
('28922811000001101', ''),
('23857311000001102', ''),
('10292811000001106', ''),
('908411000001104', ''),
('146111000001101', ''),
('30018311000001105', ''),
('38857911000001104', ''),
('773911000001103', ''),
('17888511000001105', ''),
('382411000001105', ''),
('29798411000001101', ''),
('9627311000001106', ''),
('21941711000001107', ''),
('4006211000001100', ''),
('323626004', ''),
('21710711000001103', ''),
('36090611000001106', ''),
('18542211000001108', ''),
('18446411000001102', ''),
('18421711000001100', ''),
('435911000001105', ''),
('473311000001105', ''),
('3098711000001105', ''),
('323999000', ''),
('324000003', ''),
('4597311000001106', ''),
('4597911000001107', ''),
('324003001', ''),
('324004007', ''),
('324005008', ''),
('4626311000001109', ''),
('4626611000001104', ''),
('4627111000001105', ''),
('36458411000001105', ''),
('36458511000001109', ''),
('36456811000001106', ''),
('36457111000001101', ''),
('4457111000001107', ''),
('4452211000001104', ''),
('323935008', ''),
('323936009', ''),
('37987711000001105', ''),
('33631211000001106', ''),
('33627411000001104', ''),
('37986811000001104', ''),
('36515811000001100', ''),
('34800611000001101', ''),
('7654711000001109', ''),
('4981711000001108', ''),
('323791006', ''),
('275011000001109', ''),
('813911000001109', ''),
('10290911000001100', ''),
('636511000001108', ''),
('17826511000001101', ''),
('233911000001105', ''),
('270911000001104', ''),
('323792004', ''),
('4113911000001107', ''),
('10348111000001104', ''),
('25833611000001106', ''),
('31564011000001109', ''),
('890411000001105', ''),
('30008911000001108', ''),
('612411000001100', ''),
('32201411000001108', ''),
('18085911000001103', ''),
('171911000001109', ''),
('323793009', ''),
('4114111000001106', ''),
('8825311000001105', ''),
('25834011000001102', ''),
('31564611000001102', ''),
('5311000001107', ''),
('647311000001100', ''),
('32201711000001102', ''),
('18086111000001107', ''),
('400511000001101', ''),
('323795002', ''),
('744311000001103', ''),
('64011000001107', ''),
('10291411000001104', ''),
('4323911000001106', ''),
('17826711000001106', ''),
('923811000001104', ''),
('15073011000001102', ''),
('459111000001108', ''),
('36134211000001100', ''),
('3663611000001103', ''),
('804411000001101', ''),
('4324111000001105', ''),
('168011000001109', ''),
('36134011000001105', ''),
('37011000001109', ''),
('141511000001101', ''),
('10309911000001103', ''),
('17867211000001105', ''),
('576111000001105', ''),
('36134111000001106', ''),
('745411000001106', ''),
('594511000001101', ''),
('10310111000001109', ''),
('9764411000001109', ''),
('17867411000001109', ''),
('248911000001101', ''),
('793311000001106', ''),
('602211000001101', ''),
('252811000001107', ''),
('583511000001100', ''),
('555211000001108', ''),
('803611000001101', ''),
('531011000001104', ''),
('318811000001107', ''),
('869711000001109', ''),
('323813001', ''),
('7887711000001102', ''),
('5918311000001108', ''),
('19712411000001100', ''),
('30009111000001103', ''),
('38825011000001109', ''),
('17851711000001104', ''),
('8750411000001109', ''),
('4814611000001109', ''),
('15073211000001107', ''),
('21821711000001101', ''),
('323811004', ''),
('323812006', ''),
('323816009', ''),
('674111000001108', ''),
('912111000001109', ''),
('60011000001100', ''),
('304211000001103', ''),
('323973007', ''),
('36134411000001101', ''),
('370375008', ''),
('34762811000001103', ''),
('511411000001101', ''),
('3184511000001101', ''),
('323824004', ''),
('13611511000001101', ''),
('34750011000001101', ''),
('4532811000001108', ''),
('27971011000001109', ''),
('4532411000001106', ''),
('323825003', ''),
('13611811000001103', ''),
('34749811000001100', ''),
('3940811000001102', ''),
('27969111000001102', ''),
('36516011000001102', ''),
('3940211000001103', ''),
('4558311000001100', ''),
('13612211000001106', ''),
('4533911000001105', ''),
('27969611000001105', ''),
('36516211000001107', ''),
('4533711000001108', ''),
('4532011000001102', ''),
('3939811000001107', ''),
('4533411000001102', ''),
('323829009', ''),
('28788511000001103', ''),
('34800911000001107', ''),
('323830004', ''),
('28788811000001100', ''),
('34801211000001109', ''),
('4375311000001105', ''),
('4376311000001100', ''),
('37528311000001105', ''),
('37529711000001100', ''),
('323982001', ''),
('35369711000001108', ''),
('3929911000001104', ''),
('3930911000001108', ''),
('323989005', ''),
('13612411000001105', ''),
('34750811000001107', ''),
('23047711000001101', ''),
('27971211000001104', ''),
('323990001', ''),
('3977811000001102', ''),
('34751011000001105', ''),
('37336711000001105', ''),
('3978511000001101', ''),
('22824911000001102', ''),
('36516811000001108', ''),
('11400311000001106', ''),
('38564411000001109', ''),
('20100211000001107', ''),
('36541011000001102', ''),
('32483211000001108', ''),
('3978011000001109', ''),
('323991002', ''),
('23414711000001106', ''),
('36517011000001104', ''),
('4405611000001104', ''),
('34751211000001100', ''),
('4406311000001104', ''),
('20100411000001106', ''),
('36783811000001102', ''),
('32483411000001107', ''),
('4406011000001102', ''),
('4404611000001100', ''),
('3978911000001108', ''),
('4406611000001109', ''),
('323853003', ''),
('10188511000001108', ''),
('34750211000001106', ''),
('36537311000001106', ''),
('8744311000001107', ''),
('19837811000001105', ''),
('32483611000001105', ''),
('323854009', ''),
('10188111000001104', ''),
('34750411000001105', ''),
('36760611000001107', ''),
('8745211000001103', ''),
('23055511000001100', ''),
('36516411000001106', ''),
('19843211000001101', ''),
('36540611000001104', ''),
('32483811000001109', ''),
('9470311000001109', ''),
('323855005', ''),
('10188311000001102', ''),
('34750611000001108', ''),
('36611411000001109', ''),
('8745411000001104', ''),
('23057711000001104', ''),
('36516611000001109', ''),
('19842311000001104', ''),
('36540811000001100', ''),
('32484011000001101', ''),
('9470511000001103', ''),
('323852008', ''),
('323849000', ''),
('35798511000001105', ''),
('4373011000001106', ''),
('4374011000001108', ''),
('3930311000001107', ''),
('4374611000001101', ''),
('4375711000001109', ''),
('10283311000001108', ''),
('4374311000001106', ''),
('3930711000001106', ''),
('4374911000001107', ''),
('323880005', ''),
('4740011000001101', ''),
('34751411000001101', ''),
('36754511000001105', ''),
('36134711000001107', ''),
('3939111000001100', ''),
('11617911000001109', ''),
('36613111000001103', ''),
('36605111000001104', ''),
('36754311000001104', ''),
('4557611000001106', ''),
('4530611000001108', ''),
('11617611000001103', ''),
('36613311000001101', ''),
('36605311000001102', ''),
('36753811000001105', ''),
('4740211000001106', ''),
('3939311000001103', ''),
('4530311000001103', ''),
('11775211000001105', ''),
('11775411000001109', ''),
('11775611000001107', ''),
('323868002', ''),
('323869005', ''),
('10096411000001100', ''),
('10271811000001105', ''),
('19712711000001106', ''),
('30011011000001101', ''),
('38826311000001102', ''),
('17853111000001104', ''),
('9547111000001104', ''),
('15074511000001108', ''),
('10885511000001106', ''),
('13743011000001107', ''),
('21831411000001105', ''),
('323872003', ''),
('323874002', ''),
('228011000001102', ''),
('211911000001100', ''),
('238811000001105', ''),
('3253511000001109', ''),
('323883007', ''),
('716611000001106', ''),
('34811000001107', ''),
('606011000001105', ''),
('10388711000001105', ''),
('22631111000001107', ''),
('37509711000001109', ''),
('3611000001101', ''),
('763611000001104', ''),
('27996311000001105', ''),
('30009611000001106', ''),
('38826011000001100', ''),
('19187811000001108', ''),
('216811000001100', ''),
('9376611000001109', ''),
('17851911000001102', ''),
('612311000001107', ''),
('29782311000001109', ''),
('758111000001108', ''),
('21822811000001100', ''),
('323884001', ''),
('660211000001101', ''),
('596511000001107', ''),
('324911000001101', ''),
('10388911000001107', ''),
('22631511000001103', ''),
('37510111000001100', ''),
('648411000001106', ''),
('850211000001103', ''),
('27996611000001100', ''),
('30010111000001106', ''),
('38826411000001109', ''),
('19188011000001101', ''),
('86911000001101', ''),
('9376411000001106', ''),
('17852111000001105', ''),
('305811000001101', ''),
('29782711000001108', ''),
('587511000001105', ''),
('21823311000001104', ''),
('323887008', ''),
('639611000001104', ''),
('640011000001104', ''),
('534211000001106', ''),
('10456111000001106', ''),
('22631711000001108', ''),
('37510911000001102', ''),
('34311000001103', ''),
('30010411000001101', ''),
('38825611000001102', ''),
('560011000001100', ''),
('18086311000001109', ''),
('233111000001107', ''),
('15073911000001103', ''),
('6211000001105', ''),
('21826411000001101', ''),
('323888003', ''),
('800711000001101', ''),
('707211000001109', ''),
('158511000001109', ''),
('10456311000001108', ''),
('30136211000001103', ''),
('37510711000001104', ''),
('835511000001109', ''),
('30010611000001103', ''),
('38827711000001100', ''),
('887911000001102', ''),
('18086511000001103', ''),
('728211000001103', ''),
('15074111000001104', ''),
('344611000001109', ''),
('21826611000001103', ''),
('36134311000001108', ''),
('30769411000001109', ''),
('31565211000001103', ''),
('8825611000001100', ''),
('32202211000001102', ''),
('15074311000001102', ''),
('21825911000001102', ''),
('323885000', ''),
('719911000001109', ''),
('924811000001101', ''),
('600911000001106', ''),
('10389111000001102', ''),
('22631911000001105', ''),
('37510511000001109', ''),
('360811000001108', ''),
('483611000001107', ''),
('427011000001102', ''),
('11267511000001101', ''),
('17852311000001107', ''),
('232811000001108', ''),
('15052511000001101', ''),
('362911000001104', ''),
('21827211000001103', ''),
('323886004', ''),
('652611000001105', ''),
('149411000001104', ''),
('863911000001108', ''),
('10389411000001107', ''),
('22632111000001102', ''),
('37510311000001103', ''),
('887511000001109', ''),
('331411000001105', ''),
('38824911000001109', ''),
('452411000001109', ''),
('11267711000001106', ''),
('17852511000001101', ''),
('687811000001103', ''),
('29782911000001105', ''),
('199411000001106', ''),
('21830211000001100', ''),
('4865011000001104', ''),
('35227111000001103', ''),
('35210711000001106', ''),
('19188211000001106', ''),
('11267111000001105', ''),
('4861711000001104', ''),
('4515811000001108', ''),
('35215211000001108', ''),
('35210911000001108', ''),
('19188411000001105', ''),
('11267311000001107', ''),
('4514011000001101', ''),
('904711000001102', ''),
('343411000001108', ''),
('474311000001107', ''),
('471811000001100', ''),
('96011000001104', ''),
('875311000001101', ''),
('3234011000001103', ''),
('733011000001104', ''),
('362611000001105', ''),
('91011000001106', ''),
('622911000001103', ''),
('691711000001103', ''),
('757911000001105', ''),
('323944009', ''),
('441611000001103', ''),
('48711000001106', ''),
('13576111000001100', ''),
('266111000001108', ''),
('821811000001106', ''),
('38825311000001107', ''),
('141011000001109', ''),
('17852711000001106', ''),
('231211000001100', ''),
('29783111000001101', ''),
('601211000001108', ''),
('21830611000001103', ''),
('323945005', ''),
('810111000001104', ''),
('277711000001100', ''),
('22632411000001107', ''),
('88011000001101', ''),
('332811000001103', ''),
('30010811000001104', ''),
('38825511000001101', ''),
('688511000001102', ''),
('17852911000001108', ''),
('750911000001109', ''),
('29783311000001104', ''),
('392711000001103', ''),
('21831111000001100', ''),
('323947002', ''),
('323948007', ''),
('36134511000001102', ''),
('705811000001100', ''),
('8911000001102', ''),
('3466111000001104', ''),
('795711000001106', ''),
('14511000001100', ''),
('435511000001103', ''),
('769211000001104', ''),
('324343004', ''),
('28963111000001109', ''),
('34711611000001107', ''),
('35306811000001105', ''),
('35834011000001101', ''),
('26812711000001104', ''),
('23021211000001100', ''),
('35247011000001102', ''),
('18486711000001104', ''),
('38009511000001105', ''),
('37655611000001101', ''),
('324344005', ''),
('29714711000001100', ''),
('34711811000001106', ''),
('35306611000001106', ''),
('35829511000001105', ''),
('26812911000001102', ''),
('23049211000001102', ''),
('35246811000001106', ''),
('18486011000001101', ''),
('38009811000001108', ''),
('37656911000001100', ''),
('32391011000001106', ''),
('4382011000001108', ''),
('4381711000001103', ''),
('4792411000001101', ''),
('36691911000001100', ''),
('38564211000001105', ''),
('4779811000001104', ''),
('428353009', ''),
('14236111000001106', ''),
('4396211000001103', ''),
('24416411000001106', ''),
('24200611000001109', ''),
('36568011000001102', ''),
('22980411000001102', ''),
('18852711000001100', ''),
('323970005', ''),
('4391811000001107', ''),
('4392111000001105', ''),
('4391611000001108', ''),
('324607004', ''),
('170311000001103', ''),
('19834111000001108', ''),
('18460011000001101', ''),
('624611000001101', ''),
('211411000001108', ''),
('9795711000001102', ''),
('10393211000001107', ''),
('15988911000001106', ''),
('19713611000001107', ''),
('11017911000001103', ''),
('7426211000001108', ''),
('810711000001103', ''),
('254711000001109', ''),
('38834811000001101', ''),
('19729511000001101', ''),
('38794711000001100', ''),
('317211000001107', ''),
('36574211000001108', ''),
('10442211000001104', ''),
('11401111000001103', ''),
('17858211000001102', ''),
('827711000001107', ''),
('485011000001104', ''),
('15077111000001109', ''),
('368511000001108', ''),
('18280611000001105', ''),
('370811000001102', ''),
('13743811000001101', ''),
('36840911000001109', ''),
('21852511000001102', ''),
('826011000001107', ''),
('36140911000001100', ''),
('11546011000001109', ''),
('8967411000001108', ''),
('36570411000001101', ''),
('22982111000001106', ''),
('324606008', ''),
('625611000001100', ''),
('19834311000001105', ''),
('18460411000001105', ''),
('920811000001106', ''),
('238711000001102', ''),
('9785111000001102', ''),
('10393511000001105', ''),
('15989111000001101', ''),
('648911000001103', ''),
('19713911000001101', ''),
('11018811000001107', ''),
('7426411000001107', ''),
('491511000001105', ''),
('2511000001107', ''),
('38835111000001107', ''),
('19729711000001106', ''),
('38715111000001103', ''),
('823711000001102', ''),
('36574711000001101', ''),
('36696711000001108', ''),
('11401511000001107', ''),
('17858511000001104', ''),
('735711000001101', ''),
('327011000001108', ''),
('15077911000001107', ''),
('938011000001100', ''),
('18280811000001109', ''),
('62011000001101', ''),
('13744011000001109', ''),
('36841511000001109', ''),
('21853011000001101', ''),
('15261211000001108', ''),
('324600002', ''),
('675411000001102', ''),
('227611000001105', ''),
('130511000001107', ''),
('17964311000001102', ''),
('15988711000001109', ''),
('19713411000001109', ''),
('11017111000001101', ''),
('780711000001102', ''),
('38834611000001100', ''),
('36575111000001103', ''),
('17858011000001107', ''),
('926611000001109', ''),
('15076711000001107', ''),
('671111000001105', ''),
('799111000001107', ''),
('36839911000001104', ''),
('324605007', ''),
('366711000001102', ''),
('19833511000001102', ''),
('23483711000001106', ''),
('469011000001100', ''),
('872511000001101', ''),
('17964511000001108', '')
GO
INSERT INTO #tmp84_broad_ab_prescriptions_codelist (code, category) VALUES
('10393811000001108', ''),
('15989311000001104', ''),
('19714211000001108', ''),
('11019511000001103', ''),
('7426611000001105', ''),
('849311000001100', ''),
('271111000001108', ''),
('38835411000001102', ''),
('19730111000001102', ''),
('38715311000001101', ''),
('36574511000001106', ''),
('11402111000001108', ''),
('17858811000001101', ''),
('935711000001105', ''),
('868011000001102', ''),
('15078411000001100', ''),
('630111000001102', ''),
('18281011000001107', ''),
('591811000001100', ''),
('13744211000001104', ''),
('36841911000001102', ''),
('21853311000001103', ''),
('9207911000001103', ''),
('12020311000001106', ''),
('11980911000001105', ''),
('12019511000001104', ''),
('11975011000001109', ''),
('12020511000001100', ''),
('11972111000001103', ''),
('12019611000001100', ''),
('11975511000001101', ''),
('12020611000001101', ''),
('11972711000001102', ''),
('12020811000001102', ''),
('11973911000001107', ''),
('12020711000001105', ''),
('11973311000001106', ''),
('12019911000001106', ''),
('11977411000001106', ''),
('8973011000001101', ''),
('28040911000001104', ''),
('36570611000001103', ''),
('22983111000001100', ''),
('34611511000001102', ''),
('12020211000001103', ''),
('11980311000001109', ''),
('12020011000001108', ''),
('11978711000001104', ''),
('12020911000001107', ''),
('11974611000001103', ''),
('36141011000001108', ''),
('35515811000001102', ''),
('11761311000001107', ''),
('36141511000001100', ''),
('32775511000001107', ''),
('35516111000001103', ''),
('35831211000001109', ''),
('11761811000001103', ''),
('324602005', ''),
('12020411000001104', ''),
('11971311000001105', ''),
('12019711000001109', ''),
('11976011000001100', ''),
('12019811000001101', ''),
('11976411000001109', ''),
('12020111000001109', ''),
('11979311000001109', ''),
('10892711000001106', ''),
('18756911000001102', ''),
('34648611000001102', ''),
('34532811000001105', ''),
('10889411000001105', ''),
('10892811000001103', ''),
('11528211000001101', ''),
('13793511000001105', ''),
('34648911000001108', ''),
('34533011000001108', ''),
('10889711000001104', ''),
('10892911000001108', ''),
('11528411000001102', ''),
('13793711000001100', ''),
('34649111000001103', ''),
('10890011000001105', ''),
('455911000001109', ''),
('417611000001101', ''),
('162511000001103', ''),
('661311000001104', ''),
('902411000001101', ''),
('8951511000001108', ''),
('8954311000001104', ''),
('785511000001102', ''),
('854011000001101', ''),
('3492511000001109', ''),
('324579006', ''),
('19681911000001107', ''),
('26854011000001101', ''),
('19172111000001106', ''),
('324578003', ''),
('35445511000001100', ''),
('36028911000001108', ''),
('3683611000001101', ''),
('4058911000001101', ''),
('4059711000001107', ''),
('3852811000001105', ''),
('324612003', ''),
('465511000001105', ''),
('527011000001106', ''),
('16062011000001100', ''),
('37463211000001108', ''),
('724511000001107', ''),
('30852711000001100', ''),
('4273411000001105', ''),
('7464011000001104', ''),
('319311000001109', ''),
('15112111000001109', ''),
('792611000001106', ''),
('21821611000001105', ''),
('324620001', ''),
('238911000001100', ''),
('412511000001103', ''),
('16062211000001105', ''),
('37463811000001109', ''),
('787111000001102', ''),
('30853111000001107', ''),
('4818111000001107', ''),
('7464911000001100', ''),
('525111000001103', ''),
('15112411000001104', ''),
('339611000001109', ''),
('38752711000001101', ''),
('12905211000001105', ''),
('12895811000001101', ''),
('12897211000001105', ''),
('12896211000001108', ''),
('12905311000001102', ''),
('12905411000001109', ''),
('12898411000001108', ''),
('12897811000001106', ''),
('362511000001106', ''),
('491611000001109', ''),
('4415111000001109', ''),
('324621002', ''),
('822711000001105', ''),
('254211000001102', ''),
('511511000001102', ''),
('739911000001102', ''),
('17947511000001107', ''),
('35549811000001106', ''),
('18745111000001108', ''),
('21816311000001102', ''),
('866311000001103', ''),
('324634001', ''),
('19359911000001108', ''),
('21286011000001107', ''),
('19298011000001103', ''),
('19359211000001104', ''),
('24366511000001100', ''),
('19512011000001105', ''),
('29673511000001109', ''),
('30220211000001100', ''),
('19837511000001107', ''),
('29890211000001100', ''),
('19178911000001107', ''),
('22070611000001101', ''),
('324633007', ''),
('19359511000001101', ''),
('21285711000001101', ''),
('19296611000001109', ''),
('19358511000001107', ''),
('24366211000001103', ''),
('19511711000001100', ''),
('29673211000001106', ''),
('37098711000001101', ''),
('19837211000001109', ''),
('29889711000001104', ''),
('19178611000001101', ''),
('22070311000001106', ''),
('36038911000001106', ''),
('19359011000001109', ''),
('34754611000001101', ''),
('19448711000001105', ''),
('19447411000001103', ''),
('19447611000001100', ''),
('38236111000001105', ''),
('35831811000001105', ''),
('21660611000001102', ''),
('23108311000001101', ''),
('24416711000001100', ''),
('38745711000001107', ''),
('36571111000001100', ''),
('22985411000001109', ''),
('34611911000001109', ''),
('32522511000001104', ''),
('3078311000001102', ''),
('3077511000001109', ''),
('4602911000001104', ''),
('19374111000001107', ''),
('19374511000001103', ''),
('28922411000001103', ''),
('32507311000001103', ''),
('408015000', ''),
('24919311000001109', ''),
('24683911000001108', ''),
('24775911000001105', ''),
('38618511000001108', ''),
('37453311000001107', ''),
('30834211000001104', ''),
('28697411000001107', ''),
('29927511000001104', ''),
('24673211000001107', ''),
('16756911000001108', ''),
('25876211000001100', ''),
('36571311000001103', ''),
('36881911000001109', ''),
('36028511000001101', ''),
('36003311000001109', ''),
('35992311000001106', ''),
('4360711000001109', ''),
('16751911000001103', ''),
('10496311000001104', '')
GO
-- Query for broad_ab_prescriptions
SELECT * INTO #broad_ab_prescriptions FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
COUNT(*) AS number_of_matches_in_period,
MAX(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp84_broad_ab_prescriptions_codelist
ON DMD_ID = #tmp84_broad_ab_prescriptions_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(DAY, -1137, #patient_index_date.patient_index_date) AND DATEADD(DAY, -42, #patient_index_date.patient_index_date)
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for ethnicity
CREATE TABLE #tmp85_ethnicity_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp85_ethnicity_codelist (code, category) VALUES
('110761000000106', '1'),
('494131000000105', '1'),
('92391000000108', '1'),
('92541000000108', '1'),
('92551000000106', '1'),
('92561000000109', '1'),
('92571000000102', '1'),
('93921000000101', '1'),
('494161000000100', '1'),
('92401000000106', '1'),
('110401000000103', '1'),
('88911000000101', '1'),
('88921000000107', '1'),
('88931000000109', '1'),
('88941000000100', '1'),
('88951000000102', '1'),
('88961000000104', '1'),
('88971000000106', '1'),
('88981000000108', '1'),
('92411000000108', '1'),
('92791000000109', '1'),
('93931000000104', '1'),
('93941000000108', '1'),
('93951000000106', '1'),
('93961000000109', '1'),
('93981000000100', '1'),
('93991000000103', '1'),
('94001000000108', '1'),
('94011000000105', '1'),
('94021000000104', '1'),
('94031000000102', '1'),
('94041000000106', '1'),
('94051000000109', '1'),
('92421000000102', '2'),
('92431000000100', '2'),
('92441000000109', '2'),
('110771000000104', '2'),
('92451000000107', '2'),
('92581000000100', '2'),
('92591000000103', '2'),
('92601000000109', '2'),
('92611000000106', '2'),
('92621000000100', '2'),
('92631000000103', '2'),
('92721000000106', '2'),
('110751000000108', '3'),
('92461000000105', '3'),
('92471000000103', '3'),
('110781000000102', '3'),
('86461000000107', '3'),
('92481000000101', '3'),
('92641000000107', '3'),
('92651000000105', '3'),
('92661000000108', '3'),
('92671000000101', '3'),
('92681000000104', '3'),
('92691000000102', '3'),
('92701000000102', '3'),
('92751000000101', '3'),
('92761000000103', '3'),
('92771000000105', '3'),
('92781000000107', '3'),
('107691000000105', '4'),
('92491000000104', '4'),
('92711000000100', '4'),
('92731000000108', '4'),
('110791000000100', '4'),
('92501000000105', '4'),
('92741000000104', '4'),
('92511000000107', '5'),
('89001000000105', '5'),
('89011000000107', '5'),
('89021000000101', '5'),
('92521000000101', '5'),
('94061000000107', '5'),
('94071000000100', '5'),
('94081000000103', '5'),
('94091000000101', '5'),
('94101000000109', '5'),
('94111000000106', '5'),
('94121000000100', '5'),
('94151000000105', '5')
GO
-- Query for ethnicity
SELECT * INTO #ethnicity FROM (
SELECT
Patient_ID AS patient_id,
category AS category,
ConsultationDate AS date
FROM (
SELECT CodedEvent_SNOMED.Patient_ID, category, ConsultationDate,
ROW_NUMBER() OVER (
PARTITION BY CodedEvent_SNOMED.Patient_ID
ORDER BY ConsultationDate DESC, CodedEvent_SNOMED.CodedEvent_ID
) AS rownum
FROM CodedEvent_SNOMED
INNER JOIN #tmp85_ethnicity_codelist
ON ConceptID = #tmp85_ethnicity_codelist.code
WHERE 1=1
AND NOT 0 = 1
AND 1 = 1
) t
WHERE rownum = 1
) t
GO
-- Uploading codelist for care_home
CREATE TABLE #tmp86_care_home_codelist (
code VARCHAR(16) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp86_care_home_codelist (code, category) VALUES
('1024771000000108', ''),
('160734000', ''),
('160737007', ''),
('224224003', ''),
('248171000000108', ''),
('394923006', '')
GO
-- Query for care_home
SELECT * INTO #care_home FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp86_care_home_codelist
ON ConceptID = #tmp86_care_home_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate <= #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Query for index_of_multiple_deprivation
SELECT * INTO #index_of_multiple_deprivation FROM (
SELECT
t.Patient_ID AS patient_id,
ImdRankRounded AS index_of_multiple_deprivation
FROM (
SELECT PatientAddress.Patient_ID, ImdRankRounded,
ROW_NUMBER() OVER (
PARTITION BY PatientAddress.Patient_ID
ORDER BY
StartDate DESC,
EndDate DESC,
IIF(MSOACode = 'NPC', 1, 0),
PatientAddress_ID
) AS rownum
FROM PatientAddress
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = PatientAddress.patient_id
WHERE StartDate <= #patient_index_date.patient_index_date AND EndDate > #patient_index_date.patient_index_date
) t
WHERE rownum = 1
) t
GO
-- Query for practice
SELECT * INTO #practice FROM (
SELECT
t.Patient_ID AS patient_id,
Organisation.Organisation_ID AS pseudo_id
FROM (
SELECT RegistrationHistory.Patient_ID, Organisation_ID,
ROW_NUMBER() OVER (
PARTITION BY RegistrationHistory.Patient_ID
ORDER BY StartDate DESC, EndDate DESC, Registration_ID
) AS rownum
FROM RegistrationHistory
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = RegistrationHistory.patient_id
WHERE StartDate <= #patient_index_date.patient_index_date AND EndDate > #patient_index_date.patient_index_date
) t
LEFT JOIN Organisation
ON Organisation.Organisation_ID = t.Organisation_ID
WHERE t.rownum = 1
) t
GO
-- Query for region
SELECT * INTO #region FROM (
SELECT
t.Patient_ID AS patient_id,
Organisation.Region AS nuts1_region_name
FROM (
SELECT RegistrationHistory.Patient_ID, Organisation_ID,
ROW_NUMBER() OVER (
PARTITION BY RegistrationHistory.Patient_ID
ORDER BY StartDate DESC, EndDate DESC, Registration_ID
) AS rownum
FROM RegistrationHistory
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = RegistrationHistory.patient_id
WHERE StartDate <= #patient_index_date.patient_index_date AND EndDate > #patient_index_date.patient_index_date
) t
LEFT JOIN Organisation
ON Organisation.Organisation_ID = t.Organisation_ID
WHERE t.rownum = 1
) t
GO
-- Query for bmi
SELECT * INTO #bmi FROM (
SELECT
patients.Patient_ID AS patient_id,
ROUND(COALESCE(weight/SQUARE(NULLIF(height, 0)), bmis.BMI), 1) AS value,
CASE
WHEN weight IS NULL OR height IS NULL THEN bmis.ConsultationDate
ELSE weights.ConsultationDate
END AS date
FROM (
SELECT Patient_ID, DateOfBirth
FROM Patient
) AS patients
LEFT JOIN (
SELECT t.Patient_ID, t.weight, t.ConsultationDate
FROM (
SELECT CodedEvent.Patient_ID, NumericValue AS weight, ConsultationDate,
ROW_NUMBER() OVER (
PARTITION BY CodedEvent.Patient_ID ORDER BY ConsultationDate DESC, CodedEvent_ID
) AS rownum
FROM CodedEvent
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE CTV3Code IN ('X76C7','22A..') AND ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
) t
WHERE t.rownum = 1
) AS weights
ON weights.Patient_ID = patients.Patient_ID AND DATEDIFF(YEAR, patients.DateOfBirth, weights.ConsultationDate) >= 18
LEFT JOIN (
SELECT t.Patient_ID, t.height, t.ConsultationDate
FROM (
SELECT CodedEvent.Patient_ID, NumericValue AS height, ConsultationDate,
ROW_NUMBER() OVER (
PARTITION BY CodedEvent.Patient_ID ORDER BY ConsultationDate DESC, CodedEvent_ID
) AS rownum
FROM CodedEvent
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE CTV3Code IN ('XM01E','229..') AND ConsultationDate <= #patient_index_date.patient_index_date
) t
WHERE t.rownum = 1
) AS heights
ON heights.Patient_ID = patients.Patient_ID AND DATEDIFF(YEAR, patients.DateOfBirth, heights.ConsultationDate) >= 18
LEFT JOIN (
SELECT t.Patient_ID, t.BMI, t.ConsultationDate
FROM (
SELECT CodedEvent.Patient_ID, NumericValue AS BMI, ConsultationDate,
ROW_NUMBER() OVER (
PARTITION BY CodedEvent.Patient_ID ORDER BY ConsultationDate DESC, CodedEvent_ID
) AS rownum
FROM CodedEvent
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE CTV3Code = '22K..' AND ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
) t
WHERE t.rownum = 1
) AS bmis
ON bmis.Patient_ID = patients.Patient_ID AND DATEDIFF(YEAR, patients.DateOfBirth, bmis.ConsultationDate) >= 18
-- XXX maybe add a "WHERE NULL..." here
) t
GO
-- Uploading codelist for most_recent_smoking_code
CREATE TABLE #tmp87_most_recent_smoking_code_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp87_most_recent_smoking_code_codelist (code, category) VALUES
('1377.', 'E'),
('1378.', 'E'),
('1379.', 'E'),
('137A.', 'E'),
('137B.', 'E'),
('137F.', 'E'),
('137K.', 'E'),
('137N.', 'E'),
('137O.', 'E'),
('137T.', 'E'),
('137l.', 'E'),
('Ub0p1', 'E'),
('Ub1na', 'E'),
('XE0oj', 'E'),
('XE0ok', 'E'),
('XE0ol', 'E'),
('XE0om', 'E'),
('XE0on', 'E'),
('XE0op', 'E'),
('Xa1bv', 'E'),
('XaQ8V', 'E'),
('XaQUI', 'E'),
('XaQzw', 'E'),
('XaXP6', 'E'),
('XaXP8', 'E'),
('XaXP9', 'E'),
('Y0984', 'E'),
('Y1152', 'E'),
('Y1153', 'E'),
('Y6626', 'E'),
('Y6627', 'E'),
('Y6628', 'E'),
('1371.', 'N'),
('137L.', 'N'),
('Ub0oq', 'N'),
('XE0oh', 'N'),
('XaQUC', 'N'),
('XaXYo', 'N'),
('Y0993', 'N'),
('Y099f', 'N'),
('Y09a0', 'S'),
('1372.', 'S'),
('1373.', 'S'),
('1374.', 'S'),
('1375.', 'S'),
('1376.', 'S'),
('137H.', 'S'),
('137J.', 'S'),
('137M.', 'S'),
('137P.', 'S'),
('137Q.', 'S'),
('137R.', 'S'),
('E251.', 'S'),
('E2510', 'S'),
('E2511', 'S'),
('E2512', 'S'),
('E251z', 'S'),
('Eu17.', 'S'),
('Eu170', 'S'),
('Eu171', 'S'),
('Eu172', 'S'),
('Eu175', 'S'),
('Eu176', 'S'),
('Eu177', 'S'),
('Eu17y', 'S'),
('Eu17z', 'S'),
('H3101', 'S'),
('Ua2Cl', 'S'),
('Ub1tR', 'S'),
('Ub1tS', 'S'),
('Ub1tT', 'S'),
('Ub1tU', 'S'),
('Ub1tV', 'S'),
('Ub1tW', 'S'),
('X20Qm', 'S'),
('XE0oi', 'S'),
('XE0oq', 'S'),
('XE0or', 'S'),
('XE1b4', 'S'),
('XaBSp', 'S'),
('XaIIu', 'S'),
('XaIkW', 'S'),
('XaIkX', 'S'),
('XaIkY', 'S'),
('XaItg', 'S'),
('XaJX2', 'S'),
('XaLQh', 'S'),
('XaQUB', 'S'),
('XaWNE', 'S'),
('XagO3', 'S'),
('Y0983', 'S'),
('Y0994', 'S'),
('Y19d7', 'S'),
('Y2869', 'S'),
('Y3985', 'S'),
('Y7110', 'S'),
('Y7467', 'S'),
('Y7677', 'S'),
('Y9843', 'S'),
('YA602', 'S'),
('ZV6D8', 'S')
GO
-- Query for most_recent_smoking_code
SELECT * INTO #most_recent_smoking_code FROM (
SELECT
Patient_ID AS patient_id,
category AS category,
ConsultationDate AS date
FROM (
SELECT CodedEvent.Patient_ID, category, ConsultationDate,
ROW_NUMBER() OVER (
PARTITION BY CodedEvent.Patient_ID
ORDER BY ConsultationDate DESC, CodedEvent.CodedEvent_ID
) AS rownum
FROM CodedEvent
INNER JOIN #tmp87_most_recent_smoking_code_codelist
ON CTV3Code = #tmp87_most_recent_smoking_code_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate <= #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
) t
WHERE rownum = 1
) t
GO
-- Uploading codelist for ever_smoked
CREATE TABLE #tmp88_ever_smoked_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp88_ever_smoked_codelist (code, category) VALUES
('1377.', 'E'),
('1378.', 'E'),
('1379.', 'E'),
('137A.', 'E'),
('137B.', 'E'),
('137F.', 'E'),
('137K.', 'E'),
('137N.', 'E'),
('137O.', 'E'),
('137T.', 'E'),
('137l.', 'E'),
('Ub0p1', 'E'),
('Ub1na', 'E'),
('XE0oj', 'E'),
('XE0ok', 'E'),
('XE0ol', 'E'),
('XE0om', 'E'),
('XE0on', 'E'),
('XE0op', 'E'),
('Xa1bv', 'E'),
('XaQ8V', 'E'),
('XaQUI', 'E'),
('XaQzw', 'E'),
('XaXP6', 'E'),
('XaXP8', 'E'),
('XaXP9', 'E'),
('Y0984', 'E'),
('Y1152', 'E'),
('Y1153', 'E'),
('Y6626', 'E'),
('Y6627', 'E'),
('Y6628', 'E'),
('Y09a0', 'S'),
('1372.', 'S'),
('1373.', 'S'),
('1374.', 'S'),
('1375.', 'S'),
('1376.', 'S'),
('137H.', 'S'),
('137J.', 'S'),
('137M.', 'S'),
('137P.', 'S'),
('137Q.', 'S'),
('137R.', 'S'),
('E251.', 'S'),
('E2510', 'S'),
('E2511', 'S'),
('E2512', 'S'),
('E251z', 'S'),
('Eu17.', 'S'),
('Eu170', 'S'),
('Eu171', 'S'),
('Eu172', 'S'),
('Eu175', 'S'),
('Eu176', 'S'),
('Eu177', 'S'),
('Eu17y', 'S'),
('Eu17z', 'S'),
('H3101', 'S'),
('Ua2Cl', 'S'),
('Ub1tR', 'S'),
('Ub1tS', 'S'),
('Ub1tT', 'S'),
('Ub1tU', 'S'),
('Ub1tV', 'S'),
('Ub1tW', 'S'),
('X20Qm', 'S'),
('XE0oi', 'S'),
('XE0oq', 'S'),
('XE0or', 'S'),
('XE1b4', 'S'),
('XaBSp', 'S'),
('XaIIu', 'S'),
('XaIkW', 'S'),
('XaIkX', 'S'),
('XaIkY', 'S'),
('XaItg', 'S'),
('XaJX2', 'S'),
('XaLQh', 'S'),
('XaQUB', 'S'),
('XaWNE', 'S'),
('XagO3', 'S'),
('Y0983', 'S'),
('Y0994', 'S'),
('Y19d7', 'S'),
('Y2869', 'S'),
('Y3985', 'S'),
('Y7110', 'S'),
('Y7467', 'S'),
('Y7677', 'S'),
('Y9843', 'S'),
('YA602', 'S'),
('ZV6D8', 'S')
GO
-- Query for ever_smoked
SELECT * INTO #ever_smoked FROM (
SELECT
CodedEvent.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent
INNER JOIN #tmp88_ever_smoked_codelist
ON CTV3Code = #tmp88_ever_smoked_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate <= #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent.Patient_ID
) t
GO
-- Uploading codelist for smoking_status_date
CREATE TABLE #tmp89_smoking_status_date_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp89_smoking_status_date_codelist (code, category) VALUES
('1377.', 'E'),
('1378.', 'E'),
('1379.', 'E'),
('137A.', 'E'),
('137B.', 'E'),
('137F.', 'E'),
('137K.', 'E'),
('137N.', 'E'),
('137O.', 'E'),
('137T.', 'E'),
('137l.', 'E'),
('Ub0p1', 'E'),
('Ub1na', 'E'),
('XE0oj', 'E'),
('XE0ok', 'E'),
('XE0ol', 'E'),
('XE0om', 'E'),
('XE0on', 'E'),
('XE0op', 'E'),
('Xa1bv', 'E'),
('XaQ8V', 'E'),
('XaQUI', 'E'),
('XaQzw', 'E'),
('XaXP6', 'E'),
('XaXP8', 'E'),
('XaXP9', 'E'),
('Y0984', 'E'),
('Y1152', 'E'),
('Y1153', 'E'),
('Y6626', 'E'),
('Y6627', 'E'),
('Y6628', 'E'),
('1371.', 'N'),
('137L.', 'N'),
('Ub0oq', 'N'),
('XE0oh', 'N'),
('XaQUC', 'N'),
('XaXYo', 'N'),
('Y0993', 'N'),
('Y099f', 'N'),
('Y09a0', 'S'),
('1372.', 'S'),
('1373.', 'S'),
('1374.', 'S'),
('1375.', 'S'),
('1376.', 'S'),
('137H.', 'S'),
('137J.', 'S'),
('137M.', 'S'),
('137P.', 'S'),
('137Q.', 'S'),
('137R.', 'S'),
('E251.', 'S'),
('E2510', 'S'),
('E2511', 'S'),
('E2512', 'S'),
('E251z', 'S'),
('Eu17.', 'S'),
('Eu170', 'S'),
('Eu171', 'S'),
('Eu172', 'S'),
('Eu175', 'S'),
('Eu176', 'S'),
('Eu177', 'S'),
('Eu17y', 'S'),
('Eu17z', 'S'),
('H3101', 'S'),
('Ua2Cl', 'S'),
('Ub1tR', 'S'),
('Ub1tS', 'S'),
('Ub1tT', 'S'),
('Ub1tU', 'S'),
('Ub1tV', 'S'),
('Ub1tW', 'S'),
('X20Qm', 'S'),
('XE0oi', 'S'),
('XE0oq', 'S'),
('XE0or', 'S'),
('XE1b4', 'S'),
('XaBSp', 'S'),
('XaIIu', 'S'),
('XaIkW', 'S'),
('XaIkX', 'S'),
('XaIkY', 'S'),
('XaItg', 'S'),
('XaJX2', 'S'),
('XaLQh', 'S'),
('XaQUB', 'S'),
('XaWNE', 'S'),
('XagO3', 'S'),
('Y0983', 'S'),
('Y0994', 'S'),
('Y19d7', 'S'),
('Y2869', 'S'),
('Y3985', 'S'),
('Y7110', 'S'),
('Y7467', 'S'),
('Y7677', 'S'),
('Y9843', 'S'),
('YA602', 'S'),
('ZV6D8', 'S')
GO
-- Query for smoking_status_date
SELECT * INTO #smoking_status_date FROM (
SELECT
CodedEvent.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent
INNER JOIN #tmp89_smoking_status_date_codelist
ON CTV3Code = #tmp89_smoking_status_date_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate <= #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent.Patient_ID
) t
GO
-- Uploading codelist for most_recent_unclear_smoking_cat_date
CREATE TABLE #tmp90_most_recent_unclear_smoking_cat_date_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp90_most_recent_unclear_smoking_cat_date_codelist (code, category) VALUES
('E2513', 'E'),
('Eu173', 'E'),
('Eu174', 'E'),
('XaXPD', 'N'),
('137C.', 'S'),
('137D.', 'S'),
('137G.', 'S'),
('6791.', 'S'),
('67A3.', 'S'),
('9OO..', 'S'),
('9OO1.', 'S'),
('9OO2.', 'S'),
('9OO3.', 'S'),
('9OO4.', 'S'),
('9OO5.', 'S'),
('9OO6.', 'S'),
('9OO7.', 'S'),
('9OO8.', 'S'),
('9OO9.', 'S'),
('9OOA.', 'S'),
('Ua1Nz', 'S'),
('Ua1O0', 'S'),
('Ub1nZ', 'S'),
('Xa1dC', 'S'),
('XaBUG', 'S'),
('XaCGl', 'S'),
('XaEKU', 'S'),
('XaF98', 'S'),
('XaFw9', 'S'),
('XaIQi', 'S'),
('XaIQj', 'S'),
('XaIQk', 'S'),
('XaIQl', 'S'),
('XaIQm', 'S'),
('XaIQn', 'S'),
('XaIpo', 'S'),
('XaItC', 'S'),
('XaIth', 'S'),
('XaIuQ', 'S'),
('XaIye', 'S'),
('XaKlS', 'S'),
('XaLD4', 'S'),
('XaLIY', 'S'),
('XaLIZ', 'S'),
('XaLMR', 'S'),
('XaLMS', 'S'),
('XaMlI', 'S'),
('XaMlJ', 'S'),
('XaMlK', 'S'),
('XaMlL', 'S'),
('XaMlM', 'S'),
('XaMlN', 'S'),
('XaMt6', 'S'),
('XaMwY', 'S'),
('XaPid', 'S'),
('XaQT5', 'S'),
('XaQVQ', 'S'),
('XaREz', 'S'),
('XaW0h', 'S'),
('XaX0O', 'S'),
('XaX0i', 'S'),
('XaX5W', 'S'),
('XaX5X', 'S'),
('XaXPX', 'S'),
('XaXR4', 'S'),
('XaXUL', 'S'),
('XaXnG', 'S'),
('XaXnf', 'S'),
('XaXng', 'S'),
('XaXni', 'S'),
('XaXnk', 'S'),
('XaZ01', 'S'),
('XaZhB', 'S'),
('Xaa26', 'S'),
('XaaDx', 'S'),
('XaaDy', 'S'),
('XacZz', 'S'),
('Xaca0', 'S'),
('Xaety', 'S'),
('Y0018', 'S'),
('Y01e6', 'S'),
('Y0790', 'S'),
('XaFst', 'S'),
('XaJIs', 'S'),
('XaRFh', 'S'),
('XaZIE', 'S'),
('137Z.', 'X'),
('Ub0p2', 'X'),
('Ub1tI', 'X'),
('Ub1tJ', 'X'),
('Ub1tK', 'X'),
('XaIr7', 'S')
GO
-- Query for most_recent_unclear_smoking_cat_date
SELECT * INTO #most_recent_unclear_smoking_cat_date FROM (
SELECT
CodedEvent.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent
INNER JOIN #tmp90_most_recent_unclear_smoking_cat_date_codelist
ON CTV3Code = #tmp90_most_recent_unclear_smoking_cat_date_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate <= #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent.Patient_ID
) t
GO
-- Query for flu_vaccine_tpp
SELECT * INTO #flu_vaccine_tpp FROM (
SELECT
Vaccination.Patient_ID AS patient_id,
1 AS binary_flag,
MIN(VaccinationDate) AS date
FROM Vaccination
INNER JOIN VaccinationReference AS ref
ON ref.VaccinationName_ID = Vaccination.VaccinationName_ID
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = Vaccination.patient_id
WHERE VaccinationDate BETWEEN DATEADD(MONTH, -12, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date AND ref.VaccinationContent IN ('influenza')
GROUP BY Vaccination.Patient_ID
) t
GO
-- Uploading codelist for flu_vaccine_med
CREATE TABLE #tmp91_flu_vaccine_med_codelist (
code VARCHAR(17) COLLATE Latin1_General_CI_AS,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp91_flu_vaccine_med_codelist (code, category) VALUES
('3252611000001103', ''),
('3244411000001106', ''),
('10133911000001103', ''),
('11278411000001109', ''),
('37547211000001103', ''),
('3249511000001109', ''),
('3255011000001100', ''),
('35727111000001109', ''),
('3245911000001104', ''),
('3247011000001105', ''),
('3255311000001102', ''),
('10306611000001101', ''),
('4365711000001104', ''),
('9511411000001107', ''),
('10455811000001107', ''),
('10859911000001105', ''),
('15382311000001101', ''),
('15454511000001101', ''),
('15506511000001107', ''),
('19820511000001106', ''),
('27114211000001105', ''),
('20292211000001109', ''),
('22628411000001107', ''),
('22704311000001109', ''),
('30935711000001104', ''),
('34680411000001107', ''),
('37514711000001105', ''),
('35726811000001104', ''),
('35727411000001104', ''),
('36509011000001106', ''),
('36754111000001101', ''),
('348047008', ''),
('10309511000001105', ''),
('15474011000001107', ''),
('15507511000001109', ''),
('19821411000001103', ''),
('348046004', ''),
('36755311000001100', ''),
('37531311000001101', '')
GO
-- Query for flu_vaccine_med
SELECT * INTO #flu_vaccine_med FROM (
SELECT
MedicationIssue.Patient_ID AS patient_id,
1 AS binary_flag,
MIN(ConsultationDate) AS date
FROM MedicationIssue
INNER JOIN MedicationDictionary
ON MedicationIssue.MultilexDrug_ID = MedicationDictionary.MultilexDrug_ID
INNER JOIN #tmp91_flu_vaccine_med_codelist
ON DMD_ID = #tmp91_flu_vaccine_med_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = MedicationIssue.patient_id
WHERE ConsultationDate BETWEEN DATEADD(MONTH, -12, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY MedicationIssue.Patient_ID
) t
GO
-- Uploading codelist for flu_vaccine_clinical
CREATE TABLE #tmp92_flu_vaccine_clinical_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp92_flu_vaccine_clinical_codelist (code, category) VALUES
('XaPwi', ''),
('XaPwj', ''),
('XaPyT', ''),
('XaQhk', ''),
('XaQhl', ''),
('XaQhm', ''),
('XaQhn', ''),
('XaQho', ''),
('XaQhp', ''),
('XaQhq', ''),
('XaQhr', ''),
('XaZ0e', ''),
('XaZfY', ''),
('Xaa9G', ''),
('XaaED', ''),
('XaaEF', ''),
('XaaZp', ''),
('Xaac1', ''),
('Xaac2', ''),
('Xaac3', ''),
('Xaac4', ''),
('Xaac5', ''),
('Xaac6', ''),
('Xaac7', ''),
('Xaac8', ''),
('XabvT', ''),
('Xac5J', ''),
('Xad9j', ''),
('Xad9k', ''),
('Xaeet', ''),
('Xaeeu', ''),
('Xaeev', ''),
('Xaeew', ''),
('Y0c3f', ''),
('Y0c40', '')
GO
-- Uploading codelist for flu_vaccine_clinical
CREATE TABLE #tmp93_flu_vaccine_clinical_codelist (
code VARCHAR(5) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp93_flu_vaccine_clinical_codelist (code, category) VALUES
('XaIBI', ''),
('XaIOT', ''),
('XaJ5n', ''),
('XaL1V', ''),
('XaPw7', ''),
('XaPwe', ''),
('XaPwk', ''),
('XaX4R', ''),
('XaZ0i', ''),
('XaZ0j', ''),
('XaZ0k', ''),
('XaaDp', ''),
('XaaDq', ''),
('XaaWK', ''),
('XaaWM', ''),
('XaadS', ''),
('XaadT', ''),
('XaadU', ''),
('XaadV', ''),
('XaadX', ''),
('XaadZ', '')
GO
SELECT
CodedEvent.Patient_ID AS Patient_ID,
CAST(ConsultationDate AS date) AS day
INTO #tmp94_flu_vaccine_clinical_same_day_events
FROM CodedEvent
INNER JOIN #tmp93_flu_vaccine_clinical_codelist
ON CTV3Code = #tmp93_flu_vaccine_clinical_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate BETWEEN DATEADD(MONTH, -12, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
GO
CREATE CLUSTERED INDEX ix ON #tmp94_flu_vaccine_clinical_same_day_events (Patient_ID, day)
GO
-- Query for flu_vaccine_clinical
SELECT * INTO #flu_vaccine_clinical FROM (
SELECT
CodedEvent.Patient_ID AS patient_id,
1 AS binary_flag,
MIN(ConsultationDate) AS date
FROM CodedEvent
INNER JOIN #tmp92_flu_vaccine_clinical_codelist
ON CTV3Code = #tmp92_flu_vaccine_clinical_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent.patient_id
WHERE ConsultationDate BETWEEN DATEADD(MONTH, -12, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT
EXISTS (
SELECT 1 FROM #tmp94_flu_vaccine_clinical_same_day_events
WHERE
CodedEvent.Patient_ID = #tmp94_flu_vaccine_clinical_same_day_events.Patient_ID
AND CAST(CodedEvent.ConsultationDate AS date) = #tmp94_flu_vaccine_clinical_same_day_events.day
)
AND 1 = 1
GROUP BY CodedEvent.Patient_ID
) t
GO
-- Query for covrx1_dat
SELECT * INTO #covrx1_dat FROM (
SELECT
Vaccination.Patient_ID AS patient_id,
1 AS binary_flag,
MIN(VaccinationDate) AS date
FROM Vaccination
INNER JOIN VaccinationReference AS ref
ON ref.VaccinationName_ID = Vaccination.VaccinationName_ID
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = Vaccination.patient_id
WHERE VaccinationDate BETWEEN '20201129' AND #patient_index_date.patient_index_date AND ref.VaccinationName IN ('COVID-19 mRNA Vac BNT162b2 30mcg/0.3ml conc for susp for inj multidose vials (Pfizer-BioNTech)','COVID-19 Vac AstraZeneca (ChAdOx1 S recomb) 5x10000000000 viral particles/0.5ml dose sol for inj MDV','COVID-19 mRNA (nucleoside modified) Vaccine Moderna 0.1mg/0.5mL dose dispersion for inj MDV')
GROUP BY Vaccination.Patient_ID
) t
GO
-- Query for covrx2_dat
SELECT * INTO #covrx2_dat FROM (
SELECT
Vaccination.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(VaccinationDate) AS date
FROM Vaccination
INNER JOIN VaccinationReference AS ref
ON ref.VaccinationName_ID = Vaccination.VaccinationName_ID
LEFT JOIN #covrx1_dat
ON #covrx1_dat.patient_id = Vaccination.patient_id
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = Vaccination.patient_id
WHERE VaccinationDate BETWEEN DATEADD(DAY, 19, #covrx1_dat.date) AND #patient_index_date.patient_index_date AND ref.VaccinationName IN ('COVID-19 mRNA Vac BNT162b2 30mcg/0.3ml conc for susp for inj multidose vials (Pfizer-BioNTech)','COVID-19 Vac AstraZeneca (ChAdOx1 S recomb) 5x10000000000 viral particles/0.5ml dose sol for inj MDV','COVID-19 mRNA (nucleoside modified) Vaccine Moderna 0.1mg/0.5mL dose dispersion for inj MDV')
GROUP BY Vaccination.Patient_ID
) t
GO
-- Uploading codelist for cancer_comor
CREATE TABLE #tmp95_cancer_comor_codelist (
code VARCHAR(16) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp95_cancer_comor_codelist (code, category) VALUES
('10069009', ''),
('103419001', ''),
('10376009', ''),
('103991000000107', ''),
('104001000000102', ''),
('106243009', ''),
('106252000', ''),
('108369006', ''),
('1090241000000107', ''),
('1090251000000105', ''),
('1090261000000108', ''),
('1090291000000102', ''),
('1090301000000103', ''),
('1090311000000101', ''),
('1090321000000107', ''),
('1090921000000106', ''),
('1090941000000104', ''),
('1090951000000101', ''),
('1091861000000100', ''),
('1091921000000103', ''),
('109266006', ''),
('109267002', ''),
('109270003', ''),
('109272006', ''),
('109274007', ''),
('109276009', ''),
('109278005', ''),
('109284008', ''),
('109290007', ''),
('109294003', ''),
('109347009', ''),
('109355002', ''),
('109358000', ''),
('109367000', ''),
('109369002', ''),
('109371002', ''),
('109373004', ''),
('109378008', ''),
('109383000', ''),
('109384006', ''),
('109385007', ''),
('109388009', ''),
('109391009', ''),
('109392002', ''),
('109823006', ''),
('109830000', ''),
('109835005', ''),
('109836006', ''),
('109837002', ''),
('109841003', ''),
('109843000', ''),
('109844006', ''),
('109847004', ''),
('109848009', ''),
('109850001', ''),
('109853004', ''),
('109874003', ''),
('109875002', ''),
('109876001', ''),
('109878000', ''),
('109885001', ''),
('109888004', ''),
('109889007', ''),
('109911004', ''),
('109912006', ''),
('109919002', ''),
('109948008', ''),
('109962001', ''),
('109965004', ''),
('109966003', ''),
('109969005', ''),
('109975001', ''),
('109976000', ''),
('109977009', ''),
('109978004', ''),
('109980005', ''),
('109988003', ''),
('109989006', ''),
('109991003', ''),
('109992005', ''),
('109994006', ''),
('109995007', ''),
('109996008', ''),
('109998009', ''),
('110000005', ''),
('110002002', ''),
('110004001', ''),
('110005000', ''),
('110006004', ''),
('110007008', ''),
('110013004', ''),
('11073003', ''),
('112676006', ''),
('112677002', ''),
('112683004', ''),
('112685006', ''),
('115215004', ''),
('115223002', ''),
('115224008', ''),
('115225009', ''),
('115229003', ''),
('115232000', ''),
('115234004', ''),
('115237006', ''),
('115240006', ''),
('115243008', ''),
('115244002', ''),
('115245001', ''),
('11671000', ''),
('11793003', ''),
('118287003', ''),
('118599009', ''),
('118600007', ''),
('118601006', ''),
('118602004', ''),
('118604003', ''),
('118605002', ''),
('118606001', ''),
('118607005', ''),
('118608000', ''),
('118609008', ''),
('118610003', ''),
('118611004', ''),
('118612006', ''),
('118613001', ''),
('118614007', ''),
('118615008', ''),
('118617000', ''),
('118618005', ''),
('12302002', ''),
('12354007', ''),
('123844007', ''),
('12400006', ''),
('12478003', ''),
('12622007', ''),
('126667002', ''),
('126724001', ''),
('126837005', ''),
('126853008', ''),
('126859007', ''),
('126879004', ''),
('12690005', ''),
('127021009', ''),
('127225006', ''),
('127330008', ''),
('127569003', ''),
('128623006', ''),
('128632008', ''),
('128665000', ''),
('128694007', ''),
('128799007', ''),
('128803008', ''),
('128805001', ''),
('128812005', ''),
('128813000', ''),
('128831004', ''),
('128832006', ''),
('128839002', ''),
('128841001', ''),
('128842008', ''),
('128843003', ''),
('128844009', ''),
('128846006', ''),
('128847002', ''),
('128848007', ''),
('128849004', ''),
('128850004', ''),
('128851000', ''),
('128852007', ''),
('128854008', ''),
('128858006', ''),
('128875000', ''),
('128916007', ''),
('128920006', ''),
('128922003', ''),
('128923008', ''),
('128925001', ''),
('128929007', ''),
('128930002', ''),
('128931003', ''),
('128933000', ''),
('128934006', ''),
('128935007', ''),
('129000002', ''),
('13071008', ''),
('134156006', ''),
('134160009', ''),
('134166003', ''),
('134178004', ''),
('134179007', ''),
('134182002', ''),
('13583002', ''),
('13875003', ''),
('14269005', ''),
('14317002', ''),
('1443001', ''),
('14494009', ''),
('145162009', ''),
('145200007', ''),
('145227006', ''),
('145251001', ''),
('14537002', ''),
('145597000', ''),
('14990007', ''),
('15176003', ''),
('154435005', ''),
('154491004', ''),
('154506000', ''),
('154548007', ''),
('154550004', ''),
('154553002', ''),
('154579006', ''),
('154580009', ''),
('154581008', ''),
('154582001', ''),
('154588002', ''),
('154592009', ''),
('154598008', ''),
('154600002', ''),
('154636004', ''),
('154637008', ''),
('154639006', ''),
('154640008', ''),
('154643005', ''),
('1556006', ''),
('15619004', ''),
('15674004', ''),
('1586004', ''),
('15949004', ''),
('16034002', ''),
('16090008', ''),
('16189002', ''),
('1623000', ''),
('16741004', ''),
('167934009', ''),
('167935005', ''),
('167973009', ''),
('167998005', ''),
('168021008', ''),
('168405008', ''),
('168406009', ''),
('16893006', ''),
('16974005', ''),
('17264009', ''),
('17302008', ''),
('17788007', ''),
('18105004', ''),
('18588008', ''),
('186723002', ''),
('18680006', ''),
('187597000', ''),
('187598005', ''),
('187599002', ''),
('187600004', ''),
('187601000', ''),
('187604008', ''),
('187606005', ''),
('187608006', ''),
('187613005', ''),
('187614004', ''),
('187615003', ''),
('187619009', ''),
('187621004', ''),
('187622006', ''),
('187624007', ''),
('187625008', ''),
('187630007', ''),
('187631006', ''),
('187632004', ''),
('187633009', ''),
('187635002', ''),
('187636001', ''),
('187637005', ''),
('187638000', ''),
('187640005', ''),
('187641009', ''),
('187644001', ''),
('187645000', ''),
('187646004', ''),
('187649006', ''),
('187650006', ''),
('187651005', ''),
('187652003', ''),
('187653008', ''),
('187656000', ''),
('187658004', ''),
('187659007', ''),
('187660002', ''),
('187665007', ''),
('187666008', ''),
('187667004', ''),
('187670000', ''),
('187671001', ''),
('187672008', ''),
('187674009', ''),
('187675005', ''),
('187678007', ''),
('187680001', ''),
('187681002', ''),
('187682009', ''),
('187683004', ''),
('187684005', ''),
('187685006', ''),
('187688008', ''),
('187691008', ''),
('187692001', ''),
('187693006', ''),
('187694000', ''),
('187697007', ''),
('187700006', ''),
('187702003', ''),
('187707009', ''),
('187708004', ''),
('187709007', ''),
('187712005', ''),
('187714006', ''),
('187716008', ''),
('187722004', ''),
('187723009', ''),
('187724003', ''),
('187725002', ''),
('187726001', ''),
('187727005', ''),
('187731004', ''),
('187732006', ''),
('187733001', ''),
('187734007', ''),
('187735008', ''),
('187736009', ''),
('187737000', ''),
('187738005', ''),
('187739002', ''),
('187740000', ''),
('187741001', ''),
('187742008', ''),
('187750004', ''),
('187752007', ''),
('187755009', ''),
('187756005', ''),
('187757001', ''),
('187759003', ''),
('187760008', ''),
('187761007', ''),
('187762000', ''),
('187764004', ''),
('187767006', ''),
('187768001', ''),
('187769009', ''),
('187771009', ''),
('187772002', ''),
('187773007', ''),
('187777008', ''),
('187779006', ''),
('187782001', ''),
('187783006', ''),
('187784000', ''),
('187785004', ''),
('187786003', ''),
('187791002', ''),
('187792009', ''),
('187793004', ''),
('187794005', ''),
('187798008', ''),
('187800001', ''),
('187801002', ''),
('187803004', ''),
('187804005', ''),
('187805006', ''),
('187807003', ''),
('187808008', ''),
('187810005', ''),
('187811009', ''),
('187812002', ''),
('187813007', ''),
('187814001', ''),
('187815000', ''),
('187820000', ''),
('187821001', ''),
('187822008', ''),
('187823003', ''),
('187824009', ''),
('187828007', ''),
('187829004', ''),
('187830009', ''),
('187831008', ''),
('187832001', ''),
('187833006', ''),
('187834000', ''),
('187835004', ''),
('187836003', ''),
('187838002', ''),
('187840007', ''),
('187841006', ''),
('187842004', ''),
('187843009', ''),
('187844003', ''),
('187845002', ''),
('187846001', ''),
('187847005', ''),
('187849008', ''),
('187851007', ''),
('187854004', ''),
('187855003', ''),
('187856002', ''),
('187857006', ''),
('187858001', ''),
('187859009', ''),
('187860004', ''),
('187861000', ''),
('187862007', ''),
('187864008', ''),
('187865009', ''),
('187866005', ''),
('187868006', ''),
('187869003', ''),
('187870002', ''),
('187873000', ''),
('187876008', ''),
('187877004', ''),
('187879001', ''),
('187880003', ''),
('187881004', ''),
('187884007', ''),
('187886009', ''),
('187887000', ''),
('187888005', ''),
('187897009', ''),
('187900002', ''),
('187901003', ''),
('187902005', ''),
('187903000', ''),
('187904006', ''),
('187905007', ''),
('187906008', ''),
('187907004', ''),
('187908009', ''),
('187909001', ''),
('187910006', ''),
('187911005', ''),
('187912003', ''),
('187913008', ''),
('187915001', ''),
('187916000', ''),
('187917009', ''),
('187918004', ''),
('187919007', ''),
('187920001', ''),
('187922009', ''),
('187923004', ''),
('187924005', ''),
('187925006', ''),
('187926007', ''),
('187927003', ''),
('187929000', ''),
('187930005', ''),
('187931009', ''),
('187932002', ''),
('187933007', ''),
('187934001', ''),
('187936004', ''),
('187937008', ''),
('187938003', ''),
('187947006', ''),
('187949009', ''),
('187950009', ''),
('187951008', ''),
('187952001', ''),
('187953006', ''),
('187954000', ''),
('187955004', ''),
('187956003', ''),
('187957007', ''),
('187959005', ''),
('187960000', ''),
('187961001', ''),
('187962008', ''),
('187963003', ''),
('187966006', ''),
('187967002', ''),
('187968007', ''),
('187973001', ''),
('187976009', ''),
('187978005', ''),
('187979002', ''),
('187987001', ''),
('187988006', ''),
('187989003', ''),
('18799007', ''),
('187991006', ''),
('187992004', ''),
('187993009', ''),
('187994003', ''),
('187995002', ''),
('187996001', ''),
('187997005', ''),
('187999008', ''),
('188000002', ''),
('188001003', ''),
('188002005', ''),
('188003000', ''),
('188004006', ''),
('188005007', ''),
('188009001', ''),
('188010006', ''),
('188011005', ''),
('188012003', ''),
('188013008', ''),
('188015001', ''),
('188016000', ''),
('188017009', ''),
('188019007', ''),
('188020001', ''),
('188021002', ''),
('188022009', ''),
('188029000', ''),
('188030005', ''),
('188031009', ''),
('188032002', ''),
('188033007', ''),
('188034001', ''),
('188037008', ''),
('188038003', ''),
('188039006', ''),
('188040008', ''),
('188041007', ''),
('188042000', ''),
('188043005', ''),
('188044004', ''),
('188045003', ''),
('188046002', ''),
('188047006', ''),
('188049009', ''),
('188050009', ''),
('188051008', ''),
('188052001', ''),
('188053006', ''),
('188054000', ''),
('188055004', ''),
('188056003', ''),
('188057007', ''),
('188059005', ''),
('188060000', ''),
('188061001', ''),
('188062008', ''),
('188063003', ''),
('188064009', ''),
('188065005', ''),
('188067002', ''),
('188068007', ''),
('188069004', ''),
('188070003', ''),
('188071004', ''),
('188072006', ''),
('188073001', ''),
('188074007', ''),
('188075008', ''),
('188076009', ''),
('188077000', ''),
('188078005', ''),
('188080004', ''),
('188081000', ''),
('188082007', ''),
('188140006', ''),
('188146000', ''),
('188147009', ''),
('188148004', ''),
('188149007', ''),
('188151006', ''),
('188152004', ''),
('188153009', ''),
('188154003', ''),
('188155002', ''),
('188156001', ''),
('188157005', ''),
('188159008', ''),
('188161004', ''),
('188162006', ''),
('188163001', ''),
('188164007', ''),
('188165008', ''),
('188167000', ''),
('188168005', ''),
('188169002', ''),
('188172009', ''),
('188173004', ''),
('188174005', ''),
('188175006', ''),
('188176007', ''),
('188177003', ''),
('188178008', ''),
('188179000', ''),
('188180002', ''),
('188182005', ''),
('188183000', ''),
('188184006', ''),
('188185007', ''),
('188186008', ''),
('188187004', ''),
('188188009', ''),
('188189001', ''),
('188190005', ''),
('188191009', ''),
('188192002', ''),
('188193007', ''),
('188194001', ''),
('188195000', ''),
('188196004', ''),
('188198003', ''),
('188200009', ''),
('188202001', ''),
('188203006', ''),
('188206003', ''),
('188209005', ''),
('188210000', ''),
('188211001', ''),
('188212008', ''),
('188213003', ''),
('188214009', ''),
('188218007', ''),
('188219004', ''),
('188222002', ''),
('188223007', ''),
('188224001', ''),
('188225000', ''),
('188226004', ''),
('188227008', ''),
('188230001', ''),
('188231002', ''),
('188232009', ''),
('188233004', ''),
('188234005', ''),
('188235006', ''),
('188239000', ''),
('188240003', ''),
('188241004', ''),
('188242006', ''),
('188243001', ''),
('188244007', ''),
('188245008', ''),
('188247000', ''),
('188248005', ''),
('188249002', ''),
('188250002', ''),
('188251003', ''),
('188252005', ''),
('188253000', ''),
('188254006', ''),
('188255007', ''),
('188256008', ''),
('188259001', ''),
('188260006', ''),
('188261005', ''),
('188263008', ''),
('188264002', ''),
('188265001', ''),
('188267009', ''),
('188268004', ''),
('188270008', ''),
('188272000', ''),
('188273005', ''),
('188274004', ''),
('188278001', ''),
('188279009', ''),
('188280007', ''),
('188281006', ''),
('188282004', ''),
('188285002', ''),
('188286001', ''),
('188287005', ''),
('188288000', ''),
('188289008', ''),
('188291000', ''),
('188292007', ''),
('188295009', ''),
('188296005', ''),
('188297001', ''),
('188298006', ''),
('188300006', ''),
('188301005', ''),
('188303008', ''),
('188304002', ''),
('188305001', ''),
('188307009', ''),
('188308004', ''),
('188311003', ''),
('188316008', ''),
('188320007', ''),
('188321006', ''),
('188322004', ''),
('188323009', ''),
('188324003', ''),
('188325002', ''),
('188326001', ''),
('188327005', ''),
('188332006', ''),
('188334007', ''),
('188337000', ''),
('188338005', ''),
('188339002', ''),
('188340000', ''),
('188342008', ''),
('188345005', ''),
('188346006', ''),
('188347002', ''),
('188353002', ''),
('188354008', ''),
('188355009', ''),
('188356005', ''),
('188357001', ''),
('188358006', ''),
('188359003', ''),
('188360008', ''),
('188361007', ''),
('188362000', ''),
('188363005', ''),
('188364004', ''),
('188365003', ''),
('188366002', ''),
('188367006', ''),
('188368001', ''),
('188369009', ''),
('188370005', ''),
('188371009', ''),
('188372002', ''),
('188373007', ''),
('188374001', ''),
('188375000', ''),
('188376004', ''),
('188377008', ''),
('188475001', ''),
('188476000', ''),
('188477009', ''),
('188478004', ''),
('188480005', ''),
('188482002', ''),
('188483007', ''),
('188486004', ''),
('188487008', ''),
('188488003', ''),
('188489006', ''),
('188491003', ''),
('188495007', ''),
('188497004', ''),
('188498009', ''),
('188499001', ''),
('188500005', ''),
('188501009', ''),
('188502002', ''),
('188504001', ''),
('188506004', ''),
('188507008', ''),
('188508003', ''),
('188510001', ''),
('188511002', ''),
('188512009', ''),
('188514005', ''),
('188518008', ''),
('188520006', ''),
('188521005', ''),
('188534006', ''),
('18854008', ''),
('188547001', ''),
('188554007', ''),
('188559002', ''),
('188562004', ''),
('188565002', ''),
('188566001', ''),
('188567005', ''),
('188568000', ''),
('188571008', ''),
('188572001', ''),
('188573006', ''),
('188575004', ''),
('188576003', ''),
('188579005', ''),
('188583005', ''),
('188589009', ''),
('188592008', ''),
('188593003', ''),
('188594009', ''),
('188595005', ''),
('188596006', ''),
('188603004', ''),
('188605006', ''),
('188608008', ''),
('188609000', ''),
('188610005', ''),
('18861007', ''),
('188611009', ''),
('188613007', ''),
('188617008', ''),
('188618003', ''),
('188627002', ''),
('188628007', ''),
('188638002', ''),
('188639005', ''),
('188640007', ''),
('188643009', ''),
('188653005', ''),
('188654004', ''),
('188655003', ''),
('188659009', ''),
('188660004', ''),
('188661000', ''),
('188666005', ''),
('188669003', ''),
('188672005', ''),
('188674006', ''),
('188675007', ''),
('188676008', ''),
('188679001', ''),
('188683001', ''),
('188684007', ''),
('188685008', ''),
('188686009', ''),
('188687000', ''),
('188688005', ''),
('188690006', ''),
('188691005', ''),
('188692003', ''),
('188694002', ''),
('188695001', ''),
('188702000', ''),
('188704004', ''),
('188716005', ''),
('188718006', ''),
('188720009', ''),
('188721008', ''),
('188723006', ''),
('188724000', ''),
('188725004', ''),
('188726003', ''),
('188727007', ''),
('188729005', ''),
('188731001', ''),
('188732008', ''),
('188733003', ''),
('188734009', ''),
('188736006', ''),
('188737002', ''),
('188738007', ''),
('188743000', ''),
('188744006', ''),
('188745007', ''),
('188746008', ''),
('188747004', ''),
('188749001', ''),
('188751002', ''),
('188752009', ''),
('188754005', ''),
('188755006', ''),
('188756007', ''),
('188757003', ''),
('188759000', ''),
('188761009', ''),
('188763007', ''),
('188765000', ''),
('188767008', ''),
('188768003', ''),
('188770007', ''),
('188772004', ''),
('188773009', ''),
('188775002', ''),
('189209004', ''),
('189212001', ''),
('189214000', ''),
('189216003', ''),
('189218002', ''),
('189219005', ''),
('189220004', ''),
('189221000', ''),
('189223002', ''),
('189225009', ''),
('189226005', ''),
('189227001', ''),
('189228006', ''),
('189229003', ''),
('189230008', ''),
('189231007', ''),
('189233005', ''),
('189236002', ''),
('189237006', ''),
('189238001', ''),
('189239009', ''),
('189241005', ''),
('189242003', ''),
('189243008', ''),
('189244002', ''),
('189245001', ''),
('189249007', ''),
('189251006', ''),
('189252004', ''),
('189253009', ''),
('189254003', ''),
('189255002', ''),
('189258000', ''),
('189259008', ''),
('189260003', ''),
('189261004', ''),
('189262006', ''),
('189263001', ''),
('189264007', ''),
('189265008', ''),
('189266009', ''),
('189267000', ''),
('189268005', ''),
('189270001', ''),
('189273004', ''),
('189275006', ''),
('189320002', ''),
('189321003', ''),
('189322005', ''),
('189324006', ''),
('189325007', ''),
('189327004', ''),
('189328009', ''),
('189329001', ''),
('189330006', ''),
('189331005', ''),
('189336000', ''),
('189337009', ''),
('189338004', ''),
('189339007', ''),
('189340009', ''),
('189341008', ''),
('189343006', ''),
('189345004', ''),
('189346003', ''),
('189347007', ''),
('189352002', ''),
('189354001', ''),
('189355000', ''),
('189356004', ''),
('189357008', ''),
('189358003', ''),
('189359006', ''),
('189444004', ''),
('189508006', ''),
('189509003', ''),
('189515003', ''),
('189548003', ''),
('189549006', ''),
('189551005', ''),
('189552003', ''),
('189553008', ''),
('189554002', ''),
('189555001', ''),
('189562005', ''),
('189563000', ''),
('189566008', ''),
('189567004', ''),
('189576006', ''),
('189577002', ''),
('189582009', ''),
('189584005', ''),
('189585006', ''),
('189588008', ''),
('189590009', ''),
('189596003', ''),
('189598002', ''),
('189601007', ''),
('189606002', ''),
('189607006', ''),
('189612007', ''),
('189619003', ''),
('189621008', ''),
('189624000', ''),
('189626003', ''),
('189628002', ''),
('189630000', ''),
('189632008', ''),
('189633003', ''),
('189635005', ''),
('189637002', ''),
('189641003', ''),
('189642005', ''),
('189643000', ''),
('189649001', ''),
('189679008', ''),
('189681005', ''),
('189685001', ''),
('189687009', ''),
('189692006', ''),
('189699002', ''),
('189702009', ''),
('189709000', ''),
('189711009', ''),
('189713007', ''),
('189747005', ''),
('189754004', ''),
('189756002', ''),
('189762007', ''),
('189764008', ''),
('189765009', ''),
('189766005', ''),
('189772005', ''),
('189777004', ''),
('189790006', ''),
('189796000', '')
GO
INSERT INTO #tmp95_cancer_comor_codelist (code, category) VALUES
('189802003', ''),
('189803008', ''),
('189805001', ''),
('189806000', ''),
('189808004', ''),
('189825002', ''),
('189826001', ''),
('189837000', ''),
('189840000', ''),
('189841001', ''),
('189843003', ''),
('189849004', ''),
('189857001', ''),
('189858006', ''),
('189877008', ''),
('189878003', ''),
('189882001', ''),
('189886003', ''),
('189908003', ''),
('189910001', ''),
('189913004', ''),
('189916007', ''),
('189920006', ''),
('189921005', ''),
('189922003', ''),
('189926000', ''),
('189934006', ''),
('189935007', ''),
('189957000', ''),
('189959002', ''),
('189960007', ''),
('189962004', ''),
('189963009', ''),
('189964003', ''),
('189968000', ''),
('189970009', ''),
('189972001', ''),
('189973006', ''),
('189974000', ''),
('189976003', ''),
('189981007', ''),
('189982000', ''),
('189985003', ''),
('189987006', ''),
('189988001', ''),
('189992008', ''),
('190002009', ''),
('190003004', ''),
('190004005', ''),
('190006007', ''),
('190008008', ''),
('190010005', ''),
('190011009', ''),
('190012002', ''),
('190025005', ''),
('190027002', ''),
('190034000', ''),
('190038002', ''),
('190040007', ''),
('190043009', ''),
('190047005', ''),
('190054004', ''),
('190055003', ''),
('190056002', ''),
('190058001', ''),
('190065009', ''),
('190068006', ''),
('190069003', ''),
('190075007', ''),
('190086009', ''),
('190088005', ''),
('190105009', ''),
('190109003', ''),
('190110008', ''),
('190112000', ''),
('190120003', ''),
('190121004', ''),
('190122006', ''),
('190127000', ''),
('190131006', ''),
('190136001', ''),
('190142002', ''),
('190152003', ''),
('190157009', ''),
('190159007', ''),
('190161003', ''),
('190165007', ''),
('190167004', ''),
('190168009', ''),
('190171001', ''),
('190178007', ''),
('190182009', ''),
('190187003', ''),
('190188008', ''),
('190229005', ''),
('19071004', ''),
('1929004', ''),
('193209005', ''),
('193210000', ''),
('19340000', ''),
('19467007', ''),
('196095009', ''),
('19756007', ''),
('198363008', ''),
('198364002', ''),
('198391000', ''),
('198392007', ''),
('198393002', ''),
('19906005', ''),
('203436008', ''),
('20365006', ''),
('20380000', ''),
('20667008', ''),
('2092003', ''),
('20955008', ''),
('21008007', ''),
('21165006', ''),
('21326004', ''),
('2142002', ''),
('21589007', ''),
('21708004', ''),
('21912003', ''),
('21964009', ''),
('22197008', ''),
('2227007', ''),
('22687000', ''),
('22694002', ''),
('23109009', ''),
('231834005', ''),
('236385009', ''),
('24007003', ''),
('24072005', ''),
('24505004', ''),
('24604009', ''),
('248881000000100', ''),
('25081006', ''),
('25173007', ''),
('25190001', ''),
('252986008', ''),
('252991009', ''),
('252992002', ''),
('252993007', ''),
('253040001', ''),
('253071005', ''),
('25370001', ''),
('254292007', ''),
('254293002', ''),
('254360008', ''),
('254383006', ''),
('254459004', ''),
('254484001', ''),
('254582000', ''),
('254645002', ''),
('254837009', ''),
('254901000', ''),
('254980001', ''),
('255052006', ''),
('255056009', ''),
('255066001', ''),
('255067005', ''),
('255068000', ''),
('255069008', ''),
('255077007', ''),
('255081007', ''),
('255085003', ''),
('255086002', ''),
('255090000', ''),
('255091001', ''),
('255102004', ''),
('255106001', ''),
('255107005', ''),
('255130004', ''),
('255150000', ''),
('25707000', ''),
('25874003', ''),
('25910003', ''),
('26138003', ''),
('26211003', ''),
('26325004', ''),
('26888009', ''),
('269456006', ''),
('269457002', ''),
('269459004', ''),
('269460009', ''),
('269461008', ''),
('269464000', ''),
('269465004', ''),
('269467007', ''),
('269468002', ''),
('269469005', ''),
('269471005', ''),
('269472003', ''),
('269474002', ''),
('269475001', ''),
('269476000', ''),
('269477009', ''),
('269478004', ''),
('269503007', ''),
('269504001', ''),
('269506004', ''),
('269509006', ''),
('269510001', ''),
('269511002', ''),
('269515006', ''),
('269579005', ''),
('269580008', ''),
('269628007', ''),
('269960002', ''),
('27090000', ''),
('27092008', ''),
('271323007', ''),
('271325000', ''),
('271466001', ''),
('271467005', ''),
('271468000', ''),
('271486002', ''),
('271525004', ''),
('271568003', ''),
('2735009', ''),
('274087000', ''),
('275268007', ''),
('275399006', ''),
('275419009', ''),
('275464006', ''),
('275524009', ''),
('276799004', ''),
('276871002', ''),
('276872009', ''),
('276873004', ''),
('276874005', ''),
('276875006', ''),
('277473004', ''),
('277567002', ''),
('277571004', ''),
('277597005', ''),
('277600006', ''),
('277601005', ''),
('277606000', ''),
('277613000', ''),
('277615007', ''),
('277619001', ''),
('277622004', ''),
('277625002', ''),
('277641001', ''),
('277654008', ''),
('278065000', ''),
('27849002', ''),
('28047004', ''),
('28054005', ''),
('28173006', ''),
('28351005', ''),
('28558000', ''),
('285636001', ''),
('28655007', ''),
('28950004', ''),
('28953002', ''),
('29370006', ''),
('29792007', ''),
('2985005', ''),
('30156004', ''),
('302816009', ''),
('302817000', ''),
('302835009', ''),
('302836005', ''),
('302842009', ''),
('302849000', ''),
('302855005', ''),
('30289006', ''),
('30383009', ''),
('30440004', ''),
('30546008', ''),
('30566004', ''),
('30713000', ''),
('307576001', ''),
('307593001', ''),
('307651005', ''),
('308120004', ''),
('308121000', ''),
('308122007', ''),
('30924005', ''),
('30962008', ''),
('309770002', ''),
('309808004', ''),
('309831004', ''),
('3102004', ''),
('310498001', ''),
('310504009', ''),
('31131002', ''),
('313248004', ''),
('313427003', ''),
('313428008', ''),
('313429000', ''),
('313430005', ''),
('313431009', ''),
('31396002', ''),
('31470003', ''),
('314955001', ''),
('314968009', ''),
('315034006', ''),
('315036008', ''),
('315058005', ''),
('315230006', ''),
('31671006', ''),
('3172003', ''),
('32280000', ''),
('324170002', ''),
('32456001', ''),
('32913002', ''),
('32968003', ''),
('33176006', ''),
('33681003', ''),
('342511000000104', ''),
('342561000000102', ''),
('342571000000109', ''),
('34360000', ''),
('35232005', ''),
('35262004', ''),
('35287006', ''),
('354002', ''),
('35562000', ''),
('35718007', ''),
('35917007', ''),
('36087009', ''),
('36310008', ''),
('363346000', ''),
('363348004', ''),
('363349007', ''),
('363350007', ''),
('363351006', ''),
('363352004', ''),
('363353009', ''),
('363354003', ''),
('363355002', ''),
('363358000', ''),
('363360003', ''),
('363365008', ''),
('363366009', ''),
('363367000', ''),
('363370001', ''),
('363372009', ''),
('363373004', ''),
('363374005', ''),
('363375006', ''),
('363376007', ''),
('363377003', ''),
('363378008', ''),
('363379000', ''),
('363380002', ''),
('363381003', ''),
('363382005', ''),
('363383000', ''),
('363384006', ''),
('363385007', ''),
('363386008', ''),
('363387004', ''),
('363388009', ''),
('363389001', ''),
('363390005', ''),
('363391009', ''),
('363392002', ''),
('363393007', ''),
('363394001', ''),
('363395000', ''),
('363397008', ''),
('363398003', ''),
('363399006', ''),
('363400004', ''),
('363401000', ''),
('363402007', ''),
('363403002', ''),
('363404008', ''),
('363405009', ''),
('363406005', ''),
('363407001', ''),
('363408006', ''),
('363409003', ''),
('363410008', ''),
('363411007', ''),
('363412000', ''),
('363413005', ''),
('363414004', ''),
('363415003', ''),
('363416002', ''),
('363417006', ''),
('363418001', ''),
('363419009', ''),
('363420003', ''),
('363421004', ''),
('363422006', ''),
('363423001', ''),
('363424007', ''),
('363425008', ''),
('363426009', ''),
('363427000', ''),
('363428005', ''),
('363429002', ''),
('363430007', ''),
('363431006', ''),
('363432004', ''),
('363433009', ''),
('363434003', ''),
('363435002', ''),
('363436001', ''),
('363437005', ''),
('363438000', ''),
('363439008', ''),
('363440005', ''),
('363441009', ''),
('363443007', ''),
('363444001', ''),
('363445000', ''),
('363446004', ''),
('363447008', ''),
('363449006', ''),
('363450006', ''),
('363451005', ''),
('363452003', ''),
('363453008', ''),
('363454002', ''),
('363456000', ''),
('363457009', ''),
('363458004', ''),
('363459007', ''),
('363460002', ''),
('363461003', ''),
('363462005', ''),
('363463000', ''),
('363464006', ''),
('363465007', ''),
('363466008', ''),
('363467004', ''),
('363468009', ''),
('363469001', ''),
('363470000', ''),
('363471001', ''),
('363472008', ''),
('363473003', ''),
('363474009', ''),
('363475005', ''),
('363476006', ''),
('363477002', ''),
('363478007', ''),
('363481002', ''),
('363482009', ''),
('363483004', ''),
('363484005', ''),
('363489000', ''),
('363490009', ''),
('363491008', ''),
('363492001', ''),
('363494000', ''),
('363497007', ''),
('363498002', ''),
('363499005', ''),
('363502009', ''),
('363503004', ''),
('363504005', ''),
('363505006', ''),
('363506007', ''),
('363507003', ''),
('363508008', ''),
('363509000', ''),
('363514001', ''),
('363515000', ''),
('363516004', ''),
('363518003', ''),
('366059005', ''),
('367651003', ''),
('369775001', ''),
('369777009', ''),
('37138001', ''),
('371964008', ''),
('371965009', ''),
('371972005', ''),
('371973000', ''),
('371979001', ''),
('371982006', ''),
('37206003', ''),
('372062007', ''),
('372063002', ''),
('372064008', ''),
('372065009', ''),
('372095001', ''),
('372097009', ''),
('372099007', ''),
('372140005', ''),
('372151005', ''),
('373168002', ''),
('37810007', ''),
('37995004', ''),
('385377005', ''),
('38549000', ''),
('38713004', ''),
('387837005', ''),
('387922007', ''),
('387927001', ''),
('389331000000104', ''),
('389361000000109', ''),
('389371000000102', ''),
('389491000000107', ''),
('38969003', ''),
('389731000000103', ''),
('389751000000105', ''),
('389761000000108', ''),
('389771000000101', ''),
('389841000000100', ''),
('389861000000104', ''),
('39000009', ''),
('390261000000107', ''),
('390281000000103', ''),
('390391000000109', ''),
('390401000000107', ''),
('39056008', ''),
('39086001', ''),
('391691000000109', ''),
('39274007', ''),
('392747007', ''),
('392990002', ''),
('392991003', ''),
('392992005', ''),
('392993000', ''),
('392994006', ''),
('392995007', ''),
('392996008', ''),
('392997004', ''),
('392998009', ''),
('392999001', ''),
('393000000', ''),
('393001001', ''),
('393002008', ''),
('393003003', ''),
('393004009', ''),
('393005005', ''),
('393006006', ''),
('393007002', ''),
('393008007', ''),
('393702003', ''),
('393946002', ''),
('393947006', ''),
('393948001', ''),
('393949009', ''),
('393950009', ''),
('393951008', ''),
('393952001', ''),
('393953006', ''),
('393954000', ''),
('393955004', ''),
('393956003', ''),
('393957007', ''),
('393958002', ''),
('393959005', ''),
('393960000', ''),
('393961001', ''),
('393962008', ''),
('393963003', ''),
('393964009', ''),
('394648007', ''),
('394930000', ''),
('394931001', ''),
('394932008', ''),
('394933003', ''),
('394939004', ''),
('394940002', ''),
('394941003', ''),
('394942005', ''),
('394943000', ''),
('394944006', ''),
('394945007', ''),
('394946008', ''),
('394947004', ''),
('394948009', ''),
('395099008', ''),
('396241000000108', ''),
('396431000000103', ''),
('396491000000102', ''),
('396691000000100', ''),
('396731000000106', ''),
('396761000000101', ''),
('396781000000105', ''),
('396791000000107', ''),
('396801000000106', ''),
('396811000000108', ''),
('397009000', ''),
('397121000000107', ''),
('397151000000102', ''),
('397354007', ''),
('397621000000100', ''),
('397811000000105', ''),
('398623004', ''),
('39896009', ''),
('399068003', ''),
('399211000000101', ''),
('399326009', ''),
('399456004', ''),
('399501000000100', ''),
('399933001', ''),
('400011005', ''),
('40009002', ''),
('400122007', ''),
('400155002', ''),
('400851000000103', ''),
('401221000000100', ''),
('401311008', ''),
('40244008', ''),
('403451000000108', ''),
('404037002', ''),
('40411000', ''),
('404133000', ''),
('404148006', ''),
('405843009', ''),
('4079000', ''),
('408281000000107', ''),
('408291004', ''),
('408292006', ''),
('408321000000104', ''),
('408331000000102', ''),
('408351000000109', ''),
('408401000000103', ''),
('408791000000100', ''),
('408851000000100', ''),
('408861000000102', ''),
('408871000000109', ''),
('408881000000106', ''),
('408891000000108', ''),
('409151000000100', ''),
('409171000000109', ''),
('409181000000106', ''),
('409471000000101', ''),
('409561000000107', ''),
('409571000000100', ''),
('409651000000108', ''),
('409661000000106', ''),
('409691000000100', ''),
('409841000000109', ''),
('410571000000108', ''),
('411561000000109', ''),
('413440007', ''),
('413441006', ''),
('413537009', ''),
('413961000000100', ''),
('414467006', ''),
('414628006', ''),
('414629003', ''),
('415112005', ''),
('415181008', ''),
('41529000', ''),
('415461000000108', ''),
('41556003', ''),
('41607009', ''),
('416669000', ''),
('416769008', ''),
('416842003', ''),
('416901000000108', ''),
('416911000000105', ''),
('417417007', ''),
('417554000', ''),
('418331000000100', ''),
('419052002', ''),
('41919003', ''),
('420441000000109', ''),
('420631000000103', ''),
('421249001', ''),
('42194009', ''),
('42392001', ''),
('424621000000108', ''),
('424671000000107', ''),
('424711000000108', ''),
('424771000000103', ''),
('424981000000103', ''),
('425121000000100', ''),
('425131000000103', ''),
('425333006', ''),
('425541000000104', ''),
('42596004', ''),
('426031000000107', ''),
('426711000000102', ''),
('426731000000105', ''),
('426751000000103', ''),
('427151000000101', ''),
('428031000000108', ''),
('428061005', ''),
('428100006', ''),
('428311000000102', ''),
('428322007', ''),
('428367000', ''),
('428905002', ''),
('428971000000106', ''),
('429221000000106', ''),
('4305004', ''),
('430621000', ''),
('430991000000109', ''),
('43149009', ''),
('432328008', ''),
('43296007', ''),
('433141000000108', ''),
('437231000000102', ''),
('437751000000102', ''),
('437761000000104', ''),
('437771000000106', ''),
('437801000000109', ''),
('437821000000100', ''),
('437831000000103', ''),
('437871000000101', ''),
('437961000000102', ''),
('438011000000102', ''),
('438191000000105', ''),
('438251000000108', ''),
('438331000000107', ''),
('438671000000101', ''),
('438691000000102', ''),
('439271000000107', ''),
('43985008', ''),
('440781000000105', ''),
('442537007', ''),
('442591000000102', ''),
('443354006', ''),
('443487006', ''),
('443565000', ''),
('443677002', ''),
('443679004', ''),
('44474009', ''),
('444910004', ''),
('445105005', ''),
('445227008', ''),
('445269007', ''),
('44529004', ''),
('445406001', ''),
('445691000000108', ''),
('445738007', ''),
('446643000', ''),
('446711009', ''),
('44769000', ''),
('447883002', ''),
('447949005', ''),
('448212009', ''),
('448233000', ''),
('448668007', ''),
('448670003', ''),
('448674007', ''),
('448708002', ''),
('448868009', ''),
('449067008', ''),
('449096009', ''),
('449108003', ''),
('449220000', ''),
('449224009', ''),
('449308006', ''),
('449377002', ''),
('449386007', ''),
('449420002', ''),
('449627008', ''),
('449741000000108', ''),
('449881000000109', ''),
('449971000000104', ''),
('450041000000102', ''),
('450191000000106', ''),
('450201000000108', ''),
('450211000000105', ''),
('45024009', ''),
('450611000000107', ''),
('450861000000108', ''),
('450958009', ''),
('450971000000109', ''),
('450981000000106', ''),
('451111000000105', ''),
('451131000000102', ''),
('451751000000105', ''),
('45410002', ''),
('45490001', ''),
('4553004', ''),
('455551000000102', ''),
('45572000', ''),
('455781000000101', ''),
('457571000000102', ''),
('4584002', ''),
('4590003', ''),
('461431000000101', ''),
('461871000000101', ''),
('461881000000104', ''),
('461901000000101', ''),
('462461000000100', ''),
('462491000000106', ''),
('463091000000106', ''),
('4631006', ''),
('463221000000103', ''),
('463371000000109', ''),
('463391000000108', ''),
('464031000000108', ''),
('464261000000109', ''),
('466481000000108', ''),
('46732000', ''),
('468681000000109', ''),
('468691000000106', ''),
('469341000000100', ''),
('470351000000104', ''),
('47107000', ''),
('472871000000100', ''),
('47299001', ''),
('477501000000108', ''),
('477541000000106', ''),
('477851000000107', ''),
('478031000000107', ''),
('478131000000106', ''),
('478151000000104', ''),
('478171000000108', ''),
('478201000000109', ''),
('478211000000106', ''),
('478521000000103', ''),
('478981000000107', ''),
('479011000000106', ''),
('479021000000100', ''),
('4797003', ''),
('48430004', ''),
('48460009', ''),
('48952003', ''),
('4935000', ''),
('49430005', ''),
('4950009', ''),
('49937004', ''),
('50102004', ''),
('50150000', ''),
('50422007', ''),
('50542000', ''),
('50813003', ''),
('51092000', ''),
('51217003', ''),
('51617009', ''),
('51642000', ''),
('51757004', ''),
('51793002', ''),
('52040006', ''),
('52178006', ''),
('52220008', ''),
('52248008', ''),
('5257006', ''),
('53530009', ''),
('53654007', ''),
('54087003', ''),
('54124005', ''),
('54443001', ''),
('54666007', ''),
('55081009', ''),
('55150002', ''),
('55320002', ''),
('55342001', ''),
('55353007', ''),
('55921005', ''),
('55937004', ''),
('5600009', ''),
('56484001', ''),
('56565002', ''),
('5658009', ''),
('5688000', ''),
('56944001', ''),
('57485005', ''),
('57513006', ''),
('57596004', ''),
('58248003', ''),
('5843004', ''),
('58477004', ''),
('59238007', ''),
('59367005', ''),
('59529006', ''),
('5958006', ''),
('59583009', ''),
('60286009', ''),
('60346004', ''),
('61217001', ''),
('62064005', ''),
('6219000', ''),
('62383007', ''),
('6250003', ''),
('62621002', ''),
('62681000', ''),
('63211008', ''),
('63264007', ''),
('63364005', ''),
('63373002', ''),
('63449009', ''),
('63634009', ''),
('6381009', ''),
('64204000', ''),
('64524002', ''),
('64575004', ''),
('6492006', ''),
('65278006', ''),
('65646006', ''),
('65692009', ''),
('66445009', ''),
('66515009', ''),
('67159000', ''),
('67182003', ''),
('67280001', ''),
('67830002', ''),
('68358000', ''),
('68827007', ''),
('68880006', ''),
('68956006', ''),
('69028005', ''),
('69077002', ''),
('69835003', ''),
('7010000', ''),
('70179006', ''),
('702391001', ''),
('703545003', ''),
('70401000', ''),
('70555003', ''),
('70594002', ''),
('70600005', ''),
('712525007', ''),
('712750007', ''),
('71298006', ''),
('71314006', ''),
('713572001', ''),
('713897006', ''),
('71447003', ''),
('71985006', ''),
('721567004', ''),
('72174007', ''),
('722237009', ''),
('72495009', ''),
('72907003', ''),
('72969003', ''),
('7300000', ''),
('73506006', ''),
('73676002', ''),
('738770003', ''),
('739301006', ''),
('73982001', ''),
('74042001', ''),
('74189002', ''),
('74279005', ''),
('74364000', ''),
('74409009', ''),
('74532006', ''),
('74654000', ''),
('74751003', ''),
('75320001', ''),
('75622000', ''),
('75931002', ''),
('75987005', ''),
('76060004', ''),
('76312009', ''),
('76345009', ''),
('76422004', ''),
('76481008', ''),
('76594008', ''),
('76817009', ''),
('76909002', ''),
('77284006', ''),
('77418004', ''),
('77430005', ''),
('77455004', ''),
('77659000', ''),
('77870005', ''),
('77986002', ''),
('78010001', ''),
('78197004', ''),
('78303004', ''),
('78453009', ''),
('78838008', ''),
('79143006', ''),
('80061003', ''),
('80091008', ''),
('80570006', ''),
('8139000', ''),
('81446001', ''),
('8145008', ''),
('815121000000102', ''),
('815131000000100', ''),
('81920005', ''),
('820601000000103', ''),
('82267002', ''),
('82591005', ''),
('82711006', ''),
('83118000', ''),
('83217000', ''),
('83270006', ''),
('83284001', ''),
('83292005', ''),
('835009', ''),
('83950009', ''),
('84570003', ''),
('84664004', ''),
('847481000000109', ''),
('847631000000107', ''),
('847651000000100', ''),
('847691000000108', ''),
('847701000000108', ''),
('847741000000106', ''),
('849091000000106', ''),
('85654004', ''),
('85956000', ''),
('86293007', ''),
('863741000000108', ''),
('863761000000109', ''),
('863781000000100', ''),
('86406008', ''),
('86616005', '')
GO
INSERT INTO #tmp95_cancer_comor_codelist (code, category) VALUES
('87163000', ''),
('87364003', ''),
('87737001', ''),
('87992000', ''),
('88195001', ''),
('88253001', ''),
('88400008', ''),
('88591002', ''),
('88897007', ''),
('89623007', ''),
('89740008', ''),
('89906000', ''),
('89996007', ''),
('900006', ''),
('90120004', ''),
('90282004', ''),
('90725004', ''),
('915007', ''),
('91855006', ''),
('91857003', ''),
('91861009', ''),
('92527000', ''),
('92530007', ''),
('92531006', ''),
('92537005', ''),
('92539008', ''),
('92542002', ''),
('92545000', ''),
('92546004', ''),
('92549006', ''),
('92550006', ''),
('92558004', ''),
('92559007', ''),
('92560002', ''),
('92564006', ''),
('92568009', ''),
('92570000', ''),
('92574009', ''),
('92575005', ''),
('92577002', ''),
('92580001', ''),
('92582009', ''),
('92584005', ''),
('92585006', ''),
('92586007', ''),
('92587003', ''),
('92588008', ''),
('92590009', ''),
('92591008', ''),
('92594000', ''),
('92595004', ''),
('92598002', ''),
('92599005', ''),
('92600008', ''),
('92603005', ''),
('92605003', ''),
('92608001', ''),
('92612007', ''),
('92613002', ''),
('92618006', ''),
('92621008', ''),
('92634009', ''),
('92643000', ''),
('92644006', ''),
('92648009', ''),
('92650001', ''),
('92653004', ''),
('92654005', ''),
('92655006', ''),
('92656007', ''),
('92658008', ''),
('92660005', ''),
('92663007', ''),
('92664001', ''),
('92668003', ''),
('92669006', ''),
('92670007', ''),
('92672004', ''),
('92675002', ''),
('92679008', ''),
('92681005', ''),
('92683008', ''),
('92685001', ''),
('92691004', ''),
('92692006', ''),
('92693001', ''),
('92695008', ''),
('92696009', ''),
('92706007', ''),
('92708008', ''),
('92753005', ''),
('92754004', ''),
('92755003', ''),
('92756002', ''),
('92764008', ''),
('92767001', ''),
('92769003', ''),
('92772005', ''),
('92773000', ''),
('92780003', ''),
('92791005', ''),
('92802003', ''),
('92812005', ''),
('92814006', ''),
('92818009', ''),
('9294008', ''),
('93135004', ''),
('93139005', ''),
('93143009', ''),
('93144003', ''),
('93171003', ''),
('93173000', ''),
('93177004', ''),
('93178009', ''),
('93182006', ''),
('93191005', ''),
('93192003', ''),
('93193008', ''),
('93194002', ''),
('93195001', ''),
('93196000', ''),
('93197009', ''),
('93198004', ''),
('93209006', ''),
('93217003', ''),
('93223008', ''),
('93225001', ''),
('93451002', ''),
('93493001', ''),
('93494007', ''),
('93495008', ''),
('93500006', ''),
('93518009', ''),
('93520007', ''),
('93522004', ''),
('93523009', ''),
('93524003', ''),
('93525002', ''),
('93526001', ''),
('93527005', ''),
('93542008', ''),
('93643005', ''),
('93651008', ''),
('93655004', ''),
('93661001', ''),
('93677000', ''),
('93678005', ''),
('93680004', ''),
('93681000', ''),
('93728003', ''),
('93752005', ''),
('93757004', ''),
('93759001', ''),
('93763008', ''),
('93770008', ''),
('93772000', ''),
('93786001', ''),
('93798006', ''),
('93799003', ''),
('93806005', ''),
('93810008', ''),
('93814004', ''),
('93817006', ''),
('93827000', ''),
('93833009', ''),
('93841009', ''),
('93842002', ''),
('93853008', ''),
('93870000', ''),
('93880001', ''),
('93888008', ''),
('93916003', ''),
('93919005', ''),
('93924008', ''),
('93925009', ''),
('93927001', ''),
('93937006', ''),
('93941005', ''),
('93945001', ''),
('93947009', ''),
('9395006', ''),
('93957005', ''),
('93973004', ''),
('93975006', ''),
('93979000', ''),
('93986008', ''),
('93990005', ''),
('93995000', ''),
('93997008', ''),
('94066004', ''),
('94073009', ''),
('94083008', ''),
('94085001', ''),
('94099002', ''),
('94112009', ''),
('94134006', ''),
('94142007', ''),
('94145009', ''),
('94705007', ''),
('94707004', ''),
('94710006', ''),
('94712003', ''),
('94719007', ''),
('95186006', ''),
('95188007', ''),
('95192000', ''),
('95210003', ''),
('95214007', ''),
('95224004', ''),
('95231000', ''),
('9618003', ''),
('9801004', ''),
('9903002', ''),
('999000', '')
GO
-- Query for cancer_comor
SELECT * INTO #cancer_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp95_cancer_comor_codelist
ON ConceptID = #tmp95_cancer_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for cardiovascular_comor
CREATE TABLE #tmp96_cardiovascular_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp96_cardiovascular_comor_codelist (code, category) VALUES
('1055001', ''),
('111298007', ''),
('1386000', ''),
('138755007', ''),
('15258001', ''),
('155395002', ''),
('155396001', ''),
('155397005', ''),
('155398000', ''),
('155399008', ''),
('155400001', ''),
('155401002', ''),
('155402009', ''),
('155404005', ''),
('155406007', ''),
('155410005', ''),
('155411009', ''),
('155412002', ''),
('158205008', ''),
('158207000', ''),
('161484004', ''),
('186893003', ''),
('191505005', ''),
('191512001', ''),
('192813004', ''),
('193377008', ''),
('193644003', ''),
('195153006', ''),
('195154000', ''),
('195155004', ''),
('195160000', ''),
('195162008', ''),
('195165005', ''),
('195166006', ''),
('195167002', ''),
('195168007', ''),
('195169004', ''),
('195173001', ''),
('195175008', ''),
('195176009', ''),
('195180004', ''),
('195182007', ''),
('195183002', ''),
('195184008', ''),
('195185009', ''),
('195186005', ''),
('195187001', ''),
('195188006', ''),
('195189003', ''),
('195190007', ''),
('195191006', ''),
('195192004', ''),
('195193009', ''),
('195194003', ''),
('195195002', ''),
('195196001', ''),
('195197005', ''),
('195198000', ''),
('195199008', ''),
('195200006', ''),
('195201005', ''),
('195202003', ''),
('195204002', ''),
('195205001', ''),
('195206000', ''),
('195207009', ''),
('195208004', ''),
('195209007', ''),
('195210002', ''),
('195211003', ''),
('195212005', ''),
('195213000', ''),
('195216008', ''),
('195217004', ''),
('195219001', ''),
('195222004', ''),
('195226001', ''),
('195228000', ''),
('195229008', ''),
('195230003', ''),
('195231004', ''),
('195232006', ''),
('195233001', ''),
('195234007', ''),
('195235008', ''),
('195236009', ''),
('195237000', ''),
('195238005', ''),
('195239002', ''),
('195240000', ''),
('195241001', ''),
('195243003', ''),
('195248007', ''),
('195249004', ''),
('195595007', ''),
('195597004', ''),
('195600003', ''),
('200329005', ''),
('200330000', ''),
('200332008', ''),
('20059004', ''),
('206829008', ''),
('206830003', ''),
('206831004', ''),
('21454007', ''),
('230690007', ''),
('230691006', ''),
('230692004', ''),
('230697005', ''),
('230699008', ''),
('230700009', ''),
('230710000', ''),
('230716006', ''),
('230724001', ''),
('230729006', ''),
('230730001', ''),
('230736007', ''),
('233963002', ''),
('266253001', ''),
('266254007', ''),
('266255008', ''),
('266256009', ''),
('266257000', ''),
('266258005', ''),
('266995000', ''),
('270883006', ''),
('271371007', ''),
('274100004', ''),
('274662006', ''),
('275434003', ''),
('275526006', ''),
('276284000', ''),
('28366008', ''),
('29322000', ''),
('302213007', ''),
('302909007', ''),
('307756005', ''),
('307766002', ''),
('307767006', ''),
('308064009', ''),
('308128006', ''),
('315757009', ''),
('34781003', ''),
('35486000', ''),
('363302008', ''),
('366963000', ''),
('367187006', ''),
('36994005', ''),
('390936003', ''),
('394517009', ''),
('397809001', ''),
('411911000000103', ''),
('413102000', ''),
('419701000000103', ''),
('42994005', ''),
('431981000000102', ''),
('432504007', ''),
('442413005', ''),
('443929000', ''),
('462581000000105', ''),
('478331000000109', ''),
('49422009', ''),
('496211000000103', ''),
('509351000000105', ''),
('509371000000101', ''),
('52201006', ''),
('55382008', ''),
('61683000', ''),
('62914000', ''),
('64009001', ''),
('64586002', ''),
('6594005', ''),
('69116000', ''),
('705066004', ''),
('713082007', ''),
('71444005', ''),
('732923001', ''),
('75038005', ''),
('75543006', ''),
('7713009', ''),
('78569004', ''),
('86003009', ''),
('87224000', ''),
('88032003', ''),
('95455008', ''),
('95457000', ''),
('95460007', '')
GO
-- Query for cardiovascular_comor
SELECT * INTO #cardiovascular_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp96_cardiovascular_comor_codelist
ON ConceptID = #tmp96_cardiovascular_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for chronic_obstructive_pulmonary_comor
CREATE TABLE #tmp97_chronic_obstructive_pulmonary_comor_codelist (
code VARCHAR(16) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp97_chronic_obstructive_pulmonary_comor_codelist (code, category) VALUES
('10501004', ''),
('1086701000000102', ''),
('1086711000000100', ''),
('11211003', ''),
('12295008', ''),
('12428000', ''),
('134381004', ''),
('134383001', ''),
('134384007', ''),
('135855000', ''),
('135859006', ''),
('135861002', ''),
('135862009', ''),
('135863004', ''),
('14700006', ''),
('147877003', ''),
('147878008', ''),
('147879000', ''),
('147880002', ''),
('147883000', ''),
('147884006', ''),
('147885007', ''),
('147893007', ''),
('147894001', ''),
('147896004', ''),
('147897008', ''),
('150990002', ''),
('150991003', ''),
('150992005', ''),
('150993000', ''),
('150994006', ''),
('150995007', ''),
('153445004', ''),
('155574008', ''),
('155575009', ''),
('155578006', ''),
('155579003', ''),
('155580000', ''),
('155588007', ''),
('155591007', ''),
('155613001', ''),
('16838000', ''),
('170631002', ''),
('170632009', ''),
('170633004', ''),
('170634005', ''),
('170635006', ''),
('170636007', ''),
('170637003', ''),
('170638008', ''),
('170641004', ''),
('170642006', ''),
('170643001', ''),
('170644007', ''),
('170645008', ''),
('170646009', ''),
('170647000', ''),
('170655007', ''),
('170656008', ''),
('170657004', ''),
('170658009', ''),
('170664002', ''),
('170665001', ''),
('17385007', ''),
('17996008', ''),
('182724005', ''),
('182726007', ''),
('182727003', ''),
('182728008', ''),
('182729000', ''),
('182730005', ''),
('182731009', ''),
('185242005', ''),
('187687003', ''),
('190848001', ''),
('195738009', ''),
('195967001', ''),
('195970002', ''),
('195971003', ''),
('195972005', ''),
('195973000', ''),
('195974006', ''),
('195976008', ''),
('195977004', ''),
('195979001', ''),
('195980003', ''),
('195981004', ''),
('195982006', ''),
('195983001', ''),
('195984007', ''),
('195985008', ''),
('195986009', ''),
('196005004', ''),
('196006003', ''),
('196007007', ''),
('196008002', ''),
('196009005', ''),
('196010000', ''),
('196011001', ''),
('196012008', ''),
('196013003', ''),
('196016006', ''),
('196017002', ''),
('196025000', ''),
('196026004', ''),
('196027008', ''),
('196028003', ''),
('196049002', ''),
('196050002', ''),
('196053000', ''),
('196123009', ''),
('196125002', ''),
('196126001', ''),
('196128000', ''),
('196160008', ''),
('196229000', ''),
('201031000000108', ''),
('201041000000104', ''),
('201051000000101', ''),
('201191000000108', ''),
('201201000000105', ''),
('201211000000107', ''),
('21341004', ''),
('225057002', ''),
('22607003', ''),
('23315001', ''),
('233659006', ''),
('233678006', ''),
('233679003', ''),
('233680000', ''),
('233681001', ''),
('233682008', ''),
('233683003', ''),
('233685005', ''),
('233703007', ''),
('233721005', ''),
('236302005', ''),
('266356006', ''),
('266359004', ''),
('266360009', ''),
('266361008', ''),
('266362001', ''),
('266363006', ''),
('266364000', ''),
('266365004', ''),
('266398009', ''),
('266400008', ''),
('266401007', ''),
('274105009', ''),
('286964001', ''),
('29422001', ''),
('312453004', ''),
('312454005', ''),
('31387002', ''),
('33325001', ''),
('340891000000106', ''),
('340901000000107', ''),
('340911000000109', ''),
('340921000000103', ''),
('340931000000101', ''),
('366787009', ''),
('366788004', ''),
('366790003', ''),
('366793001', ''),
('366794007', ''),
('366795008', ''),
('366796009', ''),
('366865006', ''),
('366866007', ''),
('366868008', ''),
('366871000', ''),
('366872007', ''),
('366873002', ''),
('366874008', ''),
('367039004', ''),
('367268006', ''),
('370202007', ''),
('370203002', ''),
('370204008', ''),
('370205009', ''),
('370206005', ''),
('370207001', ''),
('370208006', ''),
('370210008', ''),
('370218001', ''),
('370219009', ''),
('370220003', ''),
('370221004', ''),
('370225008', ''),
('370226009', ''),
('373899003', ''),
('389145006', ''),
('389853000', ''),
('389857004', ''),
('389858009', ''),
('389860006', ''),
('390585000', ''),
('390589006', ''),
('390590002', ''),
('390592005', ''),
('390872009', ''),
('390877003', ''),
('390878008', ''),
('390921001', ''),
('393030008', ''),
('393031007', ''),
('393036002', ''),
('393082005', ''),
('393986005', ''),
('393987001', ''),
('393992004', ''),
('394033000', ''),
('394700004', ''),
('394701000', ''),
('394720003', ''),
('395022009', ''),
('39871006', ''),
('400987003', ''),
('40100001', ''),
('401193004', ''),
('40122008', ''),
('40527005', ''),
('405720007', ''),
('406162001', ''),
('40640008', ''),
('407674008', ''),
('412775002', ''),
('41553006', ''),
('416601004', ''),
('424643009', ''),
('42680007', ''),
('426896000', ''),
('471141000000109', ''),
('473391009', ''),
('47515009', ''),
('49840000', ''),
('51277007', ''),
('51615001', ''),
('56968009', ''),
('57607007', ''),
('59327009', ''),
('62371005', ''),
('63088003', ''),
('700250006', ''),
('708038006', ''),
('708090002', ''),
('708093000', ''),
('708094006', ''),
('708358003', ''),
('708373002', ''),
('71193007', ''),
('719218000', ''),
('73144008', ''),
('734904007', ''),
('736056000', ''),
('74015002', ''),
('771941000000102', ''),
('772051000000106', ''),
('77690003', ''),
('78723001', ''),
('805002', ''),
('8247009', ''),
('8312004', ''),
('85761009', ''),
('86157004', ''),
('866901000000103', ''),
('87153008', ''),
('91340006', '')
GO
-- Query for chronic_obstructive_pulmonary_comor
SELECT * INTO #chronic_obstructive_pulmonary_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp97_chronic_obstructive_pulmonary_comor_codelist
ON ConceptID = #tmp97_chronic_obstructive_pulmonary_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for heart_failure_comor
CREATE TABLE #tmp98_heart_failure_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp98_heart_failure_comor_codelist (code, category) VALUES
('10633002', ''),
('128404006', ''),
('134378009', ''),
('134401001', ''),
('142256001', ''),
('151157005', ''),
('155327003', ''),
('155374007', ''),
('155375008', ''),
('155376009', ''),
('155377000', ''),
('158355003', ''),
('158732004', ''),
('165086001', ''),
('182826002', ''),
('194885004', ''),
('194887007', ''),
('194889005', ''),
('194890001', ''),
('195109001', ''),
('195110006', ''),
('195111005', ''),
('195112003', ''),
('195114002', ''),
('195116000', ''),
('195117009', ''),
('207027002', ''),
('207553000', ''),
('247361000000100', ''),
('266233000', ''),
('266248006', ''),
('266294009', ''),
('275514001', ''),
('308118002', ''),
('3545003', ''),
('366784002', ''),
('366829001', ''),
('366862009', ''),
('366910008', ''),
('367363000', ''),
('389838008', ''),
('389937002', ''),
('390570006', ''),
('390671000', ''),
('390884006', ''),
('390885007', ''),
('392748002', ''),
('393703008', ''),
('395105005', ''),
('395650008', ''),
('395704004', ''),
('40541001', ''),
('407596008', ''),
('407597004', ''),
('410431009', ''),
('416610007', ''),
('416683003', ''),
('416717003', ''),
('417359009', ''),
('420300004', ''),
('420913000', ''),
('421704003', ''),
('422293003', ''),
('42343007', ''),
('426611007', ''),
('429589006', ''),
('446221000', ''),
('497771000000100', ''),
('501871000000106', ''),
('56675007', ''),
('71892000', ''),
('79955004', ''),
('84114007', ''),
('85232009', ''),
('87837008', ''),
('88805009', ''),
('89138009', ''),
('92506005', '')
GO
-- Query for heart_failure_comor
SELECT * INTO #heart_failure_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp98_heart_failure_comor_codelist
ON ConceptID = #tmp98_heart_failure_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for connective_tissue_comor
CREATE TABLE #tmp99_connective_tissue_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp99_connective_tissue_comor_codelist (code, category) VALUES
('105969002', ''),
('10713006', ''),
('138835002', ''),
('143243002', ''),
('148071003', ''),
('154425004', ''),
('155440007', ''),
('155441006', ''),
('155445002', ''),
('155621007', ''),
('156450004', ''),
('156451000', ''),
('156455009', ''),
('156457001', ''),
('156471009', ''),
('156472002', ''),
('156473007', ''),
('156474001', ''),
('156475000', ''),
('156477008', ''),
('156478003', ''),
('156482001', ''),
('156656001', ''),
('161567008', ''),
('164773008', ''),
('165839004', ''),
('170845006', ''),
('170848008', ''),
('170849000', ''),
('170850000', ''),
('170851001', ''),
('170853003', ''),
('170854009', ''),
('187230004', ''),
('187233002', ''),
('187235009', ''),
('190815001', ''),
('191033003', ''),
('192673008', ''),
('193101001', ''),
('193177003', ''),
('193178008', ''),
('193179000', ''),
('193180002', ''),
('193181003', ''),
('193195000', ''),
('193248005', ''),
('193249002', ''),
('193250002', ''),
('193251003', ''),
('193252005', ''),
('193253000', ''),
('193776001', ''),
('195033009', ''),
('195135000', ''),
('195136004', ''),
('195138003', ''),
('195346008', ''),
('195347004', ''),
('195351002', ''),
('195352009', ''),
('195353004', ''),
('195354005', ''),
('195355006', ''),
('195356007', ''),
('195357003', ''),
('195361009', ''),
('195362002', ''),
('195363007', ''),
('195365000', ''),
('195368003', ''),
('195375002', ''),
('196132006', ''),
('196133001', ''),
('196136009', ''),
('196137000', ''),
('196138005', ''),
('197368002', ''),
('197607004', ''),
('201435004', ''),
('201436003', ''),
('201438002', ''),
('201439005', ''),
('201440007', ''),
('201441006', ''),
('201444003', ''),
('201764007', ''),
('201765008', ''),
('201766009', ''),
('201767000', ''),
('201768005', ''),
('201769002', ''),
('201770001', ''),
('201771002', ''),
('201772009', ''),
('201773004', ''),
('201774005', ''),
('201775006', ''),
('201776007', ''),
('201777003', ''),
('201778008', ''),
('201779000', ''),
('201780002', ''),
('201781003', ''),
('201782005', ''),
('201783000', ''),
('201784006', ''),
('201785007', ''),
('201786008', ''),
('201787004', ''),
('201788009', ''),
('201789001', ''),
('201790005', ''),
('201791009', ''),
('201794001', ''),
('201797008', ''),
('201799006', ''),
('201800005', ''),
('201808003', ''),
('201810001', ''),
('202834009', ''),
('203042003', ''),
('203730003', ''),
('203732006', ''),
('203780009', ''),
('203782001', ''),
('203784000', ''),
('203786003', ''),
('203787007', ''),
('203788002', ''),
('236502006', ''),
('236503001', ''),
('236506009', ''),
('23782005', ''),
('239791005', ''),
('239792003', ''),
('239793008', ''),
('239801005', ''),
('239887007', ''),
('239920006', ''),
('239933000', ''),
('239938009', ''),
('24369008', ''),
('266265002', ''),
('266323005', ''),
('267874003', ''),
('267988003', ''),
('268049000', ''),
('268524007', ''),
('275902004', ''),
('276657008', ''),
('276681000000101', ''),
('287006005', ''),
('28880005', ''),
('298285004', ''),
('302896008', ''),
('308143008', ''),
('309762007', ''),
('310607007', ''),
('31384009', ''),
('31541009', ''),
('31848007', ''),
('31996006', ''),
('33719002', ''),
('359789008', ''),
('361197009', ''),
('372929001', ''),
('390001000', ''),
('393589007', ''),
('398049005', ''),
('398640008', ''),
('398726004', ''),
('400054000', ''),
('400130008', ''),
('408471000000106', ''),
('408751000000108', ''),
('409421000000100', ''),
('409631000000101', ''),
('410793008', ''),
('410795001', ''),
('414341000', ''),
('42153001', ''),
('422801000', ''),
('424881000000105', ''),
('425481000000106', ''),
('429192004', ''),
('444133002', ''),
('452681000000101', ''),
('477721000000109', ''),
('478741000000101', ''),
('50581000', ''),
('50782009', ''),
('50803006', ''),
('515691000000108', ''),
('52089001', ''),
('54072008', ''),
('55464009', ''),
('55941000', ''),
('57160007', ''),
('60555002', ''),
('64757003', ''),
('65323003', ''),
('66121003', ''),
('68815009', ''),
('698706005', ''),
('69896004', ''),
('70933002', ''),
('72470008', ''),
('74250003', ''),
('74391003', ''),
('75053002', ''),
('7548000', ''),
('75822003', ''),
('82275008', ''),
('829821000000102', ''),
('83901003', ''),
('84017003', ''),
('847261000000104', ''),
('89155008', ''),
('95415006', ''),
('95609003', ''),
('95644001', ''),
('9631008', '')
GO
-- Query for connective_tissue_comor
SELECT * INTO #connective_tissue_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp99_connective_tissue_comor_codelist
ON ConceptID = #tmp99_connective_tissue_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for dementia_comor
CREATE TABLE #tmp100_dementia_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp100_dementia_comor_codelist (code, category) VALUES
('12348006', ''),
('13092008', ''),
('134422007', ''),
('134423002', ''),
('138736007', ''),
('154846004', ''),
('154847008', ''),
('154849006', ''),
('154996004', ''),
('15662003', ''),
('161465002', ''),
('191448002', ''),
('191449005', ''),
('191450005', ''),
('191451009', ''),
('191452002', ''),
('191454001', ''),
('191455000', ''),
('191456004', ''),
('191457008', ''),
('191458003', ''),
('191459006', ''),
('191461002', ''),
('191462009', ''),
('191463004', ''),
('191464005', ''),
('191465006', ''),
('191466007', ''),
('191467003', ''),
('191493005', ''),
('191519005', ''),
('192164001', ''),
('192170007', ''),
('192171006', ''),
('192174003', ''),
('192175002', ''),
('192176001', ''),
('192177005', ''),
('192180006', ''),
('192184002', ''),
('192804001', ''),
('192808003', ''),
('194481000', ''),
('198681000000106', ''),
('21921000119103', ''),
('229672009', ''),
('230275004', ''),
('230276003', ''),
('230277007', ''),
('230285003', ''),
('230286002', ''),
('230287006', ''),
('231463001', ''),
('248711000000102', ''),
('249181000000100', ''),
('268615009', ''),
('268744003', ''),
('26929004', ''),
('2776000', ''),
('279982005', ''),
('281004', ''),
('35919005', ''),
('402771000000101', ''),
('412631000000106', ''),
('413281000000101', ''),
('414351000000102', ''),
('414361000000104', ''),
('416780008', ''),
('416975007', ''),
('421529006', ''),
('425390006', ''),
('429458009', ''),
('429998004', ''),
('442344002', ''),
('443491000000105', ''),
('443541000000101', ''),
('443781000000102', ''),
('455381000000102', ''),
('45864009', ''),
('471341000000106', ''),
('479161000000109', ''),
('52448006', ''),
('56267009', ''),
('713821000000106', ''),
('715821000000107', ''),
('716221000000104', ''),
('716671000000102', ''),
('716991000000108', ''),
('717471000000101', ''),
('71961003', ''),
('792004', ''),
('80098002', '')
GO
-- Query for dementia_comor
SELECT * INTO #dementia_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp100_dementia_comor_codelist
ON ConceptID = #tmp100_dementia_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for diabetes_comor
CREATE TABLE #tmp101_diabetes_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp101_diabetes_comor_codelist (code, category) VALUES
('111552007', ''),
('11530004', ''),
('127012008', ''),
('127013003', ''),
('143082008', ''),
('143083003', ''),
('147979001', ''),
('147980003', ''),
('147994002', ''),
('154737003', ''),
('165680008', ''),
('165681007', ''),
('170746002', ''),
('170747006', ''),
('170764009', ''),
('170768007', ''),
('190323008', ''),
('190328004', ''),
('190329007', ''),
('190330002', ''),
('190331003', ''),
('190332005', ''),
('190333000', ''),
('190336008', ''),
('190337004', ''),
('190362004', ''),
('190367005', ''),
('190371008', ''),
('190372001', ''),
('190373006', ''),
('190384004', ''),
('190392008', ''),
('190395005', ''),
('190404002', ''),
('190406000', ''),
('190416008', ''),
('190422004', ''),
('190447002', ''),
('190759004', ''),
('191044006', ''),
('191045007', ''),
('199230006', ''),
('199231005', ''),
('236367002', ''),
('237599002', ''),
('237604008', ''),
('237632004', ''),
('26298008', ''),
('267430007', ''),
('267469001', ''),
('268519009', ''),
('268599005', ''),
('28453007', ''),
('290002008', ''),
('312905005', ''),
('312907002', ''),
('313435000', ''),
('313436004', ''),
('314194001', ''),
('314771006', ''),
('335621000000101', ''),
('366909003', ''),
('371055001', ''),
('385051000000106', ''),
('389840003', ''),
('390572003', ''),
('390715006', ''),
('390716007', ''),
('395204000', ''),
('408540003', ''),
('408660003', ''),
('413183008', ''),
('420270002', ''),
('420422005', ''),
('420662003', ''),
('420868002', ''),
('420996007', ''),
('421075007', ''),
('421750000', ''),
('421847006', ''),
('422014003', ''),
('422126006', ''),
('426705001', ''),
('426875007', ''),
('44054006', ''),
('442541000000107', ''),
('443694000', ''),
('444073006', ''),
('46635009', ''),
('51002006', ''),
('609561005', ''),
('609562003', ''),
('70694009', ''),
('719216001', ''),
('73211009', ''),
('74627003', ''),
('75524006', ''),
('8801005', '')
GO
-- Query for diabetes_comor
SELECT * INTO #diabetes_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp101_diabetes_comor_codelist
ON ConceptID = #tmp101_diabetes_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for diabetes_complications_comor
CREATE TABLE #tmp102_diabetes_complications_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp102_diabetes_complications_comor_codelist (code, category) VALUES
('127013003', ''),
('127014009', ''),
('154678005', ''),
('154679002', ''),
('154680004', ''),
('154681000', ''),
('154682007', ''),
('154684008', ''),
('154685009', ''),
('154686005', ''),
('155107006', ''),
('155114008', ''),
('190349003', ''),
('190357000', ''),
('190358005', ''),
('190359002', ''),
('190368000', ''),
('190369008', ''),
('190370009', ''),
('190374000', ''),
('190375004', ''),
('190376003', ''),
('190380008', ''),
('190388001', ''),
('190389009', ''),
('190390000', ''),
('190391001', ''),
('190396006', ''),
('190397002', ''),
('190398007', ''),
('190402003', ''),
('190410002', ''),
('193141005', ''),
('193156001', ''),
('193183000', ''),
('193184006', ''),
('193185007', ''),
('193211001', ''),
('193263008', ''),
('193349004', ''),
('193350004', ''),
('193351000', ''),
('193352007', ''),
('193353002', ''),
('193489006', ''),
('195302000', ''),
('195303005', ''),
('197605007', ''),
('198493003', ''),
('200687002', ''),
('201250006', ''),
('201251005', ''),
('201252003', ''),
('201723002', ''),
('201724008', ''),
('207022008', ''),
('207023003', ''),
('230572002', ''),
('230577008', ''),
('232020009', ''),
('236500003', ''),
('25093002', ''),
('267381003', ''),
('267471001', ''),
('267472008', ''),
('267604001', ''),
('267722005', ''),
('275522008', ''),
('280137006', ''),
('309426007', ''),
('311782002', ''),
('31411005', ''),
('314368001', ''),
('314369009', ''),
('314370005', ''),
('314371009', ''),
('314377008', ''),
('314378003', ''),
('314893005', ''),
('314902007', ''),
('314903002', ''),
('314904008', ''),
('373041000000101', ''),
('389377004', ''),
('390108009', ''),
('39058009', ''),
('390718008', ''),
('390834004', ''),
('390854003', ''),
('392797006', ''),
('392801007', ''),
('393751000', ''),
('393755009', ''),
('394673007', ''),
('394674001', ''),
('39710007', ''),
('401110002', ''),
('408409007', ''),
('408410002', ''),
('408411003', ''),
('408412005', ''),
('408413000', ''),
('408414006', ''),
('408415007', ''),
('408416008', ''),
('414890007', ''),
('414894003', ''),
('414906009', ''),
('414910007', ''),
('417677008', ''),
('420279001', ''),
('420436000', ''),
('420486006', ''),
('420514000', ''),
('420715001', ''),
('420756003', ''),
('420789003', ''),
('420918009', ''),
('421326000', ''),
('421365002', ''),
('421468001', ''),
('421631007', ''),
('421779007', ''),
('421893009', ''),
('421895002', ''),
('421920002', ''),
('421986006', ''),
('422034002', ''),
('422088007', ''),
('422099009', ''),
('422166005', ''),
('422183001', ''),
('422228004', ''),
('422275004', ''),
('425911000000109', ''),
('43959009', ''),
('4855003', ''),
('49455004', ''),
('497731000000102', ''),
('497741000000106', ''),
('50620007', ''),
('59276001', ''),
('713702000', ''),
('713703005', ''),
('713705003', ''),
('713706002', ''),
('739681000', ''),
('866003', '')
GO
-- Query for diabetes_complications_comor
SELECT * INTO #diabetes_complications_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp102_diabetes_complications_comor_codelist
ON ConceptID = #tmp102_diabetes_complications_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for hemiplegia_comor
CREATE TABLE #tmp103_hemiplegia_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp103_hemiplegia_comor_codelist (code, category) VALUES
('11538006', ''),
('140810007', ''),
('140812004', ''),
('140813009', ''),
('155026001', ''),
('155029008', ''),
('155030003', ''),
('155031004', ''),
('1593000', ''),
('163601006', ''),
('163604003', ''),
('163605002', ''),
('192941004', ''),
('192942006', ''),
('192943001', ''),
('192944007', ''),
('192946009', ''),
('192949002', ''),
('192953000', ''),
('192955007', ''),
('192964002', ''),
('192965001', ''),
('192966000', ''),
('192967009', ''),
('20022000', ''),
('230775003', ''),
('267589002', ''),
('275468009', ''),
('278284007', ''),
('278285008', ''),
('278286009', ''),
('278287000', ''),
('307324001', ''),
('48721008', ''),
('50582007', ''),
('60389000', ''),
('79633009', ''),
('80935004', ''),
('813921000000104', '')
GO
-- Query for hemiplegia_comor
SELECT * INTO #hemiplegia_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp103_hemiplegia_comor_codelist
ON ConceptID = #tmp103_hemiplegia_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for hiv_comor
CREATE TABLE #tmp104_hiv_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp104_hiv_comor_codelist (code, category) VALUES
('111880001', ''),
('143224002', ''),
('165816005', ''),
('186705005', ''),
('186706006', ''),
('186707002', ''),
('186708007', ''),
('186719005', ''),
('186721000', ''),
('186722007', ''),
('186723002', ''),
('187438009', ''),
('187443002', ''),
('198609003', ''),
('234644008', ''),
('420403001', ''),
('420524008', ''),
('420818005', ''),
('421529006', ''),
('421671002', ''),
('422003001', ''),
('442537007', ''),
('468931000000102', ''),
('62479008', ''),
('713572001', ''),
('713897006', ''),
('81000119104', ''),
('86406008', ''),
('91947003', ''),
('95892003', '')
GO
-- Query for hiv_comor
SELECT * INTO #hiv_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp104_hiv_comor_codelist
ON ConceptID = #tmp104_hiv_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for metastatic_cancer_comor
CREATE TABLE #tmp105_metastatic_cancer_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp105_metastatic_cancer_comor_codelist (code, category) VALUES
('128462008', ''),
('134421000', ''),
('14799000', ''),
('188436005', ''),
('188438006', ''),
('188441002', ''),
('188442009', ''),
('188445006', ''),
('188446007', ''),
('188454009', ''),
('188455005', ''),
('188456006', ''),
('188457002', ''),
('188458007', ''),
('188459004', ''),
('188461008', ''),
('188462001', ''),
('188464000', ''),
('188469005', ''),
('188470006', ''),
('188471005', ''),
('188472003', ''),
('188481009', ''),
('189543007', ''),
('189550006', ''),
('236005001', ''),
('255122000', ''),
('255126002', ''),
('269473008', ''),
('274088005', ''),
('303194003', ''),
('303201005', ''),
('309741006', ''),
('448922007', ''),
('463191000000105', ''),
('713572001', ''),
('79282002', ''),
('94161006', ''),
('94181007', ''),
('94186002', ''),
('94222008', ''),
('94225005', ''),
('94227002', ''),
('94248000', ''),
('94260004', ''),
('94275007', ''),
('94297009', ''),
('94313005', ''),
('94335002', ''),
('94336001', ''),
('94338000', ''),
('94344001', ''),
('94347008', ''),
('94350006', ''),
('94351005', ''),
('94360002', ''),
('94365007', ''),
('94381002', ''),
('94391008', ''),
('94392001', ''),
('94393006', ''),
('94395004', ''),
('94396003', ''),
('94398002', ''),
('94408005', ''),
('94409002', ''),
('94410007', ''),
('94442001', ''),
('94449005', ''),
('94455000', ''),
('94475009', ''),
('94477001', ''),
('94481001', ''),
('94493005', ''),
('94503003', ''),
('94513006', ''),
('94515004', ''),
('94544002', ''),
('94554003', ''),
('94566009', ''),
('94575006', ''),
('94579000', ''),
('94580002', ''),
('94600009', ''),
('94609005', ''),
('94611001', ''),
('94612008', ''),
('94623007', ''),
('94627008', ''),
('94628003', ''),
('94638008', ''),
('94642006', ''),
('94659001', ''),
('94661005', ''),
('94663008', ''),
('94665001', ''),
('94668004', ''),
('94681006', '')
GO
-- Query for metastatic_cancer_comor
SELECT * INTO #metastatic_cancer_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp105_metastatic_cancer_comor_codelist
ON ConceptID = #tmp105_metastatic_cancer_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for mild_liver_comor
CREATE TABLE #tmp106_mild_liver_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp106_mild_liver_comor_codelist (code, category) VALUES
('10295004', ''),
('12368000', ''),
('124437004', ''),
('128302006', ''),
('155811002', ''),
('155813004', ''),
('155815006', ''),
('1761006', ''),
('186637001', ''),
('186639003', ''),
('186640001', ''),
('197279005', ''),
('197284004', ''),
('197285003', ''),
('197286002', ''),
('197287006', ''),
('197288001', ''),
('197289009', ''),
('197290000', ''),
('197293003', ''),
('197294009', ''),
('197296006', ''),
('197303009', ''),
('197307005', ''),
('197308000', ''),
('197309008', ''),
('197310003', ''),
('197311004', ''),
('197313001', ''),
('197359004', ''),
('197360009', ''),
('197361008', ''),
('197362001', ''),
('197553002', ''),
('19943007', ''),
('235869004', ''),
('235891006', ''),
('235892004', ''),
('235894003', ''),
('235896001', ''),
('266467008', ''),
('266468003', ''),
('266469006', ''),
('266470007', ''),
('266471006', ''),
('266472004', ''),
('266540000', ''),
('271440004', ''),
('29633007', ''),
('307757001', ''),
('31712002', ''),
('399126000', ''),
('41889008', ''),
('419728003', ''),
('420054005', ''),
('43904005', ''),
('470971000000107', ''),
('57339008', ''),
('6183001', ''),
('61977001', ''),
('68784009', ''),
('74669004', ''),
('75393009', ''),
('76301009', ''),
('76783007', ''),
('776981000000103', ''),
('89580002', '')
GO
-- Query for mild_liver_comor
SELECT * INTO #mild_liver_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp106_mild_liver_comor_codelist
ON ConceptID = #tmp106_mild_liver_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for mod_severe_liver_comor
CREATE TABLE #tmp107_mod_severe_liver_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp107_mod_severe_liver_comor_codelist (code, category) VALUES
('13920009', ''),
('14223005', ''),
('155820006', ''),
('155821005', ''),
('174425003', ''),
('174426002', ''),
('174427006', ''),
('174428001', ''),
('174429009', ''),
('17709002', ''),
('18027006', ''),
('195474004', ''),
('195475003', ''),
('195476002', ''),
('195477006', ''),
('195479009', ''),
('213153001', ''),
('28670008', ''),
('308129003', ''),
('309783001', ''),
('312980002', ''),
('316061004', ''),
('34742003', ''),
('426356008', ''),
('464381000000109', ''),
('51292008', ''),
('72836002', ''),
('737297006', '')
GO
-- Query for mod_severe_liver_comor
SELECT * INTO #mod_severe_liver_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp107_mod_severe_liver_comor_codelist
ON ConceptID = #tmp107_mod_severe_liver_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for mod_severe_renal_comor
CREATE TABLE #tmp108_mod_severe_renal_comor_codelist (
code VARCHAR(16) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp108_mod_severe_renal_comor_codelist (code, category) VALUES
('1003181000000102', ''),
('116223007', ''),
('138957005', ''),
('151048001', ''),
('151055004', ''),
('161665007', ''),
('161693006', ''),
('175899003', ''),
('175901007', ''),
('175902000', ''),
('175903005', ''),
('175904004', ''),
('175910004', ''),
('17778006', ''),
('180266001', ''),
('180267005', ''),
('180268000', ''),
('180269008', ''),
('180270009', ''),
('180272001', ''),
('180273006', ''),
('180277007', ''),
('193196004', ''),
('194909006', ''),
('195791000119101', ''),
('197612003', ''),
('197613008', ''),
('197614002', ''),
('197615001', ''),
('197616000', ''),
('197618004', ''),
('197619007', ''),
('197620001', ''),
('197621002', ''),
('197655004', ''),
('197656003', ''),
('197657007', ''),
('197707007', ''),
('197708002', ''),
('197709005', ''),
('197713003', ''),
('197714009', ''),
('197715005', ''),
('197747000', ''),
('197755007', ''),
('198507006', ''),
('198526003', ''),
('20917003', ''),
('213047004', ''),
('213147001', ''),
('213150003', ''),
('216878005', ''),
('216933008', ''),
('233581009', ''),
('236138007', ''),
('236374007', ''),
('236392004', ''),
('236423003', ''),
('236425005', ''),
('236433006', ''),
('236522005', ''),
('236539007', ''),
('236553007', ''),
('236570004', ''),
('236573002', ''),
('236574008', ''),
('236575009', ''),
('236576005', ''),
('236577001', ''),
('236578006', ''),
('236582008', ''),
('238317004', ''),
('238318009', ''),
('248721000000108', ''),
('249311000000109', ''),
('251859005', ''),
('265550007', ''),
('265763003', ''),
('265764009', ''),
('266553002', ''),
('266614002', ''),
('271418008', ''),
('276883000', ''),
('277010001', ''),
('284348003', ''),
('302497006', ''),
('309819001', ''),
('309861000000100', ''),
('309871000000107', ''),
('316054003', ''),
('316089001', ''),
('316306003', ''),
('316307007', ''),
('316308002', ''),
('316309005', ''),
('324121000000109', ''),
('324181000000105', ''),
('324211000000106', ''),
('324251000000105', ''),
('324281000000104', ''),
('324311000000101', ''),
('324341000000100', ''),
('324371000000106', ''),
('324411000000105', ''),
('324441000000106', ''),
('324471000000100', ''),
('324501000000107', ''),
('324541000000105', ''),
('33461007', ''),
('385971003', ''),
('398471000000102', ''),
('398481000000100', ''),
('399241000000100', ''),
('410511000000103', ''),
('421032001', ''),
('423062001', ''),
('42399005', ''),
('426340003', ''),
('426351000000102', ''),
('428645009', ''),
('428648006', ''),
('429211000000100', ''),
('429496005', ''),
('430332005', ''),
('431855005', ''),
('431856006', ''),
('431857002', ''),
('433144002', ''),
('433146000', ''),
('438546008', ''),
('438548009', ''),
('44730006', ''),
('449288005', ''),
('46177005', ''),
('467241000000102', ''),
('468871000000108', ''),
('480011000000106', ''),
('49708008', ''),
('60926001', ''),
('699235009', ''),
('700378005', ''),
('700379002', ''),
('70536003', ''),
('709044004', ''),
('711411006', ''),
('711413009', ''),
('711446003', ''),
('71192002', ''),
('716651000000106', ''),
('717231000000104', ''),
('717461000000108', ''),
('717751000000104', ''),
('77182004', ''),
('80321008', ''),
('843691000000100', ''),
('844661000000109', ''),
('846461000000102', ''),
('846731000000104', ''),
('847881000000107', ''),
('853631000000103', ''),
('854161000000102', ''),
('865761000000105', ''),
('865801000000100', ''),
('865841000000102', ''),
('866001000000102', ''),
('866041000000104', ''),
('866061000000103', ''),
('867011000000102', ''),
('867051000000103', ''),
('88797001', ''),
('90688005', ''),
('90708001', '')
GO
-- Query for mod_severe_renal_comor
SELECT * INTO #mod_severe_renal_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp108_mod_severe_renal_comor_codelist
ON ConceptID = #tmp108_mod_severe_renal_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for mi_comor
CREATE TABLE #tmp109_mi_comor_codelist (
code VARCHAR(9) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp109_mi_comor_codelist (code, category) VALUES
('10273003', ''),
('129574000', ''),
('138785002', ''),
('155304006', ''),
('155306008', ''),
('155321002', ''),
('15990001', ''),
('161502000', ''),
('161503005', ''),
('161516005', ''),
('1755008', ''),
('194796000', ''),
('194797009', ''),
('194798004', ''),
('194799007', ''),
('194800006', ''),
('194801005', ''),
('194802003', ''),
('194803008', ''),
('194804002', ''),
('194808004', ''),
('194809007', ''),
('194810002', ''),
('194811003', ''),
('194824003', ''),
('194827005', ''),
('194856005', ''),
('194857001', ''),
('194858006', ''),
('194859003', ''),
('194861007', ''),
('194862000', ''),
('194863005', ''),
('194865003', ''),
('194866002', ''),
('194867006', ''),
('194868001', ''),
('194870005', ''),
('22298006', ''),
('233838001', ''),
('233843008', ''),
('233846000', ''),
('233847009', ''),
('233885007', ''),
('304914007', ''),
('307140009', ''),
('308065005', ''),
('311790002', ''),
('311792005', ''),
('311793000', ''),
('311796008', ''),
('398274000', ''),
('399211009', ''),
('401303003', ''),
('401314000', ''),
('412771006', ''),
('42531007', ''),
('52035003', ''),
('54329005', ''),
('57054005', ''),
('58612006', ''),
('62695002', ''),
('65547006', ''),
('66189004', ''),
('70211005', ''),
('70422006', ''),
('73795002', ''),
('76593002', ''),
('79009004', '')
GO
-- Query for mi_comor
SELECT * INTO #mi_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp109_mi_comor_codelist
ON ConceptID = #tmp109_mi_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for peptic_ulcer_comor
CREATE TABLE #tmp110_peptic_ulcer_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp110_peptic_ulcer_comor_codelist (code, category) VALUES
('111353003', ''),
('12274003', ''),
('128286008', ''),
('128287004', ''),
('12847006', ''),
('13200003', ''),
('155674002', ''),
('155682002', ''),
('155685000', ''),
('155686004', ''),
('155687008', ''),
('155689006', ''),
('155690002', ''),
('155692005', ''),
('155695007', ''),
('155696008', ''),
('155697004', ''),
('155699001', ''),
('155700000', ''),
('155702008', ''),
('155703003', ''),
('155705005', ''),
('155706006', ''),
('155707002', ''),
('155709004', ''),
('155710009', ''),
('15902003', ''),
('196607008', ''),
('196609006', ''),
('196627009', ''),
('196629007', ''),
('196630002', ''),
('196633000', ''),
('196634006', ''),
('196637004', ''),
('196639001', ''),
('196640004', ''),
('196641000', ''),
('196642007', ''),
('196644008', ''),
('196645009', ''),
('196647001', ''),
('196649003', ''),
('196652006', ''),
('196656009', ''),
('196658005', ''),
('196659002', ''),
('196660007', ''),
('196663009', ''),
('196664003', ''),
('196666001', ''),
('196667005', ''),
('196668000', ''),
('196669008', ''),
('196670009', ''),
('196671008', ''),
('196672001', ''),
('196675004', ''),
('196677007', ''),
('196679005', ''),
('196680008', ''),
('196681007', ''),
('196682000', ''),
('196684004', ''),
('196685003', ''),
('196688001', ''),
('196689009', ''),
('196691001', ''),
('196692008', ''),
('196694009', ''),
('196695005', ''),
('196696006', ''),
('196697002', ''),
('196700003', ''),
('196702006', ''),
('196704007', ''),
('196705008', ''),
('19850005', ''),
('22620000', ''),
('235652004', ''),
('235692002', ''),
('266436006', ''),
('266437002', ''),
('266501005', ''),
('266502003', ''),
('27281001', ''),
('30811009', ''),
('31301004', ''),
('313425006', ''),
('3483000', ''),
('36975000', ''),
('39204006', ''),
('397825006', ''),
('423643000', ''),
('424301005', ''),
('48974009', ''),
('49232000', ''),
('49916007', ''),
('51868009', ''),
('57246001', ''),
('6129004', ''),
('61347001', ''),
('62366003', ''),
('62465000', ''),
('64595005', ''),
('722200003', ''),
('76181002', ''),
('79118000', ''),
('849591000000103', ''),
('849601000000109', ''),
('849611000000106', ''),
('86895006', ''),
('88700009', ''),
('88968005', ''),
('89469000', ''),
('89748001', ''),
('95529005', ''),
('95530000', ''),
('9829001', '')
GO
-- Query for peptic_ulcer_comor
SELECT * INTO #peptic_ulcer_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp110_peptic_ulcer_comor_codelist
ON ConceptID = #tmp110_peptic_ulcer_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading codelist for peripheral_vascular_comor
CREATE TABLE #tmp111_peripheral_vascular_comor_codelist (
code VARCHAR(15) COLLATE Latin1_General_BIN,
category VARCHAR(MAX)
)
GO
INSERT INTO #tmp111_peripheral_vascular_comor_codelist (code, category) VALUES
('112828007', ''),
('116360008', ''),
('12232008', ''),
('123679006', ''),
('134379001', ''),
('138896003', ''),
('139160007', ''),
('141803005', ''),
('14336007', ''),
('155419006', ''),
('155420000', ''),
('155423003', ''),
('155424009', ''),
('155430009', ''),
('158349008', ''),
('158350008', ''),
('158352000', ''),
('161514008', ''),
('161630007', ''),
('161905007', ''),
('164625009', ''),
('175282008', ''),
('175283003', ''),
('175284009', ''),
('175286006', ''),
('175297006', ''),
('175298001', ''),
('175299009', ''),
('175301002', ''),
('175350008', ''),
('175578005', ''),
('175582007', ''),
('175594003', ''),
('175595002', ''),
('175596001', ''),
('175653002', ''),
('175670005', ''),
('175685004', ''),
('186413007', ''),
('186419006', ''),
('186422008', ''),
('186423003', ''),
('195258006', ''),
('195260008', ''),
('195262000', ''),
('195263005', ''),
('195264004', ''),
('195265003', ''),
('195266002', ''),
('195268001', ''),
('195269009', ''),
('195301007', ''),
('195302000', ''),
('195303005', ''),
('195304004', ''),
('195305003', ''),
('195306002', ''),
('195307006', ''),
('195308001', ''),
('195310004', ''),
('195311000', ''),
('195312007', ''),
('195314008', ''),
('195374003', ''),
('195618000', ''),
('207019006', ''),
('207020000', ''),
('207022008', ''),
('207023003', ''),
('207024009', ''),
('233353004', ''),
('233354005', ''),
('233355006', ''),
('233357003', ''),
('233359000', ''),
('233361009', ''),
('233362002', ''),
('233363007', ''),
('233369006', ''),
('233370007', ''),
('233374003', ''),
('233376001', ''),
('233377005', ''),
('233380006', ''),
('233383008', ''),
('233384002', ''),
('233404000', ''),
('233958001', ''),
('233961000', ''),
('233984007', ''),
('233985008', ''),
('252094004', ''),
('265492000', ''),
('265493005', ''),
('265499009', ''),
('265513006', ''),
('265852008', ''),
('266091007', ''),
('266092000', ''),
('266093005', ''),
('266260007', ''),
('266321007', ''),
('275037003', ''),
('275040003', ''),
('275520000', ''),
('301755001', ''),
('307701005', ''),
('308071004', ''),
('308546005', ''),
('312688006', ''),
('314184006', ''),
('314185007', ''),
('314186008', ''),
('32907006', ''),
('34365005', ''),
('366785001', ''),
('366863004', ''),
('367109006', ''),
('372070002', ''),
('399957001', ''),
('400047006', ''),
('400701000000105', ''),
('405463009', ''),
('405469008', ''),
('405477007', ''),
('405482000', ''),
('405516005', ''),
('426270006', ''),
('428809009', ''),
('429679003', ''),
('437911000000104', ''),
('441612006', ''),
('444569004', ''),
('44662004', ''),
('448122008', ''),
('448323005', ''),
('448529008', ''),
('450682002', ''),
('497701000000108', ''),
('497711000000105', ''),
('497731000000102', ''),
('497741000000106', ''),
('50807007', ''),
('51018000', ''),
('63491006', ''),
('67076004', ''),
('67362008', ''),
('707265005', ''),
('73067008', ''),
('74883004', ''),
('802941000000103', ''),
('80466000', '')
GO
-- Query for peripheral_vascular_comor
SELECT * INTO #peripheral_vascular_comor FROM (
SELECT
CodedEvent_SNOMED.Patient_ID AS patient_id,
1 AS binary_flag,
MAX(ConsultationDate) AS date
FROM CodedEvent_SNOMED
INNER JOIN #tmp111_peripheral_vascular_comor_codelist
ON ConceptID = #tmp111_peripheral_vascular_comor_codelist.code
LEFT JOIN #patient_index_date
ON #patient_index_date.patient_id = CodedEvent_SNOMED.patient_id
WHERE ConsultationDate BETWEEN DATEADD(YEAR, -5, #patient_index_date.patient_index_date) AND #patient_index_date.patient_index_date
AND NOT 0 = 1
AND 1 = 1
GROUP BY CodedEvent_SNOMED.Patient_ID
) t
GO
-- Uploading file for value
CREATE TABLE #tmp112_population_file (
patient_id BIGINT,
value INT
)
GO
-- Query for population
SELECT * INTO #population FROM (
SELECT
patient_id,
value
FROM
#tmp112_population_file
) t
GO
-- Join all columns for final output
SELECT
#population.patient_id AS patient_id,
ISNULL(CONVERT(VARCHAR(10), #patient_index_date.patient_index_date, 23), '') AS patient_index_date,
ISNULL(#age.value, 0) AS age,
ISNULL(#sex.value, '') AS sex,
ISNULL(#stp.stp_code, '') AS stp,
ISNULL(CONVERT(VARCHAR(10), #dereg_date.value, 23), '') AS dereg_date,
ISNULL(CONVERT(VARCHAR(10), #ons_died_date.date_of_death, 23), '') AS ons_died_date,
ISNULL(#Rx_Amikacin.number_of_matches_in_period, 0) AS Rx_Amikacin,
ISNULL(#Rx_Amoxicillin.number_of_matches_in_period, 0) AS Rx_Amoxicillin,
ISNULL(#Rx_Ampicillin.number_of_matches_in_period, 0) AS Rx_Ampicillin,
ISNULL(#Rx_Azithromycin.number_of_matches_in_period, 0) AS Rx_Azithromycin,
ISNULL(#Rx_Aztreonam.number_of_matches_in_period, 0) AS Rx_Aztreonam,
ISNULL(#Rx_Benzylpenicillin.number_of_matches_in_period, 0) AS Rx_Benzylpenicillin,
ISNULL(#Rx_Cefaclor.number_of_matches_in_period, 0) AS Rx_Cefaclor,
ISNULL(#Rx_Cefadroxil.number_of_matches_in_period, 0) AS Rx_Cefadroxil,
ISNULL(#Rx_Cefalexin.number_of_matches_in_period, 0) AS Rx_Cefalexin,
ISNULL(#Rx_Cefamandole.number_of_matches_in_period, 0) AS Rx_Cefamandole,
ISNULL(#Rx_Cefazolin.number_of_matches_in_period, 0) AS Rx_Cefazolin,
ISNULL(#Rx_Cefepime.number_of_matches_in_period, 0) AS Rx_Cefepime,
ISNULL(#Rx_Cefixime.number_of_matches_in_period, 0) AS Rx_Cefixime,
ISNULL(#Rx_Cefotaxime.number_of_matches_in_period, 0) AS Rx_Cefotaxime,
ISNULL(#Rx_Cefoxitin.number_of_matches_in_period, 0) AS Rx_Cefoxitin,
ISNULL(#Rx_Cefpirome.number_of_matches_in_period, 0) AS Rx_Cefpirome,
ISNULL(#Rx_Cefpodoxime.number_of_matches_in_period, 0) AS Rx_Cefpodoxime,
ISNULL(#Rx_Cefprozil.number_of_matches_in_period, 0) AS Rx_Cefprozil,
ISNULL(#Rx_Cefradine.number_of_matches_in_period, 0) AS Rx_Cefradine,
ISNULL(#Rx_Ceftazidime.number_of_matches_in_period, 0) AS Rx_Ceftazidime,
ISNULL(#Rx_Ceftriaxone.number_of_matches_in_period, 0) AS Rx_Ceftriaxone,
ISNULL(#Rx_Cefuroxime.number_of_matches_in_period, 0) AS Rx_Cefuroxime,
ISNULL(#Rx_Chloramphenicol.number_of_matches_in_period, 0) AS Rx_Chloramphenicol,
ISNULL(#Rx_Cilastatin.number_of_matches_in_period, 0) AS Rx_Cilastatin,
ISNULL(#Rx_Ciprofloxacin.number_of_matches_in_period, 0) AS Rx_Ciprofloxacin,
ISNULL(#Rx_Clarithromycin.number_of_matches_in_period, 0) AS Rx_Clarithromycin,
ISNULL(#Rx_Clindamycin.number_of_matches_in_period, 0) AS Rx_Clindamycin,
ISNULL(#Rx_Co_amoxiclav.number_of_matches_in_period, 0) AS Rx_Co_amoxiclav,
ISNULL(#Rx_Co_fluampicil.number_of_matches_in_period, 0) AS Rx_Co_fluampicil,
ISNULL(#Rx_Colistimethate.number_of_matches_in_period, 0) AS Rx_Colistimethate,
ISNULL(#Rx_Dalbavancin.number_of_matches_in_period, 0) AS Rx_Dalbavancin,
ISNULL(#Rx_Dalfopristin.number_of_matches_in_period, 0) AS Rx_Dalfopristin,
ISNULL(#Rx_Daptomycin.number_of_matches_in_period, 0) AS Rx_Daptomycin,
ISNULL(#Rx_Demeclocycline.number_of_matches_in_period, 0) AS Rx_Demeclocycline,
ISNULL(#Rx_Doripenem.number_of_matches_in_period, 0) AS Rx_Doripenem,
ISNULL(#Rx_Doxycycline.number_of_matches_in_period, 0) AS Rx_Doxycycline,
ISNULL(#Rx_Ertapenem.number_of_matches_in_period, 0) AS Rx_Ertapenem,
ISNULL(#Rx_Erythromycin.number_of_matches_in_period, 0) AS Rx_Erythromycin,
ISNULL(#Rx_Fidaxomicin.number_of_matches_in_period, 0) AS Rx_Fidaxomicin,
ISNULL(#Rx_Flucloxacillin.number_of_matches_in_period, 0) AS Rx_Flucloxacillin,
ISNULL(#Rx_Fosfomycin.number_of_matches_in_period, 0) AS Rx_Fosfomycin,
ISNULL(#Rx_Fusidate.number_of_matches_in_period, 0) AS Rx_Fusidate,
ISNULL(#Rx_Gentamicin.number_of_matches_in_period, 0) AS Rx_Gentamicin,
ISNULL(#Rx_Levofloxacin.number_of_matches_in_period, 0) AS Rx_Levofloxacin,
ISNULL(#Rx_Linezolid.number_of_matches_in_period, 0) AS Rx_Linezolid,
ISNULL(#Rx_Lymecycline.number_of_matches_in_period, 0) AS Rx_Lymecycline,
ISNULL(#Rx_Meropenem.number_of_matches_in_period, 0) AS Rx_Meropenem,
ISNULL(#Rx_Methenamine.number_of_matches_in_period, 0) AS Rx_Methenamine,
ISNULL(#Rx_Metronidazole.number_of_matches_in_period, 0) AS Rx_Metronidazole,
ISNULL(#Rx_Minocycline.number_of_matches_in_period, 0) AS Rx_Minocycline,
ISNULL(#Rx_Moxifloxacin.number_of_matches_in_period, 0) AS Rx_Moxifloxacin,
ISNULL(#Rx_Nalidixic_acid.number_of_matches_in_period, 0) AS Rx_Nalidixic_acid,
ISNULL(#Rx_Neomycin.number_of_matches_in_period, 0) AS Rx_Neomycin,
ISNULL(#Rx_Netilmicin.number_of_matches_in_period, 0) AS Rx_Netilmicin,
ISNULL(#Rx_Nitazoxanid.number_of_matches_in_period, 0) AS Rx_Nitazoxanid,
ISNULL(#Rx_Nitrofurantoin.number_of_matches_in_period, 0) AS Rx_Nitrofurantoin,
ISNULL(#Rx_Norfloxacin.number_of_matches_in_period, 0) AS Rx_Norfloxacin,
ISNULL(#Rx_Ofloxacin.number_of_matches_in_period, 0) AS Rx_Ofloxacin,
ISNULL(#Rx_Oxytetracycline.number_of_matches_in_period, 0) AS Rx_Oxytetracycline,
ISNULL(#Rx_Phenoxymethylpenicillin.number_of_matches_in_period, 0) AS Rx_Phenoxymethylpenicillin,
ISNULL(#Rx_Piperacillin.number_of_matches_in_period, 0) AS Rx_Piperacillin,
ISNULL(#Rx_Pivmecillinam.number_of_matches_in_period, 0) AS Rx_Pivmecillinam,
ISNULL(#Rx_Pristinamycin.number_of_matches_in_period, 0) AS Rx_Pristinamycin,
ISNULL(#Rx_Rifaximin.number_of_matches_in_period, 0) AS Rx_Rifaximin,
ISNULL(#Rx_Sulfadiazine.number_of_matches_in_period, 0) AS Rx_Sulfadiazine,
ISNULL(#Rx_Sulfamethoxazole.number_of_matches_in_period, 0) AS Rx_Sulfamethoxazole,
ISNULL(#Rx_Sulfapyridine.number_of_matches_in_period, 0) AS Rx_Sulfapyridine,
ISNULL(#Rx_Taurolidin.number_of_matches_in_period, 0) AS Rx_Taurolidin,
ISNULL(#Rx_Tedizolid.number_of_matches_in_period, 0) AS Rx_Tedizolid,
ISNULL(#Rx_Teicoplanin.number_of_matches_in_period, 0) AS Rx_Teicoplanin,
ISNULL(#Rx_Telithromycin.number_of_matches_in_period, 0) AS Rx_Telithromycin,
ISNULL(#Rx_Temocillin.number_of_matches_in_period, 0) AS Rx_Temocillin,
ISNULL(#Rx_Tetracycline.number_of_matches_in_period, 0) AS Rx_Tetracycline,
ISNULL(#Rx_Ticarcillin.number_of_matches_in_period, 0) AS Rx_Ticarcillin,
ISNULL(#Rx_Tigecycline.number_of_matches_in_period, 0) AS Rx_Tigecycline,
ISNULL(#Rx_Tinidazole.number_of_matches_in_period, 0) AS Rx_Tinidazole,
ISNULL(#Rx_Tobramycin.number_of_matches_in_period, 0) AS Rx_Tobramycin,
ISNULL(#Rx_Trimethoprim.number_of_matches_in_period, 0) AS Rx_Trimethoprim,
ISNULL(#Rx_Vancomycin.number_of_matches_in_period, 0) AS Rx_Vancomycin,
ISNULL(#ab_prescriptions.number_of_matches_in_period, 0) AS ab_prescriptions,
ISNULL(CONVERT(VARCHAR(10), #ab_first_date.date, 23), '') AS ab_first_date,
ISNULL(CONVERT(VARCHAR(10), #ab_last_date.date, 23), '') AS ab_last_date,
ISNULL(#broad_ab_prescriptions.number_of_matches_in_period, 0) AS broad_ab_prescriptions,
CASE WHEN (ISNULL(#age.value, 0) >= 18 AND ISNULL(#age.value, 0) < 30) THEN '18-29' WHEN (ISNULL(#age.value, 0) >= 30 AND ISNULL(#age.value, 0) < 40) THEN '30-39' WHEN (ISNULL(#age.value, 0) >= 40 AND ISNULL(#age.value, 0) < 50) THEN '40-49' WHEN (ISNULL(#age.value, 0) >= 50 AND ISNULL(#age.value, 0) < 60) THEN '50-59' WHEN (ISNULL(#age.value, 0) >= 60 AND ISNULL(#age.value, 0) < 70) THEN '60-69' WHEN (ISNULL(#age.value, 0) >= 70 AND ISNULL(#age.value, 0) < 80) THEN '70-79' WHEN (ISNULL(#age.value, 0) >= 80 AND ISNULL(#age.value, 0) < 110) THEN '80+' ELSE '0' END AS age_cat,
ISNULL(#ethnicity.category, '') AS ethnicity,
ISNULL(#care_home.binary_flag, 0) AS care_home,
ISNULL(CONVERT(VARCHAR(4), #care_home.date, 23), '') AS care_home_date,
CASE WHEN (ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) >= 1 AND ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) < 32844 * 1 / 5) THEN '1' WHEN (ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) >= 32844 * 1 / 5 AND ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) < 32844 * 2 / 5) THEN '2' WHEN (ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) >= 32844 * 2 / 5 AND ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) < 32844 * 3 / 5) THEN '3' WHEN (ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) >= 32844 * 3 / 5 AND ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) < 32844 * 4 / 5) THEN '4' WHEN (ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) >= 32844 * 4 / 5 AND ISNULL(#index_of_multiple_deprivation.index_of_multiple_deprivation, 0) < 32844) THEN '5' ELSE '0' END AS imd,
ISNULL(#practice.pseudo_id, 0) AS practice,
ISNULL(#region.nuts1_region_name, '') AS region,
ISNULL(#bmi.value, 0.0) AS bmi,
ISNULL(CONVERT(VARCHAR(10), #bmi.date, 23), '') AS bmi_date_measured,
CASE WHEN (ISNULL(#most_recent_smoking_code.category, '') = 'S') THEN 'S' WHEN (ISNULL(#most_recent_smoking_code.category, '') = 'E' OR ( ISNULL(#most_recent_smoking_code.category, '') = 'N' AND ( ISNULL(#ever_smoked.binary_flag, 0) != 0 ) )) THEN 'E' WHEN (ISNULL(#most_recent_smoking_code.category, '') = 'N' AND NOT ( ISNULL(#ever_smoked.binary_flag, 0) != 0 )) THEN 'N' ELSE 'M' END AS smoking_status,
ISNULL(CONVERT(VARCHAR(7), #smoking_status_date.date, 23), '') AS smoking_status_date,
ISNULL(CONVERT(VARCHAR(7), #most_recent_unclear_smoking_cat_date.date, 23), '') AS most_recent_unclear_smoking_cat_date,
ISNULL(#flu_vaccine_tpp.binary_flag, 0) AS flu_vaccine_tpp,
ISNULL(CONVERT(VARCHAR(7), #flu_vaccine_med.date, 23), '') AS flu_vaccine_med,
ISNULL(CONVERT(VARCHAR(7), #flu_vaccine_clinical.date, 23), '') AS flu_vaccine_clinical,
CASE WHEN (( ISNULL(#flu_vaccine_tpp.binary_flag, 0) != 0 ) OR ( ISNULL(CONVERT(VARCHAR(7), #flu_vaccine_med.date, 23), '') != '' ) OR ( ISNULL(CONVERT(VARCHAR(7), #flu_vaccine_clinical.date, 23), '') != '' )) THEN 1 ELSE 0 END AS flu_vaccine,
ISNULL(CONVERT(VARCHAR(10), #covrx1_dat.date, 23), '') AS covrx1_dat,
ISNULL(CONVERT(VARCHAR(10), #covrx2_dat.date, 23), '') AS covrx2_dat,
ISNULL(#cancer_comor.binary_flag, 0) AS cancer_comor,
ISNULL(#cardiovascular_comor.binary_flag, 0) AS cardiovascular_comor,
ISNULL(#chronic_obstructive_pulmonary_comor.binary_flag, 0) AS chronic_obstructive_pulmonary_comor,
ISNULL(#heart_failure_comor.binary_flag, 0) AS heart_failure_comor,
ISNULL(#connective_tissue_comor.binary_flag, 0) AS connective_tissue_comor,
ISNULL(#dementia_comor.binary_flag, 0) AS dementia_comor,
ISNULL(#diabetes_comor.binary_flag, 0) AS diabetes_comor,
ISNULL(#diabetes_complications_comor.binary_flag, 0) AS diabetes_complications_comor,
ISNULL(#hemiplegia_comor.binary_flag, 0) AS hemiplegia_comor,
ISNULL(#hiv_comor.binary_flag, 0) AS hiv_comor,
ISNULL(#metastatic_cancer_comor.binary_flag, 0) AS metastatic_cancer_comor,
ISNULL(#mild_liver_comor.binary_flag, 0) AS mild_liver_comor,
ISNULL(#mod_severe_liver_comor.binary_flag, 0) AS mod_severe_liver_comor,
ISNULL(#mod_severe_renal_comor.binary_flag, 0) AS mod_severe_renal_comor,
ISNULL(#mi_comor.binary_flag, 0) AS mi_comor,
ISNULL(#peptic_ulcer_comor.binary_flag, 0) AS peptic_ulcer_comor,
ISNULL(#peripheral_vascular_comor.binary_flag, 0) AS peripheral_vascular_comor
FROM
#population
LEFT JOIN #patient_index_date ON #patient_index_date.patient_id = #population.patient_id
LEFT JOIN #age ON #age.patient_id = #population.patient_id
LEFT JOIN #sex ON #sex.patient_id = #population.patient_id
LEFT JOIN #stp ON #stp.patient_id = #population.patient_id
LEFT JOIN #dereg_date ON #dereg_date.patient_id = #population.patient_id
LEFT JOIN #ons_died_date ON #ons_died_date.patient_id = #population.patient_id
LEFT JOIN #Rx_Amikacin ON #Rx_Amikacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Amoxicillin ON #Rx_Amoxicillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Ampicillin ON #Rx_Ampicillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Azithromycin ON #Rx_Azithromycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Aztreonam ON #Rx_Aztreonam.patient_id = #population.patient_id
LEFT JOIN #Rx_Benzylpenicillin ON #Rx_Benzylpenicillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefaclor ON #Rx_Cefaclor.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefadroxil ON #Rx_Cefadroxil.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefalexin ON #Rx_Cefalexin.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefamandole ON #Rx_Cefamandole.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefazolin ON #Rx_Cefazolin.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefepime ON #Rx_Cefepime.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefixime ON #Rx_Cefixime.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefotaxime ON #Rx_Cefotaxime.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefoxitin ON #Rx_Cefoxitin.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefpirome ON #Rx_Cefpirome.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefpodoxime ON #Rx_Cefpodoxime.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefprozil ON #Rx_Cefprozil.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefradine ON #Rx_Cefradine.patient_id = #population.patient_id
LEFT JOIN #Rx_Ceftazidime ON #Rx_Ceftazidime.patient_id = #population.patient_id
LEFT JOIN #Rx_Ceftriaxone ON #Rx_Ceftriaxone.patient_id = #population.patient_id
LEFT JOIN #Rx_Cefuroxime ON #Rx_Cefuroxime.patient_id = #population.patient_id
LEFT JOIN #Rx_Chloramphenicol ON #Rx_Chloramphenicol.patient_id = #population.patient_id
LEFT JOIN #Rx_Cilastatin ON #Rx_Cilastatin.patient_id = #population.patient_id
LEFT JOIN #Rx_Ciprofloxacin ON #Rx_Ciprofloxacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Clarithromycin ON #Rx_Clarithromycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Clindamycin ON #Rx_Clindamycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Co_amoxiclav ON #Rx_Co_amoxiclav.patient_id = #population.patient_id
LEFT JOIN #Rx_Co_fluampicil ON #Rx_Co_fluampicil.patient_id = #population.patient_id
LEFT JOIN #Rx_Colistimethate ON #Rx_Colistimethate.patient_id = #population.patient_id
LEFT JOIN #Rx_Dalbavancin ON #Rx_Dalbavancin.patient_id = #population.patient_id
LEFT JOIN #Rx_Dalfopristin ON #Rx_Dalfopristin.patient_id = #population.patient_id
LEFT JOIN #Rx_Daptomycin ON #Rx_Daptomycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Demeclocycline ON #Rx_Demeclocycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Doripenem ON #Rx_Doripenem.patient_id = #population.patient_id
LEFT JOIN #Rx_Doxycycline ON #Rx_Doxycycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Ertapenem ON #Rx_Ertapenem.patient_id = #population.patient_id
LEFT JOIN #Rx_Erythromycin ON #Rx_Erythromycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Fidaxomicin ON #Rx_Fidaxomicin.patient_id = #population.patient_id
LEFT JOIN #Rx_Flucloxacillin ON #Rx_Flucloxacillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Fosfomycin ON #Rx_Fosfomycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Fusidate ON #Rx_Fusidate.patient_id = #population.patient_id
LEFT JOIN #Rx_Gentamicin ON #Rx_Gentamicin.patient_id = #population.patient_id
LEFT JOIN #Rx_Levofloxacin ON #Rx_Levofloxacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Linezolid ON #Rx_Linezolid.patient_id = #population.patient_id
LEFT JOIN #Rx_Lymecycline ON #Rx_Lymecycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Meropenem ON #Rx_Meropenem.patient_id = #population.patient_id
LEFT JOIN #Rx_Methenamine ON #Rx_Methenamine.patient_id = #population.patient_id
LEFT JOIN #Rx_Metronidazole ON #Rx_Metronidazole.patient_id = #population.patient_id
LEFT JOIN #Rx_Minocycline ON #Rx_Minocycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Moxifloxacin ON #Rx_Moxifloxacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Nalidixic_acid ON #Rx_Nalidixic_acid.patient_id = #population.patient_id
LEFT JOIN #Rx_Neomycin ON #Rx_Neomycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Netilmicin ON #Rx_Netilmicin.patient_id = #population.patient_id
LEFT JOIN #Rx_Nitazoxanid ON #Rx_Nitazoxanid.patient_id = #population.patient_id
LEFT JOIN #Rx_Nitrofurantoin ON #Rx_Nitrofurantoin.patient_id = #population.patient_id
LEFT JOIN #Rx_Norfloxacin ON #Rx_Norfloxacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Ofloxacin ON #Rx_Ofloxacin.patient_id = #population.patient_id
LEFT JOIN #Rx_Oxytetracycline ON #Rx_Oxytetracycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Phenoxymethylpenicillin ON #Rx_Phenoxymethylpenicillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Piperacillin ON #Rx_Piperacillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Pivmecillinam ON #Rx_Pivmecillinam.patient_id = #population.patient_id
LEFT JOIN #Rx_Pristinamycin ON #Rx_Pristinamycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Rifaximin ON #Rx_Rifaximin.patient_id = #population.patient_id
LEFT JOIN #Rx_Sulfadiazine ON #Rx_Sulfadiazine.patient_id = #population.patient_id
LEFT JOIN #Rx_Sulfamethoxazole ON #Rx_Sulfamethoxazole.patient_id = #population.patient_id
LEFT JOIN #Rx_Sulfapyridine ON #Rx_Sulfapyridine.patient_id = #population.patient_id
LEFT JOIN #Rx_Taurolidin ON #Rx_Taurolidin.patient_id = #population.patient_id
LEFT JOIN #Rx_Tedizolid ON #Rx_Tedizolid.patient_id = #population.patient_id
LEFT JOIN #Rx_Teicoplanin ON #Rx_Teicoplanin.patient_id = #population.patient_id
LEFT JOIN #Rx_Telithromycin ON #Rx_Telithromycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Temocillin ON #Rx_Temocillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Tetracycline ON #Rx_Tetracycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Ticarcillin ON #Rx_Ticarcillin.patient_id = #population.patient_id
LEFT JOIN #Rx_Tigecycline ON #Rx_Tigecycline.patient_id = #population.patient_id
LEFT JOIN #Rx_Tinidazole ON #Rx_Tinidazole.patient_id = #population.patient_id
LEFT JOIN #Rx_Tobramycin ON #Rx_Tobramycin.patient_id = #population.patient_id
LEFT JOIN #Rx_Trimethoprim ON #Rx_Trimethoprim.patient_id = #population.patient_id
LEFT JOIN #Rx_Vancomycin ON #Rx_Vancomycin.patient_id = #population.patient_id
LEFT JOIN #ab_prescriptions ON #ab_prescriptions.patient_id = #population.patient_id
LEFT JOIN #ab_first_date ON #ab_first_date.patient_id = #population.patient_id
LEFT JOIN #ab_last_date ON #ab_last_date.patient_id = #population.patient_id
LEFT JOIN #broad_ab_prescriptions ON #broad_ab_prescriptions.patient_id = #population.patient_id
LEFT JOIN #ethnicity ON #ethnicity.patient_id = #population.patient_id
LEFT JOIN #care_home ON #care_home.patient_id = #population.patient_id
LEFT JOIN #index_of_multiple_deprivation ON #index_of_multiple_deprivation.patient_id = #population.patient_id
LEFT JOIN #practice ON #practice.patient_id = #population.patient_id
LEFT JOIN #region ON #region.patient_id = #population.patient_id
LEFT JOIN #bmi ON #bmi.patient_id = #population.patient_id
LEFT JOIN #most_recent_smoking_code ON #most_recent_smoking_code.patient_id = #population.patient_id
LEFT JOIN #ever_smoked ON #ever_smoked.patient_id = #population.patient_id
LEFT JOIN #smoking_status_date ON #smoking_status_date.patient_id = #population.patient_id
LEFT JOIN #most_recent_unclear_smoking_cat_date ON #most_recent_unclear_smoking_cat_date.patient_id = #population.patient_id
LEFT JOIN #flu_vaccine_tpp ON #flu_vaccine_tpp.patient_id = #population.patient_id
LEFT JOIN #flu_vaccine_med ON #flu_vaccine_med.patient_id = #population.patient_id
LEFT JOIN #flu_vaccine_clinical ON #flu_vaccine_clinical.patient_id = #population.patient_id
LEFT JOIN #covrx1_dat ON #covrx1_dat.patient_id = #population.patient_id
LEFT JOIN #covrx2_dat ON #covrx2_dat.patient_id = #population.patient_id
LEFT JOIN #cancer_comor ON #cancer_comor.patient_id = #population.patient_id
LEFT JOIN #cardiovascular_comor ON #cardiovascular_comor.patient_id = #population.patient_id
LEFT JOIN #chronic_obstructive_pulmonary_comor ON #chronic_obstructive_pulmonary_comor.patient_id = #population.patient_id
LEFT JOIN #heart_failure_comor ON #heart_failure_comor.patient_id = #population.patient_id
LEFT JOIN #connective_tissue_comor ON #connective_tissue_comor.patient_id = #population.patient_id
LEFT JOIN #dementia_comor ON #dementia_comor.patient_id = #population.patient_id
LEFT JOIN #diabetes_comor ON #diabetes_comor.patient_id = #population.patient_id
LEFT JOIN #diabetes_complications_comor ON #diabetes_complications_comor.patient_id = #population.patient_id
LEFT JOIN #hemiplegia_comor ON #hemiplegia_comor.patient_id = #population.patient_id
LEFT JOIN #hiv_comor ON #hiv_comor.patient_id = #population.patient_id
LEFT JOIN #metastatic_cancer_comor ON #metastatic_cancer_comor.patient_id = #population.patient_id
LEFT JOIN #mild_liver_comor ON #mild_liver_comor.patient_id = #population.patient_id
LEFT JOIN #mod_severe_liver_comor ON #mod_severe_liver_comor.patient_id = #population.patient_id
LEFT JOIN #mod_severe_renal_comor ON #mod_severe_renal_comor.patient_id = #population.patient_id
LEFT JOIN #mi_comor ON #mi_comor.patient_id = #population.patient_id
LEFT JOIN #peptic_ulcer_comor ON #peptic_ulcer_comor.patient_id = #population.patient_id
LEFT JOIN #peripheral_vascular_comor ON #peripheral_vascular_comor.patient_id = #population.patient_id
WHERE ISNULL(#population.value, 0) = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment