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

WVALERTR.m

Go to the documentation of this file.
WVALERTR ;HIOFO/FT - RETURN RADIOLOGY/NM REPORT IN TMP GLOBAL  ;04/01/2021
 ;;1.0;WOMEN'S HEALTH;**16,24,26**;Sep 30, 1998;Build 624
 ;AGP SMART CHANGES FOR PROTOTYPE
 ; This routine uses the following IAs:
 ;  #2479 - FILE 74 fields      (private)
 ;  #2480 - FILE 70 fields      (private)
 ;
EN(WVIEN,DIAGNS) ; Set up radiology report data
 N WVIENS,WVRPTIEN,WVSECDXS
 D RADCASE(WVIEN,.DIAGNS,.WVIENS,.WVRPTIEN,.WVSECDXS)
 D RADREP(WVIENS,WVRPTIEN,.WVSECDXS)
 S DIAGNS("P")=WVDIANGS
 Q
 ;
RADCASE(WVIEN,DIAGNS,WVIENS,WVRPTIEN,WVSECDXS) ;
 N LOOP,WVDUP,WVERR,WVJCN,WVJCN1,WVLCNT,WVRADCSE,WVRADDFN
 N WVRADDTE,WVRADIEN,WVDIANGS
 N CNT,INC,SECDX,TMP
 S WVRADIEN=$P(^WV(790.1,WVIEN,0),U,15)
 Q:WVRADIEN=""  ;no 'radiology mam case #'
 S WVRADDFN=$P(^WV(790.1,WVIEN,0),U,2)
 Q:'WVRADDFN  ;no dfn
 S WVRADDTE=$O(^RADPT("ADC",WVRADIEN,WVRADDFN,0))
 Q:'WVRADDTE  ;no inverse exam date
 S WVRADCSE=$O(^RADPT("ADC",WVRADIEN,WVRADDFN,WVRADDTE,0))
 Q:'WVRADCSE  ;no case number
 S WVRPTIEN=+$P(^RADPT(WVRADDFN,"DT",WVRADDTE,"P",WVRADCSE,0),U,17)
 Q:'WVRPTIEN  ;no report in File 74
 S CNT=0,INC=0 F  S CNT=$O(^RADPT(WVRADDFN,"DT",WVRADDTE,"P",WVRADCSE,"DX",CNT)) Q:CNT'>0  D
 .S TMP=+$G(^RADPT(WVRADDFN,"DT",WVRADDTE,"P",WVRADCSE,"DX",CNT,0)) I TMP'>0 Q
 .S SECDX=$$GET1^DIQ(78.3,TMP_",",.01) I SECDX="" Q
 .S WVSECDXS(SECDX)=""
 .S INC=INC+1,DIAGNS("S",INC)=SECDX
 S WVIENS=WVRADCSE_","_WVRADDTE_","_WVRADDFN_"," ;iens for FILE 70 entry
 Q
 ;
