DGRUGDS ;ALB/GRR - RAI/MDS DATA COLLECTION
;;5.3;Registration;**303,359**;Aug 13, 1993
;
;Display option description and allow user to terminate process
EN ;
W @IOF
N DGSTN,DGX,DGDIV
F I=0:1 S DGX=$P($T(TEXT+I),";;",2) Q:DGX="$END" W !,DGX
S DIR(0)="YA",DIR("B")="NO",DIR("A")="Do you wish to continue? "
S DIR("?")="Enter Yes to continue or No to quit"
D ^DIR K DIR
Q:'Y!$D(DIRUT)
;
;Ask user for division to seed
DIV ;
W !
N DIR,DIRUT
S DIR(0)="PO^40.8:EMZ"
S DIR("A")="Enter the Division you want to do Data Seeding for"
S DIR("?")="Select the division you want to load the patient data for into the COTS database."
D ^DIR K DIR Q:$D(DIRUT)!(+Y'>0)
S DGDIV=Y
S DGSTN=$$SITE^VASITE($$NOW^XLFDT,+DGDIV)
W !!,?4,"You have selected: ",$P(DGDIV,"^",2)
W !,?4,"Station Number : ",$S(+DGSTN>0:$P(DGSTN,"^",3),1:"Undefined Station Number"),!
I +DGSTN<0 D G DIV
.W !?4,"You cannot proceed with this division until the station number is corrected."
.W !?4,"You may select another division or quit.",!
N DIR,DUOUT,DTOUT
S DIR(0)="YAO",DIR("A")="Is this correct? ",DIR("B")="YES"
S DIR("?")="Enter Yes or No. Yes will select, No will cancel."
D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
G:'Y DIV
W !
N ZTDESC,ZTSAVE,ZTIO,ZTDTH,X,ZTQUEUED,ZTREQ,ZTRTN
S ZTDESC="RAI/MDS DATA SEED FOR DIVISION "_$P(DGDIV,"^",2)
S ZTRTN="EN1^DGRUGDS",ZTIO=""
S DGDIV=+DGDIV
S ZTSAVE("DGDIV")="",ZTSAVE("DGSTN")=""
D ^%ZTLOAD
I '$G(ZTSK) W !,"** The data seed process was not tasked **"
I $G(ZTSK) W !,"The data seed process has been tasked (#",ZTSK,")"
W !
Q
EN1 ;
N DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
S U="^",DGSENM="DGRU-RAI-A01-SERVER",DGRSIED=$O(^ORD(101,"B",DGSENM,0)) ;SET VARIABLES TO CALL HL7 INIT FUNCTION
D INIT^HLFNC2(DGSENM,.HL) ;Initialize A01 server, sets HL7 variables
I $O(HL(""))']"" D Q ;WAS UNABLE TO INTIALIZE
.S HLERR(1)=HL
.;S DGWARD="" F S DGWARD=$O(^DGPM("CN",DGWARD)) Q:DGWARD="" S DGWIEN=+$O(^DIC(42,"B",DGWARD,0)) I $$GET1^DIQ(42,DGWIEN,.035,"I")=1 D ;loop through active patients, if ward is RAI/MDS flagged, continue
.;S DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I") I DGWDIV=DGDIV S DGIEN=0 F S DGIEN=$O(^DGPM("CN",DGWARD,DGIEN)) Q:DGIEN'>0 D ;If ward in the division selected, continue
;..S DFN=$$GET1^DIQ(405,DGIEN,.03,"I") Q:DFN="" ;get patient ien
;..S DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I") Q:DGMDT=""
;..S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
;
S DGRUGDS=0
S DGWARD=""
;Loop through active patients
F S DGWARD=$O(^DGPM("CN",DGWARD)) Q:(DGWARD="")!(DGRUGDS) D
.;Task asked to stop ?
.S X="Looping through ward "_DGWARD
.S DGRUGDS=$$S^%ZTLOAD(X) Q:DGRUGDS
.S DGWIEN=+$O(^DIC(42,"B",DGWARD,0))
.;Not an RAI/MDS ward
.Q:'$$GET1^DIQ(42,DGWIEN,.035,"I")
.S DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I")
.;Ward not in selected division
.Q:DGWDIV'=DGDIV
.;Loop through movements
.S DGIEN=0
.F S DGIEN=$O(^DGPM("CN",DGWARD,DGIEN)) Q:(DGIEN'>0)!(DGRUGDS) D
..;Get patient pointer and movement date/time
..S DFN=$$GET1^DIQ(405,DGIEN,.03,"I") Q:DFN=""
..S DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I") Q:DGMDT=""
..;Send message to RAI/MDS machine
..S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
..;Task asked to stop ?
..S X="Looping through ward "_DGWARD_" -- Last DFN sent was "_DFN
..S DGRUGDS=$$S^%ZTLOAD(X) Q:DGRUGDS
;Update task message with completion status
I DGRUGDS S X=$$S^%ZTLOAD("Task stopped as requested")
I 'DGRUGDS S X=$$S^%ZTLOAD("Task ran to completion")
Q
;
TEXT ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
;;HL7 A01 Admit messages will be created for patients currently active in wards
;;assigned to the selected division. This option should be run only once per
;;division and the COTS system database should be empty of patient data prior
;;to using this option.
;;
;;***NOTE***
;;
;;It is extremely important that both the Ward translation file (#46.12) and the
;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
;;division BEFORE this option is run.
;;
;;$END
;;
;Entry point for individual data seed
EN3 ;
W @IOF
N DGINPT,DGPTNM,DGFNM,DGLNM
F I=0:1 S DGX=$P($T(TEXT3+I),";;",2) Q:DGX="$END" W !,DGX
S DIR(0)="YA",DIR("B")="NO",DIR("A")="Do you wish to continue? "
S DIR("?")="Enter Yes to continue or No to quit"
D ^DIR K DIR
Q:'Y!$D(DIRUT)
;
;Select patient(s)
INPAT ;
W !
N DIR,DIRUT,DFN,DGIEN,DGWIEN,DGMDT
S DIR(0)="PAO^2:EMZ"
S DIR("A")="Enter the patient you want to data seed: "
S DIR("?")="Select the patient you want to load into the COTS database."
D ^DIR K DIR Q:$D(DIRUT)!(+Y'>0)
S DGINPT=+Y
S DGPTNM=$$GET1^DIQ(2,DGINPT,.01)
S DGFNM=$P(DGPTNM,",",2)
S DGLNM=$P(DGPTNM,",",1)
S DGPTNM=DGFNM_" "_DGLNM
W !!,?4,"You have selected: ",DGPTNM
W !
I +DGINPT<0 D G INPAT
.W !?4,"You cannot proceed with this patient"
.W !?4,"You may select another patient or quit.",!
N DIR,DUOUT,DTOUT
S DIR(0)="YAO",DIR("A")="Is this correct? ",DIR("B")="YES"
S DIR("?")="Enter Yes or No. Yes will select this patient. No will cancel the selection of this patient."
D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
G:'Y INPAT D EN4
;Allow another selection
W !
S DIR(0)="YAO",DIR("A")="Select another patient? ",DIR("B")="NO"
S DIR("?")="Enter Yes or No. Yes will allow you to select another patient."
D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))!('Y)
G:Y INPAT
W !
Q
;
;Set variables to call HL7 Function
EN4 ;
N DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
S U="^",DGSENM="DGRU-RAI-A01-SERVER",DGRSIED=$O(^ORD(101,"B",DGSENM,0))
D INIT^HLFNC2(DGSENM,.HL) ;Initialize A01 server, sets HL7 variables
I $O(HL(""))']"" D Q ;WAS UNABLE TO INTIALIZE
.S HLERR(1)=HL
;
;Get selected patient's last ward location. If RAI ward, send message.
;If not an RAI ward, allow another inpatient selection. If current
;ward location is empty, patient is inactive & allow another selection.
ACTIVE ;
S DFN=DGINPT
S DGRUGDS=0
S VAIP("D")="LAST"
D IN5^VADPT
I '$$CHKWARD^DGRUUTL(+$P(VAIP(5),"^")) W !!?4,DGPTNM_" is not in an RAI ward." D EXIT Q
I $$GET1^DIQ(2,DFN,.1)="" W !!?4,DGPTNM_" is not an active patient in an RAI ward." D EXIT Q
I $$CHKWARD^DGRUUTL(+$P(VAIP(5),"^")) S DGWIEN=+$P(VAIP(5),"^"),DGIEN=VAIP(1),DGMDT=+$P(VAIP(3),"^")
S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
W !!?4,"Sending message..."
D EXIT
Q
;Reset variables for next selection
EXIT ;
K DFN,DGIEN,DGINPT,DGWIEN,DGMDT,VAIP
;
TEXT3 ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
;;HL7 A01 Admit messages will be created for selected patients currently active in
;;RAI designated wards.
;;
;;***NOTE***
;;
;;It is extremely important that both the Ward translation file (#46.12)and the
;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
;;division BEFORE this option is run.
;;
;;$END
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGRUGDS 7264 printed Dec 13, 2024@02:58:22 Page 2
DGRUGDS ;ALB/GRR - RAI/MDS DATA COLLECTION
+1 ;;5.3;Registration;**303,359**;Aug 13, 1993
+2 ;
+3 ;Display option description and allow user to terminate process
EN ;
+1 WRITE @IOF
+2 NEW DGSTN,DGX,DGDIV
+3 FOR I=0:1
SET DGX=$PIECE($TEXT(TEXT+I),";;",2)
if DGX="$END"
QUIT
WRITE !,DGX
+4 SET DIR(0)="YA"
SET DIR("B")="NO"
SET DIR("A")="Do you wish to continue? "
+5 SET DIR("?")="Enter Yes to continue or No to quit"
+6 DO ^DIR
KILL DIR
+7 if 'Y!$DATA(DIRUT)
QUIT
+8 ;
+9 ;Ask user for division to seed
DIV ;
+1 WRITE !
+2 NEW DIR,DIRUT
+3 SET DIR(0)="PO^40.8:EMZ"
+4 SET DIR("A")="Enter the Division you want to do Data Seeding for"
+5 SET DIR("?")="Select the division you want to load the patient data for into the COTS database."
+6 DO ^DIR
KILL DIR
if $DATA(DIRUT)!(+Y'>0)
QUIT
+7 SET DGDIV=Y
+8 SET DGSTN=$$SITE^VASITE($$NOW^XLFDT,+DGDIV)
+9 WRITE !!,?4,"You have selected: ",$PIECE(DGDIV,"^",2)
+10 WRITE !,?4,"Station Number : ",$SELECT(+DGSTN>0:$PIECE(DGSTN,"^",3),1:"Undefined Station Number"),!
+11 IF +DGSTN<0
Begin DoDot:1
+12 WRITE !?4,"You cannot proceed with this division until the station number is corrected."
+13 WRITE !?4,"You may select another division or quit.",!
End DoDot:1
GOTO DIV
+14 NEW DIR,DUOUT,DTOUT
+15 SET DIR(0)="YAO"
SET DIR("A")="Is this correct? "
SET DIR("B")="YES"
+16 SET DIR("?")="Enter Yes or No. Yes will select, No will cancel."
+17 DO ^DIR
KILL DIR
if $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+18 if 'Y
GOTO DIV
+19 WRITE !
+20 NEW ZTDESC,ZTSAVE,ZTIO,ZTDTH,X,ZTQUEUED,ZTREQ,ZTRTN
+21 SET ZTDESC="RAI/MDS DATA SEED FOR DIVISION "_$PIECE(DGDIV,"^",2)
+22 SET ZTRTN="EN1^DGRUGDS"
SET ZTIO=""
+23 SET DGDIV=+DGDIV
+24 SET ZTSAVE("DGDIV")=""
SET ZTSAVE("DGSTN")=""
+25 DO ^%ZTLOAD
+26 IF '$GET(ZTSK)
WRITE !,"** The data seed process was not tasked **"
+27 IF $GET(ZTSK)
WRITE !,"The data seed process has been tasked (#",ZTSK,")"
+28 WRITE !
+29 QUIT
EN1 ;
+1 NEW DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
+2 ;SET VARIABLES TO CALL HL7 INIT FUNCTION
SET U="^"
SET DGSENM="DGRU-RAI-A01-SERVER"
SET DGRSIED=$ORDER(^ORD(101,"B",DGSENM,0))
+3 ;Initialize A01 server, sets HL7 variables
DO INIT^HLFNC2(DGSENM,.HL)
+4 ;WAS UNABLE TO INTIALIZE
IF $ORDER(HL(""))']""
Begin DoDot:1
+5 SET HLERR(1)=HL
+6 ;S DGWARD="" F S DGWARD=$O(^DGPM("CN",DGWARD)) Q:DGWARD="" S DGWIEN=+$O(^DIC(42,"B",DGWARD,0)) I $$GET1^DIQ(42,DGWIEN,.035,"I")=1 D ;loop through active patients, if ward is RAI/MDS flagged, continue
+7 ;S DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I") I DGWDIV=DGDIV S DGIEN=0 F S DGIEN=$O(^DGPM("CN",DGWARD,DGIEN)) Q:DGIEN'>0 D ;If ward in the division selected, continue
End DoDot:1
QUIT
+8 ;..S DFN=$$GET1^DIQ(405,DGIEN,.03,"I") Q:DFN="" ;get patient ien
+9 ;..S DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I") Q:DGMDT=""
+10 ;..S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
+11 ;
+12 SET DGRUGDS=0
+13 SET DGWARD=""
+14 ;Loop through active patients
+15 FOR
SET DGWARD=$ORDER(^DGPM("CN",DGWARD))
if (DGWARD="")!(DGRUGDS)
QUIT
Begin DoDot:1
+16 ;Task asked to stop ?
+17 SET X="Looping through ward "_DGWARD
+18 SET DGRUGDS=$$S^%ZTLOAD(X)
if DGRUGDS
QUIT
+19 SET DGWIEN=+$ORDER(^DIC(42,"B",DGWARD,0))
+20 ;Not an RAI/MDS ward
+21 if '$$GET1^DIQ(42,DGWIEN,.035,"I")
QUIT
+22 SET DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I")
+23 ;Ward not in selected division
+24 if DGWDIV'=DGDIV
QUIT
+25 ;Loop through movements
+26 SET DGIEN=0
+27 FOR
SET DGIEN=$ORDER(^DGPM("CN",DGWARD,DGIEN))
if (DGIEN'>0)!(DGRUGDS)
QUIT
Begin DoDot:2
+28 ;Get patient pointer and movement date/time
+29 SET DFN=$$GET1^DIQ(405,DGIEN,.03,"I")
if DFN=""
QUIT
+30 SET DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I")
if DGMDT=""
QUIT
+31 ;Send message to RAI/MDS machine
+32 SET DGSEED=1
DO BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
+33 ;Task asked to stop ?
+34 SET X="Looping through ward "_DGWARD_" -- Last DFN sent was "_DFN
+35 SET DGRUGDS=$$S^%ZTLOAD(X)
if DGRUGDS
QUIT
End DoDot:2
End DoDot:1
+36 ;Update task message with completion status
+37 IF DGRUGDS
SET X=$$S^%ZTLOAD("Task stopped as requested")
+38 IF 'DGRUGDS
SET X=$$S^%ZTLOAD("Task ran to completion")
+39 QUIT
+40 ;
TEXT ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
+1 ;;HL7 A01 Admit messages will be created for patients currently active in wards
+2 ;;assigned to the selected division. This option should be run only once per
+3 ;;division and the COTS system database should be empty of patient data prior
+4 ;;to using this option.
+5 ;;
+6 ;;***NOTE***
+7 ;;
+8 ;;It is extremely important that both the Ward translation file (#46.12) and the
+9 ;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
+10 ;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
+11 ;;division BEFORE this option is run.
+12 ;;
+13 ;;$END
+14 ;;
+15 ;Entry point for individual data seed
EN3 ;
+1 WRITE @IOF
+2 NEW DGINPT,DGPTNM,DGFNM,DGLNM
+3 FOR I=0:1
SET DGX=$PIECE($TEXT(TEXT3+I),";;",2)
if DGX="$END"
QUIT
WRITE !,DGX
+4 SET DIR(0)="YA"
SET DIR("B")="NO"
SET DIR("A")="Do you wish to continue? "
+5 SET DIR("?")="Enter Yes to continue or No to quit"
+6 DO ^DIR
KILL DIR
+7 if 'Y!$DATA(DIRUT)
QUIT
+8 ;
+9 ;Select patient(s)
INPAT ;
+1 WRITE !
+2 NEW DIR,DIRUT,DFN,DGIEN,DGWIEN,DGMDT
+3 SET DIR(0)="PAO^2:EMZ"
+4 SET DIR("A")="Enter the patient you want to data seed: "
+5 SET DIR("?")="Select the patient you want to load into the COTS database."
+6 DO ^DIR
KILL DIR
if $DATA(DIRUT)!(+Y'>0)
QUIT
+7 SET DGINPT=+Y
+8 SET DGPTNM=$$GET1^DIQ(2,DGINPT,.01)
+9 SET DGFNM=$PIECE(DGPTNM,",",2)
+10 SET DGLNM=$PIECE(DGPTNM,",",1)
+11 SET DGPTNM=DGFNM_" "_DGLNM
+12 WRITE !!,?4,"You have selected: ",DGPTNM
+13 WRITE !
+14 IF +DGINPT<0
Begin DoDot:1
+15 WRITE !?4,"You cannot proceed with this patient"
+16 WRITE !?4,"You may select another patient or quit.",!
End DoDot:1
GOTO INPAT
+17 NEW DIR,DUOUT,DTOUT
+18 SET DIR(0)="YAO"
SET DIR("A")="Is this correct? "
SET DIR("B")="YES"
+19 SET DIR("?")="Enter Yes or No. Yes will select this patient. No will cancel the selection of this patient."
+20 DO ^DIR
KILL DIR
if $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+21 if 'Y
GOTO INPAT
DO EN4
+22 ;Allow another selection
+23 WRITE !
+24 SET DIR(0)="YAO"
SET DIR("A")="Select another patient? "
SET DIR("B")="NO"
+25 SET DIR("?")="Enter Yes or No. Yes will allow you to select another patient."
+26 DO ^DIR
KILL DIR
if $DATA(DTOUT)!($DATA(DUOUT))!('Y)
QUIT
+27 if Y
GOTO INPAT
+28 WRITE !
+29 QUIT
+30 ;
+31 ;Set variables to call HL7 Function
EN4 ;
+1 NEW DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
+2 SET U="^"
SET DGSENM="DGRU-RAI-A01-SERVER"
SET DGRSIED=$ORDER(^ORD(101,"B",DGSENM,0))
+3 ;Initialize A01 server, sets HL7 variables
DO INIT^HLFNC2(DGSENM,.HL)
+4 ;WAS UNABLE TO INTIALIZE
IF $ORDER(HL(""))']""
Begin DoDot:1
+5 SET HLERR(1)=HL
End DoDot:1
QUIT
+6 ;
+7 ;Get selected patient's last ward location. If RAI ward, send message.
+8 ;If not an RAI ward, allow another inpatient selection. If current
+9 ;ward location is empty, patient is inactive & allow another selection.
ACTIVE ;
+1 SET DFN=DGINPT
+2 SET DGRUGDS=0
+3 SET VAIP("D")="LAST"
+4 DO IN5^VADPT
+5 IF '$$CHKWARD^DGRUUTL(+$PIECE(VAIP(5),"^"))
WRITE !!?4,DGPTNM_" is not in an RAI ward."
DO EXIT
QUIT
+6 IF $$GET1^DIQ(2,DFN,.1)=""
WRITE !!?4,DGPTNM_" is not an active patient in an RAI ward."
DO EXIT
QUIT
+7 IF $$CHKWARD^DGRUUTL(+$PIECE(VAIP(5),"^"))
SET DGWIEN=+$PIECE(VAIP(5),"^")
SET DGIEN=VAIP(1)
SET DGMDT=+$PIECE(VAIP(3),"^")
+8 SET DGSEED=1
DO BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
+9 WRITE !!?4,"Sending message..."
+10 DO EXIT
+11 QUIT
+12 ;Reset variables for next selection
EXIT ;
+1 KILL DFN,DGIEN,DGINPT,DGWIEN,DGMDT,VAIP
+2 ;
TEXT3 ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
+1 ;;HL7 A01 Admit messages will be created for selected patients currently active in
+2 ;;RAI designated wards.
+3 ;;
+4 ;;***NOTE***
+5 ;;
+6 ;;It is extremely important that both the Ward translation file (#46.12)and the
+7 ;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
+8 ;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
+9 ;;division BEFORE this option is run.
+10 ;;
+11 ;;$END
+12 ;;