Skip to content

Commit

Permalink
Included the lab name as the result's source, facility address and ch…
Browse files Browse the repository at this point in the history
…anges in procedure section output to show both the surgery and lab procedure orders.

Changing the sqlconf.php back to original.

Signed-off-by: Ajil <[email protected]>
  • Loading branch information
Ajil authored and bradymiller committed May 10, 2011
1 parent d215da3 commit 52f45a4
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 32 deletions.
5 changes: 5 additions & 0 deletions ccr/createCCR.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ function createCCR($action,$raw="no"){
$patientID = getUuid();
$sourceID = getUuid();
$oemrID = getUuid();

$result = getActorData();
while($res = sqlFetchArray($result[2])){
${"labID{$res['id']}"} = getUuid();
}

$ccr = new DOMDocument('1.0','UTF-8');
$e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="stylesheet/ccr.xsl"');
Expand Down
128 changes: 124 additions & 4 deletions ccr/createCCRActor.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,54 @@

$e_Name = $ccr->createElement('Name', $row1['facility']);
$e_InformationSystem->appendChild($e_Name);

$e_Type = $ccr->createElement('Type', 'Facility');
$e_InformationSystem->appendChild($e_Type);

$e_IDs = $ccr->createElement('IDs');
$e_Actor->appendChild($e_IDs);

$e_Type = $ccr->createElement('Type');
$e_IDs->appendChild($e_Type);

$e_Text = $ccr->createElement('Text', '');
$e_Type->appendChild($e_Text);

$e_ID = $ccr->createElement('ID', '');
$e_IDs->appendChild($e_ID);

$e_Source = $ccr->createElement('Source');
$e_IDs->appendChild($e_Source);

$e_SourceActor = $ccr->createElement('Actor');
$e_Source->appendChild($e_SourceActor);

$e_ActorID = $ccr->createElement('ActorID', $authorID);
$e_SourceActor->appendChild($e_ActorID);

$e_Address = $ccr->createElement('Address');
$e_Actor->appendChild($e_Address);

$e_Line1 = $ccr->createElement('Line1',$row1['street']);
$e_Address->appendChild($e_Line1);

$e_Line2 = $ccr->createElement('Line2');
$e_Address->appendChild($e_Line1);

$e_City = $ccr->createElement('City',$row1['city']);
$e_Address->appendChild($e_City);

$e_State = $ccr->createElement('State',$row1['state'].' ');
$e_Address->appendChild($e_State);

$e_PostalCode = $ccr->createElement('PostalCode',$row1['postal_code']);
$e_Address->appendChild($e_PostalCode);

$e_Telephone = $ccr->createElement('Telephone');
$e_Actor->appendChild($e_Telephone);

$e_Phone = $ccr->createElement('Value',$row1['phone']);
$e_Telephone->appendChild($e_Phone);

$e_Source = $ccr->createElement('Source');
$e_Actor->appendChild($e_Source);
Expand Down Expand Up @@ -194,19 +242,19 @@
$e_Address = $ccr->createElement('Address');
$e_Actor->appendChild($e_Address);

$e_Line1 = $ccr->createElement('Line1','000 Sample Line');
$e_Line1 = $ccr->createElement('Line1','2365 Springs Rd. NE');
$e_Address->appendChild($e_Line1);

$e_Line2 = $ccr->createElement('Line2');
$e_Address->appendChild($e_Line1);

$e_City = $ccr->createElement('City','Sample City');
$e_City = $ccr->createElement('City','Hickory');
$e_Address->appendChild($e_City);

$e_State = $ccr->createElement('State','Sample State');
$e_State = $ccr->createElement('State','NC ');
$e_Address->appendChild($e_State);

$e_PostalCode = $ccr->createElement('PostalCode','00000');
$e_PostalCode = $ccr->createElement('PostalCode','28601');
$e_Address->appendChild($e_PostalCode);

$e_Telephone = $ccr->createElement('Telephone');
Expand All @@ -223,5 +271,77 @@

$e_ActorID = $ccr->createElement('ActorID', $authorID);
$e_Actor->appendChild($e_ActorID);

while ($row2 = sqlFetchArray($result[2])) {

$e_Actor = $ccr->createElement('Actor');
$e_Actors->appendChild($e_Actor);

$e_ActorObjectID = $ccr->createElement('ActorObjectID', ${"labID{$row2['id']}"});
$e_Actor->appendChild($e_ActorObjectID);

$e_InformationSystem = $ccr->createElement('InformationSystem');
$e_Actor->appendChild($e_InformationSystem);

$e_Name = $ccr->createElement('Name', $row2['lname']." ".$row2['fname']);
$e_InformationSystem->appendChild($e_Name);

$e_Type = $ccr->createElement('Type', 'Lab Service');
$e_InformationSystem->appendChild($e_Type);

$e_IDs = $ccr->createElement('IDs');
$e_Actor->appendChild($e_IDs);

$e_Type = $ccr->createElement('Type');
$e_IDs->appendChild($e_Type);

$e_Text = $ccr->createElement('Text', '');
$e_Type->appendChild($e_Text);

$e_ID = $ccr->createElement('ID', '');
$e_IDs->appendChild($e_ID);

$e_Source = $ccr->createElement('Source');
$e_IDs->appendChild($e_Source);

$e_SourceActor = $ccr->createElement('Actor');
$e_Source->appendChild($e_SourceActor);

$e_ActorID = $ccr->createElement('ActorID', $authorID);
$e_SourceActor->appendChild($e_ActorID);

$e_Address = $ccr->createElement('Address');
$e_Actor->appendChild($e_Address);

$e_Line1 = $ccr->createElement('Line1',$row2['street']);
$e_Address->appendChild($e_Line1);

$e_Line2 = $ccr->createElement('Line2');
$e_Address->appendChild($e_Line1);

$e_City = $ccr->createElement('City',$row2['city']);
$e_Address->appendChild($e_City);

$e_State = $ccr->createElement('State',$row2['state'].' ');
$e_Address->appendChild($e_State);

$e_PostalCode = $ccr->createElement('PostalCode',$row2['zip']);
$e_Address->appendChild($e_PostalCode);

$e_Telephone = $ccr->createElement('Telephone');
$e_Actor->appendChild($e_Telephone);

$e_Phone = $ccr->createElement('Value',$row2['phone']);
$e_Telephone->appendChild($e_Phone);

$e_Source = $ccr->createElement('Source');
$e_Actor->appendChild($e_Source);

$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID', $authorID);
$e_Actor->appendChild($e_ActorID);
}

?>
39 changes: 19 additions & 20 deletions ccr/createCCRProcedure.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@

$e_Text = $ccr->createElement('Text', $row['type']);
$e_Type->appendChild($e_Text);


$e_Description = $ccr->createElement('Description' );
$e_Procedure->appendChild($e_Description);

$e_Text->nodeValue = $row['proc_title'];
$e_Description->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', $row['proc_title']);
$e_Description->appendChild($e_Text);

$e_Code = $ccr->createElement('Code');
$e_Description->appendChild($e_Code);
Expand All @@ -69,8 +68,8 @@
$e_Status = $ccr->createElement('Status');
$e_Procedure->appendChild($e_Status);

$e_Text->nodeValue = $row['outcome'];
$e_Status->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', $row['outcome']);
$e_Status->appendChild($e_Text);

$e_Procedure->appendChild(sourceType($ccr, $sourceID));

Expand All @@ -83,8 +82,8 @@
$e_Description = $ccr->createElement('Description' );
$e_Location->appendChild($e_Description);

$e_Text->nodeValue = 'body_location'; //$row['laterality'];
$e_Description->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', $row['laterality']);
$e_Description->appendChild($e_Text);

$e_Practitioners = $ccr->createElement('Practitioners');
$e_Procedure->appendChild($e_Practitioners);
Expand All @@ -95,41 +94,41 @@
$e_ActorRole = $ccr->createElement('ActorRole');
$e_Practitioner->appendChild($e_ActorRole);

$e_Text->nodeValue = 'None';
$e_ActorRole->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', 'None');
$e_ActorRole->appendChild($e_Text);

$e_Duration = $ccr->createElement('Duration');
$e_Procedure->appendChild($e_Duration);

$e_Description = $ccr->createElement('Description' );
$e_Duration->appendChild($e_Description);

$e_Text->nodeValue = 'None';
$e_Description->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', 'None');
$e_Description->appendChild($e_Text);

$e_Substance = $ccr->createElement('Substance');
$e_Procedure->appendChild($e_Substance);

$e_Text->nodeValue = 'substance';
$e_Substance->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', '');
$e_Substance->appendChild($e_Text);

$e_Method = $ccr->createElement('Method');
$e_Procedure->appendChild($e_Method);

$e_Text->nodeValue = 'method'; //?
$e_Method->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', '');
$e_Method->appendChild($e_Text);

$e_Position = $ccr->createElement('Position'); //$row['laterality']
$e_Position = $ccr->createElement('Position');
$e_Procedure->appendChild($e_Position);

$e_Text->nodeValue = 'body_position';// $row['laterality'];
$e_Position->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', $row['laterality']);
$e_Position->appendChild($e_Text);

$e_Site = $ccr->createElement('Site');
$e_Procedure->appendChild($e_Site);

$e_Text->nodeValue = 'body_site';//$row['body_site'];
$e_Site->appendChild(clone $e_Text);
$e_Text = $ccr->createElement('Text', $row['body_site']);
$e_Site->appendChild($e_Text);

} while ($row = sqlFetchArray($result));

