Patient Registration Date

Hello everyone, I am new here.

Please I would like to find out how to include the patient registration date (date created) as part of the data displayed on the menu bar (where we have the patient name, pubid, DoB).

After making that change, then we have

patient name (pubid)
DoB
registration Date

I have identified the files that contribute to rendering the files but don’t know what and how to achieve this.

Hope these links to the files helps
interface/main/tabs/js/application_view_model.js
interface/main/tabs/js/patient_data_view_model.js
interface/main/tabs/templates/patient_data_tempate.php
interface/main/tabs/js/frame_proxies.js

Thanks much

3 Likes

I did more digging into this and it looks like frame_proxies.js sets up the patient_data_view_model in the left_nav.setPatient function.

Now you’re not going to like this… but I did a search in the codebase for left_nav.setPatient function and found about 14 places in the codebase where that setPatient function is called that you would need to add the registration date. The biggest spot would be in demographics.php as that is the main one when a patient is selected from the patient finder. However, if your clinic uses any of those other pages to select a patient… you will lose the registration date information…

1 Like

I appreciate the quick response. I’ll try that and get back to you

hello Stephen, I was able to get the registration date to display on the menu bar. I wanted it to display on the next line after the DoB. When i try to add a new line in the demographics.php, i get this error

Uncaught SyntaxError: missing ) after argument list

after printing this on the nextline

 echo "Reg Date: " . oeFormatShortDate($result['date']) ; 

So the workaround was to concatenate the DoB with the registration date… making it all display on the same line. Could you please suggest a way i can make the registration date appear on the next line?

Thanks in advance

So if you look at the code that you tried modifying the php output is creating a javascript function call using php.

 parent.left_nav.setPatient(<?php echo js_escape($result['fname'] . " " . $result['lname']) .
                "," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",'',";
        if (empty($date_of_death)) {
            echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD']));
        } else {
            echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age at death') . ": " . oeFormatAge($result['DOB_YMD'], $date_of_death));
        }?>);

So you will need to add a comma after just like the other arguments here:
so on my machine on line 634 in demographics.php you would add something like this

633  echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age at death') . ": " . oeFormatAge($result['DOB_YMD'], $date_of_death));
634  } echo "," . xlt("Reg Date") . ": " . oeFormatShortDate($result['date']); ?>);

You’ll still need to update the left_nav.setPatient function in frame_proxies.js as well as the patient_data_view_model function in patient_data_view_model.js
Once all of that is complete you can add the line in patient_data_template.php probably after lines 74-76 which are:

74 <div>
75     <span data-bind="text:patient().str_dob()"></span>
76 </div>

So you’d probably want something like

77 <div>
78     <span data-bind="text:patient().str_date_registered()"></span>
79 </div>

Thank you Stephen for your effort. I have made these changes and i still got the same error

Uncaught SyntaxError: missing ) after argument list

You need to provide the full error message (including line numbers stack traces etc) and even paste snippets of your code (including the lines above and the lines below your change.

That single line you pasted does not give enough details to help us understand what is going wrong.

Thanks.
The listing below is from frame_proxies.js

    left_nav.setPatient = function(pname, pid, pubpid, frname, str_dob, str_date_registered) {
    if ((app_view_model.application_data.patient() !== null) && (pid === app_view_model.application_data.patient().pid())) {
        app_view_model.application_data.patient().pname(pname);
        app_view_model.application_data.patient().pubpid(pubpid);
        app_view_model.application_data.patient().str_dob(str_dob);
        app_view_model.application_data.patient().str_date_registered(str_date_registered);

        return;
    }
    var new_patient = new patient_data_view_model(pname, pid, pubpid, str_dob, str_date_registered);
    app_view_model.application_data.patient(new_patient);
    app_view_model.application_data.therapy_group(null);
    navigateTab(webroot_url + "/interface/patient_file/history/encounters.php", "enc", function() {
        tabCloseByName('rev');
    });

    /* close therapy group tabs */
    tabCloseByName('gdg');
    attendant_type = 'patient';
    app_view_model.attendant_template_type('patient-data-template');
};

Listing from patient_data_view_model.js

function patient_data_view_model(pname, pid, pubpid, str_dob, str_date_registered) {
    var self = this;
    self.pname = ko.observable(pname);
    self.pid = ko.observable(pid);
    self.pubpid = ko.observable(pubpid);
    self.str_dob = ko.observable(str_dob);
    self.str_date_registered = ko.observable(str_date_registered);
    self.patient_picture = ko.computed(function() {
        return webroot_url + '/controller.php' +
            '?document&retrieve' +
            '&patient_id=' + encodeURIComponent(pid) +
            '&document_id=-1' +
            '&as_file=false' +
            '&original_file=true' +
            '&disable_exit=false' +
            '&show_original=true' +
            '&context=patient_picture';
    }, self);

    self.encounterArray = ko.observableArray();
    self.selectedEncounterID = ko.observable();
    self.selectedEncounter = ko.observable();
    self.selectedEncounterID.extend({ notify: 'always' });
    self.selectedEncounterID.subscribe(function(newVal) {
        for (var encIdx = 0; encIdx < self.encounterArray().length; encIdx++) {
            var curEnc = self.encounterArray()[encIdx];
            if (curEnc.id() == newVal) {

                self.selectedEncounter(curEnc);
                return;
            }
        }
        // No valid encounter ID found, so clear selected encounter;
        self.selectedEncounter(null);
    });
    return this;
}

Listing from patient_data_template.php

Listing from demographics.php

    parent.left_nav.setPatient(<?php echo js_escape($result['fname'] . " " . $result['lname']) .
                "," . js_escape($pid) . "," . js_escape($result['pubpid']) . ",'',";
        if (empty($date_of_death)) {
            echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAgeDisplay($result['DOB_YMD'])) ;
        } else {
            echo js_escape(" " . xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age at death') . ": " . oeFormatAge($result['DOB_YMD'], $date_of_death));
        } echo "," . xlt("Reg Date") . ": " . oeFormatShortDate($result['date']);?>);

Error Details
The only error i receive in my console is what i presented earlier. Thanks

Try replacing

echo "," . xlt("Reg Date") . ": " . oeFormatShortDate($result['date']);?>);

With

echo "," . js_escape(" " . xl("Reg Date") . ": " . oeFormatShortDate($result['date']));?>);

You can see that it was missing the surrounding quotes that js_escape puts out.

This is the error i am getting

Uncaught TypeError: Unable to process binding "text: function(){return patient().str_date_registered() }"

Message: patient(…).str_date_registered is not a function
at text (eval at parseBindingsString (knockout-latest.js?v=61:74), :3:74)
at e (knockout-latest.js?v=61:75)
at knockout-latest.js?v=61:78
at update (knockout-latest.js?v=61:111)
at a.$.l (knockout-latest.js?v=61:79)
at Function.yd (knockout-latest.js?v=61:55)
at Function.zd (knockout-latest.js?v=61:55)
at Function.ha (knockout-latest.js?v=61:54)
at Object.a.o.a.$ (knockout-latest.js?v=61:52)
at knockout-latest.js?v=61:79

Try to put a javascript debug breakpoint in patient_data_view_model and see if the function is actually being created. I suspect that you have a browser cache issue and somehow your changes in patient_data_view_model.js is not actually being loaded.

Yes please. I agree with you. It was a browser cache problem. Problem solved. Thanks a million