Extract {ProblemList} codes to template document

Hi,

I’m creating a word document that will automatically fill out with pacient details etc. I want to add a list of issues the patients has. I can pull out the issues with {ProblemList} but each of these problems/issues has a code attached on our system. The codes are actually what I need for government reason. Could anyone help me or point me in the direction of how to do this?

Thanks in advance.

hi @Stewart_Cusick , add some functionality to interface/patient_file/download_template.php.

Specifically, grab the code from the diagnosis field by adding it to the sql query.

Hi Stephen,

No sure I follow you here do I just have to add diagnosis to the code line as shown below? Will this pull the codes out with when I use this code {ProblemList} in the .odt file or is there another code?

$lres = sqlStatement("SELECT title, diagnosis, comments FROM lists WHERE " .

and then add a little code inside the while loop to add the diagnosis codes so will look something like

// Return a string naming all issues for the specified patient and issue type.
function getIssues($type)
{
    $tmp = '';
    $lres = sqlStatement("SELECT title, diagnosis, comments FROM lists WHERE " .
    "pid = ? AND type = ? AND enddate IS NULL " .
    "ORDER BY begdate", array($GLOBALS['pid'], $type));
    while ($lrow = sqlFetchArray($lres)) {
        if ($tmp) {
            $tmp .= '; ';
        }

        $tmp .= $lrow['title'];

        if ($lrow['diagnosis']) {
            $tmp .= ' (' . $lrow['diagnosis'] . ')';
        }
        if ($lrow['comments']) {
            $tmp .= ' (' . $lrow['comments'] . ')';
        }
    }

    return $tmp;
}