Expand Down
2 changes: 1 addition & 1 deletion ccr/createCCRResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$e_Actor = $ccr->createElement('Actor');
$e_Source->appendChild($e_Actor);

$e_ActorID = $ccr->createElement('ActorID',$uuid);
$e_ActorID = $ccr->createElement('ActorID',${"labID{$row['lab']}"});
$e_Actor->appendChild($e_ActorID);

$e_Test = $ccr->createElement('Test');
Expand Down
35 changes: 28 additions & 7 deletions library/sql-ccr.inc
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ function getResultData() {
$sql = "
SELECT
prs.procedure_result_id as pid,
pt.name as `name`,
pt.procedure_type_id as `type`,
prs.date as `date`,
pt.name as name,
pt.procedure_type_id as type,
prs.date as date,
concat_ws(' ',prs.result,lo.title) as result,
prs.range as `range`,
prs.range as range,
prs.abnormal as abnormal,
prs.comments as comments,
ptt.lab_id AS lab
Expand All @@ -210,6 +210,9 @@ function getResultData() {
ON prp.procedure_order_id = po.procedure_order_id
LEFT JOIN procedure_type AS pt
ON prs.procedure_type_id = pt.procedure_type_id
LEFT JOIN procedure_type AS ptt
ON pt.parent = ptt.procedure_type_id
AND ptt.procedure_type = 'ord'
LEFT JOIN list_options AS lo
ON lo.list_id = 'proc_unit' AND pt.units = lo.option_id
WHERE po.patient_id=?";
Expand All @@ -230,12 +233,30 @@ function getActorData() {
$result[0] = sqlStatement($sql, array($pid) );

$sql2 = "
select facility
from users
where id=?";
SELECT * FROM users AS u LEFT JOIN facility AS f ON u.facility_id = f.id WHERE u.id=?";

$result[1] = sqlStatement($sql2, array($_SESSION['authUserID']) );

$sql3 = "
SELECT
u.*
FROM
procedure_type AS pt
LEFT JOIN procedure_order AS po
ON po.procedure_type_id = pt.procedure_type_id
LEFT JOIN forms AS f
ON f.form_id = po.procedure_order_id
LEFT JOIN list_options AS lo
ON lo.title = f.form_name
LEFT JOIN users AS u
ON pt.lab_id = u.id
WHERE f.pid = ?
AND lo.list_id = 'proc_type'
AND lo.option_id = 'ord'
GROUP BY u.id";

$result[2] = sqlStatement($sql3, array($pid) );

return $result;
}

Expand Down

0 comments on commit 52f45a4

Please sign in to comment.