Search the OSCAR Documentation
< All Topics
Print

eForm Magic Part C – Enhanced Database Operations

Share this

Documentation updated by Adrian Starzynski 2024

Preface

This article is in the series of articles on creating eForms in OSCAR. Advanced techniques for making eForms in OSCAR.

Need to order an eForm to be created? Need help with programming? Custom RTL Templates? Need OSCAR help? Contact us

Enhanced Database Tags

oscarOPEN=”eFormname”

This will allow to open another eForm by name. The eForm must exist and be active in your OSCAR eForms list and the name must match exactly for this to work. The following is a button that will open the eForm ‘Cytology’:

<input type="button" name="provideAname" oscarOPEN="Cytology" />

This is used to link to another eForm from within an eForm. For example, you may have a referral form that requires the practitioner to input the patient’s GAD7 score – you could put a button that will oscarOPEN the GAD7 eForm for the practitioner to calculate the score.

Updating with oscarDBinput

eForms mostly pull from the database “reading” existing values.  Do you know that eForms can also push and update entries as well?

Not all tags can be updated.  Only the ones marked in resources/oscar/eform/apconfig.xml with a <ap-insql> can be updated.

For the default OSCAR 19 those tags are

  • patient_nameL
  • patient_nameF
  • patient_nameM
  • patient_alias

To use one of these tags you must have the field marked as in the below example

<input type="text" name="test" oscarDB=patient_nameL oscarDBinput>

A check box and a button will be added to the form.  The eform users must check the “Update fields in database” for the database to be updated.  The change will be documented in the security log as a DatabaseAP “edit” action, along with the query that was executed.  Users can click on the “Refresh DB Fields” button to update all of the tags with an oscarDB attribute with the most recently available data from the database.

If you want to create your own apconfig.xml (for ease of upgrades I recommend that you keep your custom copy in eForm images and adjust oscar.properties to look for it there).  The <ap-insql> tag allows the following variables for use in the SQL statement eg
<ap-insql>UPDATE demographic SET last_name=’${value}’ WHERE demographic_no=${demographic}</ap-insql>

  • ${value} (value of the entered field),
  • ${demographic} (demographic number),
  • ${provider} (provider number), and
  • ${fid} (eform id).

e$

oscarDB=e$first#{var_name}   and oscarDB=e$last#{var_name}

Parameter: {var_name} = (name of eform field)
Description: This ap retrieves the value of field {var_name} from the same eform.  For first/last this is the value for the field which is first/last submitted. Only the value of the same eform (same fid) is retrieved, therefore eforms using this ap must have a field {var_name}. Deleted eform data (fdid status=0) is excluded. 

For example if you want to retrieve the value of the first patient which is stored in the field “name” for whom a copy of the same  eForm is saved you would use:

oscarDB=e$first#name

For example to retrieve the value of field “resident” in the same eForm which is last submitted:

oscarDB=e$last#resident

oscarDB=e$count#{var_name}

oscarDB=e$count#{var_name} var$value={var_value}

oscarDB=e$count#{var_name} ref${var_name}

oscarDB=e$count#{var_name} ref${var_name}={var_value}

Parameter: {var_name} = (name of eform field)
Description: This ap retrieves the count of field {var_name} from the same eform.  For first/last this is the value for the field which is first/last submitted. Only value of the same eform (same fid) is retrieved, therefore eforms using this ap must have a field {var_name}. Deleted eform data (fdid status=0) is excluded.  Count is the count of non empty entries that had been saved

For example to retrieve the total number of fields “bp” which are filled in all the same eForms:

oscarDB=e$count#bp

Var$value lets you count the instances when the eform field has a given value.  The value can be dynamic (see below) but has to be present on eform load

For example if you want to retrieve how many of the specific eforms were filled by doctor Gregory House

oscarDB=e$count#doctor var$value="House, Gregory"

Ref${var_name} lets you count the total number of a certain field in the same eForm which contains another non-empty field {var_name}. 

For example to count  the total number of field “resident” in all the same eForms which also have the field “observer” filled:

oscarDB=e$count#resident ref$observer

{var_value} = (value of eform field) works together with e$count to count the total number of a certain field in the same forms which contains another  field {var_name} with the value {var_value}.  If {var_value} contains space, it must be quoted (“…”).
{var_value} can be a static value or be dynamic, see *Dynamic var_value* for detail.

