Skip to content

Commit

Permalink
modified output to add cause of death code system and code correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
regulator95 committed Feb 26, 2016
1 parent 6e7f267 commit d7e0f55
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
13 changes: 7 additions & 6 deletions js/load_xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ function createHealthHistory(pi) {
if (o.gender != undefined) {
if (o.cause_of_death_code != undefined) {
var re = /other-/;
if (re.exec(o.cause_of_death_code) || re2.exec(o.cause_of_death_code)) {
personal_information[x]['cause_of_death_code'] = o.cause_of_death_code.replace("other-","").replace("-undefined","")
var snomed_re = /SNOMED_CT-EMPTY/;
if (re.exec(o.cause_of_death_code) || snomed_re.exec(o.cause_of_death_code)) {
personal_information[x]['cause_of_death_code'] = o.detailed_cause_of_death;
}
}
for (var item in o['Health History']) {
var disease_code = o['Health History'][item]['Disease Code'];
if (re.exec(disease_code) || re2.exec(disease_code)) {
if (re.exec(disease_code) || re2.exec(disease_code) || re3.exec(disease_code) || snomed_re.exec(disease_code)) {
personal_information[x]['Health History'][item]['Disease Code'] = "other-undefined";
// personal_information[x]['Health History'][item]['Disease Code'] = o['Health History'][item]['Disease Code'].replace("other-","")
add_other_disease(o['Health History'][item]['Disease Name']);
Expand Down Expand Up @@ -539,7 +540,7 @@ function parse_xml(data) {
var detailed_cause_of_death = death.parent().parent().children("code").attr("displayName");
var cause_of_death_code = death.parent().parent().children("code").attr("code");
var cause_of_death_system = death.parent().parent().children("code").attr("codeSystemName");
var is_other_cause_of_death = cause_of_death_code==detailed_cause_of_death;
var is_other_cause_of_death = cause_of_death_code=="OTHER";
// alert (relative.name + " died around [" + death_age + "] of :[" + cause_of_death+ "]");
if (cause_of_death_system == 'undefined' || cause_of_death_system == null) relative.cause_of_death_system = 'SNOMED_CT';
else if (cause_of_death_system == 'SNOMED COMPLETE') relative.cause_of_death_system = 'SNOMED_CT';
Expand All @@ -551,7 +552,7 @@ function parse_xml(data) {

// if cause of death is other //
if (is_other_cause_of_death) {
relative.cause_of_death_code = cause_of_death_code;
relative.cause_of_death_code = detailed_cause_of_death;
}
// if cause of death is not other
else {
Expand All @@ -563,7 +564,7 @@ function parse_xml(data) {
}
relative.cause_of_death = get_high_level_disease_name_from_disease_code(cause_of_death_code);
if (is_other_cause_of_death)
relative.cause_of_death = cause_of_death_code;
relative.cause_of_death = detailed_cause_of_death;

if (relative.detailed_cause_of_death != detailed_cause_of_death) relative.detailed_cause_of_death = detailed_cause_of_death;
relative.estimated_death_age = death_age;
Expand Down
27 changes: 20 additions & 7 deletions js/save_xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ function googlePostAuthSave(authResult) {
'title': filename,
'mimeType': content_type
};
console.log(output_string)
window.base64Data = output_string;
var base64Data = btoa(output_string);
var multipartRequestBody =
Expand Down Expand Up @@ -262,7 +261,6 @@ function bind_save_heath_vault() {
window.open(url_w_params, "", "width=1000, height=600, scrollbars=yes");
timer = setInterval(function(){
var st = window.localStorage.getItem("HV Status");
console.log("Checking status of save: " + st);
if (st != null && st != "") {
$("#save_personal_history_dialog").dialog("close");
if (st == "Failed") {
Expand Down Expand Up @@ -635,7 +633,6 @@ function add_diseases(tag, diseases) {
if (disease_code_and_system == 'other' || disease_code_and_system == 'other-undefined') {
disease_code_and_system = 'SNOMED_CT-OTHER';
}
console.log(disease_code_and_system, diseases[i]["Detailed Disease Name"])
if (!detailed_disease_name) detailed_disease_name = disease_name;
var age_at_diagnosis = diseases[i]["Age At Diagnosis"];

Expand Down Expand Up @@ -732,6 +729,12 @@ function add_death_age(tag, estimated_death_age) {
}

function add_cause_of_death(tag, cause_of_death_code, cause_of_death) {
var is_other_disease;

if (cause_of_death_code==cause_of_death) {
is_other_disease = true;
}

if (cause_of_death == null) return;
var temp_cause_of_death = cause_of_death_code;
var observation_tag = doc.createElement("clinicalObservation");
Expand All @@ -746,7 +749,7 @@ function add_cause_of_death(tag, cause_of_death_code, cause_of_death) {
else {
code_tag.setAttribute("displayName", cause_of_death);
code_tag.setAttribute("originalText", cause_of_death);
code_system = "other";
code_system = "SNOMED_CT";
}


Expand All @@ -767,7 +770,12 @@ function add_cause_of_death(tag, cause_of_death_code, cause_of_death) {
if (cause_of_death_code.substring(0, 10) == "SNOMED_CT-") cause_of_death_code = cause_of_death_code.substring(0, 10)
if (cause_of_death_code == null) cause_of_death_code = "OTHER";

code_tag.setAttribute("code", cause_of_death_code);
if (is_other_disease) {
code_tag.setAttribute("code", "OTHER");
}
else {
code_tag.setAttribute("code", cause_of_death_code);
}
observation_tag.appendChild(code_tag);

var sourceOf_tag = doc.createElement("sourceOf");
Expand All @@ -776,9 +784,14 @@ function add_cause_of_death(tag, cause_of_death_code, cause_of_death) {
newcode_tag.setAttribute("displayName", "death");
var re = /SNOMED_CT/;

newcode_tag.setAttribute("codeSystemName", "SNOMED_CT");

newcode_tag.setAttribute("code", SNOMED_CODE.DEATH);
newcode_tag.setAttribute("codeSystemName", "SNOMED_CT");
if (is_other_disease) {
newcode_tag.setAttribute("code", "OTHER");
}
else {
newcode_tag.setAttribute("code", SNOMED_CODE.DEATH);
}
sourceOf_tag.appendChild(newcode_tag);
}

Expand Down

0 comments on commit d7e0f55

Please sign in to comment.