Skip to content

Commit

Permalink
Merge pull request #2 from pophealth/expired
Browse files Browse the repository at this point in the history
Adding expired date calculations
  • Loading branch information
rdingwell committed Mar 3, 2014
2 parents 3376329 + 7b5f782 commit 032f94e
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/assets/javascripts/patient_api_extension.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ hQuery.Patient::allDevices = -> this.conditions().concat(this.procedures()).conc
hQuery.Patient::activeDiagnoses = -> this.conditions().concat(this.socialHistories()).withStatuses(['active'])
hQuery.Patient::inactiveDiagnoses = -> this.conditions().concat(this.socialHistories()).withStatuses(['inactive'])
hQuery.Patient::resolvedDiagnoses = -> this.conditions().concat(this.socialHistories()).withStatuses(['resolved'])
hQuery.Patient::deathdate = ->
hQuery.dateFromUtcSeconds this.json["deathdate"]

hQuery.CodedEntry::asIVL_TS = ->
tsLow = new TS()
tsLow.date = this.startDate() || this.date() || null
Expand Down
13 changes: 12 additions & 1 deletion lib/generator/characteristic.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ events = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.re
<%- end -%>
events.specificContext=hqmf.SpecificsManager.identity();
return events;
<%- elsif criteria.property == :expired or criteria.property == :clinicalTrialParticipant -%>
<%- elsif criteria.property == :expired %>
var return_value = matchingValue(value, 'true');

<%- if criteria.temporal_references -%>
var events = [patient.deathdate()];
<%- criteria.temporal_references.each do |temporal_reference| -%>
return_value = <%= temporal_reference.type %>(events, hqmfjs.<%= temporal_reference.reference.id %>(patient)<%= ", #{js_for_bounds(temporal_reference.range)}" if temporal_reference.range %>);
<%- end -%>
<%- end -%>
return_value.specificContext=hqmf.SpecificsManager.identity();
return return_value
<%- elsif criteria.property == :clinicalTrialParticipant -%>
matching = matchingValue(value, 'true');
matching.specificContext=hqmf.SpecificsManager.identity();
return matching
Expand Down
148 changes: 148 additions & 0 deletions test/fixtures/json/59New.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,154 @@
]
}
},
"dead4MonthsBeforeMeasurePeriod": {
"title": "Deceased",
"description": "Patient Characteristic Expired: Deceased",
"standard_category": "individual_characteristic",
"qds_data_type": "individual_characteristic",
"code_list_id": "2.16.840.1.113883.3.67.1.101.11.721",
"property": "expired",
"type": "characteristic",
"definition": "patient_characteristic_expired",
"hard_status": false,
"negation": false,
"source_data_criteria": "PatientCharacteristicExpiredDeceased",
"inline_code_list": {
"SNOMED-CT": [
"18632008",
"371828006"
]
},
"temporal_references": [
{
"type": "SBS",
"reference": "MeasurePeriod",
"range": {
"type": "IVL_PQ",
"low": {
"type": "PQ",
"unit": "mo",
"value": "4",
"inclusive?": true,
"derived?": false
}
}
}
]
},
"dead3MonthsBeforeMeasurePeriod": {
"title": "Deceased",
"description": "Patient Characteristic Expired: Deceased",
"standard_category": "individual_characteristic",
"qds_data_type": "individual_characteristic",
"code_list_id": "2.16.840.1.113883.3.67.1.101.11.721",
"property": "expired",
"type": "characteristic",
"definition": "patient_characteristic_expired",
"hard_status": false,
"negation": false,
"source_data_criteria": "PatientCharacteristicExpiredDeceased",
"inline_code_list": {
"SNOMED-CT": [
"18632008",
"371828006"
]
},
"temporal_references": [
{
"type": "SBS",
"reference": "MeasurePeriod",
"range": {
"type": "IVL_PQ",
"low": {
"type": "PQ",
"unit": "mo",
"value": "3",
"inclusive?": true,
"derived?": false
}
}
}
]
},

"dead3MonthsAfterMeasurePeriod": {
"title": "Deceased",
"description": "Patient Characteristic Expired: Deceased",
"standard_category": "individual_characteristic",
"qds_data_type": "individual_characteristic",
"code_list_id": "2.16.840.1.113883.3.67.1.101.11.721",
"property": "expired",
"type": "characteristic",
"definition": "patient_characteristic_expired",
"hard_status": false,
"negation": false,
"source_data_criteria": "PatientCharacteristicExpiredDeceased",
"inline_code_list": {
"SNOMED-CT": [
"18632008",
"371828006"
]
},
"temporal_references": [
{
"type": "SAS",
"reference": "MeasurePeriod",
"range": {
"type": "IVL_PQ",
"low": {
"type": "PQ",
"unit": "mo",
"value": "3",
"inclusive?": true,
"derived?": false
}
}
}
]
},
"deadBetween5and6MonthsDuringMeasurePeriod": {
"title": "Deceased",
"description": "Patient Characteristic Expired: Deceased",
"standard_category": "individual_characteristic",
"qds_data_type": "individual_characteristic",
"code_list_id": "2.16.840.1.113883.3.67.1.101.11.721",
"property": "expired",
"type": "characteristic",
"definition": "patient_characteristic_expired",
"hard_status": false,
"negation": false,
"source_data_criteria": "PatientCharacteristicExpiredDeceased",
"inline_code_list": {
"SNOMED-CT": [
"18632008",
"371828006"
]
},
"temporal_references": [
{
"type": "SAS",
"reference": "MeasurePeriod",
"range": {
"type": "IVL_PQ",
"low": {
"type": "PQ",
"unit": "mo",
"value": "5",
"inclusive?": true,
"derived?": false
},
"high": {
"type": "PQ",
"unit": "mo",
"value": "6",
"inclusive?": true,
"derived?": false
}
}
}
]
},
"genderMale": {
"title": "Gender",
"standard_category": "individual_characteristic",
Expand Down
36 changes: 36 additions & 0 deletions test/unit/hqmf_from_json_javascript_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ def test_converted_hqmf
assert !@context.eval("hqmfjs.ageBetween40and49(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.ageBetween50and59(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.ageBetween60and64(numeratorPatient).isTrue()")


# record does not have a death date so false
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2010,11).to_i}")
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2010,10).to_i}")
assert @context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2011,2).to_i}")
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2011,4).to_i}")
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert @context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2011,6).to_i}")
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert @context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert @context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2011,9).to_i}")
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert @context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

# Birthdate function
assert_equal 1, @context.eval("hqmfjs.birthdateThirtyYearsBeforeMeasurementPeriod(numeratorPatient)").count
Expand Down

0 comments on commit 032f94e

Please sign in to comment.