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

LRLNCUTL.m

Go to the documentation of this file.
  1. LRLNCUTL ;DALOI/RH-LEDI HL7 CODES AND CALCULATE CHECKDIGIT ;11-OCT-1998
  1. ;;5.2T9;LR;**1018**;Nov 17, 2004
  1. ;;5.2;LAB SERVICE;**215,232**;Sep 27,1994
  1. EN ;
  1. W @IOF
  1. W !,$$CJ^XLFSTR("This option allows the user to add/edit",IOM)
  1. W !,$$CJ^XLFSTR(" Lab Electronic specimen codes in the Topography file.",IOM)
  1. W !!,$$CJ^XLFSTR("It is recommended that you print a copy of Specimen codes ",IOM)
  1. W !,$$CJ^XLFSTR(" to assist you in editing SITE/SPECIMENS.",IOM)
  1. START ;BEGINS PRINTING THE REPORT
  1. D DT^DICRW W !
  1. S DIR(0)="Y",DIR("A")="Print a copy of the Electronic Code specimens"
  1. S DIR("B")="NO" D ^DIR Q:$D(DIRUT)
  1. I Y D ^LRLNCHL7 W !!
  1. D ADEN
  1. D EXIT
  1. Q
  1. ADEN ; ADD/EDIT LEDI HL7 CODE AND TIME ASPECT
  1. D EXIT
  1. I $Y+5>IOSL W @IOF
  1. S DIC=61,DIC(0)="AQEZNM"
  1. S DIC("A")="Select Topography Specimen to Map: "
  1. D ^DIC Q:Y<1
  1. S DA=+Y,DIE="^LAB(61,",DR=".09:.0961" S DIC("S")="I $P(^(0),U,7)=""S""" D ^DIE
  1. W !! D ADEN
  1. Q
  1. MOD10 ;Instructions used to Calculate Mod 10 Check Digits
  1. ;Appendix B of the LOINC User's Guide
  1. ;Example using 12345
  1. ;Step 1: assign position to digits, right to left
  1. ;pos1=5 pos2=4 pos3=3 pos4=2 pos5=1
  1. ;Step 2: take odd digit pos counting from the right
  1. ;pos1 - pos3 - pos5 = 531
  1. ;Step 3: multiply 531*2 = 1062
  1. ;Step 4: take even digit starting from the right
  1. ;pos2 - pos4 = 42
  1. ;Step 5: append Step 4_Step3 = 421062
  1. ;Step 6: add the digits of Step 5 together
  1. ;4+2+1+0+6+2 = 15
  1. ;Step 7: find the next higest multiple of 10
  1. ;20
  1. ;Step 8: substract Step 6 from Step 7
  1. ;20-15 = 5
  1. CHEKDIG(X) ;
  1. N LREVEN,LRI,LRL,LRSTR,LRODD,LRDIG,LRCHDIG,LRCHSUM
  1. S LRSTR=""
  1. S (LRI,LRL)=$L(X) F S LRSTR=LRSTR_$E(X,LRI),LRI=LRI-1 Q:LRI<1
  1. S LRODD="" F LRI=1:1:LRL S:LRI#2 LRODD=LRODD_$E(LRSTR,LRI)
  1. S LRODD=LRODD*2
  1. S LREVEN="" F LRI=1:1:LRL S:'(LRI#2) LREVEN=LREVEN_$E(LRSTR,LRI)
  1. S LRCHSUM=LREVEN_LRODD,LRL1=$L(LRCHSUM)
  1. S LRDIG="" F LRI=1:1:LRL1 S LRDIG=LRDIG+$E(LRCHSUM,LRI)
  1. F LRI=10:10 S LRCHDIG=LRI-LRDIG Q:LRCHDIG>-1
  1. Q LRCHDIG
  1. Q
  1. EXIT K DIC,DA,DIE,X,Y,DUOUT,DTOUT
  1. Q