Tod means Fox

Business Intelligence, Data Warehousing, SQL, Visual FoxPro.

Archive for March, 2007


Published March 20th, 2007

HIPAA, PHI and the Patriot Act

Although this isn’t new news, I thought I would bring it up. We had what is called a “lunch-and-learn” session today at work, where the company pays for some pizza and during the lunch hour we al sit around and learn something. Today’s topic was about personal health information (or, PHI). Basically, only certain people under certain circumstances are allowed access to this information. To give you an idea of how strict this is: A husband cannot see his wife’s PHI without her consent. This protection falls under HIPAA.

I asked a question about how the Patriot Act (and Homeland Security) Act changes our rights of privacy in regards to HIPAA. Normally, the most restrictive rules apply. This is the case, for example, with states laws verses federal laws — the more restrictive/protective law takes precedence. But these acts are different.

Therefore, the department of Homeland Security has the authority to seek and obtain your PHI:

“This authority can be interpreted to include requests for PHI of any type without the expressed authorization of the patient or legal guardian. ”

You can read more about this here. Of course the government denies that it will misuse the power, I doubt it. At least this current regime.

Published March 20th, 2007

UNION oddity (or maybe it’s just me)

I had a situation come up today where I needed to add the contents of one cursor (cursorA) to another (cursorB), without adding any duplicates in the process. Both cursors had the exact same structure. CursorA was going to be closed (a little later), while cursorB would persist (for another few processes). Immediately I turned to the UNION clause. My strategy was to select * from both tables, union them together, and put the results back into cursorB like this:

SELECT * FROM cursorB ;
    UNION ;
SELECT * FROM cursorA ;
INTO CURSOR cursorB READWRITE

I was surprised to see the open dialog box pop up, basically asking me to locate cursorB! What happens here is that the INTO clause seems to strike first, essentially closing cursorB. I suppose I was a little surprised because I do stuff like this all the time:

SELECT * FROM cursorB WHERE .T. INTO CURSOR cursorB

I worked around this by modyfing my SQL to the following:

SELECT * FROM (SELECT * FROM cursorB) as tmp ;
    UNION ;
SELECT * FROM cursorA ;
INTO CURSOR cursorB READWRITE

I should mention that this only works in VFP9. VFP7 will complain that the syntax is wrong (I presume the same in VFP8 too). The only solution that I can think of in VFP7 would be in two-steps:

SELECT * FROM cursorB ;
    UNION ;
SELECT * FROM cursorA ;
INTO CURSOR cursorC
 
SELECT * FROM cursorC INTO cursorB READWRITE

Published March 14th, 2007

Future of FoxPro

Yair Alan Griver (known as YAG) has posted on his blog “yag: Community and Architecture” a message for the VFP community: There will be no VFP10. I assume he means ever.

As other VFP bloggers will certainly do, I plan on talking more about this in the coming weeks. Especially in regards to CodePlex, and how VFP programmers might begin to approach the future. Make no mistake, VFP is a mature language and there are many VFP application out and about across the world. It’s not like this news is a shock, nor will it send VFP applications to the graveyard in my opinion. More to come…

Published March 14th, 2007

Parsing City/State/Zip

Many applications today still carry the city, state, and zip in a composite field. The problem with this type of concatenation is that you can’t easily query the data or use it for other things (such as building a report by state). There really is no benefit or good reason to keep them together. I have yet to hear a good ‘excuse’:

1.) This is how I got the data
2.) It makes it easier for the end-user to enter everything in a single field
3.) I don’t have to worry about combining them on labels
4.) (insert your bad excuse here)

To add value to these legacy composite fields, you can write a program to split them up.

Usually, the data has some form such as “city, state zip” where the state is almost certainly abbreviated. The following program can be used to parse out city, state, and zip from a concatenated field into atomic parts. Two assumption are made with this program (important ones, at that): that state will be 2 digits and that city names don’t begin with a number. Another excellent approach would be to grab a zipcode file from the post office (or other data supplier) so that you could compare each segment to determine not only that it IS a zip code or city or state abbreviation (or full state name for that matter) but that it actually exists! I’ll leave that part up to you! Here is my simple solution to get things atomic:

lcCity = ""
lcState = ""
lcZip = ""
lcCSZ= "Marlborough, MA 01752"
*-- lcCSZ= "North Providence RI 02988"
*-- lcCSZ= "Boston MA"
 
? parse_csz(lcCSZ , @lcCity, @lcState , @lcZip )
? "city: " + lcCity
? "state: " + lcState
? "zip: " + lcZip
 
