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,PKR - PCE's APIs ;07/13/2021
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**15,14,27,28,124,164,210,211,217**;Aug 12, 1996;Build 134
  1. Q
  1. ;
  1. GMPARAMS(FILENUM,IEN) ;Return the measurement parameters for the
  1. ;FILENUM and IEN.
  1. N MNODE
  1. S MNODE=$S(FILENUM=9999999.09:$G(^AUTTEDT(IEN,220)),FILENUM=9999999.15:$G(^AUTTEXAM(IEN,220)),FILENUM=9999999.64:$G(^AUTTHF(IEN,220)),1:"")
  1. Q MNODE
  1. ;
  1. PROVNARR(PXPNAR,PXFILE,PXCLEX) ;Add or lookup external Provider Narrative.
  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 an 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 ^ PXPNAR if was unsuccessful.
  1. ;
  1. I PXPNAR="" Q -1
  1. I PXPNAR="-1" Q -1
  1. ;Provider narrative must be at least 2 characters.
  1. I $L(PXPNAR)<2 Q -1_U_PXPNAR
  1. N MSG,RESULT,X,Y
  1. S X=$E(PXPNAR,1,245)
  1. ;It is possible there may already be an invalid entry in the Provider
  1. ;Narrative file, if the user happens to select it, the lookup on the
  1. ;"B" index will return it so validate the input passes the input
  1. ;transform before the lookup.
  1. D VAL^DIE(9999999.27,"+1",.01,"EU",X,.RESULT,"","MSG")
  1. I RESULT="^" Q -1_U_X
  1. S Y=+$O(^AUTNPOV("B",X,""))
  1. I Y>0 Q Y_U_X
  1. ;
  1. ;Add a new entry.
  1. N FDA,FDAIEN
  1. S FDA(9999999.27,"+1,",.01)=X
  1. ;Make sure PXFILE is a valid file number.
  1. I $G(PXFILE)'="" D
  1. . N DATA
  1. . D FILE^DID(PXFILE,"","NAME","DATA","MSG")
  1. . I $G(DATA("NAME"))'="" S FDA(9999999.27,"+1,",75702)=PXFILE
  1. . K MSG
  1. D UPDATE^DIE("E","FDA","FDAIEN","MSG")
  1. I $D(MSG) Q -1_U_X
  1. ;If a pointer to file #757.01 was passed validate it.
  1. ;ICR #457
  1. I ($G(PXCLEX)'=""),($D(^LEX(757.01,PXCLEX,0))>0) D
  1. . K FDA,MSG
  1. . S FDA(9999999.27,FDAIEN(1)_",",75701)=PXCLEX
  1. . D FILE^DIE("","FDA","MSG")
  1. Q FDAIEN(1)_U_X_U_1
  1. ;
  1. STOPCODE(PXASTOP,PXAPAT,PXADATE) ;This is the function call to return the
  1. ;quantity of a particular Stop Code for a patient on one day. ICR #1898
  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
  1. ;quantity of a particular CPT for a patient on one day and for
  1. ;one hospital location if passed. ICR #1898
  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 quantity) of that CPT code are stored for
  1. ; 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
  1. ;prompt the user for Visit and related V-file data used to document
  1. ;an encounter. See INTV^PXBAPI for parameters and return values.
  1. ; ICR #1891
  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,ERROR,PROBARR) ;Deletes the requested data
  1. ;related to the visit. See DELVFILE^PXAPIDEL for parameters and return
  1. ;values. ICR #1890
  1. ;
  1. Q $$DELVFILE^PXAPIDEL(WHICH,VISIT,$G(PACKAGE),$G(SOURCE),$G(ASK),$G(ECHO),$G(USER),.ERROR,.PROBARR)
  1. ;
  1. DATA2PCE(DATA,PACKAGE,SOURCE,VISIT,USER,DISPLAY,ERROR,SCREEN,ARRAY,ACCOUNT) ;
  1. ;PI to pass data for add/edit/delete to PCE
  1. ;See DATA2PCE^PXAI for parameters and return values. ICR #1889
  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),.ERROR,$G(SCREEN),.ARRAY,.ACCOUNT) ;PX*1.0*164 CHANGED $G(ERROR) TO .ERROR
  1. ;
  1. SOURCE(SOURCE) ;Get IEN of data source in the PCE Data Source file
  1. ;ICR #1896
  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. ICR #1893
  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. ICR #1892
  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. ICR #1892
  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. ICR #1894
  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^PXKENCOUNTER for parameters and return values. ICR #1894
  1. ;
  1. D ENCEVENT^PXKENCOUNTER($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. ICR #1895
  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. ICR #1895
  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). ICR #1897
  1. Q $P($G(^PX(815,1,0)),"^",2)
  1. ;
  1. SWITCHCK(DATE) ;Returns 1 if after the switch over date 0 otherwise. ICR #1897
  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. ICR #2349
  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. ICR #2349
  1. Q $$PRVCLASS^PXAPIUTL($G(PROVIDER),$G(VISITDT))
  1. ;
  1. VIS(PXRESULT,PXVIS,PXDATE) ;Return Vaccine Information Statement entry
  1. ;See VIS^PXAPIIM for parameters and return values.
  1. ;
  1. I '$G(PXVIS) Q
  1. S PXDATE=$G(PXDATE,$$NOW^XLFDT())
  1. D VIS^PXAPIIM(.PXRESULT,PXVIS,PXDATE)
  1. Q