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

LR469A.m

Go to the documentation of this file.
LR469A ;DSS/TFF - LAB ANATOMIC PATHOLOGY INSTALLATION SUPPORT;03/04/16 12:21 ;08/12/16  11:25
 ;;5.2;LAB SERVICE;**469**;Feb 14, 1996;Build 19
 ;
 ;
 ;
 ;
ENV ; Environment Check
 D ENVT W ! D ENVS
 I '$$FIND1^DIC(62,,"X","AP SPECIMEN") S XPDQUIT=1 D
 . W !!,"        *********************** AP SPECIMEN ***********************"
 . W !,"        *  COLLECTION SAMPLE (File 62) 'AP SPECIMEN' is missing!  *"
 . W !,"        *********************** AP SPECIMEN ***********************"
 Q
 ;
ENVT ; Environment Check Orderable Items
 N I,STR,NAM,IEN,SUCCS
 F I=1:1 S STR=$P($T(TTEST+I),";;",2) Q:STR=""  D
 . S NAM=$$UP^XLFSTR($P(STR,";",2))
 . I '$D(^ORD(101.43,"B",NAM)) S XPDQUIT=1 D  Q
 . . W !,"   *** There is no ORDERABLE ITEM with the name '"_NAM_"'"
 . S (IEN,SUCCS)=0 F  S IEN=$O(^ORD(101.43,"B",NAM,IEN)) Q:'IEN  D
 . . Q:$$UP^XLFSTR($P($G(^ORD(101.43,IEN,0)),U))'=NAM
 . . Q:$$UP^XLFSTR($$GET1^DIQ(101.43,IEN_",",5))'="ANATOMIC PATHOLOGY"
 . . S SUCCS=SUCCS+1
 . I SUCCS>1 S XPDQUIT=1 D  Q
 . . W !,"   *** ORDERABLE ITEM '"_NAM_"' exists but there are multiple entries"
 . I 'SUCCS S XPDQUIT=1 D  Q
 . . W !,"   *** There is no ORDERABLE ITEM '"_NAM_"' within the ANATOMIC PATHOLOGY display group"
 . I SUCCS W !,"   Found ORDERABLE ITEM '"_NAM_"'"
 Q
 ;
ENVS ; Enviroment Check Specimen
 N I,STR,NAM,CODE,SPEC,IEN,SUCCS
 F I=1:1 S STR=$P($T(TSPEC+I),";;",2) Q:STR=""  D
 . S NAM=$$UP^XLFSTR($P(STR,";",2)),CODE=$P(STR,";",3)
 . I CODE="" S XPDQUIT=1 D  Q
 . . W !!,"   *** '"_NAM_"'",!,?10,"SNOMED CT for SPECIMEN not provided for '"_NAM_"'"
 . I '$D(^LAB(61,"F",CODE)) S XPDQUIT=1 D  Q
 . . W !!,"   *** '"_NAM_"'",!,?10,"SNOMED CT '"_CODE_"' has not been assigned to a SPECIMEN"
 . K SPEC S (IEN,SUCCS)=0 F  S IEN=$O(^LAB(61,"F",CODE,IEN)) Q:'IEN  D
 . . S SPEC(IEN)=$$UP^XLFSTR($P($G(^LAB(61,IEN,0)),U)),SUCCS=SUCCS+1
 . I SUCCS>1 D  Q
 . . S (IEN,SUCCS)=0 F  S IEN=$O(SPEC(IEN)) Q:'IEN  D
 . . . I SPEC(IEN)=NAM S SUCCS=SUCCS+1
 . . I SUCCS'=1 S XPDQUIT=1 D  Q
 . . . W !!,"   *** '"_NAM_"'",!,?10,"Multiple matches for SNOMED CT '"_CODE_"' with "
 . . . W $S(SUCCS>1:"same name matches",1:"no name match")
 . . W !!,"   *** '"_NAM_"'",!,?10,"Found SPECIMEN for SNOMED CT '"_CODE_"' and name '"_NAM_"'"
 . W !!,"   *** '"_NAM_"'",!,?10,"Found SPECIMEN for SNOMED CT '"_CODE_"'"
 Q
 ;
POST ; Post Install - REBUILD THE AP DIALOG DATA
 N I,STR,IEN,NAM,S,SIEN,SCODE,SNAM,DIK
 F I=1:1 S STR=$P($T(TTEST+I),";;",2) Q:STR=""  D
 . S IEN=$P(STR,";"),NAM=$$UP^XLFSTR($P(STR,";",2))
 . I IEN'=$$FIND1("TTEST",NAM) S IEN=$$TEST(IEN,NAM)
 . I IEN F S=1:1 S STR=$P($T(TSPEC+S),";;",2) Q:STR=""  D
 . . S SIEN=$P(STR,";"),SNAM=$$UP^XLFSTR($P(STR,";",2)),SCODE=$P(STR,";",3)
 . . I SIEN'=$$FIND1("TSPEC",SNAM,SCODE) D SPEC(IEN,SIEN,SNAM,SCODE)
 ; *** ReIndex
 K ^LAB(69.73,"B")
 S DIK="^LAB(69.73," D IXALL2^DIK,IXALL^DIK
 Q
 ;
