HI all,
I am trying to get a function to work as a "CAM" in a note to look for when an order is placed.
Function seems to be working in all situations I have thought to test it.
But is causing an error for users that I am not able to replicate.
{if ORDER_LIST_CHANGES()"" THEN fcn_nipt_instructions() ELSE "" ENDIF 0) then
if (match(plan,"kaiser")>0) then
inst_size=size(DOCUMENT.TEMP_CCC_PI_MLEF)
if inst_size>0 then n="\r\n"
endif
DOCUMENT.TEMP_CCC_PI_MLEF=DOCUMENT.TEMP_CCC_PI_MLEF+n+"We ordered a prenatal genetic test for you today. Additional paperwork is needed before you go to the lab to have this drawn. Please allow 3 days for FCN Lab to process paperwork. Your test can only be drawn at these FCN lab locations:"+HRET+"Whatcom County: Medical Testing & Urgent Care Center"+HRET+"Monday - Thursday 7:00am-3pm"+HRET+"3130 Squalicum Parkway, Bellingham, WA 98225"+HRET+"Skagit County: North Cascade Family Physicians"+HRET+"Monday - Thursday 7:30am-3pm"+HRET+"2116 E. Section Street, Mount Vernon, WA 98274"
endif
endif
endif
endif
return ""
}}
{' {if ORDER_LIST_CHANGES()"" THEN fcn_nipt_instructions() ELSE "" ENDIF} '}
Hello,
I think part of your code is missing (which is just an issue with this site). I don't see where fcn_nipt_instructions() is defined. In general though I would say your best bet is to find a patient that is having the issue, turn on MEL trace, and open the document. Then search the trace result for fcn_nipt_instructions and see what is happening with this specific instance.
It also looks like you may be (I don't know for sure without seeing the beginning of the function) adding this same statement every time the form is opened after the order is added, which would probably run into the '32785 Too much data for field, retry?' error after awhile. If that's the case, you need to add a check of whether the document variable already contains the text that you are trying to add.
Heres my reply trying to paste in the entire function again for you to see as it may be cut off above:
{local orderlist,plan,inst_size,n=""
orderlist=ORDER_LIST_CHANGES()
plan=tolower(INS_PLAN("P"))
if ok(DOCUMENT.TEMP_CCC_PI_MLEF) then
if (match(DOCUMENT.TEMP_CCC_PI_MLEF,"Additional paperwork is needed before you go to the lab to have this drawn.")==0) then
if (match(orderlist,"NIPT")>0) then
if (match(plan,"kaiser")>0) then
inst_size=size(DOCUMENT.TEMP_CCC_PI_MLEF)
if inst_size>0 then n="\r\n"
endif
DOCUMENT.TEMP_CCC_PI_MLEF=DOCUMENT.TEMP_CCC_PI_MLEF+n+"We ordered a prenatal genetic test for you today. Additional paperwork is needed before you go to the lab to have this drawn. Please allow 3 days for FCN Lab to process paperwork. Your test can only be drawn at these FCN lab locations:"+HRET+"Whatcom County: Medical Testing & Urgent Care Center"+HRET+"Monday - Thursday 7:00am-3pm"+HRET+"3130 Squalicum Parkway, Bellingham, WA 98225"+HRET+"Skagit County: North Cascade Family Physicians"+HRET+"Monday - Thursday 7:30am-3pm"+HRET+"2116 E. Section Street, Mount Vernon, WA 98274"
endif
endif
endif
endif
return ""
}}
That looks okay, I don't think you need to be concerned with the duplication. Do you have all of this in a text component? If so, I don't believe you can really set it up that way. The function is only going to be in scope until the document is placed on hold. So it should work the first time. However, when you place it on hold and reopen it, the document will be left with only the continuously evaluating part of it, the last part, and no function definition, so you would be left with an error that you could see in the text translation that would say <- FUNCTION DEFINITION NOT EXECUTABLE.
If that is the scenario, you would have to define the function itself elsewhere. I would recommend in the usrlib.txt file in the client directory, you could also put it in another form if you want and some people use function libraries for that. Let us know if that is not what you are seeing.
Mike