For example to count the total number of field “resident” in all the same eForm which also have field “observer”=”Cheng, Ronnie”:

oscarDB=e$count#resident ref$observer="Cheng, Ronnie"

eform$name={eform_name}

Parameter: {eform_name} = (name of another eForm)

This ap works together with all e$ to retrieve values from another eForm instead of the eForm in use.

NOTE: If more than one eForms have the same name, only the first one (smallest fid) is referenced.

For example to count the total number of field “resident” in all the “Teaching Field Note” eforms which also have the field “observer” filled):

oscarDB=e$count#resident ref$observer eform$name="Teaching Field Note"

oscarDB=o${table_name}#{other_id_name}

Parameter:
{table_name} = appointment/patient
{other_id_name} = (name of the alternative id)

Description: This ap retrieves alternative id from the other_id table.
Other_id table stores alternative id for patient demographics and appointments.
For patient demographics alternative id, this ap references the demographic no of the current eForm.
For appointments alternative id, it references the appointment no parameter passed when calling eForm from the appointment screen.
NOTE: Appointments alternative id won’t work if calling eForm from “Search demographic”.

For example to retrieve an appointment alternative id named “mc_number”:

oscarDB=o$appointment#mc_number

*Dynamic var_value*

var_value can be set to reference a field value in the eForm. To use this, simply write a field name and surround it with a pair of brackets {}.
NOTE: The var_value reference is made once when the eForm is loaded. Therefore the field being referenced must have an initial value (value=… or oscarDB=…). User input to the referenced field will NOT change the var_value.

Example to count the total number of field “patient” in all the same eForms which has the value of field “patient” in this eForm:

<input name="patient" type="text" oscarDB=patient_name>
<input name="total_encounter" type="text" oscarDB=e$count#patient var$value={patient}>

Summary Template

Summary templates are defined in an eForm to write a summary of the eForm content into Oscar message, eDoc or eChart when the eForm is submitted.

The template must be placed in comment <!– … –>

Special value tags are used to extract field values from eForm.

Template Format

<!--
<template>
    <document belong=provider|patient>
        <docdesc>{document description}</docdesc>
        <docowner>{document owner}</docowner>
        <content>{content}</content>
    </document>

    <message>
        <subject>{subject}</subject>
        <sendto>{recipient1,recipient2,...}</sendto>
        <content>{content}</content>
    </message>

    <encounternote>{content}</encounternote>
    <socialhistory>{content}</socialhistory>
    <familyhistory>{content}</familyhistory>
    <medicalhistory>{content}</medicalhistory>
    <ongoingconcerns>{content}</ongoingconcerns>
    <riskfactors>{content}</riskfactors>
    <reminders>{content}</reminders>
    <othermeds>{content}</othermeds>
</template>
-->

Description: Document template has a “belong=” attribute. If belong=provider, it is written as a provider document. If belong=patient, it is written as a patient document. The default is belong=provider.

The <docowner> entry must be a number. It is a provider_no/demographic_no. The default is the eForm form_provider/demographic_no.

Message template <sendto> entry (ie recipient) must be one or more provider_no. There is no default to this entry.

For all the eChart templates (<encounternote>, <socialhistory>, etc.), a link to the eForm is added to the eChart alongside the summary.

Value Tags

Value tags can be used anywhere in the summary templates, as long as it suits the format requirements.

Value tags come in 2 types: $t{…} and $te{…}

$t{…}

Put a field name inside the bracket. The field value will be filled-in when eForm is submitted.

If the field name does not exist in eForm, the tag will be written as it is to the summary.

$te{…}

These are “eForm attribute” tags. They can be one of the following:

$te{eform.name|eform.subject|eform.patient|eform.provider|eform.link|eform.html}

In place of $te{eform.html}, the complete html of the eform will be written, with the action statement removed.

In place of $te{eform.link}, a link to the eform will be written and the eform name will be shown.

NOTE: Tag $te{eform.link} does not work in message content. Also, it’s not necessary in echart templates because a link will already be in place.

Example:

eForm “TESTING” source html:

<html>
<input type="text" name="resident" value="Cheng, Ronnie">
</html>
<!--
<template>
 <encounternote>
This is the eform $te{eform.link}, it belongs to resident $t{resident}.
 </encounternote>
</template>
-->

Summary Template Output:

This is the eform TESTING, it belongs to resident Cheng, Ronnie.

(*The word TESTING is a link to the eform)

Table of Contents