TEST(IEN,NAM) ; Get/Set the old global entry
 Q:'$D(^LAB(69.73,IEN)) 0
 N NEW,CT,STR,CAP
 S NEW=$$FIND1("TTEST",NAM) I NEW D
 . S CT=$NA(^LAB(69.73,IEN)) F  S CT=$Q(@CT) Q:CT=""  Q:$QS(CT,1)'=69.73!($QS(CT,2)'=IEN)  D
 . . S STR=CT,$P(STR,",",2)=NEW
 . . S CAP(STR)=@CT
 . . I $QL(CT)=3,$QS(CT,3)=0 S CAP(STR)=NEW
 K ^LAB(69.73,IEN)
 Q:'$D(CAP) IEN
 S CT="" F  S CT=$O(CAP(CT)) Q:CT=""  S:$E(CT,1,11)="^LAB(69.73," @CT=CAP(CT)
 Q NEW
 ;
SPEC(IEN,SPC,NAM,CODE) ; Get the old global sub entry for specimen
 N NEW,CT,STR,CAP
 S NEW=$$FIND1("TSPEC",NAM,CODE) I NEW D
 . S CT=$NA(^LAB(69.73,IEN,3,SPC)) F  S CT=$Q(@CT) Q:CT=""  Q:$QS(CT,1)'=69.73!($QS(CT,2)'=IEN)!($QS(CT,3)'=3)!($QS(CT,4)'=SPC)   D
 . . S STR=CT,$P(STR,",",4)=NEW
 . . S CAP(STR)=@CT
 . . I $QL(CT)=5,$QS(CT,5)=0 S CAP(STR)=NEW
 Q:'$D(CAP)
 K ^LAB(69.73,IEN,3,SPC)
 S CT="" F  S CT=$O(CAP(CT)) Q:CT=""  S:$E(CT,1,11+$L(IEN))="^LAB(69.73,"_IEN @CT=CAP(CT)
 Q
 ;
