Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5048 - Add Encounter to Transaction Form #5049

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions library/layout.inc.php
Expand Up @@ -23,6 +23,7 @@
*/

// array of the data_types of the fields
// TODO: Move these all to a statically typed class with constants that can be referenced throughout the codebase!
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2DV

$datatypes = array(
"1" => xl("List box"),
"2" => xl("Textbox"),
Expand Down Expand Up @@ -60,6 +61,7 @@
"46" => xl("List box w/comment"),
"51" => xl("Patient"),
"52" => xl("Previous Names"),
"53" => xl("Patient Encounters List")
);

// These are the data types that can reference a list.
Expand Down
33 changes: 33 additions & 0 deletions library/options.inc.php
Expand Up @@ -46,13 +46,16 @@

// note: isOption() returns true/false

// NOTE: All of the magic constants for the data types here are found in library/layout.inc.php

require_once("user.inc");
require_once("patient.inc");
require_once("lists.inc");
require_once(dirname(dirname(__FILE__)) . "/custom/code_types.inc.php");

use OpenEMR\Common\Acl\AclExtended;
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Services\EncounterService;
use OpenEMR\Services\FacilityService;
use OpenEMR\Services\PatientService;

Expand Down Expand Up @@ -1669,6 +1672,25 @@ class='form-control{$smallform}'
}
echo "</select>";
echo "<button type='button' class='btn btn-primary btn-sm' id='type_52_add' onclick='return specialtyFormDialog()'>" . xlt('Add') . "</button></div>";
// Patient Encounter List Field
} else if ($data_type == 53) {
global $pid;
$encounterService = new EncounterService();
$res = $encounterService->getEncountersForPatientByPid($pid);
echo "<div class='input-group w-75'>";
echo "<select name='form_$field_id_esc'" . " id='form_$field_id_esc' title='$description' $lbfonchange $disabled class='form-control$smallform select-encounters'>";
echo "<option value=''>" . xlt("Select Encounter") . "</option>";
foreach ($res as $row) {
$label = text(date("Y-m-d", strtotime($row['date'])) . " " . ($row['pc_catname'] ?? ''));
$optionId = attr($row['eid']);
// all names always selected
if ($currvalue == $row['eid']) {
echo "<option value='$optionId'" . " selected>$label</option>";
} else {
echo "<option value='$optionId'>$label</option>";
}
}
echo "</select>";
}
}

Expand Down Expand Up @@ -2861,6 +2883,17 @@ function generate_display_field($frow, $currvalue)
}
$i++;
}
// now that we've concatenated everything, let's escape it.
$s = text($s);
} elseif ($data_type == 53) {
$service = new EncounterService();
if (!empty($currvalue)) {
$encounterResult = $service->getEncounterById($currvalue);
if (!empty($encounterResult) && $encounterResult->hasData()) {
$encounter = reset($encounterResult->getData());
$s = text($encounter['date'] ?? '');
}
}
}
adunsulag marked this conversation as resolved.
Show resolved Hide resolved

return $s;
Expand Down
7 changes: 7 additions & 0 deletions sql/6_1_0-to-7_0_0_upgrade.sql
Expand Up @@ -210,3 +210,10 @@ INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `activity`)
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `activity`) VALUES ('ecqm_2022_reporting','CMS771v3','Urinary Symptom Score Change 6-12 Months After Diagnosis of Benign Prostatic Hyperplasia',460,0);
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `activity`) VALUES ('ecqm_2022_reporting','CMS90v11','Functional Status Assessments for Congestive Heart Failure',470,0);
#EndIf

#IfNotRow2D layout_options LBTref field_id encounter_id
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`
,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`)
VALUES ('LBTref','encounter_id' ,'1','Patient Referral Encounter', 10, 53,1, 0, 0,'',1,1,'',''
,'Encounter that the referral/transfer of care is based on', 0);
#EndIf
2 changes: 1 addition & 1 deletion sql/database.sql
Expand Up @@ -3549,6 +3549,7 @@ INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`dat
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTref','reply_services' ,'2','Services Provided' ,16, 3,1,30, 0,'' ,1,1,'' ,'' ,'Service provided by specialist', 3);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTref','reply_recommend' ,'2','Recommendations' ,17, 3,1,30, 0,'' ,1,1,'' ,'' ,'Recommendations by specialist', 3);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTref','reply_rx_refer' ,'2','Prescriptions/Referrals',18, 3,1,30, 0,'' ,1,1,'' ,'' ,'Prescriptions and/or referrals by specialist', 3);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTref','encounter_id' ,'1','Patient Referral Encounter', 10, 53,1, 0, 0,'',1,1,'','','Encounter that the referral/transfer of care is based on', 0);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTptreq','body','1','Details',10,3,2,30,0,'',1,3,'','','Content',5);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTphreq','body','1','Details',10,3,2,30,0,'',1,3,'','','Content',5);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('LBTlegal','body','1','Details',10,3,2,30,0,'',1,3,'','','Content',5);
Expand Down Expand Up @@ -3593,7 +3594,6 @@ INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`dat
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('FACUSR', 'provider_id', '1', 'Provider ID', 1, 2, 1, 15, 63, '', 1, 1, '', '', 'Provider ID at Specified Facility', 0);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('FACUSR', 'role_code', '1', 'Provider Role', 2, 43, 1, 0, 0, 'us-core-provider-role', 1, 1, '', '', 'Provider Role at Specified Facility', 0);
INSERT INTO `layout_options` (`form_id`,`field_id`,`group_id`,`title`,`seq`,`data_type`,`uor`,`fld_length`,`max_length`,`list_id`,`titlecols`,`datacols`,`default_value`,`edit_options`,`description`,`fld_rows`) VALUES ('FACUSR', 'specialty_code', '1', 'Provider Specialty', 3, 43, 1, 0, 0, 'us-core-provider-specialty', 1, 1, '', '', 'Provider Specialty at Specified Facility', 0);
adunsulag marked this conversation as resolved.
Show resolved Hide resolved

-- --------------------------------------------------------

--
Expand Down