Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding expired date calculations #2

Merged
merged 1 commit into from
Mar 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected]("hqmfjs.ageBetween40and49(numeratorPatient).isTrue()")
assert [email protected]("hqmfjs.ageBetween50and59(numeratorPatient).isTrue()")
assert [email protected]("hqmfjs.ageBetween60and64(numeratorPatient).isTrue()")


# record does not have a death date so false
assert [email protected]("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert [email protected]("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert [email protected]("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

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

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

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

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

@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2011,6).to_i}")
assert [email protected]("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 [email protected]("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
assert @context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
assert [email protected]("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")

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