Hello,
Just wanted to put some input into this discussion. I was dabbing in AI in VistA for a few months and I came up with some cool results.
Below is a working routine that uses OpenAI's Assistants API. Using the GPT-4-turbo model. as you can see it is able to solve some trivial mumps coding issues, as well as describe complex routines.
Below is a copy paste from my VistA system. as you see there is a prompt for the user, some processing status', and the response from the API.
I also wrote a complete backend system for saving conversions to be picked up later or modified and managing user access with regards to API keys and Assistant model IDS, all with Fileman.
=======================================================================================================================
MACROS
| M=Macro-Option | R=Attach-Routine | Q=Attach-Question |
Enter a message: R=XV Q=CAN YOU EXAMINE THIS ROUTINE AND LET ME KNOW WHAT IT DOES?
Uploading Attached Files
Submitting Message
Processing your request :-)
Status: in_progress [1] Seconds
Status: in_progress [5] Seconds
Status: in_progress [10] Seconds
Status: in_progress [15] Seconds
Status: in_progress [20] Seconds
Status: completed [25] Seconds
Request Complete!
Response #1:
The routine provided appears to be part of the VPE (Victory Programming Environment) for VistA (Veterans Health Information Systems
and Technology Architecture). Below is a brief overview of what this routine does:
1. **Initialization**: The routine starts by setting up an error trap and checking for simulated errors for testing purposes. It ini
tializes variables and checks for user information (`DUZ`), ensuring that the necessary VistA FileMan environment variables (`U`, `D
TIME`, `DT`) are set. If not, it sets up a minimal environment or a FileMan environment depending on the detection of FileMan's pres
ence.
2. **User Setup**: It prompts for the `DUZ` (user ID) if it's missing and sets up essential VistA environment variables if they are
not present.
3. **Main Environment Initialization**: Calls `^XVEMSY` to initialize many settings and objects required for the VPE to function cor
rectly.
4. **Building VPE Structure**: It checks and builds the `^XVEMS` structure (`^XVEMBLD`) if it doesn't exist, indicating the setup of
VPE quick commands and help files. Additionally, it sets up necessary FileMan files for VPE if they are not already set up.
5. **Running VPE**: The routine enters a main loop, initiated by calling `^XVSS` to save the symbol table and initialize necessary s
ettings, and then runs the VPE shell (`^XVSA`). If the user chooses to exit (by setting `XVVSHC` to `^`), it performs cleanup operat
ions (`^XVSK`).
6. **Upgrade and Reset Options**: Provides functions (`UPGRADE` and `RESET`) to upgrade VPE from a previous version or reset VPE to
its pristine state, respectively. The upgrade process involves saving user data, cleaning up the VPE global and FileMan data, and th
en rebuilding and restoring the VPE structure. The reset process involves deleting data and Data Dictionary (DD) entries for all VPE
files and resetting the VPE global.
In summary, this routine seems to set up the Victory Programming Environment, ensuring the user and environment are correctly initia
lized, builds necessary structures if they are not present, and provides an entry point to running VPE. It also includes options to
upgrade VPE or reset it to a default state.
MACROS
| M=Macro-Option | R=Attach-Routine | Q=Attach-Question |
Enter a message: R=BUGGEDROUTINE Q=CAN YOU NOW LOOK AT THIS ROUTINE AND IDENTIFY AND FIX THE ISSUES? SHOW ME BEFORE AND AFTER
Uploading Attached Files
Submitting Message
Processing your request :-)
Status: in_progress [1] Seconds
Status: in_progress [5] Seconds
Status: in_progress [10] Seconds
Status: in_progress [15] Seconds
Status: in_progress [20] Seconds
Status: in_progress [25] Seconds
Status: in_progress [30] Seconds
Status: in_progress [35] Seconds
Status: in_progress [40] Seconds
Status: in_progress [45] Seconds
Status: in_progress [50] Seconds
Request Complete!
Response #26:
**Before Fix**:
The original `BUGGEDROUTINE` has the following issues:
mumps
BUGGEDROUTINE
QUIT
; ##DETAILS
; **RETRIEVES A CONFIG GIVEN EITHER A B CROSS REFERENCE 'NAME' OR "CID" FOR A CONFIG
;
NEW CONFIG,PREF S PREF="2"
NEW NPFILE,CFILE,AFILE,TFILE S NPFILE=200,CFILE=999007,AFILE=999011,TFILE=999013
I $O(^VA(NPFILE,DUZ,6,"B",PREF,""))'=""$$GET1^DIQ(CFILE,PREF,5,"I") D
. S CONFIG("PREF")=PREF
. S CONFIG("AID")=$G(AIC(AFILE,$G(^AIC(CFILE,PREF,2),"N/A"),1))
. S CONFIG("TID")=$G(AIC(TFILE,$P($G(^AIC(CFILE,PREF,0),"N/A"),"^",3),1))
QUIT
**Issues Identified**:
- The conditional line contains a syntax error where it attempts to concatenate a non-empty string check with a FileMan DBS API `$$G
ET1^DIQ` call without an explicit AND `&` operator.
- The symbol `AIC` is used without previously being defined, or it could be a typo and meant to represent a subroutine or a global v
ariable not shown here.
- The manner of accessing `^AIC` global might not accomplish what's intended because the variables `CFILE`, `AFILE`, and `TFILE` poi
nt to numbers which are likely intended to be file numbers, but it's unclear if `^AIC` is a proper global root in this context.
**After Fix**:
Below is a corrected version of the routine with comments:
mumps
BUGGEDROUTINE
QUIT
; ##DETAILS
; **RETRIEVES A CONFIG GIVEN EITHER A B CROSS REFERENCE 'NAME' OR "CID" FOR A CONFIG
;
NEW CONFIG,PREF S PREF="2"
NEW NPFILE,CFILE,AFILE,TFILE S NPFILE=200,CFILE=999007,AFILE=999011,TFILE=999013
I $O(^VA(NPFILE,DUZ,6,"B",PREF,""))'=""&($$GET1^DIQ(CFILE,PREF,5,"I")'="") D ; Fixed syntax error by adding correct logical o
perator &
. S CONFIG("PREF")=PREF
. ; Assuming AIC should be a global ^AIC, replaced AIC with a correct global reference
. S CONFIG("AID")=$G(^AIC(AFILE,$G(^AIC(CFILE,PREF,2),"N/A"),1)) ; Assuming ^AIC represents a valid global structure
. S CONFIG("TID")=$G(^AIC(TFILE,$P($G(^AIC(CFILE,PREF,0),"N/A"),"^",3),1)) ; Assuming ^AIC represents a valid global structure
QUIT
**Corrections Made**:
- Introduced the correct AND `&` operator to fix logical operation in the conditional check.
- Replaced `AIC` with assumed correct global reference `^AIC` assuming the context of this code fragment. However, since the origina
l context is unknown, it's essential to verify `^AIC` represents a valid and intended global structure used within this routine.
- Added comment annotations clarifying assumptions and changes for clarity.
Without further detailed specifications or the broader context of how `BUGGEDROUTINE` integrates with the overall system, these adju
stments are based on syntax corrections and presumed intent behind the original code.
MACROS
| M=Macro-Option | R=Attach-Routine | Q=Attach-Question |
Enter a message:
=======================================================================================================================
Its a pretty neat system and I can definitely see some benefits. This is just a personal project so Obviously It can be greatly improved :)
- David Blackstone