[796] | 1 | TMGTIU01 ;TMG/kst-Misc TIU Related Fns;11/08/08
|
---|
| 2 | ;;1.0;TMG-LIB;**1**;11/08/08
|
---|
| 3 | ;
|
---|
| 4 | ;"Kevin Toppenberg MD
|
---|
| 5 | ;"GNU General Public License (GPL) applies
|
---|
| 6 | ;"11/08/08
|
---|
| 7 |
|
---|
| 8 | ;"---------------------------------------------------------------------------
|
---|
| 9 | ;"PUBLIC FUNCTIONS
|
---|
| 10 | ;"---------------------------------------------------------------------------
|
---|
| 11 | ;"ENSURVST(PATIENT,VISIT,CLINIC,DOCTOR) -- Ensure that patient has an entry in the VISIT file.
|
---|
| 12 | ;"GetPCEInfo(.array,DFN,DT,LocIEN) -- Get Patient Care Event info for patient on given date.
|
---|
| 13 |
|
---|
| 14 | ;"---------------------------------------------------------------------------
|
---|
| 15 | ;"PRIVATE FUNCTIONS
|
---|
| 16 | ;"---------------------------------------------------------------------------
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | ;"---------------------------------------------------------------------------
|
---|
| 21 |
|
---|
| 22 | T1
|
---|
| 23 | new DFN,IEN,Y,X,DIC
|
---|
| 24 | set DIC=2,DIC(0)="MAEQ"
|
---|
| 25 | do ^DIC write !
|
---|
| 26 | if +Y'>0 goto TDone
|
---|
| 27 | set DFN=+Y
|
---|
| 28 |
|
---|
| 29 | new locIEN
|
---|
| 30 | set DIC=44 ;"hospital location
|
---|
| 31 | do ^DIC write !
|
---|
| 32 | if +Y'>0 goto TDone
|
---|
| 33 | set locIEN=+Y
|
---|
| 34 |
|
---|
| 35 | new %DT,selDT
|
---|
| 36 | set %DT="AE"
|
---|
| 37 | do ^%DT write !
|
---|
| 38 | if Y'>0 goto TDone
|
---|
| 39 | set setDT=Y
|
---|
| 40 |
|
---|
| 41 | new array
|
---|
| 42 | do GetPCEInfo(.array,DFN,setDT,locIEN)
|
---|
| 43 | if $data(array) zwr array
|
---|
| 44 |
|
---|
| 45 | TDone
|
---|
| 46 | quit
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | ENSURVST(PATIENT,VISIT,CLINIC,DOCTOR) ;
|
---|
| 50 | ;"Purpose: To ensure that patient has an entry in the VISIT file.
|
---|
| 51 | ;"Input: PATIENT: the name and DOB of the patient. format:
|
---|
| 52 | ;" 'LName,FName I^12/12/1912'
|
---|
| 53 | ;" VISIT: Date and time of visit. Format: 12/12/1912@23:15 (military time)
|
---|
| 54 | ;" CLINIC: the name of the clinic, to match entry in HOSPITAL LOCATION file
|
---|
| 55 | ;" DOCTOR: the name of the provider for the appt, to match entry in NEW PERSON file
|
---|
| 56 | ;"Results: 1=OK, or 0^Error Message
|
---|
| 57 |
|
---|
| 58 | new result set result=1
|
---|
| 59 | new IEN2,Entry
|
---|
| 60 | set Entry(.01)=$piece(PATIENT,"^",1) ;"Name
|
---|
| 61 | set Entry(.03)=$piece(PATIENT,"^",2) ;"DOB
|
---|
| 62 |
|
---|
| 63 | set IEN2=$$GetDFN2^TMGGDFN(Entry,AutoRegister)
|
---|
| 64 | if IEN2'>0 do goto EVDone
|
---|
| 65 | . set result="0^Patient Name/DOB not registered"
|
---|
| 66 |
|
---|
| 67 | new HLIEN,DIC,X,Y
|
---|
| 68 | set DIC=44 ;"HOSPITAL LOCATION file
|
---|
| 69 | set DIC(0)="M",X=CLINIC
|
---|
| 70 | do ^DIC
|
---|
| 71 | if Y'>0 do goto EVDone
|
---|
| 72 | . set result="0^Can't find clinic '"_CLINIC_"' in HOSPITAL LOCATION file"
|
---|
| 73 |
|
---|
| 74 | set DIC=200,X=DOCTOR
|
---|
| 75 | do ^DIC
|
---|
| 76 | if Y'>0 do goto EVDone
|
---|
| 77 | . set result="0^Can't find doctor '"_DOCTOR+"' in NEW PERSON file"
|
---|
| 78 |
|
---|
| 79 | new VDT,%DT kill Y
|
---|
| 80 | set %DT="T",X=VISIT
|
---|
| 81 | do ^%DT
|
---|
| 82 | if Y'>0 do goto EVDone
|
---|
| 83 | . set result="0^Invalid visit date: '"_VISIT_"'"
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 | EVDone
|
---|
| 88 | quit result
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | GetPCEInfo(array,DFN,DT,LocIEN)
|
---|
| 92 | ;"Purpose: to get Patient Care Event info for patient on given date.
|
---|
| 93 | ;"Input: array -- PASS BY REFERENCE, an OUT PARAMETER. Prior data killed.
|
---|
| 94 | ;" DFN -- the patient IEN
|
---|
| 95 | ;" DT -- the Date of the visit in FM format.
|
---|
| 96 | ;" LocIEN -- the IEN in the HOSPITAL LOCATION file for the clinic.
|
---|
| 97 | ;"Output: array is filled, format:
|
---|
| 98 | ;" array(VISITDT,#)=InfoLine
|
---|
| 99 | ;" array(VISITDT,#)=InfoLine
|
---|
| 100 | ;" ...,1)=HDR^AllowEdit^CPTRequired^VStr^Author^hasCPT
|
---|
| 101 | ;" ...,n)=TYP+^CODE^CAT^NARR^QUAL1^QUAL2 (QUAL1=Primary!Qty, QUAL2=Prv)
|
---|
| 102 | ;"Results: None
|
---|
| 103 |
|
---|
| 104 | kill array
|
---|
| 105 | new vIEN set vIEN=0
|
---|
| 106 | for set vIEN=$order(^AUPNVSIT("C",DFN,vIEN)) quit:(+vIEN'>0) do
|
---|
| 107 | . new vDT set vDT=$piece($get(^AUPNVSIT(vIEN,0)),"^",1)
|
---|
| 108 | . if vDT'>0 quit
|
---|
| 109 | . new %Y,X,X1,X2 set X1=setDT,X2=vDT
|
---|
| 110 | . do ^%DTC
|
---|
| 111 | . if (X'=0)!(%Y=0) quit
|
---|
| 112 | . new tempArray
|
---|
| 113 | . do PCE4NOTE^ORWPCE3(.tempArray,,DFN,LocIEN_";"_vDT)
|
---|
| 114 | . merge array(vDT)=tempArray
|
---|
| 115 | quit
|
---|
| 116 |
|
---|