FIND1(TAG,NAM,CODE) ; Lookup
 N CT,IEN,SUCCS,SPEC
 S NAM=$$UP^XLFSTR($G(NAM)),CODE=$G(CODE),SUCCS=0
 I TAG="TTEST" D
 . Q:'$D(^ORD(101.43,"B",NAM))
 . S (CT,IEN)=0 F  S CT=$O(^ORD(101.43,"B",NAM,CT)) Q:'CT  D
 . . Q:$$UP^XLFSTR($P($G(^ORD(101.43,CT,0)),U))'=NAM
 . . Q:$$UP^XLFSTR($$GET1^DIQ(101.43,CT_",",5))'="ANATOMIC PATHOLOGY"
 . . S SUCCS=SUCCS+1,IEN=CT
 I TAG="TSPEC" D
 . Q:CODE=""
 . K SPEC S (CT,SUCCS)=0 F  S CT=$O(^LAB(61,"F",CODE,CT)) Q:'CT  D
 . . S SPEC(CT)=$$UP^XLFSTR($P($G(^LAB(61,CT,0)),U)),SUCCS=SUCCS+1,IEN=CT
 . I SUCCS>1 D  Q
 . . S (CT,SUCCS,IEN)=0 F  S CT=$O(SPEC(CT)) Q:'CT  D
 . . . I SPEC(CT)=NAM S SUCCS=SUCCS+1,IEN=CT
 . . I SUCCS>1 S IEN=0
 Q $S(SUCCS'=1:0,$G(IEN):IEN,1:0)
 ;
BUILD ; Build the Transport Routine Text
 N ND,SP,SPEC
 I '$D(^LAB(69.73,"B")) W !,"***** No configuration to print. *****",! Q
 W !,"TTEST ; Dialog data to convert",!
 S ND=0 F  S ND=$O(^LAB(69.73,"B",ND)) Q:'ND  D
 . W " ;;",ND,";",$P($G(^ORD(101.43,ND,0)),U),!
 W " ;;",!," Q",!," ;",!
 W "TSPEC ; Specimen data to convert",!
 S ND=$NA(^LAB(69.73)) F  S ND=$Q(@ND) Q:ND=""  Q:$QS(ND,1)'=69.73  D
 . I $QS(ND,3)=3,$QS(ND,5)=0 D
 . . S SP=$P($G(^LAB(61,+$P(@ND,U),0)),U) I SP'="" D
 . . . S SPEC(SP)=+$P(@ND,U)_";"_SP_";"_$$GET1^DIQ(61,+$P(@ND,U)_",",20)
 I $D(SPEC) S SP="" F  S SP=$O(SPEC(SP)) Q:SP=""  W " ;;",SPEC(SP),!
 W " ;;",!," Q",!
 Q
 ;
 ; ******** RUN BUILD ABOVE AND UPDATE BELOW THIS LINE WITH THE OUTPUT ********
 ;
TTEST ; Dialog data to convert
 ;;766;BONE MARROW
 ;;4968;BRONCHIAL BIOPSY
 ;;4969;BRONCHIAL CYTOLOGY
 ;;4970;DERMATOLOGY
 ;;4971;FINE NEEDLE ASPIRATE
 ;;4972;GASTROINTESTINAL ENDOSCOPY
 ;;4974;GENERAL FLUID
 ;;4975;GYNECOLOGY (PAP SMEAR)
 ;;4976;TISSUE EXAM
 ;;4977;UROLOGY,BLADDER/URETER
 ;;4978;UROLOGY,PROSTATE
 ;;4979;RENAL BIOPSY
 ;;4980;URINE
 ;;
 Q
 ;
TSPEC ; Specimen data to convert
 ;;114;ABDOMEN;113345001
 ;;23;ADRENAL GLAND;23451007
 ;;5451;ANAL CANAL;34381000
 ;;66;APPENDIX;66754008
 ;;5401;ASCENDING COLON;9040008
 ;;5137;BILE DUCT CYTOLOGIC MATERIAL;110928002
 ;;5079;BILE DUCT MUCOUS MEMBRANE;7035006
 ;;4707;BILIARY TRACT;34707002
 ;;5117;BODY OF PANCREAS;40133006
 ;;322;BONE;3138006
 ;;319;BONE MARROW;14016003
 ;;318;BREAST;76752008
 ;;3533;BRONCHIAL CYTOLOGIC MATERIAL;110912007
 ;;336;BRONCHUS;955009
 ;;5248;CARDIAC INCISURE OF STOMACH;5459006
 ;;5246;CARDIAC OSTIUM OF STOMACH;63853002
 ;;5205;CARDIO-ESOPHAGEAL JUNCTION;25271004
 ;;231;CECUM;32713005
 ;;6464;CEREBROSPINAL FLUID CYTOLOGIC MATERIAL;110969006
 ;;6242;CERVICAL CYTOLOGIC MATERIAL;110949001
 ;;6079;CHORIONIC VILLI;2049008
 ;;67;COLON;71854001
 ;;5405;DESCENDING COLON;32622004
 ;;64;DUODENUM;38848004
 ;;62;ESOPHAGUS;32849002
 ;;5204;ESOPHAGUS, LOWER THIRD;67173009
 ;;5202;ESOPHAGUS, MIDDLE THIRD;19000002
 ;;5200;ESOPHAGUS, UPPER THIRD;54738009
 ;;5247;GASTRIC FUNDUS;414003
 ;;5482;GASTRIC JUICE;31773000
 ;;5241;GREATER CURVATURE OF STOMACH;89382009
 ;;5114;HEAD OF PANCREAS;64163001
 ;;5336;ILEUM;34516001
 ;;5329;JEJUNUM;21306003
 ;;22;KIDNEY;64033007
 ;;5404;LEFT COLIC FLEXURE;72592005
 ;;17;LEFT TESTIS;63239009
 ;;5239;LESSER CURVATURE OF STOMACH;80085006
 ;;56;LIVER;10200004
 ;;21;LUNG;39607008
 ;;213;LYMPH NODE;59441001
 ;;172;MEDIASTINUM;72410000
 ;;8310;NECK, LEFT SIDE;170583000
 ;;8309;NECK, RIGHT SIDE;170303002
 ;;4;PANCREAS;15776009
 ;;4946;PAROTID GLAND;45289007
 ;;116;PELVIS;12921003
 ;;3758;PERICARDIAL CYTOLOGIC MATERIAL;110919003
 ;;5569;PERIRENAL TISSUE;47145004
 ;;5504;PERITONEAL CYTOLOGIC MATERIAL;110944006
 ;;171;PERITONEUM;15425007
 ;;3561;PLEURAL CYTOLOGIC MATERIAL;110913002
 ;;15;PROSTATE;41216001
 ;;5252;PYLORIC ANTRUM;66051006
 ;;5254;PYLORUS;280119005
 ;;5443;RECTOSIGMOID JUNCTION;49832006
 ;;68;RECTUM;34402009
 ;;186;RENAL PELVIS;25990002
 ;;143;RETROPERITONEUM;82849001
 ;;5402;RIGHT COLIC FLEXURE;48338005
 ;;16;RIGHT TESTIS;15598003
 ;;55;SALIVARY GLAND;385294005
 ;;5406;SIGMOID COLON;60184004
 ;;315;SKIN;39937001
 ;;5273;SMALL INTESTINE;30315005
 ;;314;SOFT TISSUES;87784001
 ;;3;SPLEEN;78961009
 ;;63;STOMACH;69695003
 ;;4960;SUBLINGUAL GLAND;88481005
 ;;4968;SUBMAXILLARY GLAND;54019009
 ;;8433;SUBPHRENIC FOSSA;243974009
 ;;3117;SYNOVIAL CYTOLOGIC MATERIAL;110895009
 ;;5125;TAIL OF PANCREAS;73239005
 ;;5;THYROID GLAND;69748006
 ;;8729;TISSUE;85756007
 ;;5403;TRANSVERSE COLON;485005
 ;;351;URETER;87953007
 ;;87;URINARY BLADDER;89837001
 ;;71;URINE;78014005
 ;;234;VAS DEFERENS;57671007
 ;;189;VERTEBRA;51282000
 ;;
 Q