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

PXAPI.m

Go to the documentation of this file.
  1. PXAPI ;ISL/dee - PCE's APIs ;4/16/97
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**14,15,27,28**;Aug 12, 1996
  1. Q
  1. ;
  1. PROVNARR(PXPNAR,PXFILE,PXCLEX) ;Convert external Provider Narrative to internal.
  1. ;Input:
  1. ; PXPNAR Is the text of the provider narrative.
  1. ; PXFILE Is the file that the returned pointer will be stored in.
  1. ; If a new entry is created then this tells the context
  1. ; that it was created under by the file using it.
  1. ; PXCLEX Is and optional pointer to the Lexicon for this narrative.
  1. ;
  1. ;Returns:
  1. ; Pointer to the provider narrative file ^ narrative
  1. ; or pointer to the provider narrative file ^ narrative ^1
  1. ; where 1 indicates that the entry has just been added
  1. ; or -1 if was unsuccessful.
  1. ;
  1. N DIC,Y,DLAYGO,DD,DO,DA
  1. S DIC="^AUTNPOV(",DIC(0)="L",DLAYGO=9999999.27
  1. S (DA,Y)=0
  1. S X=$E(PXPNAR,1,245)
  1. Q:X="" -1
  1. L +^AUTNPOV(0):60
  1. E W !,"The Provider Narrative is LOCKED try again." Q -1
  1. F S DA=$O(^AUTNPOV("B",$E(X,1,30),DA)) Q:DA'>0 I $P(^AUTNPOV(DA,0),"^")=X S Y=DA_"^"_X Q
  1. I '(+Y) D
  1. . K DA,Y
  1. . D FILE^DICN
  1. . I +Y>0,($G(PXCLEX)!$G(PXFILE)) S ^AUTNPOV(+Y,757)=$G(PXCLEX)_"^"_$G(PXFILE)
  1. L -^AUTNPOV(0)
  1. Q $S(+Y>0:Y,1:-1)
  1. ;
  1. STOPCODE(PXASTOP,PXAPAT,PXADATE) ;This is the function call to return the quantity
  1. ; of a particular Stop Code for a patient on one day.
  1. ;Input
  1. ; PXASTOP (required) pointer to #40.7
  1. ; PXAPAT (required) pointer to #2
  1. ; PXADATE (required) the date in Fileman format
  1. ; (time is ignored if passed)
  1. ;Returns
  1. ; the count of how many of that stop code are stored for that one day
  1. ;
  1. N PXAVST,PXREVDAT,PXENDDAT,PXACOUNT
  1. S PXASTOP=$G(PXASTOP)
  1. S PXAPAT=+$G(PXAPAT)
  1. S PXADATE=+$G(PXADATE)
  1. S (PXACOUNT,PXAVST)=0
  1. S PXREVDAT=9999999-$P(PXADATE,".")-.00000001
  1. S PXENDDAT=PXREVDAT+.9
  1. F S PXREVDAT=$O(^AUPNVSIT("AA",PXAPAT,PXREVDAT)) Q:'PXREVDAT!(PXREVDAT>PXENDDAT) D
  1. . F S PXAVST=$O(^AUPNVSIT("AA",PXAPAT,PXREVDAT,PXAVST)) Q:'PXAVST D
  1. .. I PXASTOP=$P(^AUPNVSIT(PXAVST,0),"^",8),"E"'=$P(^AUPNVSIT(PXAVST,0),"^",7) S PXACOUNT=PXACOUNT+1
  1. Q PXACOUNT
  1. ;
  1. CPT(PXACPT,PXAPAT,PXADATE,PXAHLOC) ;This is the function call to return the quantity
  1. ; of a particular CPT for a patient on one day and for
  1. ; one hospital location if passed.
  1. ;Input
  1. ; PXACPT (required) pointer to #81
  1. ; PXAPAT (required) pointer to #2
  1. ; PXADATE (required) the date in Fileman format
  1. ; (time is ignored if passed)
  1. ; PXAHLOC (optional) pointer to #44
  1. ;Returns
  1. ; the count of how many (and quinity) of that cpt code are stored for that one day
  1. ;
  1. ;
  1. N PXAVST,PXAVCPT,PXREVDAT,PXENDDAT,PXACOUNT
  1. S PXACPT=$G(PXACPT)
  1. S PXAPAT=+$G(PXAPAT)
  1. S PXADATE=+$G(PXADATE)
  1. S PXAHLOC=+$G(PXAHLOC)
  1. S (PXACOUNT,PXAVST)=0
  1. S PXREVDAT=9999999-$P(PXADATE,".")-.00000001
  1. S PXENDDAT=PXREVDAT+.9
  1. F S PXREVDAT=$O(^AUPNVSIT("AA",PXAPAT,PXREVDAT)) Q:'PXREVDAT!(PXREVDAT>PXENDDAT) D
  1. . F S PXAVST=$O(^AUPNVSIT("AA",PXAPAT,PXREVDAT,PXAVST)) Q:'PXAVST D
  1. .. Q:"E"=$P(^AUPNVSIT(PXAVST,0),"^",7)
  1. .. Q:"1"=$P(^AUPNVSIT(PXAVST,150),"^",2)
  1. .. I PXAHLOC>0,PXAHLOC'=$P(^AUPNVSIT(PXAVST,0),"^",22) Q
  1. .. S PXAVCPT=0
  1. .. F S PXAVCPT=$O(^AUPNVCPT("AD",PXAVST,PXAVCPT)) Q:'PXAVCPT D
  1. ... I PXACPT=$P(^AUPNVCPT(PXAVCPT,0),"^",1) S PXACOUNT=PXACOUNT+$P(^(0),"^",16)
  1. Q PXACOUNT
  1. ;
  1. INTV(WHAT,PACKAGE,SOURCE,VISIT,HL,DFN,APPT,LIMITDT,ALLHLOC) ;This api will prompt the user for Visit and related V-file data used to document an encounter.
  1. ;See INTV^PXBAPI for parameters and return values.
  1. ;
  1. I '($D(VISIT)#2) S VISIT=""
  1. I '($D(DFN)#2) S DFN=""
  1. I '($D(HL)#2) S HL=""
  1. ;
  1. Q $$INTV^PXBAPI(WHAT,PACKAGE,SOURCE,.VISIT,.HL,.DFN,$G(APPT),$G(LIMITDT),$G(ALLHLOC))
  1. ;
  1. DELVFILE(WHICH,VISIT,PACKAGE,SOURCE,ASK,ECHO,USER) ;Deletes the requesed data related to the visit.
  1. ;See DELVFILE^PXAPIDEL for parameters and return values.
  1. ;
  1. Q $$DELVFILE^PXAPIDEL(WHICH,VISIT,$G(PACKAGE),$G(SOURCE),$G(ASK),$G(ECHO),$G(USER))
  1. ;
  1. DATA2PCE(DATA,PACKAGE,SOURCE,VISIT,USER,DISPLAY,ERROR,SCREEN,ARRAY) ;API to pass data for add/edit/delete to PCE
  1. ;See DATA2PCE^PXAI for parameters and return values.
  1. ;
  1. I '($D(DATA)#2) Q -3
  1. I '($D(PACKAGE)#2) Q -3
  1. I '($D(SOURCE)#2) Q -3
  1. I '($D(VISIT)#2) S VISIT=""
  1. Q $$DATA2PCE^PXAI(DATA,PACKAGE,SOURCE,.VISIT,$G(USER),$G(DISPLAY),$G(ERROR),$G(SCREEN),.ARRAY)
  1. ;
  1. SOURCE(SOURCE) ;Get IEN of data source in the PCE Data Source file
  1. Q $$SOURCE^PXAPIUTL($G(SOURCE))
  1. ;
  1. VISITLST(DFN,BEGINDT,ENDDT,HLOC,SCREEN,APPOINT,PROMPT,COSTATUS) ;--GATHER VISITS
  1. ;See VISITLST^PXBGVST for parameters and return values.
  1. ;
  1. I '($D(DFN)#2) Q "-2^NO PATIENT SELECTED"
  1. Q $$VISITLST^PXBGVST(DFN,$G(BEGINDT),$G(ENDDT),$G(HLOC),$G(SCREEN),$G(APPOINT),$G(PROMPT),$G(COSTATUS))
  1. ;
  1. ENCEDIT(WHAT,PACKAGE,SOURCE,DFN,BEGINDT,ENDDT,HLOC,SCREEN,APPOINT,PROMPT,COSTATUS) ;--Ask for encounter the edit it of delete it
  1. ;See ENCEDIT^PXAPIEED for parameters and return values.
  1. ;
  1. Q $$ENCEDIT^PXAPIEED($G(WHAT),$G(PACKAGE),$G(SOURCE),$G(DFN),$G(BEGINDT),$G(ENDDT),$G(HLOC),$G(SCREEN),$G(APPOINT),$G(PROMPT),$G(COSTATUS))
  1. ;
  1. LOPENCED(WHAT,PACKAGE,SOURCE,DFN,BEGINDT,ENDDT,HLOC,SCREEN,APPOINT,PROMPT,COSTATUS) ;--Ask for encounter the edit it of delete it
  1. ;See LOPENCED^PXAPIEED for parameters and return values.
  1. ;
  1. Q $$LOPENCED^PXAPIEED($G(WHAT),$G(PACKAGE),$G(SOURCE),$G(DFN),$G(BEGINDT),$G(ENDDT),$G(HLOC),$G(SCREEN),$G(APPOINT),$G(PROMPT),$G(COSTATUS))
  1. ;
  1. GETENC(DFN,ENCDT,HLOC) ;--Get all of the encounter data
  1. ;See GETENC^PXKENC for parameters and return values.
  1. ;
  1. Q $$GETENC^PXKENC($G(DFN),$G(ENCDT),$G(HLOC))
  1. ;
  1. ENCEVENT(VISIT,DONTKILL) ;--Get all of the encounter data
  1. ;See ENCEVENT^PXKENC for parameters and return values.
  1. ;
  1. D ENCEVENT^PXKENC($G(VISIT),$G(DONTKILL))
  1. Q
  1. ;
  1. VST2APPT(VISIT) ;Is this visit related to an appointment
  1. ;See VST2APPT^PXUTL1 for parameters and return values.
  1. ;
  1. Q $$VST2APPT^PXUTL1($G(VISIT))
  1. ;
  1. APPT2VST(DFN,ENCDT,HLOC) ;Get the visit for an Appointment
  1. ;See APPT2VST^PXUTL1 for parameters and return values.
  1. ;
  1. Q $$APPT2VST^PXUTL1($G(DFN),$G(ENCDT),$G(HLOC))
  1. ;
  1. SWITCHD() ;This returns the date that PCE starts collecting the data
  1. ; instead Scheduling (switch over date).
  1. Q $P($G(^PX(815,1,0)),"^",2)
  1. ;
  1. SWITCHCK(DATE) ;Returns 1 if after the switch over date 0 otherwise.
  1. N SWITCH
  1. S SWITCH=$P($G(^PX(815,1,0)),"^",2)
  1. Q:SWITCH<2960000 0
  1. Q SWITCH'>DATE
  1. ;
  1. DISPVSIT ;Called by Scheduling to create a visit for a disposition
  1. ;Add to fix scheduling calling visit tracking wrong without the
  1. ; dispositioning clinic. Hospital Location is required by Visit
  1. ; Tracking to work correctly.
  1. I $G(VSIT("LOC"))>0,'$D(^PX(815,1,"DHL","B",VSIT("LOC"))) S VSIT("LOC")=""
  1. I $G(VSIT("LOC"))'>0,'$D(ZTQUEUED) D
  1. . I $P(^PX(815,1,"DHL",0),"^",4)=1 S VSIT("LOC")=$O(^PX(815,1,"DHL","B",0))
  1. . E D
  1. .. ;ask for Hospital location from those that can disposition
  1. .. N DIC,DA,X,Y
  1. DISPASK .. S DA(1)=1
  1. .. S DIC="^PX(815,1,""DHL"","
  1. .. S DIC("P")=$P(^DD(815,401,0),"^",2)
  1. .. S DIC(0)="AEOQ"
  1. .. D ^DIC
  1. .. I Y>0 S VSIT("LOC")=$P(Y,"^",2)
  1. .. ;E I '$D(DTOUT),'$D(DUOUT) W !!,$C(7),"Disposition Hospital Location is required." G DISPASK
  1. .. E W !!,$C(7),"Disposition Hospital Location is required." G DISPASK
  1. I $G(VSIT("LOC"))'>0 S VSIT("IEN")=-1
  1. E D ^VSIT
  1. Q
  1. ;
  1. ACTIVPRV(PROVIDER,VISITDT) ;See if this is a good provider on the date of
  1. ;VISITDT and returns 1 if it is 0 if it is not.
  1. ;Can be used like S DIC("S")="I $$ACTIVPRV^PXAPIUTL(PRV,DATE)"
  1. Q:+$$PRVCLASS^PXAPIUTL($G(PROVIDER),$G(VISITDT))>0 1
  1. Q 0
  1. ;
  1. PRVCLASS(PROVIDER,VISITDT) ;See if this is a good provider
  1. ;See PRVCLASS^PXAPIUTL for parameters and return values.
  1. Q $$PRVCLASS^PXAPIUTL($G(PROVIDER),$G(VISITDT))
  1. ;