Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGRUGDS

DGRUGDS.m

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