RADREP(WVIENS,WVRPTIEN,WVSECDXS) ;
 K ^TMP($J,"WV RPT"),^TMP($J,"WV CH")
 ; get clincal history from FILE 70
 I $G(WVIENS)="" D  Q
 .S ^TMP("WV RPT",$J,1,0)="The radiology report text is not available."
 .S ^TMP("WV RPT",$J,2,0)="Please review the imaging report on the reports tab or contact the radiology department."
 D GETS^DIQ(70.03,WVIENS,400,"EIZ","^TMP($J,""WV CH"")","WVERR")
 ; get data from FILE 74
 K WVERR
 D GETS^DIQ(74,WVRPTIEN_",","*","EI","^TMP($J,""WV RPT"")","WVERR")
 N CNT,FIRST,WVSECDX
 S CNT=0
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="                   DAY-CASE #: "_$G(^TMP($J,"WV RPT",74,WVRPTIEN_",",.01,"E"))_$S($$AMEND(WVRPTIEN):"                    (AMENDED REPORT)",1:"")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="               EXAM DATE/TIME: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",3,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="          VERIFYING PHYSICIAN: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",9,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="                    PROCEDURE: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",102,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="             CATEGORY OF EXAM: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",104,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="                         WARD: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",106,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)=" TREATING SERVICE (INPATIENT): "_^TMP($J,"WV RPT",74,WVRPTIEN_",",107,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="             PRINCIPAL CLINIC: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",108,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="      CONTRACT SHARING SOURCE: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",109,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="PRIMARY INTERPRETING RESIDENT: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",112,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="   PRIMARY INTERPRETING STAFF: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",115,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="            PRIMARY DIAGNOSIS: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",113,"E")
 S WVDIANGS=^TMP($J,"WV RPT",74,WVRPTIEN_",",113,"E")
 I $D(WVSECDXS) D
 .S FIRST=1,WVSECDX=""
 .F  S WVSECDX=$O(WVSECDXS(WVSECDX)) Q:WVSECDX=""  D
 ..I FIRST=1 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="          SECONDARY DIAGNOSIS: "_WVSECDX,FIRST=0 Q
 ..S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="                               "_WVSECDX
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="         REQUESTING PHYSICIAN: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",114,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="                 COMPLICATION: "_^TMP($J,"WV RPT",74,WVRPTIEN_",",116,"E")
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)=" "
 S CNT=CNT+1,^TMP("WV RPT",$J,CNT,0)="CLINICAL HISTORY:"
 S LOOP=0
 ;WVLCNT=CNT
 S WVDUP=$$COMPARE()
 I WVDUP=1 D  ;Clinical History text in files 70 & 74 are different
 .S LOOP=0
 .F  S LOOP=$O(^TMP($J,"WV CH",70.03,WVIENS,400,LOOP)) Q:'LOOP  D
 ..S CNT=CNT+1
 ..S ^TMP("WV RPT",$J,CNT,0)=^TMP($J,"WV CH",70.03,WVIENS,400,LOOP,0)
 ..Q
 .;I WVLCNT>16 D  ;insert blank line if different texts exist
 .S CNT=CNT+1
 .S ^TMP("WV RPT",$J,CNT,0)=" "
 .;.Q
 .S LOOP=0
 .F  S LOOP=$O(^TMP($J,"WV RPT",74,WVRPTIEN_",",400,LOOP)) Q:'LOOP  D
 ..S CNT=CNT+1
 ..S ^TMP("WV RPT",$J,CNT,0)=^TMP($J,"WV RPT",74,WVRPTIEN_",",400,LOOP)
 ..Q
 .Q
 I WVDUP=0 D  ;Clinical History field is same
 .S LOOP=0
 .F  S LOOP=$O(^TMP($J,"WV RPT",74,WVRPTIEN_",",400,LOOP)) Q:'LOOP  D
 ..S CNT=CNT+1
 ..S ^TMP("WV RPT",$J,CNT,0)=^TMP($J,"WV RPT",74,WVRPTIEN_",",400,LOOP)
 ..Q
 .Q
 S CNT=CNT+1
 S ^TMP("WV RPT",$J,CNT,0)=" "
 S CNT=CNT+1
 S ^TMP("WV RPT",$J,CNT,0)="IMPRESSION TEXT:"
 S LOOP=0
 F  S LOOP=$O(^TMP($J,"WV RPT",74,WVRPTIEN_",",300,LOOP)) Q:'LOOP  D
 .S CNT=CNT+1
 .S ^TMP("WV RPT",$J,CNT,0)=^TMP($J,"WV RPT",74,WVRPTIEN_",",300,LOOP)
 .Q
 S CNT=CNT+1
 S ^TMP("WV RPT",$J,CNT,0)=" "
 S CNT=CNT+1
 S ^TMP("WV RPT",$J,CNT,0)="REPORT TEXT:"
 S LOOP=0
 F  S LOOP=$O(^TMP($J,"WV RPT",74,WVRPTIEN_",",200,LOOP)) Q:'LOOP  D
 .S CNT=CNT+1
 .S ^TMP("WV RPT",$J,CNT,0)=^TMP($J,"WV RPT",74,WVRPTIEN_",",200,LOOP)
 .Q
 K ^TMP($J,"WV RPT"),^TMP($J,"WV CH")
 Q
AMEND(WVRPTIEN) ; Check if RAD/NM report is amended.
 ; WVRPTIEN - File 74 ien
 N WVAMEND
 K ^TMP("DILIST",$J),^TMP("DIERR",$J)
 D LIST^DIC(74.06,","_WVRPTIEN_",",.01)
 S WVAMEND=$O(^TMP("DILIST",$J,0))
 K ^TMP("DILIST",$J),^TMP("DIERR",$J)
 Q WVAMEND
 ;
COMPARE() ; Compares Clincal History fields in files 70 & 74
 ; Returns 1 (different) or 0 (same)
 N LOOP,WVFLAG,WV70CNT,WV70IEN,WV74CNT,WV74IEN,WVNODE70,WVNODE74
 S (LOOP,WV70CNT,WV74CNT,WVFLAG)=0
 S WV70IEN=WVIENS,WV74IEN=WVRPTIEN_","
 I '$O(^TMP($J,"WV CH",70.03,WV70IEN,400,0)) S WVFLAG=WVFLAG+1
 I '$O(^TMP($J,"WV RPT",74,WV74IEN,400,0)) S WVFLAG=WVFLAG+1
 I WVFLAG=1 Q 1  ;different (field was purged in one file, exists in
 ;                the other file)
 I WVFLAG=2 Q 0  ;same (field was purged in 70 & 74)
 F  S LOOP=$O(^TMP($J,"WV CH",70.03,WV70IEN,400,LOOP)) Q:'LOOP  D
 .S WV70CNT=WV70CNT+1
 .Q
 S LOOP=0
 F  S LOOP=$O(^TMP($J,"WV RPT",74,WV74IEN,400,LOOP)) Q:'LOOP  D
 .S WV74CNT=WV74CNT+1
 .Q
 I WV70CNT'=WV74CNT Q 1  ;line counts are different
 S LOOP=0
 F  S LOOP=$O(^TMP($J,"WV CH",70.03,WV70IEN,400,LOOP)) Q:'LOOP!(WVFLAG=1)  D
 .S WVNODE70=$G(^TMP($J,"WV CH",70.03,WV70IEN,400,LOOP,0))
 .S WVNODE74=$G(^TMP($J,"WV RPT",74,WV74IEN,400,LOOP))
 .I WVNODE70'=WVNODE74 S WVFLAG=1
 .Q
 Q WVFLAG
 ;