Tag Archives: c sharp programming

Central Designer : Custom Function

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)

Tip #5 – Download library of 200+ Code Samples

Download 200+ highly organized code samples with a single click of the mouse. Each sample includes an explanation of the syntax involved.

This library can become a programmer’s expanding toolkit that will rapidly increase productivity over time. Progress Monitor members can always download the latest version of this growing library as a single file.

CodeSamples

Check out http://idealprogrammer.com/ if you are new to VB.NET or ASP technology

Tip #4 – Install LinqPad

Tired of querying in antiquated SQL?

Well, you don’t have to! LINQPad lets you interactively query databases in a modern query language: LINQ. Kiss goodbye to SQL Management Studio!

LinqPad comes with 100s of great LINQ samples. Work through the 5-minute induction under the Samples section after installing Low Impact version of LinqPad 4.0.

LinqPad

Check out http://idealprogrammer.com/ if you are new to VB.NET or ASP technology

Tip #3 – Become an Expert at Debugging

Studies have shown that we spend 50% of our time debugging, but only learn debugging by trial and error. This webcast by John Robbins was in the top 10 favorites on Microsoft web site, and it is a real goldmine. Watch this 4-hour webcast on debugging, and you are bound to save many times that in the future. Here is the handout for the webcast – be sure to download the source code for the Visual Studio macros. John Robbins is the co-founder of Wintellect and the author of several books on .NET Debugging.

Check out http://idealprogrammer.com/ if you are new to VB.NET or ASP technology.