VaultNetwork.netVault Network Boards
Author Topic: It takes a certain type of personality to write code [Locked]
AzureTyger  2 stars
Title: Awesome
Posts: 462
Registered: 2002-4-1 15:49:04
Mine is easier.

This is IBM eSQL, and the criteria were:

If order type is "CARDI" and patient location is "HOSPA" or "HOSPB" and the order type isn't "CARDI-EKG" or "CARDI-TT" send the message
If order type is "CARDI" and patient location is not "HOSPA" or " HOSPB " and the order type is not an EKG, TT, HM, PS, SC, TR, TT , send the message

Don't send anything else

The original code was:


CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

DECLARE input REFERENCE TO Body;

DECLARE Processchk BOOLEAN 'UNKNOWN';

DECLARE hl7 NAMESPACE 'urn:hl7-org:v2xml';

DECLARE flag, pv1_3, obr_4, obr_18 CHAR;


SET flag = substring(input.hl7BR.hl7:"OBR.4.UniversalServiceIdentifier".hl7:"CE.1" FROM 1 FOR 5);

SET pv1_3 = substring(input.hl7V1.hl7:"PV1.3.AssignedPatientLocation".hl7:"PL.1" FROM 1 FOR 5);

SET obr_4 = substring(input.hl7BR.hl7:"OBR.4.UniversalServiceIdentifier".hl7:"CE.1" FROM 1 FOR 9);

SET obr_18 = substring(input.hl7BR.hl7:"OBR.18.PlacerField1" FROM 1 FOR 5);


