- PXUTL1 ;ISL/dee - Utility routines used by PCE ;4/3/97
- ;;1.0;PCE PATIENT CARE ENCOUNTER;**25**;Aug 12, 1996
- ;; ;
- Q
- ;
- EXTTEXT(IEN,REQUIRED,FILE,FIELD1,FIELD2) ;Returns the external form.
- ;Parameters:
- ; IEN the ien in the file that the text is wanted for.
- ; REQUIRED if this is not zero and no text is found
- ; then "UNKNOWN" is returned.
- ; FILE the file number
- ; FIELD1 the field number that the text is in
- ; FIELD2 if the parameter is passed and there is no text
- ; in field1 then the text in this field will be
- ; returned if there is some.
- ;
- N DIC,DR,DA,DIQ,PXUTDIQ1,PXTEXT,Y,X
- I $G(FILE)>0,$G(FIELD1)>0 D
- . S DIC=FILE
- . S DR=FIELD1
- . S:$G(FIELD2)>0 DR=DR_";"_FIELD2
- . S DA=IEN
- . S DIQ="PXUTDIQ1("
- . S DIQ(0)="E"
- . D EN^DIQ1
- . I PXUTDIQ1(FILE,DA,FIELD1,"E")]"" S PXTEXT=PXUTDIQ1(FILE,DA,FIELD1,"E")
- . E I $G(FIELD2)>0,PXUTDIQ1(FILE,DA,FIELD2,"E")]"" S PXTEXT=PXUTDIQ1(FILE,DA,FIELD2,"E")
- . E I REQUIRED S PXTEXT="UNKNOWN"
- E I REQUIRED S PXTEXT="UNKNOWN"
- Q PXTEXT
- ;
- PRIMVPRV(PXUTVST) ;Returns the primary provider if there is one
- ; for the passed visit otherwise returns 0.
- N PXCATEMP
- S PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPRV",0,4)
- Q $S(PXCATEMP>0:$P(^AUPNVPRV(PXCATEMP,0),"^"),1:0)
- ;
- PRIMVPOV(PXUTVST) ;Returns the primary diagnosis if there is one
- ; for the passed visit otherwise returns 0.
- N PXCATEMP
- S PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPOV",0,12)
- Q $S(PXCATEMP>0:$P(^AUPNVPOV(PXCATEMP,0),"^"),1:0)
- ;
- PRIMSEC(PXUTVST,PXUTAUPN,PXUTNODE,PXUPIECE) ;Returns ien of the primary one
- ; if there is one for the passed visit otherwise returns 0.
- ; Parameters:
- ; PXUTVST Pointer to the visit
- ; PXUTAUPN V-File global e.g. "^AUPNVPRV"
- ; PXUTNODE The node that the Primary/Secondary field is on
- ; PXUPIECE The piece of the Primary/Secondary field
- ;
- N PXUTPRIM
- S PXUTPRIM=0
- F S PXUTPRIM=$O(@(PXUTAUPN_"(""AD"",PXUTVST,PXUTPRIM)")) Q:PXUTPRIM'>0 I "P"=$P(@(PXUTAUPN_"(PXUTPRIM,PXUTNODE)"),"^",PXUPIECE) Q
- Q +PXUTPRIM
- ;
- DISPOSIT(PXUTLDFN,PXUTLDT,PXUTVIEN) ;Checks to see if a visit is a dispoition
- I PXUTVIEN=+$P($G(^SCE(+$P($G(^DPT(+PXUTLDFN,"DIS",9999999-PXUTLDT,0)),"^",18),0)),"^",5) Q +$P($G(^DPT(+PXUTLDFN,"DIS",9999999-PXUTLDT,0)),"^",18)
- Q 0
- ;
- APPOINT(PXUTLDFN,PXUTLDT,HLOC) ;Returns 1 if the patient has and appointment
- ;at PXUTLDT for clinic HLOC.
- Q HLOC=+$G(^DPT(+PXUTLDFN,"S",+PXUTLDT,0))
- ;
- VST2APPT(VISIT) ;Is this visit related to an appointment
- ;Returns
- ; 1 if the visit is being pointed to by an appointment
- ; 0 if the visit is NOT being pointed to by an appointment
- ;-1 if the visit is invalued
- ;
- N VISIT0
- S VISIT0=$G(^AUPNVSIT($G(VISIT),0))
- Q:VISIT0="" -1
- Q $$VSTAPPT($P(VISIT0,"^",5),$P(VISIT0,"^",1),$P(VISIT0,"^",22),VISIT)
- ;
- VSTAPPT(PXUTLPAT,PXUTLDT,PXUTLLOC,PXUTLVST) ;Returns 1 if the visit is being pointed to by an
- ; appointment otherwise 0.
- I PXUTLLOC]"",PXUTLLOC=+$G(^DPT(+PXUTLPAT,"S",+PXUTLDT,0)),PXUTLVST=+$P($G(^SCE(+$P($G(^DPT(PXUTLPAT,"S",PXUTLDT,0)),"^",20),0)),"^",5) Q 1
- Q 0
- ;
- APPT2VST(PXUTLPAT,PXUTLDT,HLOC) ;Returns ien of visit that the related
- ;appointment points to at PXUTLDT for clinic HLOC otherwise 0.
- I HLOC=+$G(^DPT(+PXUTLPAT,"S",+PXUTLDT,0)) Q +$P($G(^SCE(+$P($G(^DPT(PXUTLPAT,"S",PXUTLDT,0)),"^",20),0)),"^",5)
- Q 0
- ;
- PXUTL1 ;ISL/dee - Utility routines used by PCE ;4/3/97
- +1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**25**;Aug 12, 1996
- +2 ;; ;
- +3 QUIT
- +4 ;
- EXTTEXT(IEN,REQUIRED,FILE,FIELD1,FIELD2) ;Returns the external form.
- +1 ;Parameters:
- +2 ; IEN the ien in the file that the text is wanted for.
- +3 ; REQUIRED if this is not zero and no text is found
- +4 ; then "UNKNOWN" is returned.
- +5 ; FILE the file number
- +6 ; FIELD1 the field number that the text is in
- +7 ; FIELD2 if the parameter is passed and there is no text
- +8 ; in field1 then the text in this field will be
- +9 ; returned if there is some.
- +10 ;
- +11 NEW DIC,DR,DA,DIQ,PXUTDIQ1,PXTEXT,Y,X
- +12 IF $GET(FILE)>0
- IF $GET(FIELD1)>0
- Begin DoDot:1
- +13 SET DIC=FILE
- +14 SET DR=FIELD1
- +15 IF $GET(FIELD2)>0
- SET DR=DR_";"_FIELD2
- +16 SET DA=IEN
- +17 SET DIQ="PXUTDIQ1("
- +18 SET DIQ(0)="E"
- +19 DO EN^DIQ1
- +20 IF PXUTDIQ1(FILE,DA,FIELD1,"E")]""
- SET PXTEXT=PXUTDIQ1(FILE,DA,FIELD1,"E")
- +21 IF '$TEST
- IF $GET(FIELD2)>0
- IF PXUTDIQ1(FILE,DA,FIELD2,"E")]""
- SET PXTEXT=PXUTDIQ1(FILE,DA,FIELD2,"E")
- +22 IF '$TEST
- IF REQUIRED
- SET PXTEXT="UNKNOWN"
- End DoDot:1
- +23 IF '$TEST
- IF REQUIRED
- SET PXTEXT="UNKNOWN"
- +24 QUIT PXTEXT
- +25 ;
- PRIMVPRV(PXUTVST) ;Returns the primary provider if there is one
- +1 ; for the passed visit otherwise returns 0.
- +2 NEW PXCATEMP
- +3 SET PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPRV",0,4)
- +4 QUIT $SELECT(PXCATEMP>0:$PIECE(^AUPNVPRV(PXCATEMP,0),"^"),1:0)
- +5 ;
- PRIMVPOV(PXUTVST) ;Returns the primary diagnosis if there is one
- +1 ; for the passed visit otherwise returns 0.
- +2 NEW PXCATEMP
- +3 SET PXCATEMP=$$PRIMSEC(PXUTVST,"^AUPNVPOV",0,12)
- +4 QUIT $SELECT(PXCATEMP>0:$PIECE(^AUPNVPOV(PXCATEMP,0),"^"),1:0)
- +5 ;
- PRIMSEC(PXUTVST,PXUTAUPN,PXUTNODE,PXUPIECE) ;Returns ien of the primary one
- +1 ; if there is one for the passed visit otherwise returns 0.
- +2 ; Parameters:
- +3 ; PXUTVST Pointer to the visit
- +4 ; PXUTAUPN V-File global e.g. "^AUPNVPRV"
- +5 ; PXUTNODE The node that the Primary/Secondary field is on
- +6 ; PXUPIECE The piece of the Primary/Secondary field
- +7 ;
- +8 NEW PXUTPRIM
- +9 SET PXUTPRIM=0
- +10 FOR
- SET PXUTPRIM=$ORDER(@(PXUTAUPN_"(""AD"",PXUTVST,PXUTPRIM)"))
- IF PXUTPRIM'>0
- QUIT
- IF "P"=$PIECE(@(PXUTAUPN_"(PXUTPRIM,PXUTNODE)"),"^",PXUPIECE)
- QUIT
- +11 QUIT +PXUTPRIM
- +12 ;
- DISPOSIT(PXUTLDFN,PXUTLDT,PXUTVIEN) ;Checks to see if a visit is a dispoition
- +1 IF PXUTVIEN=+$PIECE($GET(^SCE(+$PIECE($GET(^DPT(+PXUTLDFN,"DIS",9999999-PXUTLDT,0)),"^",18),0)),"^",5)
- QUIT +$PIECE($GET(^DPT(+PXUTLDFN,"DIS",9999999-PXUTLDT,0)),"^",18)
- +2 QUIT 0
- +3 ;
- APPOINT(PXUTLDFN,PXUTLDT,HLOC) ;Returns 1 if the patient has and appointment
- +1 ;at PXUTLDT for clinic HLOC.
- +2 QUIT HLOC=+$GET(^DPT(+PXUTLDFN,"S",+PXUTLDT,0))
- +3 ;
- VST2APPT(VISIT) ;Is this visit related to an appointment
- +1 ;Returns
- +2 ; 1 if the visit is being pointed to by an appointment
- +3 ; 0 if the visit is NOT being pointed to by an appointment
- +4 ;-1 if the visit is invalued
- +5 ;
- +6 NEW VISIT0
- +7 SET VISIT0=$GET(^AUPNVSIT($GET(VISIT),0))
- +8 IF VISIT0=""
- QUIT -1
- +9 QUIT $$VSTAPPT($PIECE(VISIT0,"^",5),$PIECE(VISIT0,"^",1),$PIECE(VISIT0,"^",22),VISIT)
- +10 ;
- VSTAPPT(PXUTLPAT,PXUTLDT,PXUTLLOC,PXUTLVST) ;Returns 1 if the visit is being pointed to by an
- +1 ; appointment otherwise 0.
- +2 IF PXUTLLOC]""
- IF PXUTLLOC=+$GET(^DPT(+PXUTLPAT,"S",+PXUTLDT,0))
- IF PXUTLVST=+$PIECE($GET(^SCE(+$PIECE($GET(^DPT(PXUTLPAT,"S",PXUTLDT,0)),"^",20),0)),"^",5)
- QUIT 1
- +3 QUIT 0
- +4 ;
- APPT2VST(PXUTLPAT,PXUTLDT,HLOC) ;Returns ien of visit that the related
- +1 ;appointment points to at PXUTLDT for clinic HLOC otherwise 0.
- +2 IF HLOC=+$GET(^DPT(+PXUTLPAT,"S",+PXUTLDT,0))
- QUIT +$PIECE($GET(^SCE(+$PIECE($GET(^DPT(PXUTLPAT,"S",PXUTLDT,0)),"^",20),0)),"^",5)
- +3 QUIT 0
- +4 ;