Initial Checking with all 820 MLMs
This commit is contained in:
230
MLMStripper/bin/Debug/ACS/ACS_RESULT_IMPRESSION_LOOKUP.mlm
Normal file
230
MLMStripper/bin/Debug/ACS/ACS_RESULT_IMPRESSION_LOOKUP.mlm
Normal file
@@ -0,0 +1,230 @@
|
||||
maintenance:
|
||||
|
||||
title: Generic Lookup;;
|
||||
mlmname: ACS_result_impression_Lookup;;
|
||||
arden: version 2.5;;
|
||||
version: 5.00;;
|
||||
institution: Allscripts;;
|
||||
author: Allscripts Custom Services;;
|
||||
specialist: Allscripts Custom Services;;
|
||||
date: 2011-11-05;;
|
||||
validation: testing;;
|
||||
|
||||
library:
|
||||
purpose: lookup and parse out the "IMPRESSION" from a set of patient{{{SINGLE-QUOTE}}}s results.
|
||||
;;
|
||||
explanation:
|
||||
;;
|
||||
keywords:
|
||||
;;
|
||||
knowledge:
|
||||
type: data-driven;;
|
||||
data:
|
||||
/****************** Make Your code stretch NO WIDER THAN THIS! *************************/
|
||||
(Client_guid,
|
||||
Client_visit_guid,
|
||||
Client_chart_guid,
|
||||
Getdata_from,//“historical” or “current” (use SQL or current object navigation)
|
||||
Data_value_type,//Object to retrieve (“HealthIssue”, “order”, etc.)
|
||||
Data_item,//Attribute to retrieve (“name”, “itemname”, “typecode”, “code”, etc.)
|
||||
Filterable_item,//Filterable attribute (“name”, “itemname”, “typecode”, “code”, etc.)
|
||||
Filterable_operator,//Filterable operator (“=”, “<>”, “in”, “matches pattern”, etc.)
|
||||
Filterable_value,//Filterable value(s)(“chronic”, “atb”,“(‘480.00’,’480.30’)", etc.)
|
||||
Additional_condition)//Additional condition(s)
|
||||
//(“orderstatuslevelnum between 55 and 60”,
|
||||
//“performedtm > dateadd(-24, hh, getdate()”, etc.)
|
||||
:= ARGUMENT;
|
||||
|
||||
//setting for
|
||||
current:= Now - 8 years ; //24 hours;
|
||||
|
||||
//initialize
|
||||
strFilterSQL :="";
|
||||
|
||||
if called_by_editor then
|
||||
(client_guid, client_visit_guid, client_chart_guid) :=
|
||||
read last {clientvisit: clientguid, guid, chartguid};
|
||||
Getdata_from := "Historical";
|
||||
Data_value_type := "Results";
|
||||
Data_item := "text_val";
|
||||
Filterable_item := "r.code"; // "itemname";
|
||||
filterable_operator := "="; // "like";
|
||||
filterable_value := "Medical Imaging"; // "chest";
|
||||
endif;
|
||||
|
||||
IF any(exists Filterable_item AND (not (Filterable_item is in ("", "No"))))
|
||||
AND any(exists Filterable_operator AND (not(Filterable_operator is in ("", "No"))))
|
||||
AND any(exists Filterable_value AND (not (Filterable_value is in ("", "No")))) THEN
|
||||
strFilterSQL := Filterable_item || " " || Filterable_operator || " ";
|
||||
IF Filterable_operator = "IN" THEN
|
||||
strFilterSQL := strFilterSQL || "(" || Filterable_value || ")";
|
||||
ELSEIF Filterable_operator ="LIKE" THEN
|
||||
strFilterSQL := strFilterSQL || "{{{SINGLE-QUOTE}}}%" || Filterable_value|| "%{{{SINGLE-QUOTE}}}";
|
||||
ELSE
|
||||
strFilterSQL := strFilterSQL || SQL(Filterable_value);
|
||||
ENDIF;
|
||||
ENDIF;
|
||||
if any(exists Additional_condition AND (not (Additional_condition is in ("", "No")))) then
|
||||
strFilterSQL := strFilterSQL || " and " ||Additional_condition;
|
||||
endif;
|
||||
// add filter for time, if not present
|
||||
if not(strFilterSQL matches pattern "%where%performeddtm%") then
|
||||
strFilterSQL := strFilterSQL || " and b.entered >= " || sql(current) ;
|
||||
endif;
|
||||
|
||||
(result_items, result_times, result_impressions) := read
|
||||
// set up (temporary) tables for data entry
|
||||
{" declare @txt_src table (titem varchar(125), "
|
||||
||" tguid numeric(16,0), ttime datetime, tln int, ttext varchar(255)) "
|
||||
||" declare @maxln table (tguid numeric(16,0), mln int) "
|
||||
||" declare @txt_imp table "
|
||||
||" (id numeric(16,0) not null, "
|
||||
||" item varchar(125) null, "
|
||||
||" obs_time datetime null, "
|
||||
||" min_line_num int null, "
|
||||
||" curr_line_num int null, "
|
||||
||" max_line_num int null, "
|
||||
||" obs_text varchar(8000) null) "
|
||||
|
||||
// pull patient specific data for processing
|
||||
||" insert @txt_src "
|
||||
||" select b.itemname, t.ObservationGUID, o.performeddtm, t.LineNum, t.text "
|
||||
||" from CV3BasicObservation b "
|
||||
||" join CV3TextualObservationLine t on t.ClientGUID = b.ClientGUID "
|
||||
||" and b.GUID = t.ObservationGUID "
|
||||
||" join cv3order o on o.clientguid = b.clientguid "
|
||||
||" and o.chartguid = b.chartguid "
|
||||
||" and o.clientvisitguid = b.clientvisitguid "
|
||||
||" and o.guid = b.orderguid "
|
||||
||" join cv3ordercatalogmasteritem ocmi on ocmi.GUID = o.OrderCatalogMasterItemGUID "
|
||||
||" left outer join CV3OrderReviewCategory r on r.GUID = ocmi.OrderReviewCategoryGUID "
|
||||
||" where b.ClientGUID = " || sql(client_guid)
|
||||
||" and b.ChartGUID = " || sql(client_chart_guid)
|
||||
||" and b.ClientVisitGUID = " || sql(client_visit_guid)
|
||||
// ||" and b.entered >= " || sql(current)
|
||||
||" and b.IsTextual = 1 "
|
||||
||" and b.IsHistory = 0 "
|
||||
||" and " || strFilterSQL
|
||||
|
||||
// remove white spaces
|
||||
||" while (select max(patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext)) from @txt_src) > 0 "
|
||||
||" begin "
|
||||
||" update @txt_src " // remove the carriage return
|
||||
||" set ttext = stuff(ttext, patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext), 1, null) "
|
||||
||" where patindex({{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}+char(10)+{{{SINGLE-QUOTE}}}%{{{SINGLE-QUOTE}}}, ttext) > 0 "
|
||||
||" end "
|
||||
|
||||
// initialize the table
|
||||
||" insert @txt_imp " // get starting line
|
||||
||" select distinct tguid, titem, ttime, 0,0, null, {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}} "
|
||||
||" from @txt_src "
|
||||
|
||||
// get only the impression fragment, starting at {{{SINGLE-QUOTE}}}IMPRESSION:{{{SINGLE-QUOTE}}}
|
||||
||" update @txt_imp " // get starting line
|
||||
||" set min_line_num = tln, curr_line_num = tln, obs_text = "
|
||||
||" substring(tTEXT, PATINDEX({{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}}, ttext), DATALENGTH(ttext) "
|
||||
||" - PATINDEX({{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}}, ttext)) "
|
||||
||" from @txt_src "
|
||||
||" where tguid = id "
|
||||
||" and tTEXT like {{{SINGLE-QUOTE}}}%impression%{{{SINGLE-QUOTE}}} "
|
||||
|
||||
// update the max_line_num to the {{{SINGLE-QUOTE}}}dictated by{{{SINGLE-QUOTE}}} end, if exist
|
||||
||" update @txt_imp "
|
||||
||" set max_line_num = tln "
|
||||
||" from @txt_src "
|
||||
||" where id = tguid "
|
||||
||" and tln > min_line_num "
|
||||
// ||" and obs_text like {{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}} "
|
||||
||" and obs_text like {{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}} " // Added By Shivprasad CSR : 32844
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
// if no {{{SINGLE-QUOTE}}}dictated by{{{SINGLE-QUOTE}}} ending, go to end of blob
|
||||
||" insert @maxln "
|
||||
||" select tguid, mln = MAX(tln) "
|
||||
||" from @txt_src "
|
||||
||" group by tguid "
|
||||
|
||||
// no {{{SINGLE-QUOTE}}}dictated{{{SINGLE-QUOTE}}} found: set max_line_num to end of blob
|
||||
||" update @txt_imp "
|
||||
||" set max_line_num = mln "
|
||||
||" from @maxln "
|
||||
||" where id = tguid "
|
||||
||" and max_line_num is null "
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
// iterate/append all lines between min and max line numbers
|
||||
||" while (select count(*) "
|
||||
||" from @txt_imp where (max_line_num - curr_line_num) > 0 ) > 0 "
|
||||
||" begin "
|
||||
||" update @txt_imp "
|
||||
||" set curr_line_num = tln, "
|
||||
||" obs_text = obs_text + tTEXT "
|
||||
||" from @txt_src "
|
||||
||" where id = tguid "
|
||||
||" and curr_line_num < max_line_num "
|
||||
||" and tln = curr_line_num + 1 "
|
||||
||" end "
|
||||
|
||||
// truncate text to {{{SINGLE-QUOTE}}}dictated{{{SINGLE-QUOTE}}}
|
||||
||" update @txt_imp "
|
||||
// ||" set obs_text = SUBSTRING(obs_text, 1, patindex({{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}}, obs_text) + 7) "
|
||||
// ||" where patindex({{{SINGLE-QUOTE}}}%dictated%{{{SINGLE-QUOTE}}}, obs_text) > 0 "
|
||||
||" set obs_text = SUBSTRING(obs_text, 1, patindex({{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}}, obs_text) + 8 ) " // Added By Shivprasad CSR : 32844
|
||||
||" where patindex({{{SINGLE-QUOTE}}}%dictat%{{{SINGLE-QUOTE}}}, obs_text) > 0 "
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
// Now add the addendum, if it exists, useing the same logic as above
|
||||
||" update @txt_imp "
|
||||
||" set min_line_num = tln, curr_line_num = tln, max_line_num = null, "
|
||||
||" obs_text = obs_text + {{{SINGLE-QUOTE}}} +++++{{{SINGLE-QUOTE}}} + "
|
||||
||" substring(tTEXT, PATINDEX({{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}}, ttext), "
|
||||
||" DATALENGTH(ttext) - PATINDEX({{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}}, ttext)) "
|
||||
||" from @txt_src "
|
||||
||" where id = tguid "
|
||||
||" and tln >= curr_line_num "
|
||||
||" and tTEXT like {{{SINGLE-QUOTE}}}%ADDENDUM%{{{SINGLE-QUOTE}}} "
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
||" update @txt_imp "
|
||||
||" set max_line_num = tln "
|
||||
||" from @txt_src "
|
||||
||" where id = tguid "
|
||||
||" and tln >= curr_line_num "
|
||||
||" and tTEXT like {{{SINGLE-QUOTE}}}%LAST PAGE%{{{SINGLE-QUOTE}}} " // never found this...
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
||" update @txt_imp "
|
||||
||" set max_line_num = mln "
|
||||
||" from @maxln "
|
||||
||" where id = tguid "
|
||||
||" and max_line_num is null "
|
||||
||" and not (obs_text = {{{SINGLE-QUOTE}}}(no IMPRESSION found){{{SINGLE-QUOTE}}}) "
|
||||
|
||||
||" while (select count(*) "
|
||||
||" from @txt_imp where (max_line_num - curr_line_num) > 0 ) > 0 "
|
||||
||" begin "
|
||||
||" update @txt_imp "
|
||||
||" set curr_line_num = tln, "
|
||||
||" obs_text = obs_text + tTEXT "
|
||||
||" from @txt_src "
|
||||
||" where id = tguid "
|
||||
||" and curr_line_num < max_line_num "
|
||||
||" and tln = curr_line_num + 1 "
|
||||
||" end "
|
||||
|
||||
||" select item, obs_time, obs_text "
|
||||
||" from @txt_imp "
|
||||
};
|
||||
|
||||
//break;
|
||||
;;
|
||||
priority: 50
|
||||
;;
|
||||
evoke:
|
||||
;;
|
||||
logic: conclude true;
|
||||
;;
|
||||
action: return result_items, result_times, result_impressions;
|
||||
;;
|
||||
Urgency: 50;;
|
||||
end:
|
||||
Reference in New Issue
Block a user