Skip to main content

Example: OnBeforeProductionStart HL7

The following code is in the test class Tutorial.HL7ProductionTest. It overrides the OnBeforeProductionStart method. The code runs before the production starts and performs a variety of set up tasks. In particular the code does the following:

  • Sets the values of MainDir. The input file and the reference file should be placed in this directory.

  • Changes the values of the FilePath configuration settings on both the Business Service and Operation using ChangeSettings. Note that in neither case does ChangeSettings update the production class. The changes are temporary for the duration of this test. To update the production class to the new value, set the value of the last argument in the call to ChangeSettings to 1. Note also that the test uses the default values for HL7InputDir and HL7OutputDir.

  • Initializes the testing directory using CreateMainDirTree. The root of the directory is TestAutoNNN.

  • Cleans both the input and output directories using CleanUpDirectory.

  • Copies the HL7 Input file, ABC1.txt, from MainDir to HL7InputDir.


 Method OnBeforeProductionStart() As %Library.Status
{
 Set ..MainDir = "C:\Tutorial"
 
 Set s = ..ChangeSetting("Tutorial.HL7ExampleProduction",
     "TutorialHL7FileOperation","FilePath",..HL7OutputDir,0)
 Do $$$AssertEquals(s,$$$OK)
    
 Set s0 = ..ChangeSetting("Tutorial.HL7ExampleProduction",
      "TutorialHL7FileService","FilePath",..HL7InputDir,0)
 Do $$$AssertEquals(s0,$$$OK)
 
 Set s1=$$$AssertStatusOK(..CreateMainDirTree())
 Set s2 = $$$AssertStatusOK(..CleanUpDirectory(..HL7InputDir))
 Set s3 = $$$AssertStatusOK(..CleanUpDirectory(..HL7OutputDir))
 Set s4 = $$$AssertStatusOK(..CopyFile("ABC1.txt",..MainDir))
 
 if 's||'s0||'s1||'s2||'s3||'s4 
 {Quit ..Error("Error in OnBeforeProductionStart()")}

 Quit $$$OK
}
Note:

All of the auxiliary methods used above are completely described in the class documentation for %UnitTest.TestProductionOpens in a new tab.

FeedbackOpens in a new tab