var OidDictionary = {'2.16.840.1.113883.3.464.1.14':{'HL7':['00110']},'2.16.840.1.113883.3.464.1.37':{'ICD-10-CM':['E10.36','E11.36','E11.9','E13.31','E13.32','E13.33','E13.34','E13.35','E13.43','O24.42'],'ICD-9-CM':['250','250','250','250.1','250.2','250.3','250.10','250.11','250.12','250.13','250.20','250.21','250.22','250.23','250.30','250.31','250.32','250.33','250.4','250.40','250.41','250.42','250.43','250.50','250.51','250.52','250.53','250.60','250.61','250.62','250.63','250.7','250.70','250.71','250.72','250.73','250.8','250.80','250.81','250.82','250.83','250.9','250.90','250.91','250.92','250.93','357.2','362','362.1','362.2','362.3','362.4','362.5','362.6','362.7','366.41','648','648','648.1','648.2','648.3','648.4'],'SNOMED-CT':['111552007','111558006','11530004','123763000','127013003','127014009','190321005','190328004','190330002','190331003','190336008','190353001','190361006','190368000','190369008','190371008','190372001','190383005','190389009','190390000','190392008','190406000','190407009','190410002','190411003','190412005','190416001','190417004','190418009','190419001','190422004','193184006','197605007','198609003','199223000','199227004','199229001','199230006','199231005','199234002','201250006','201251005','201252003','23045005','230572002','230577008','237599002','237600004','237601000','237604008','237613005','237618001','237619009','237627000','25907005','26298008','267379000','267380002','2751001','275918005','28032008','28453007','290002008','309426007','310387003','311366001','312912001','313435000','313436004','314537004','314771006','314772004','314893005','314902007','314903002','33559001','34140002','359611005','359638003','359642000','360546002','371087003','38542009','39058009','39181008','408539000','408540003','413183008','414890007','414906009','420414003','420422005','421750000','421847006','421895002','422183001','422228004','422275004','423263001','424736006','424989000','425159004','425442003','426705001','426875007','427089005','428896009','42954008','44054006','4627003','46635009','50620007','51002006','5368009','54181000','57886004','59079001','5969009','70694009','73211009','74263009','75524006','75682002','76751001','81531005','81830002','8801005','91352004','9859006']},'2.16.840.1.113883.3.464.1.38':{'ICD-10-CM':['E10.36','E11.36','E11.9','E13.31','E13.32','E13.33','E13.34','E13.35','E13.43','O24.42']},'2.16.840.1.113883.3.464.1.39':{'ICD-9-CM':['250','250','250','250.1','250.2','250.3','250.10','250.11','250.12','250.13','250.20','250.21','250.22','250.23','250.30','250.31','250.32','250.33','250.4','250.40','250.41','250.42','250.43','250.50','250.51','250.52','250.53','250.60','250.61','250.62','250.63','250.7','250.70','250.71','250.72','250.73','250.8','250.80','250.81','250.82','250.83','250.9','250.90','250.91','250.92','250.93','357.2','362','362.1','362.2','362.3','362.4','362.5','362.6','362.7','366.41','648','648','648.1','648.2','648.3','648.4']},'2.16.840.1.113883.3.464.1.40':{'SNOMED-CT':['111552007','111558006','11530004','123763000','127013003','127014009','190321005','190328004','190330002','190331003','190336008','190353001','190361006','190368000','190369008','190371008','190372001','190383005','190389009','190390000','190392008','190406000','190407009','190410002','190411003','190412005','190416001','190417004','190418009','190419001','190422004','193184006','197605007','198609003','199223000','199227004','199229001','199230006','199231005','199234002','201250006','201251005','201252003','23045005','230572002','230577008','237599002','237600004','237601000','237604008','237613005','237618001','237619009','237627000','25907005','26298008','267379000','267380002','2751001','275918005','28032008','28453007','290002008','309426007','310387003','311366001','312912001','313435000','313436004','314537004','314771006','314772004','314893005','314902007','314903002','33559001','34140002','359611005','359638003','359642000','360546002','371087003','38542009','39058009','39181008','408539000','408540003','413183008','414890007','414906009','420414003','420422005','421750000','421847006','421895002','422183001','422228004','422275004','423263001','424736006','424989000','425159004','425442003','426705001','426875007','427089005','428896009','42954008','44054006','4627003','46635009','50620007','51002006','5368009','54181000','57886004','59079001','5969009','70694009','73211009','74263009','75524006','75682002','76751001','81531005','81830002','8801005','91352004','9859006']},'2.16.840.1.113883.3.464.1.42':{'CPT':['99221','99222','99223','99231','99232','99233','99238','99239','99251','99252','99253','99254','99255','99291','99281','99282','99283','99284','99285']},'2.16.840.1.113883.3.464.1.43':{'CPT':['99221','99222','99223','99231','99232','99233','99238','99239','99251','99252','99253','99254','99255','99291']},'2.16.840.1.113883.3.464.1.45':{'CPT':['99281','99282','99283','99284','99285']},'2.16.840.1.113883.3.464.1.46':{'CPT':['99304','99305','99306','99307','99308','99309','99310','99315','99316','99318','99324','99325','99326','99327','99328','99334','99335','99336','99337']},'2.16.840.1.113883.3.464.3.1142':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99341','99342','99343','99344','99345','99347','99348','99349','99350','99384','99385','99386','99387','99394','99395','99396','99397','99401','99402','99403','99404','99411','99412','99420','99429','99455','99456'],'ICD-9-CM':['V70.','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.1.48':{'CPT':['99201','99202','99203','99204','99205','99211','99212','99213','99214','99215','99217','99218','99219','99220','99241','99242','99243','99244','99245','99341','99342','99343','99344','99345','99347-99350','99384','99385','99386','99387','99394','99395','99396','99397','99401','99402','99403','99404','99411','99412','99420','99429','99455','99456']},'2.16.840.1.113883.3.464.1.50':{'ICD-9-CM':['V70.','V70.3','V70.5','V70.6','V70.8','V70.9']},'2.16.840.1.113883.3.464.1.67':{'ICD-10-CM':['R73.2','R73.9'],'ICD-9-CM':['648.8','648.80','648.81','648.82','648.83','648.84'],'SNOMED-CT':['11687002','420491007','420738003','420989005','421223006','421389009','421443003','422155003','46894009','71546005','75022004']},'2.16.840.1.113883.3.464.1.72':{'CPT':['83036','83037'],'LOINC':['17856-6','4548-4','4549-2'],'SNOMED-CT':['117346004','165680008','259689004','259690008','313835008','33601001','40402000','408254005','43396009']},'2.16.840.1.113883.3.464.1.94':{'RxNorm':['199149','199150','200132','205329','205330','205331','401938','200256','200257','200258','311919','314142','389139','861035','861039','861042','861044','861787','861790','665033','665038','665042','744863','847910','847915','861769','861819','602544','602549','602550','647237','647239','706895','706896','861731','861736','861740','861743','861748','861753','861760','861763','861769','861783','861787','861790','861795','861806','861816','861819','861822','665033','665038','665042','860975','860978','860981','860984','860996','860999','861004','861007','861010','861021','861025','861731','861736','861740','861743','861748','861753','861760','861763','861769','861783','861787','861790','861795','861806','861816','861819','861822','105374','153842','197306','197307','197495','197496','197737','198291','198292','198293','198294','199245','199246','199247','199825','199984','199985','200065','252960','310488','310489','310490','310534','310536','310537','310539','312440','312441','312859','312860','312861','313418','313419','314000','314006','315107','315239','317573','379804','389137','602544','602549','602550','647237','647239','706895','706896','757710','757712','844809','844824','844827','861731','861736','861740','861743','861748','861753','861760','861763','861783','861795','861806','861816','861822','312440','312441','312859','312860','312861','317573','205314','237527','242120','242916','242917','259111','260265','283394','311040','311041','311053','311054','311055','311056','311057','311058','311059','311060','311061','314038','317800','351297','358349','484322','485210','544614','763002','763007','763013','763014','833159','847191','847207','847211','847230','847239','847252','847259','847263','847416','200256','200257','200258','311919','314142','389139']},'2.16.840.1.113883.3.464.1.98':{'ICD-10-CM':['E28.2'],'ICD-9-CM':['256.4'],'SNOMED-CT':['69878008']},'2.16.840.1.113883.3.464.1.113':{'ICD-10-CM':['E08','E10','T38'],'ICD-9-CM':['249','249','249','249.1','249.1','249.10','249.11','249.2','249.20','249.21','249.3','249.30','249.31','249.4','249.40','249.41','249.5','249.50','249.51','249.6','249.60','249.61','249.7','249.70','249.71','249.8','249.80','249.81','249.9','249.90','249.91','251.8','962'],'SNOMED-CT':['190416008','190447002','53126001']}};var CD, IVL, PQ, PREVSUM, RECENT, TS, allTrue, atLeastOneTrue, filterEventsByValue, getCodes, matchingValue, __slice = Array.prototype.slice; TS = (function() { function TS(hl7ts) { var day, month, year; year = parseInt(hl7ts.substring(0, 4)); month = parseInt(hl7ts.substring(4, 6), 10) - 1; day = parseInt(hl7ts.substring(6, 8), 10); this.date = new Date(year, month, day); } TS.prototype.add = function(pq) { if (pq.unit === "a") { this.date.setFullYear(this.date.getFullYear() + pq.value); } else if (pq.unit === "mo") { this.date.setMonth(this.date.getMonth() + pq.value); } else if (pq.unit === "d") { this.date.setDate(this.date.getDate() + pq.value); } else if (pq.unit === "h") { this.date.setHours(this.date.getHours() + pq.value); } else if (pq.unit === "min") { this.date.setMinutes(this.date.getMinutes() + pq.value); } else { throw "Unknown time unit: " + pq.unit; } return this; }; TS.prototype.asDate = function() { return this.date; }; return TS; })(); CD = (function() { function CD(code) { this.code = code; } CD.prototype.code = function() { return this.code; }; CD.prototype.match = function(val) { return this.code === val; }; return CD; })(); PQ = (function() { function PQ(value, unit) { this.value = value; this.unit = unit; } PQ.prototype.unit = function() { return this.unit; }; PQ.prototype.value = function() { return this.value; }; PQ.prototype.lessThan = function(val) { return this.value < val; }; PQ.prototype.greaterThan = function(val) { return this.value > val; }; PQ.prototype.match = function(val) { return this.value === val; }; return PQ; })(); IVL = (function() { function IVL(low_pq, high_pq) { this.low_pq = low_pq; this.high_pq = high_pq; } IVL.prototype.match = function(val) { return (!(this.low_pq != null) || ((this.low_pq != null) && this.low_pq.lessThan(val))) && (!(this.high_pq != null) || ((this.high_pq != null) && this.high_pq.greaterThan(val))); }; return IVL; })(); atLeastOneTrue = function() { var trueValues, value, values; values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; trueValues = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = values.length; _i < _len; _i++) { value = values[_i]; if (value && (value === true || value.length !== 0)) _results.push(value); } return _results; })(); return trueValues.length > 0; }; allTrue = function() { var trueValues, value, values; values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; trueValues = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = values.length; _i < _len; _i++) { value = values[_i]; if (value && (value === true || value.length !== 0)) _results.push(value); } return _results; })(); return trueValues.length > 0 && trueValues.length === values.length; }; matchingValue = function(value, compareTo) { return compareTo.match(value); }; filterEventsByValue = function(events, value) { var event, matchingValues; matchingValues = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = events.length; _i < _len; _i++) { event = events[_i]; if (event.value && value.match(event.value().scalar)) _results.push(event); } return _results; })(); return matchingValues; }; getCodes = function(oid) { return OidDictionary[oid]; }; PREVSUM = function(eventList) { return eventList; }; RECENT = function(events) { var dateSortDescending; dateSortDescending = function(a, b) { return b.json.time - a.json.time; }; return events.sort(dateSortDescending)[0]; }; // Measure variables var MeasurePeriod = { "low": new TS("20110101"), "high": new TS("20111231"), "width": new PQ(1, "a") }; var StartDate = new TS("20100101"); var EndDate = new TS("20101231"); // Data critera var ageBetween17and64 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(17, "a"), new PQ(64, "a"))); } var ageBetween17and21 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(17, "a"), new PQ(21, "a"))); } var ageBetween22and29 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(22, "a"), new PQ(29, "a"))); } var ageBetween30and39 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(30, "a"), new PQ(39, "a"))); } var ageBetween40and49 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(40, "a"), new PQ(49, "a"))); } var ageBetween50and59 = function(patient) { var value = patient.age(EndDate.asDate()); return matchingValue(value, new IVL(new PQ(50, "a"), new PQ(59, "a"))); } var ageBetween60and64 = function(patient) { var value = patient.age(new TS("20100101").asDate()); return matchingValue(value, new IVL(new PQ(60, "a"), new PQ(64, "a"))); } var genderMale = function(patient) { var value = patient.gender(); return matchingValue(value, new CD("M")); } var genderFemale = function(patient) { var value = patient.gender(); return matchingValue(value, new CD("F")); } var EDorInpatientEncounter = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.42"); var start = null; var end = EndDate.add(new PQ(-2,"a")).asDate(); var events = patient.encounters().match(codes, start, end); return events; } var AmbulatoryEncounter = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.1142"); var start = null; var end = EndDate.add(new PQ(-2,"a")).asDate(); var events = patient.encounters().match(codes, start, end); events = PREVSUM(events); return events; } var DummyProcedure = function(patient) { var codes = {"SNOMED-CT":["127355002"]}; var start = new TS("20100101").asDate(); var end = new TS("20111231").asDate(); var events = patient.procedures().match(codes, start, end); return events; } var HasDiabetes = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.37"); var events = patient.conditions().match(codes); return events; } var HasGestationalDiabetes = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.67"); var start = StartDate.asDate(); var end = EndDate.asDate(); var events = patient.conditions().match(codes, start, end); return events; } var HasPolycysticOvaries = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.98"); var start = StartDate.add(new PQ(-1,"a")).asDate(); var end = EndDate.asDate(); var events = patient.conditions().match(codes, start, end); return events; } var HasSteroidInducedDiabetes = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.113"); var start = StartDate.asDate(); var end = EndDate.asDate(); var events = patient.conditions().match(codes, start, end); return events; } var HbA1C = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.72"); var events = patient.results().match(codes); events = filterEventsByValue(events, new IVL(new PQ(9, "%"), null)); events = RECENT(events); return events; } var DiabetesMedAdministered = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.94"); var start = StartDate.add(new PQ(-2,"a")).asDate(); var end = null; var events = patient.medications().match(codes, start, end); return events; } var DiabetesMedIntended = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.94"); var start = null; var end = EndDate.add(new PQ(-2,"a")).asDate(); var events = patient.medications().match(codes, start, end); return events; } var DiabetesMedSupplied = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.94"); var start = null; var end = EndDate.add(new PQ(-2,"a")).asDate(); var events = patient.medications().match(codes, start, end); return events; } var DiabetesMedOrdered = function(patient) { var codes = getCodes("2.16.840.1.113883.3.464.1.94"); var start = null; var end = EndDate.add(new PQ(-2,"a")).asDate(); var events = patient.medications().match(codes, start, end); return events; } var IPP = function(patient) { return allTrue( ageBetween17and64(patient) ); }; var DENOM = function(patient) { return allTrue( atLeastOneTrue( allTrue( HasDiabetes(patient), atLeastOneTrue( EDorInpatientEncounter(patient), AmbulatoryEncounter(patient) ) ), DiabetesMedAdministered(patient), DiabetesMedIntended(patient), DiabetesMedSupplied(patient), DiabetesMedOrdered(patient) ) ); }; var NUMER = function(patient) { return allTrue( HbA1C(patient) ); }; var DENEXCEP = function(patient) { return atLeastOneTrue( allTrue( HasPolycysticOvaries(patient), HasDiabetes(patient) ), HasSteroidInducedDiabetes(patient), HasGestationalDiabetes(patient) ); };