Bookmarks tags getting DELETED AND REPLACED with [ch=1] tags

  • WP Tools: 5.48.5, Delphi 5, Windows XP. Two WPT files sent by e-mail to support_at_wptools.de. (My apology for a long post but there is no easy way to describe this problem clearly.)

    I am developing an application that represents about 60 items in a WP document to define structure of a medical progress note.

    Each item in the progress note is represented by a Heading bookmark and a BodyText bookmark (e.g., "Examination of Heart" will have a heading and details (body text) of physician's findings). Thus, there are ~ 120 bookmarks in the document.

    All bookmarks are created into a blank editor when user starts a new note (editor has already been initialized with: RTFMemo.CheckHasBody; par := RTFMemo.FirstPar;). These are placed in pairs in the editor in a For...Loop using BookmarkInput() (Heading_XYZ then BodyText_XYZ) so they are always in that order and in a pair.

    Bookmarks are NOT added, deleted or moved once they are placed in the WP editor. Until filled by user action, bookmarks remain blank (i.e., contain no text between start and end tags.)

    Application provides interface to add predefined text fragments into bookmarks (either plain text or WP formatted text). Text is placed inside the bookmark by setting CPPosition inside the bookmark and using either InputString() (if it is plain text) or using SelectionAsString (if it is WPT formatted text).

    Of course, user can also directly type into the WP Editor. Idea is simple: bookmarks provide a structure and user action adds text.

    Basically, this works well except when it doesn't <g> as noted in this post.

    Problem described below occurs FREQUENTLY AND UNEXPECTEDLY. So far, I have not been able to identify a sequence of steps that will consistently reproduce the problem .

    I am sending TWO files as e-mail attachment - one where process [mostly] worked as expected and 2nd when similar steps deleted/changed bookmarks tags to invalid tags (e.g. opening tag [ch=2] is changed to [ch=1] ). Please see snippets from these files below.

    Problem: Inserting text into a bookmark sometimes:
    1. Deletes opening bookmark tags and changes order of bookmarks. These tags seem to be replaced by [ch=1].
    2. Order of bookmarks is changed.
    One look at file: "Bookmarks_When_Error.WPT" will show you the nature of this error.

    The 2nd file, "Bookmarks_When_Good.WPT" shows output and bookmarks when process works correctly. It was created with SIMILAR STEPS. I included this to show how Bookmarks look when this problem does not appear in display (Even this file shows some [ch=1] instead of [ch=2]).

    This may help you debug: Normally, HD-xyz (heading bookmark) always comes before BT-xyz (BodyText bookmark) as follows (from "Good" file). Note that order of first two pairs is correct but then bookmark order is reversed (BT-xyz has moved before HD-xyz):

    Code
    <begin Tag=259 style="Name:'HD-Chest';" wpsty=[[Type:3;Mode:3;Name:"HD-Chest";]] ch=2/><end Tag=259 ch=3/><begin Tag=260 style="Name:'BT-Chest';" wpsty=[[Type:3;Mode:3;Name:"BT-Chest";]] ch=2/><end Tag=260 ch=3/><begin Tag=261 style="Name:'HD-Breast';" wpsty=[[Type:3;Mode:3;Name:"HD-Breast";]] ch=2/><end Tag=261 ch=3/><begin Tag=262 style="Name:'BT-Breast';" wpsty=[[Type:3;Mode:3;Name:"BT-Breast";]] ch=2/><end Tag=262 ch=3/><begin Tag=263 style="Name:'BT-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Followup Visit";]] ch=1/><begin Tag=264 style="Name:'HD-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Followup Visit";]] ch=1/><begin Tag=265 style="Name:'BT-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Imaging Orders for Next Visit";]] ch=1/><begin Tag=266 style="Name:'HD-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Imaging Orders for Next Visit";]] ch=1/><begin Tag=267 style="Name:'BT-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Lab Orders for Next Visit";]] ch=1/><begin Tag=268 style="Name:'HD-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Lab Orders for Next Visit";]] ch=1/>

    But, in "Error" file (Below), and a few in "Good" file (above):

      1. "Order" of bookmarks has changed. Now, for many items, BodyText (BT-xyz) shows up BEFORE heading bookmark (HD-xyz).
      2. Opening Tag (ch=2) and Closing Tag (ch=3) have been replaced with ch=1 for many bookmarks.
      3. There are some (ch=1) tags in "Good" file too. These may represent an error but since I did not fill these bookmarks with text, I did not notice them in interactive mode (only noticed these while examing WPT file).

    Needless to say, this is a Show-Stopper. I have full faith you will take care of this ASAP.

    Thanks in advance.

    JayM

    • Offizieller Beitrag

    I cannot debug this in deep right now. But there is a way You can find out easier what's going wrong. You can display the bookmark codes using a setting in the FormatOptions. The display would be customouzable (see bookmarkdemo) so the user actually see what structure is in the text.

    I see your demo file and - it is very complicated. In the case of the error file the bookmarks are not closed, in the correct file they are opened and closed right after it.

    You should try to insert the text using StartTag.EmbeddedText, don't use SelectionAsString, it makes things unpredictable.

    I might make it possible to use mail merge with bookmark objects in V6, but this will take some time.

    Julian

  • First, thanks for the prompt reply even when you are on vacation.

    Code
    You can display the bookmark codes using a setting in the FormatOptions.

    I am already doing this - there is a menu option to show/hide bookmarks. However, this works only for the developer. My users will not have a clue what they are looking at, and could not care less about "how and why."

    Code
    I see your demo file and - it is very complicated.

    No really - just a bunch of bookmarks in Heading and BodyText pairs. Let's not forget: You are way smarter than I am...,<seriously>

    Code
    ...insert the text using StartTag.EmbeddedText, don't use SelectionAsString, it makes things unpredictable.

    Any guidance on: How can I do that without losing existing text within the bookmark?

    The current method (Bookmarks + InputString or SelectionAsString), support the requirement that user may need to insert multiple templates PLUS hand-type text in the same bookmark. For example, exam of left Eye may be ABnormal, and right Eye Normal. In this case, user will use two separate templates, a detailed one and a short one PLUS type in a line or two if template does not describe findings adequately. Therefore, we can't replace everything within a bookmark with StartTag.EmbeddedText. SelectionAsString allows me/user to put the cursor in the proper place and add to existing text.

    Code
    I might make it possible to use mail merge with bookmark objects in V6.

    Thanks - I will explore this when available. My initial impression is: This may NOT help my current model where user needs to "mail-merge" multiple templates PLUS free text into the same field (a bookmark).

    A progress note does NOT require that all fields (bookmark placeholders) be filled - their purpose is to provide a consistent structure. Typically, users input data into 12-15 items as relevant to the given patient. On screen, WP Editor only displays user entered text (remaining headings/bodyText are not visible until they contain some text).

    "Displaying" all items as mail-merge fields will intimidating and will imply that users need to fill all 120 fields which is not required.

    BTW: I have changed all bookmark names to be one word (there were spaces in names in the files I sent you). This may not have anything to do with the problem at hand but worth a try.

    Again, thank you very much and I am looking forward to learning what you find and fix.

    JayM

    • Offizieller Beitrag

    Hi,

    I would expect that users who type into the structure accidentally select over the end of a bookmark and delete so part of the markers.

    I understand that You do not want to show all those fields, but having 100 invisible fields and inserting text into a few ones does not sound as a good idea either.

    You now use bookmarks, but you could also use mailmerge fields or better edit fields, which offer a special protection - and you could still use the old templates. (only switch the ObjType of the embedded objects to wpobjMergeField)

    Zitat

    Text is placed inside the bookmark by setting CPPosition inside the bookmark and using either InputString() (if it is plain text) or using SelectionAsString (if it is WPT formatted text).


    This you should better do using Mergetext or by writing to EmbeddedText property of the TWPTExtObj.

    If the used should edit the added text the markers must be visible, at least the current markers. Thios could be done with editfields and the EnterField event.

    Do You have the PRO version - for that kind of app it would save You time to see the code behin the TWPTextObj class.

    Julian

  • Code
    I would expect that users who type into the structure accidentally select over the end of a bookmark and delete so part of the markers.

    I should have mentioned this: All the Bookmarks are protected and tags can not be accidently deleted by user editing.

    Code
    ...use mailmerge fields or better edit fields...

    While I personally agree with you, the issue is current workflow and "industry standards" - i.e., users are used to doing things a certain way for years and any change is resisted even if it is for better.

    Right now, users work with a blank editor and create/type text where-ever, as much/as little and in any order. As you may suspect, they are resistant to "filling out fields in a form..." type of application since historically, medical progress notes have always been totally free-form.

    BTW: I don't have the Pro edition yet but can get one if that will be of help. In which case, I really need to look at version 6.

    As always, I appreciate your support and suggestions.

    JayM

    • Offizieller Beitrag

    Hi,

    Zitat

    While I personally agree with you, the issue is current workflow and "industry standards" - i.e., users are used to doing things a certain way for years and any change is resisted even if it is for better.

    I did not mean thze user should change the way they work, the program should work differently. Mergefield in wptools are very similar to bookmarks and vice versa, they are almost interchangeable - yet, there are more options available for merge fields than for bookmarks available, esspecially the mergetext function.

    Zitat

    Right now, users work with a blank editor and create/type text where-ever, as much/as little and in any order. As you may suspect, they are resistant to "filling out fields in a form..." type of application since historically, medical progress notes have always been totally free-form.

    I was referring to Your example - if they type in anywher and do not see a bookmark name, they enter data into a random bookmark. I don't think this is what is desirable.

    Julian