IF (flag ='CARDI' THEN

IF (pv1_3 = 'HOSPA' OR pv1_3 = 'HOSPB' THEN

IF (CONTAINS(obr_4, 'CARDI-EKG' OR CONTAINS(obr_4, 'CARDI-TT') THEN

SET Processchk = 'FALSE';

END IF;

ELSE

IF (CONTAINS(obr_4, 'CARDI-EKG' OR

CONTAINS(obr_4, 'CARDI-TRI' OR

CONTAINS(obr_4, 'CARDI-HM' OR

CONTAINS(obr_4, 'CARDI-PS' OR

CONTAINS(obr_4, 'CARDI-SC' OR

CONTAINS(obr_4, 'CARDI-TT' OR

CONTAINS(obr_4, 'CARDI-TR') THEN

SET Processchk = 'FALSE';

ELSE

SET Processchk = 'TRUE';

END IF;

END IF;

ELSE

SET Processchk = 'TRUE';

END IF;


RETURN Processchk;

END;

This basically passed any value through, whether it was "CARDI" or not.

I am going to try this, which passed the syntax check. I am sure there are way more efficient and elegant ways to do it, but I don't have the skill. I would rather have used NOT IN (1,2,3,4,5) on the bottom one instead of calling the same variable over and over, but I have not been able to make that work in the past.


CREATE FUNCTION Main() RETURNS BOOLEAN

BEGIN

DECLARE input REFERENCE TO Body;

DECLARE hl7 NAMESPACE 'urn:hl7-org:v2xml';

DECLARE Processchk, CHECK1, CHECK2 BOOLEAN 'FALSE';

DECLARE UID1, PATLOC, UID2 CHAR;


SET UID1 = substring(input.hl7BR.hl7:"OBR.4.UniversalServiceIdentifier".hl7:"CE.1" FROM 1 FOR 5);

SET UID2 = substring(input.hl7BR.hl7:"OBR.4.UniversalServiceIdentifier".hl7:"CE.1" FROM 1 FOR 9);

SET PATLOC = substring(input.hl7V1.hl7:"PV1.3.AssignedPatientLocation".hl7:"PL.1" FROM 1 FOR 5);


-- Check If CARDI and HOSPA or HOSPB and not CARDI-EKG and CARDI-TT

IF ((UID1 = 'CARDI' AND

(PATLOC = 'HOSPA' OR PATLOC = 'HOSPB' AND

(UID2 <> 'CARDI-EKG' AND UID2 <> 'CARDI-TT') THEN

SET CHECK1 = 'TRUE';

ELSE

SET CHECK1 = 'FALSE';

END IF;


-- Check If CARDI and not HOSPA and HOSPB and not EKG, TT, HM, PS, SC, or TR

IF ((UID1 = 'CARDI' AND

(PATLOC <> 'HOSPA' AND PATLOC <> 'HOSPB' AND

(UID2 <> 'CARDI-EKG' AND

UID2 <> 'CARDI-TT' AND

UID2 <> 'CARDI-HM' AND

UID2 <> 'CARDI-PS' AND

UID2 <> 'CARDI-SC' AND

UID2 <> 'CARDI-TR') THEN

SET CHECK2 = 'TRUE';

ELSE

SET CHECK2 = 'FALSE';

END IF;


-- Filter message unless CHECK1 OR CHECK2 are 'TRUE'

IF (CHECK1 OR CHECK2) THEN

SET Processchk = 'TRUE';

ELSE

SET Processchk = 'FALSE';

END IF;


RETURN Processchk;

END;

 

-----signature-----
Using the mirror of ridicule to force conservatives to
confront their own stupidity.
Fist_de_Yuma  3 stars
Posts: 571
Registered: 2001-12-20 21:17:22
You guys have it so easy. When I started you had MS Basic, machine and binary. I remember spending two days trying to make a door shut without shutter on an Apple IIe. You had to deal with DOS to get anything done. You needed to write functions for even simple jobs. No tools, no graphics and little outside support. Your boss said, "I need this" without any idea what it took to get it. You had to get around the IT guy to get anything off the network, which was a language in itself. I was given a network to handle where the bosses paid for the system without my input. They decided to save money by getting a 5mb drive instead of a 10mb. I had to uninstall all the programs to sort the database. Most of the people coming for help had a Lotus file they wanted to convert into a dBase database. That is when they were not using Lotus for a Word Processor. Don't talk to me about repair. There was one time we etched our own boards. (You drew the paths on a copper sheet and dropped the board into acid to remove all but where you drew.)

I would love to have the tools today for the jobs then. I could have a years work done by the afternoon; and go home early.

(For the weak minded liberals, that is a joke, which is funny because it is partly true. Really, things were hard but less complicated. I'm sure there are different issues today that make it as hard or harder for the "computer guy"

 

-----signature-----
There are three kind of liberals;
Stupid, ignorant or evil
The result is always evil but the intent is not always evil. Not that it makes much difference in the long run.
No one here is exactly as they seem. - G'Kar
Kjarhall  3 stars
Title: The Pungent One
Posts: 915
Registered: 2002-3-1 15:47:21
Clearly all coders are conservatives!

 

-----signature-----
You're a crazy moron*
*http://vnboards.ign.com/outpost/b22180/115147923/r115151508/
hah! true story tho i'm a woman an i even love boobs..how can you not??- HallowEve
AzureTyger  2 stars
Title: Awesome
Posts: 462
Registered: 2002-4-1 15:49:04
10 test messages have all worked so far, I'll try about 20 more on Monday.

 

-----signature-----
Using the mirror of ridicule to force conservatives to
confront their own stupidity.
Szerek  2 stars
Posts: 338
Registered: 2000-8-8 09:26:09
AzureTyger posted:

10 test messages have all worked so far, I'll try about 20 more on Monday.



What kind of system is this running on? z/OS, Unix, Windows?

 

-----signature-----
"The reason they call it the American Dream is because you have to be asleep to believe it."
"The IQ and the life expectancy of the average American recently passed each other in opposite directions."
- George Carlin
AzureTyger  2 stars
Title: Awesome
Posts: 462
Registered: 2002-4-1 15:49:04
Szerek posted:

AzureTyger posted:

10 test messages have all worked so far, I'll try about 20 more on Monday.



What kind of system is this running on? z/OS, Unix, Windows?



IBM AIX

 

-----signature-----
Using the mirror of ridicule to force conservatives to
confront their own stupidity.
ZartanAround  3 stars
Title: Torpid Curmudgeon
Posts: 768
Registered: 2004-2-6 20:54:09
Sinlock posted:

Taliesihne posted:

Not when you are good at it.



Not true. Dogged, persistent, unwavering patience is mandatory in quality debugging. You cannot be an impatient debugger, or you will fail.



true dat.


"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." – Brian W. Kernighan

 

-----signature-----
what are nice chickens like you doing in a coop like this?
Sinlock  2 stars
Title: Savior of the Camelot Outpost
Posts: 376
Registered: 2000-5-14 16:20:01
I actually love writing code. The main reason is, I want people to leave me the hell alone. I like getting an assignment - "make this one thing happen" - and then I get to sit and work on it with no one annoying me with anything.

I am not management material mainly because I don't want to deal with bullshit and long meetings.

 

-----signature-----
THOOOOKA...THOOOOOKA...THOOOOOKA...
Future Grand President For Life of the Universe (you'll see! you'll be sorry then!)
Outpost Terrorist #1! I don't care what any law says!
Modeeb  4 stars
Title: A Ghost In The Machine
Posts: 1,258
Registered: 2002-4-19 10:48:36
I had to learn BASIC at USC for undergrad business in the late 70's. It was not something I enjoyed.

 

-----signature-----
"What is here is there. What is not here is nowhere." Vishvasara Tantra
"Ever tried, Ever Failed. No matter. Try Again.
Fail Again. Fail Better. Samuel Beckett
the_great_intex  4 stars
Title: This is what cool looks like
Posts: 1,669
Registered: 2002-6-27 08:18:27
I do high level system architecture now. I haven't coded for months

Way better and allows me to be way more creative. I get to tell the code monkeys what to do

I learned programming very early

 

-----signature-----
Only those who dare to fail greatly, can ever achieve greatly
In the middle of difficulty lies opportunity
The only thing in life achieved without effort is failure
Time Circuits... On. Flux Capacitor.... fluxxing.

VaultNetwork.net is an independently operated community forum and is not affiliated with, endorsed by, or technically based on IGN, GameSpy, FilePlanet, GameStats, or the former IGN/GameSpy Vault Network.
References to VaultNetwork.net mean this site/domain. VNBoards-style presentation is a visual homage only. By using this site, you agree to the forum rules.