SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ideas-boilerplate template

    Hi,

    I need to insert some boilerplate text in a description field. Basically it's related to medical domain, so the doctor need not insert text like scalp, nose, ears etc. again and again while writing medical summaries for particular patient.

    I don't know about boilerplate templates. Can u advice me on it?

  2. #2
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From what I understand a boilerplate is like shorthand? is that right? Every time he types in a shortform it gets replaced by the full word?

    If that's right, how many words is he looking to have apart of the template?

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Is it ;

    a word
    a phrase
    a sentence
    a paragraph

    of text to be inserted into a textarea, which can then be manipulated, added to edited etc? Or what.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    it's a word like: Scalps, Nose, Ears ; need to be manipulated later

  5. #5
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would set up a script to parse the content in a similar way as BB code on forums.

    So, for example, every time the doctor entered [s] it would change the word to scalpel. I would house a database of words so it would be easy to display all the shortcuts and make it easy to add new ones. I would also allow some generic ones like [1] that can be set after the report has been typed and some dynamic ones like [n] which would parse in the patient's name and [c] that would parse in their medical condition.

    Just some thoughts. I'm not sure if you need help writing a script or if you just need ideas to get you pointed in the right direction.
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi jeff..

    thanks for the response. your idea seems quite nice.
    I need help for writing scripts also

    Is it reasonable if I define some PHP Constants as an array in a file and then retreive it in description field?

  7. #7
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, you could use an array to store all the shorcuts. But if you store it in a database you'll be able to retrieve them across multiple pages and create an easier to use site (you'll be able to update the table much easier - adding, deleting and modifying the entries).

    Start by mapping out all the features you want to see (or that would be essential) and design a table for MySQL. Then you'll want to populate it with some examples.

    Then using the str_replace() have it loop through the database and replace each occurance in the text.

    If there's parts you're unclear of, then start with what you know and bring back any problems. Definitely try to attempt it.

    This is not the fastest method - but if this site doesn't have a huge amount of traffic it won't be a problem.

    How much PHP do you know?
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, db would be better. I will try and and report back if i get problems. thanks

  9. #9
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Feel free to PM me if you run into trouble - or just post on this thread -- I'll keep myself subscribed to it.
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi jeff,

    I can make a table with fields: id, words and shortcuts.
    Then query the table and put words and shotcuts into arrays.

    $words=array("scalps","nose");
    $shotcut=array("[S]","[N]");
    $newvalue=array();
    foreach($shotcut as $key=>$value)
    {
    $newvalue[$value] = $words[$key];
    }

    $test="[S]";
    foreach($newvalue as $key=>$value)
    {
    $test = str_replace($key, $value, $test);
    }
    echo $test; // I got scalps

    Am I on right track till here?

    If yes,than how can I proceed to use it in an editorfield.

    I have an dataedit (used rapyd framework) like
    $edit=new DataEdit("Examination Record","examination");
    $edit->assessment_summary = new editorField("Summary", "assessment_summary");
    $edit->assessment_summary->cols = 50;
    $edit->assessment_summary->rows = 35;

    assessment_summary is a field in table called examination


    thanks

  11. #11
    SitePoint Addict
    Join Date
    Nov 2008
    Location
    Peterborough, Ontario, Canada
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey - sorry I didn't get back to you earlier today. Busy day in the office (or rather out of the office).

    Your code looks fine - and it produces the results you're looking for. Unfortunately I've not used the Rapyd Framework before and I don't really have time right now to go over it. However, you would probably parse the information after it was submitted by from the editorfield (either into a preview pane or directly into a database or email).

    I've used tinyMCE before so I'll use it as an example.
    After you hit submit everything in the editor field gets "POST"ed to a script (through a form). That's when you would do your boiler templating (if it can be used as a verb) - after the user hits submit, but before the script saves the data to a database. If you don't have access to the script then you can just process that information before it gets sent to the $edit object and switch out the shortcuts.

    I'm looking at your $edit code, and I'm assuming that sets up the editor field. What happens when the user pushes submit?
    Have I helped you? You could help me.
    Like my business on facebook!
    Text message polls with real-time, live results.

  12. #12
    SitePoint Enthusiast
    Join Date
    Jun 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi jeff,

    before building $edit->object I can process the information filled out in assesment summary as ($summary=$edit->_dataobject->get("assessment_summary"))

    Now $summary would contain some value as : [N] test for condition of nose. [s] test for scalps etc....

    so now, how can i proceed to using scripts that switch shortcuts. Do I have to search for each shortcuts in $summary and keep it in an array; then use above coding to get full words

    thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •