NetTalk Central

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jking

Pages: 1 2 [3] 4 5 ... 27
31
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 08, 2024, 04:28:31 PM »
Hi Bruce and Ron,

   Here is what I'm doing now, after looking at the flow in the generated source:

1.  The InsertRecord:PatientEnrollment routine has the following code at the beginning:

   code
  ! Start of "Start of InsertRecord: Routine"
  ! [Priority 5000]
 
  ! End of "Start of InsertRecord: Routine"
  Clear(Enr:Record)
  do QueueToFile:PatientEnrollment
  TableAction = 'insert'
  do PrimeFields:PatientEnrollment
  Do ValidateRecord:PatientEnrollment
  If err = 0
    Get(PatientEnrollment,0) ! Prime duplicate checking for Insert
    errString = p_web.CheckForDuplicates(PatientEnrollment)
    if ErrString
      ! Start of "InsertRecord Duplicate Detected"
      ! [Priority 5000]
     
      ! End of "InsertRecord Duplicate Detected"
      Err = DupKeyErr
      p_web.AddServiceError(DupKeyErr,'EDC_Enrollment', p_web.RecordIdentifier(PatientEnrollment), clip(ErrString),'')
      p_web.trace('EDC_Enrollment -- InsertRecord:PatientEnrollment -- Error Inserting: ' & ErrString)
    Else
      ! Start of "InsertRecord Before Add"
      ! [Priority 4000]

   
   The "If err = 0", is where I think I can cause the InsertRecord routine to run conditionally.  The ValidateRecord routine is run just before this.  So, in the End of ValidateRecord embed I placed the following:

   Ins:Institution_ID = Enr:Institution_ID
         If Access:Institution.Fetch(Ins:InstID_key) <> Level:Benign     
          err = 1       
          p_web.AddServiceError(999, '', 'Inst ID Not found:', '', 'Check Institution ID')
         ELSE
          !
         END


   This allows me to check the incoming Institution_ID and if not valid, I set err = 1.  This causes most of the "Insert" code in the InsertRecord routine to be skipped, and an error message is sent back to the client, 'Inst ID Not found:'.

Finally, in the InsertRecord Before Add embed, I have the following code:

     Ins:Institution_ID = Enr:Institution_ID
          If Access:Institution.Fetch(Ins:InstID_key) = Level:Benign             
              Access:PatientEnrollment.PrimeAutoInc()   
              !Access:PatientEnrollment.PrimeRecord(1)
              Enr:Study_ID = 'Z'&Format(Enr:Institution_ID, '@N02')&'-'&Format(Enr:Patient_ID, '@N04')         
          END

This primes the auto-numbered field Patient_ID properly and the Study_ID is constructed and passed back to the client.  Let me know if you have any thoughts or comments on ways I might do this better.

Thanks,

Jeff

32
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 06, 2024, 09:24:03 AM »
Hi Ron and Bruce,

     Your suggestions have pointed me in the right direction.  I believe I have a solution.  I'm refining code and will report back when I think it is ready.

Thanks,

Jeff

33
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 06, 2024, 08:02:17 AM »
Hi Ron,

     I have tried a number of the embeds but still don't know exactly how to "jump out" before the Insert.  It is true, I'm using the "built in" action of Insert.  This particular API will only do Inserts but I want to conditionally do the Insert based on the presence of a valid Institution ID in a lookup of our list of institutions.
     I may be wrong but I thought using the p_web.AddServiceError to set an error message was a way to jump out of doing the Insert, but this has not worked for me. 

Stay Tuned!

Jeff

34
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 05, 2024, 06:41:21 PM »
Hi Bruce,

     I'm confused by what you mean by client side auto-numbering.  This is an API that a "client" custom app will access.  This API has been added to an existing NT 14.13 server app we have had running for a few years.  The NT app does auto-numbering on a single field, the Patient_ID, on Inserts.  So I guess this would be server-side auto-numbering.

     However, based on Ron's recent post (Thanks Ron!), I changed my code.  I now have the following in the InsertRecordBeforeAdd embed of the InsertRecord:PatientEnrollment routine (NetWebServiceMethod):

    Ins:Institution_ID = Enr:Institution_ID
    If Access:Institution.Fetch(Ins:InstID_key) = Level:Benign
        Access:PatientEnrollment.PrimeAutoInc()
        Enr:Study_ID = 'Z'&Enr:Institution_ID&'-'&Enr:Patient_ID
    ELSE
        PatientEnrollment_Action = 'null'
        p_web.AddServiceError(999, '', '', 'Inst ID Not found', '')
    END

The use of the PrimeAutoInc() seems to have solved my auto-numbering issue.  I no longer have any code in the ServiceMethod routine embed.

     As you can see, I'm using the AddServiceError() in the ELSE statement above, as you hinted at in the previous post.  This does indeed send an error message as a result, when the passed Institution_ID is not valid.  However, a record is still created in the target tps file, PatientEnrollment.  This is the last issue I'm trying to solve.  A record should not be created in PatientEnrollment if there is not a valid Institution_ID in the Institution tps file.

     I thought I might be able to programmatically set the PatientEnrollment_Action variable, as seen in my code above.  So far this has not worked. 

Thanks,

Jeff

35
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 05, 2024, 12:23:29 PM »
Hi Bruce,

     I've been on that "fishing trip" you recommended.  The following code is what I have come up with.  It is in the ServiceMethod Routine embed:


 Ins:Institution_ID = Enr:Institution_ID
 If Access:Institution.Fetch(Ins:InstID_key) = Level:Benign
    Set(Enr:PatID_key, Enr:PatID_key)
    Access:PatientEnrollment.Fetch(Enr:PatID_key)
    Enr:Study_ID = 'Z'&Enr:Institution_ID&'-'&Enr:Patient_ID
    Access:PatientEnrollment.Update()
 ELSE
    Access:PatientEnrollment.DeleteRecord(0)
    p_web.AddServiceError(999, '', '', 'Inst ID Not found', '')
 END


     To explain, the main goal is to use the API to do an insert on the PatientEnrollment table, and generate the Enr:Study_ID, which is passed back to the client. 

     The main problem here is the Enr:Patient_ID has an autoincrement key.  It seems the new autoincremented value of the Enr:Patient_ID is not available quickly enough during an insert, so it can be used in the construction of the Enr:Study_ID field. 

     For example, I set the passed in Enr:Institution_ID to 66, which is a valid ID in my test data, and the last Enr:Patient_ID is 1234.  After a successful Insert, I would expect the Enr:Study_ID to be:   Z66-1235.  However I get Z66-0.  Note that the insert seems to have autoincremented the Patient_ID properly as the correct value of 1235 is found in the PatientEnrollment table.

     So, my solution was to allow this partial record...that is a partial Study_ID...to be inserted and then I immediately open this record and update it with the properly constructed Study_ID.

     The other problem I found is,  when I pass an invalid Institution_ID, the API does return the proper error message I set in the above code.  However, the API still inserts a PatientEnrollment table record for this invalid Institution_ID.  I have not been able to conditionally prevent the insert, so again I delete the invalid record after the insert.

     To summarize, I'm still looking for a solution to get the next auto-incremented value of Patient_ID sooner.  Also, looking for a way to conditionally prevent the insert when the passed institution_ID is invalid.  My current solution of updating and deleting does give me the final results I'm looking for but it does seem a bit messy.

Thanks,

Jeff

36
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 01, 2024, 04:06:40 PM »
Hi Bruce,

     The user asked me to try something.  In my EDC_Enrollment API method, I allow the user to do an insert into the Enrollment tps file.  Is there a way to make this conditional?  For example, they will pass an InstitutionID and I will do a lookup into the Institution tps file to see if it is valid.  I thought I might do this lookup in the InsertRecord:PatientEnrollment, Before Add embed.  See the attached image.  If the InstitutionID is not found, how can I stop the Insert action and send back an error message about the InstitutionID not being found?

Thanks,

Jeff

37
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: February 01, 2024, 01:36:41 PM »
Hi Bruce,

     I have made quite a bit of progress with this.  My user will be coding the call to the API into their own application.  I'm stuck on one issue here.  I have a user file to check on valid users.  What if they use the header like "Authorization: Basic ZGVtbzpkZW1v", to pass the username and password.  Does NT resolve this for me or do I need to decode this in the Webhandler Authenticate embed?

Thanks,

Jeff

38
Web Server - Ask For Help / Re: Help with NT 14.13 API
« on: January 30, 2024, 09:20:00 AM »
Bruce,

     Found the registration at the top of the ClarionLive site.  I'll try to join on Thursday.

Jeff

39
Web Server - Ask For Help / Help with NT 14.13 API
« on: January 29, 2024, 02:39:32 PM »
Hello,

     I'm having trouble getting started with a new API in my NT 14.13 app.  A laboratory will build an API on their end, and send an Institution ID (eg. S01) to my app.  I want my API to take this Institution ID and do a lookup into an Institution.tps file on my server. 

     If the Institution ID is found, I want to call an Insert to create a new record in an Enrollment.tps file.  During the insert and creation of a new record, a Study ID field will be created from the Institution ID and an autoincrementing field called Patient ID.  The Study ID, for example, would be something like S01-0001.  If a record is successfully created with this new Study ID, the Study ID then needs to be sent back to the client API.

     If the Institution ID is not found, then an error message must be sent back to the Client API.

     I have added a API service and method to my app but I'm struggling on what do add to the General, Parameters and Return tabs on the API Method template.  Can anyone provide me with some steps on how to proceed?

Thanks,

Jeff King

40
Hi Bruce,

     I have looked at the source and I can see where the condition appears in the code.  See attached image.  However, rather than conditionally hide a menu item, I want to just conditionally disable it.  That is, allow the text of the menu item to remain visible, greyed out, and not clickable.  A post from a few years ago mentioned it was not possible to disable a TaskPanel menu item yet, so I was wondering if this is something planned for a future update or a way to do this now?

Thanks,

Jeff

41
Hi Jane and Bruce,

     This project was on hold for about 2 years, now I'm back on it.  I know there is a template option to add a condition to include menu items but would rather disable menu items conditionally.  Is this possible yet?

Thanks,

Jeff

42
Web Server - Ask For Help / NT 14.13 Host exe app issue
« on: January 05, 2024, 05:41:00 PM »
Hello Bruce,

     I'm having a bit of trouble with the host.exe app (C11.1.13855 and NT 14.13).  I have it loaded into a Compile Manager app created by Handy Tools.  The Compile Manager indicates a build error with the following message:

--------------------------------------
ERROR: Invalid syntax. Default option is not allowed more than '1' time(s).
Type "TIMEOUT /?" for usage.
---------------------------------------

Is there anywhere in the Host EXE, or other NT 14.13 apps, that deals with DOS batch files and uses the "TIMEOUT /?" command? 

Note, the Host EXE does actually get compiled properly, as do all my other NT apps, I have in the Compile Manager.  It's just that the Compile Manager app indicates a failed build when in fact the build did succeed.  Gus at Handy Tools thinks it is due to the Host EXE using a DOS batch file somewhere.  Any thoughts on this?

Thanks,

Jeff





43
Web Server - Ask For Help / Re: NT 14.04, Web19 example app issue
« on: November 23, 2023, 04:36:33 AM »
Bruce,

     Me, of course!

Jeff

44
Web Server - Ask For Help / Re: NT 14.04, Web19 example app issue
« on: November 22, 2023, 09:15:56 AM »
I guess you CAN teach an old dog new tricks!

Jeff

45
Web Server - Ask For Help / Re: NT 14.04, Web19 example app issue
« on: November 21, 2023, 09:23:01 AM »
Bruce,

     I think you mean the Page Settings on the General Tab, where you tick on Include Std Header and Include Std Footer.  Is this correct? 

Jeff

Pages: 1 2 [3] 4 5 ... 27