Fixing a Troublesome Document

As a Centricity content developer, I sometimes find myself in a situation where a Centricity document is in a state that will not allow it to be opened again. These documents are sometimes called dead documents. If they they cause the chart to not behave properly or cause CPS or EMR to crash when opened, I have heard the term “Poison Documents”

So these steps will remedy the situation:

Your first task is to find the document that is dead; you may be able to see the visdocid from the Centricity UI. If so, you can look it up that way; if not, you need to find the document via the PID or some other method.

SELECT [PID]
 ,[SDID]
 ,[SUMMARYNOTE]
 ,[CLINICALDATE]
 ,[HOLDTEXT]
 ,[NOTETEXT]
 ,[DB_UPDATED_DATE]
 FROM [demo].[dbo].[DOCUMENT] where PID = (Select PatientProfile.PID From [PatientProfile] where First ='Gabriele' and Last = 'Oberheim') order by DB_UPDATED_DATE DESC

Once you have found the document, you can make changes to the database to fix it. One thing you might need to do, depending on what the behavior is in the document, is to neutralize bad acting MEL code that is part of the update. Do this by changing HOLDTEXT and NOTETEXT so that it contains short, vanilla RTF.

update DOCUMENT set HOLDTEXT='{\rtf1\ansi\ftnbj{\fonttbl{\f0 \fswiss Arial;}}', NOTETEXT='{\rtf1\ansi\ftnbj{\fonttbl{\f0 \fswiss Arial;}}' where SDID = '0000000000000000'

The next thing to do is to eliminate the locks on the document which you will need to do to open it back up in the Centricity application so that you can end the update.

delete from LOGLOCKS where SDID = '0000000000000000' 

And there you have it.

Getting a Unique ID in CPS

In certain instances, you may find that theere is a defect in LinkLogic, or you may have another reason for doing this, but for what it’s worth, there may come a time when you need to insert a row into a Centricity database that has a unique ID field.

There is a built-in stored procedure that performs the task, but it takes an input parameter, which can make it tricky to call. You can either create a wrapper function for the procedure that declares an input parameter and returns the value or you can copy the code and remove the params altogether.

I have taken the second approach so that you can see the logic of the full procedure.

/****** Object:  StoredProcedure [dbo].[CUSTOMgetUniqueEMRID]    Script Date: 05/05/2013 23:05:12 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- CUSTOM_getUniqueEMRID
-- returns a generated emrid as numeric(19,0)
-- NOTE: dependent on emridcontrol table being setup and setupEMRIDControl having been called
CREATE procedure [dbo].[CUSTOM_getUniqueEMRID]

as
SET NOCOUNT ON
begin
     declare @theID numeric(19,0)
     declare @theOffset numeric(19,0)
     declare @theLastID numeric(19,0), @theWSID numeric(19,0)
     declare emridcontrolcursor cursor forward_only for
     select lastid,wsid from dbo.emridcontrol for update of lastid
     set @theID=0
     set @theOffset=50000

open emridcontrolcursor
fetch next from emridcontrolcursor
     into @theLastID, @theWSID

if @@fetch_status = 0
     begin
          set @theID = dbo.convert_date_to_id(getdate()) + @theWSID
          if @theID <=@theLastID
               set @theID = @theLastID+@theOffset
          update dbo.emridcontrol set LastID=@theID
     end
else
     RAISERROR('unable to read emridcontrol table',10,1)

close emridcontrolcursor
deallocate emridcontrolcursor
select @theID as getUniqueEMRID
end

MEL Data Symbols 201: Scoring items using getarg and getnargs

It’s not uncommon to want a form component to have the ability to do some scoring.  The scoring might be some kind of risk factors thing; PHQ-9, Falls, and Drug and Alcohol (DAST) screenings are just a few examples.

Sometimes the scoring is a one-to-one relationship where each question is responsible for a point and other times  the scoring might have many-to-one relationship where multiple questions could be responsible for the same point.  In either instance you can use getarg and getnargs within your loop but it’s particularly useful when you’d like to utilize the same fn to do many-to-one style calculations or anytime you’d like to use a function multiple times with varying numbers of arguments.

This is an example form:
getarg2

This is what the scoring code looks like:
getarg1