FUNCTION parse_csz
  LPARAMETERS tcFullString , rcCity , rcState , rcZip
 
  LOCAL lcFullString AS String   LOCAL lnSegments AS Number
 
  STORE "" TO rcCity , rcState , rcZip && reference parameters
 
  *-- remove any commas and convert to spaces
  lcFullString = STRTRAN( ALLTRIM(tcFullString ) , "," , " " )
 
  *-- get the number of segments
  lnSegments = GETWORDCOUNT( lcFullString )
 
  *-- try to be smart and figure out what to do depending
  *-- on the number of segments found
  DO CASE
    CASE lnSegments >= 3
 
        rcZip = GETWORDNUM( lcFullString, lnSegments)
        rcState = GETWORDNUM( lcFullString, lnSegments- 1)
 
        FOR x = 1 TO lnSegments - 2
            rcCity = rcCity + " " + GETWORDNUM( lcFullString, x )
        NEXT
 
        rcCity = ALLTRIM( rcCity )
 
    CASE lnSegments = 2
 
      IF ISDIGIT( GETWORDNUM(lcFullString, 2) )
          rcZip = GETWORDNUM(lcFullString, 2)
      ELSE
          IF LEN( GETWORDNUM(lcFullString, 2) ) > 2
              rcCity = GETWORDNUM(lcFullString, 1) + " " + ;
                   GETWORDNUM(lcFullString, 2)
          ELSE
              rcState = GETWORDNUM(lcFullString, 2)
              rcCity = GETWORDNUM(lcFullString, 1)
          ENDIF
      ENDIF
 
    CASE lnSegments = 1
 
      IF ISDIGIT( lcFullString )
          rcZip = lcFullString
      ELSE
          IF LEN( lcFullString ) > 2
              rcCity = lcFullString
          ELSE
              rcState = lcFullString
          ENDIF
      ENDIF
ENDCASE
 
*-- Return in a mailing format
RETURN rcCity + " " + rcState + "  " + rcZip

Published March 3rd, 2007

Full Eclipse of the moon

Note: this picture was taken by Doug Murray in 2004, which was the last time this happened.

Doug Murray, Full Eclipse of the moon

Published March 2nd, 2007

CoDe’s Sedna Issue

I got my Sedna issue of CoDe magazine the other day, and just finished reading through it. I was a little excited when it came in, and was rather pleased with the content. This was their third Fox Focus issue (why not more?). Articles by Doug Hennig, Bo Durban, Rick Schummer, Rick Strahl and others dove right into some of Sedna’s great new improvements. Although most of the content wasn’t “new” — in that I, like most VFP developers, have known about these wonderful enhancements for some time. But it is great to see them in print, in an issue especially designed for Fox.

I do admit that I skimmed over the VFP to .net stuff. I’m just not interested in porting my VFP applications to .net. Whenever I read through these sorts of things I just find myself frustrated, puzzled, and dismayed all at once. First, moving to .net would require a complete re-write. Second, I’ve developed a few .NET apps in my day and still feel that VFP (for many projects) is light years ahead of .net. Of course, I’m excited about the new C# (my .net language of choice), the cool features of the Development Studio, and LINQ. But for a Fox Focus issue, it would have been great to umm… focus more on Fox! But I digress..

Now that I have that off my chest, I’d like to comment on a few of the articles I found most interesting. First I was really happy to see Rick’s article “Visual FoxPro Web Services Revisited”. Rick gives us the goods on the Web Service Client process, ASMX, Windows Communication Foundation (WCF), and the status of SOAP. Communicating with the Web has never been fully straightforward in VFP, but with a little guidance and shove once in a while, future VFP development using Web Services looks bright.

Craig Boyd (”Welcome to the Future of Deployment”) and John M. Miller (”Integrating VFP into VSTS Team Projects”) show us how to use some of Visual Studio’s coolest features with VFP. Craig discusses ClickOnce — a deployment technology allowing you to do installs and upgrades on the Web — and how you can use it with VFP. This is a must read for anyone looking to update their distribution strategy. The company I just started working for is just beginning to do Web installs (after years of mailing CDs). This is one of the first articles I’ll be showing management.

Miller’s article really took me by surprise. Visual Studio Team System (VSTS) is Microsoft’s SDLC tool integrated into Visual Studio 2005. Although I haven’t used it in the past, this article sparked my interest. VSTS promises to help manage the often difficult task of integrating resources on complex projects. The only problem is that VSTS is a .net thing, and really not designed to use non-dotnet tools out of the box. However, as John explains, you can use VSTS extensibility features to make it happen. Thanks John!

Lastly, this issue is packed with little sidebars and tidbits. Things like ClassBrowserX, Scrollable containers for VFP, and GDIPlus-X. I think this issue has also inspired me to join CodePlex and maybe jump on one of the VFP projects (at least as a tester).

Take a look for more: http://www.code-magazine.com/focus/index.aspx