Medical Diary between two dates
###
Diary
###
33012/Any rev05
###
Generates the medical diary for treatments falling due between two dates.
###
en
###
SELECT
a.ID AS AID, a.ShelterCode, a.AnimalName,
t.AnimalType, s.SpeciesName,
a.DisplayLocation, am.TreatmentName,
am.Dosage, amt.TreatmentNumber, amt.TotalTreatments,
amt.DateRequired, am.Comments AS RegimeComments, amt.Comments
FROM animal a
INNER JOIN animaltype t ON t.ID = a.AnimalTypeID
INNER JOIN species s ON s.ID = a.SpeciesID
INNER JOIN animalmedical am ON a.ID = am.AnimalID
INNER JOIN animalmedicaltreatment amt ON amt.AnimalMedicalID = am.ID
WHERE amt.DateGiven Is Null 
AND amt.DateRequired >= '$ASK DATE Treatments due from$' AND amt.DateRequired <= '$ASK DATE to$'
AND a.Archived = 0
ORDER BY amt.DateRequired 
###
$$HEADER
<table border=1>
<thead>
<tr>
<th><b>Code</b></th>
<th><b>Name</b></th>
<th><b>Type</b></th>
<th><b>Species</b></th>
<th><b>Internal Loc</b></th>
<th><b>Therapy</b></th>
<th><b>Dosage</b></th>
<th><b>Number</b></th>
<th><b>Date Required</b></th>
<th><b>Regimen Comments</b></th>
<th><b>Comments</b></th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY<tr>
<td>$SHELTERCODE</td>
<td><a target="_blank" href="animal?id=$AID">$ANIMALNAME</a></td>
<td>$ANIMALTYPE</td>
<td>$SPECIESNAME</td>
<td>$DISPLAYLOCATION</td>
<td>$TREATMENTNAME</td>
<td>$DOSAGE</td>
<td>$TREATMENTNUMBER / $TOTALTREATMENTS</td>
<td>$DATEREQUIRED</td>
<td>$REGIMECOMMENTS</td>
<td>$COMMENTS</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
FOOTER$$
&&&
Medical Diary between two dates by animal
###
Diary
###
33012/Any rev05
###
Generates the medical diary for treatments falling due between two dates by animal.
###
en
###
SELECT
a.ID AS AID, a.ShelterCode, a.AnimalName,
t.AnimalType, s.SpeciesName,
a.DisplayLocation, am.TreatmentName,
am.Dosage, amt.TreatmentNumber, amt.TotalTreatments,
amt.DateRequired, am.Comments AS RegimeComments, amt.Comments
FROM animal a
INNER JOIN animaltype t ON t.ID = a.AnimalTypeID
INNER JOIN species s ON s.ID = a.SpeciesID
INNER JOIN animalmedical am ON a.ID = am.AnimalID
INNER JOIN animalmedicaltreatment amt ON amt.AnimalMedicalID = am.ID
WHERE amt.DateGiven Is Null 
AND amt.DateRequired >= '$ASK DATE Treatments due from$' AND amt.DateRequired <= '$ASK DATE to$'
AND a.Archived = 0
ORDER BY ShelterCode, amt.DateRequired 
###
$$HEADER
HEADER$$

$$GROUP_ShelterCode
$$HEAD
<h2>$ShelterCode - $AnimalName</h2>
<table border=1>
<thead>
<tr>
<th><b>Code</b></th>
<th><b>Name</b></th>
<th><b>Type</b></th>
<th><b>Species</b></th>
<th><b>Internal Loc</b></th>
<th><b>Therapy</b></th>
<th><b>Dosage</b></th>
<th><b>Number</b></th>
<th><b>Date Required</b></th>
<th><b>Regimen Comments</b></th>
<th><b>Comments</b></th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
GROUP$$

$$BODY
<tr>
<td>$SHELTERCODE</td>
<td><a target="_blank" href="animal?id=$AID">$ANIMALNAME</a></td>
<td>$ANIMALTYPE</td>
<td>$SPECIESNAME</td>
<td>$DISPLAYLOCATION</td>
<td>$TREATMENTNAME</td>
<td>$DOSAGE</td>
<td>$TREATMENTNUMBER / $TOTALTREATMENTS</td>
<td>$DATEREQUIRED</td>
<td>$REGIMECOMMENTS</td>
<td>$COMMENTS</td>
</tr>
BODY$$

$$FOOTER
FOOTER$$
