The Hound of the Wolf

For the strength of Pack is in the Wolf, and the strength of Wolf is in the Pack -Rudyard Kipling

Tuesday, September 23, 2008

The 1-1-4 Maternal care dilemna

The FHSIS Maternal Care indicator 1 says that a count should be made for prenatal patients with 4 prenatal visits. To query it in the database, it is as easy as checking if the COUNT function would return 4 visits if the patient is still under the prenatal period. What makes it difficult to query is to check if within the 4 visits, the patient was able to made at least 1 1st trimester visit, at least 1 for the 2nd semester and at least 2 for the 3rd trimester. Establishing the 1-1 setup is easy while 1-1-2 is quite a challenge (at least on my level). Truly a dilemna which i have been solving for 48 hours already.

The algorithm i have structured is:

1. Get all maternal id's with at least 4 visits and with a third trimester visit
2. Traverse thru the resulted array and check for visits in each trimester.
3. Mark 1 in the cell of the array corresponding with 1st and 2nd trimester indicating that 1st and 2nd trimesters are made.
4. Query for third trimester and get the second least date of prenatal visit using the SQL statement:

$q_min_date = mysql_query("SELECT MIN(prenatal_date) FROM m_consult_mc_prenatal WHERE mc_id='$mcid' AND trimester='$j' AND prenatal_date!=(SELECT MIN(prenatal_date) FROM m_consult_mc_prenatal WHERE mc_id='$mcid' AND trimester='$j')") or die("cannot query: 204");

5. If the result exists, marked the cell corresponding with 1 indicating that there is a second visit for third trimester.

6. Iterate the count for the month of the second visit of the third trimester by getting the month from the resulting date using:

$max_date = date("n",mktime(0,0,0,$latestm,$latestd,$latesty)); where $latestm,$latestd,$latesty is a result of "exploding" the visit date.

7. Return the array of consolidated months after the iteration of maternal id's that complied with the condition stated in the first step.