<?php
$strOPD="SELECT cast((VisitDate as date) AS VisitDate,
COUNT(VN) AS CountVN)
FROM DNHOSPITAL_TEST.dbo.HNOPD_MASTER AS OPD
WHERE VisitDate BETWEEN '".$years."-".$month."-1' AND '".$years."-".$month."-".$checkdate."' AND Cxl='0'
GROUP BY cast(VisitDate as date)
ORDER BY cast(VisitDate as date) ASC";
$objExecOPD = odbc_exec($conn,$strOPD) or die ("Error SQL [".$strOPD."]");
$objResultOPD=(odbc_fetch_array($objExecOPD));
$objResultOPD = !empty($objResultOPD) ? $objResultOPD->OPD : 0;
$strIPD="SELECT cast((StatDate as date) as VisitDate,
sum((NOBEDOCCBFW+NOBEDOCCNEW-NOBEDRETURN-NOBEDUNACKNOWLEDGE)) as inward,
sum(NOPATIENTADM-NOPATIENTCXLADM) as admit,
sum(NOPATIENTDISCHARGE) as discharge)
FROM DNHOSPITAL_TEST.dbo.HN_STAT_WARD_HEADER AS IPD
WHERE StatDate BETWEEN '".$years."-".$month."-1' AND '".$years."-".$month."-".$checkdate."'
GROUP BY cast(StatDate as date)
ORDER BY cast(StatDate as date) ASC";
$objExecIPD = odbc_exec($conn,$strIPD) or die ("Error SQL [".$strIPD."]");
$objResultIPD=(odbc_fetch_array($objExecIPD));
$objResultIPD = !empty($objResultIPD) ? $objResultIPD->IPD : 0;
?>
<tr>
<th><?= $objResultOPD["VisitDate"]?></th>
<td><?= $objResultOPD["CountVN"]?></td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td></td>
<td>100.00</td>
<td><?= $objResultIPD["inward"]?></td>
<td><?= $objResultIPD["admit"]?></td>
<td><?= $objResultIPD["discharge"]?></td>
<td>%</td>
</tr>