<commit_before>"use strict";

var libxmljs = require("libxmljs");
var libCCDAgen = require("../lib/templating_functions.js");
var bbm = require("blue-button-meta");
var sec_entries_codes = bbm.CCDA.sections_entries_codes.codes;

var js2xml = require("./templates/js2xml");
var entryLevel = require("./templates/entryLevel");

var observationAttrs = function (observation) {
    var attrs = {
        classCode: "OBS",
        moodCode: "EVN"
    };
    if (observation.hasOwnProperty('negation_indicator')) {
        attrs.negationInd = observation.negation_indicator.toString();
    }
    return attrs;
};

var updateObservation = function (xmlDoc, observation, index) {
    if (observation) {
        var er = xmlDoc.node('entryRelationship').attr({
            typeCode: "SUBJ",
            inversionInd: "true"
        });
        var ob = er.node('observation').attr(observationAttrs(observation));
        js2xml.update(ob, observation, entryLevel.allergyIntoleranceObservation);
    }
};

var updateEntry = function (xmlDoc, entry, index) {
    var e = xmlDoc.node('entry').attr({
        typeCode: "DRIV"
    });
    var act = e.node('act').attr({
        classCode: "ACT",
        moodCode: "EVN"
    });
    act.node('templateId').attr({
        root: "2.16.840.1.113883.10.20.22.4.30"
    });
    libCCDAgen.id(act, entry.identifiers);
    libCCDAgen.asIsCode(act, sec_entries_codes.AllergiesSection);
    act.node('statusCode').attr({
        code: 'active'
    });
    if (entry.date_time) {
        libCCDAgen.effectiveTime(act, entry.date_time);
    }
    updateObservation(act, entry.observation, index);<commit_msg>allergyIntoleranceObservation fully implemented<commit_after>"use strict";

var libxmljs = require("libxmljs");
var libCCDAgen = require("../lib/templating_functions.js");
var bbm = require("blue-button-meta");
var sec_entries_codes = bbm.CCDA.sections_entries_codes.codes;

var js2xml = require("./templates/js2xml");
var entryLevel = require("./templates/entryLevel");

var observationAttrs = function (observation) {
    var attrs = {
        classCode: "OBS",
        moodCode: "EVN"
    };
    if (observation.hasOwnProperty('negation_indicator')) {
        attrs.negationInd = observation.negation_indicator.toString();
    }
    return attrs;
};

var updateObservation = function (xmlDoc, observation, index) {
    if (observation) {
        var er = xmlDoc.node('entryRelationship').attr({
            typeCode: "SUBJ",
            inversionInd: "true"
        });
        //js2xml.fillUsingTemplate(er, observation, entryLevel.allergyIntoleranceObservation);
        var ob = er.node('observation').attr(observationAttrs(observation));
        js2xml.update(ob, observation, entryLevel.allergyIntoleranceObservation);
    }
};

var updateEntry = function (xmlDoc, entry, index) {
    var e = xmlDoc.node('entry').attr({
        typeCode: "DRIV"
    });
    var act = e.node('act').attr({
        classCode: "ACT",
        moodCode: "EVN"
    });
    act.node('templateId').attr({
        root: "2.16.840.1.113883.10.20.22.4.30"
    });
    libCCDAgen.id(act, entry.identifiers);
    libCCDAgen.asIsCode(act, sec_entries_codes.AllergiesSection);
    act.node('statusCode').attr({
        code: 'active'
    });
    if (entry.date_time) {
        libCCDAgen.effectiveTime(act, entry.date_time);
    }
    updateObservation(act, entry.observation, index);
{'fraction_non_alphanumeric': 0.14647804302976716, 'fraction_numerical': 0.015030946065428824, 'mean_word_length': 3.27455919395466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 19}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6389376', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1098, 'n_words': 188}