A few days ago I received an interesting mail from M. Gupta from my other personal website EDC Developer in which Gupta asked: “Custom Function not working. Hi Anayansi, I have developed a custom function in C# for Central designer but looks like it is not even executing could you please share the steps to create and deploy the custom function”.

First of all, sorry it took me a little longer to respond. My time is limited and I don’t often get this kind of emails from my EDC Developer personal site (this website is for recruiters / potential clients for consulting assignments). Here at {EDC} Developer wordpress, I shared knowledge-based and industry related practices.

anayansigamboa - c# programming
image credit courtesy of Google

Before you can start rules programming in Central Designer, you must make sure you have the following rights assigned to you:

Study Rule Design (either as a study designer or rule writer):

  • Import User-defined functions
  • Define/modify data entry rules
  • Define/modify constants

Some companies assigned a group of people to write rules (rule writers but without access to other modules/features in CD) and the study designer is in charged of the eCRF study build (forms design). That way, while a study designer is building a form, the rule programmer can start edit checks/rule programming activities on other forms.

Remember the custom functions are programs written outside Central Designer. Functions allow you to encapsulate a piece of code and call it from other parts of your code. You may very soon run into a situation where you need to repeat a piece of code, for multiple visits for example, and this is where functions come in.

You will need Visual Studio or C#. Once you program and test your code and assuming it is working, you can load it onto CD (see user rights and refer to the annotated eCRF).

Example: Query rules may not run as expected on initial submissions for an itemset, if there is a calculation rule that sets the value on an item in a different visit, and the calculation rule is attached to the same form as the query rule.

In a previous article about troubleshooting in CD, I discussed some ways to troubleshoot rules. It will give you some insights about what to check when a rule is not working.

Something else to consider during rule development:

  • Source control your code and binaries using VSS or similar tools.
  • dll versioning may cause existing functions to stop working.
  • You can deploy functions on a study or library level. Any changes will affect other studies.
  • Remove anything that is not being referenced
  • Try using Try-Catch
  • Remember to reference CD (still called PhaseForward or see other functions provided by Oracle/PhaseForward during the initial installation) still under the old name – PhaseForward
  • Unit test (extensively) in a test environment

Rules Unit Testing:

  • Turn on rule tracing in the InForm event log
  • Check the log (warnings / errors can give you some clues that something is not right with an edit check calling this new custom function
  • Write and run test cases for data-entry rules, global conditions or workflow rules (this is very important)

Now we are ready for testing in InForm (this requires deployment).

And if it all else fails, try this article about Learn How to Avoid The 10 Most Common C# Mistakes.

Good luck and thank you for connecting.

Comments? Please post it below.

Anayansi Gamboa, MPM, an EDC Developer Consultant and clinical programmer for the Pharmaceutical and Biotech industry with more than 13 years of experience.

Available for short-term contracts or ad-hoc requests. See my specialties section (Oracle, SQL Server, EDC Inform, EDC Rave, OpenClinica, SAS and other CDM tools)