update patvisit show, add prefix for all createdate
This commit is contained in:
parent
b856ff358d
commit
33d904e83b
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\PatVisit;
|
||||
use App\Models\CounterModel;
|
||||
use App\Models\BaseModel;
|
||||
use App\Models\CounterModel;
|
||||
use App\Models\PatVisit\PatDiagModel;
|
||||
use App\Models\PatVisit\PatVisitADTModel;
|
||||
|
||||
class PatVisitModel extends BaseModel {
|
||||
protected $table = 'patvisit';
|
||||
@ -18,14 +20,15 @@ class PatVisitModel extends BaseModel {
|
||||
protected $visnum_prefix = "DV";
|
||||
|
||||
public function show($PVID) {
|
||||
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
||||
->join('patvisitadt pva', 'pva.InternalPVID=patvisit.InternalPVID', 'left')
|
||||
$rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate")
|
||||
->join('patdiag', 'patdiag.InternalPVID=patvisit.InternalPVID', 'left')
|
||||
->join('patvisitadt', 'patvisitadt.InternalPVID=patvisit.InternalPVID', 'left')
|
||||
->where('patvisit.PVID',$PVID)->findAll();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function showByPatient($InternalPID) {
|
||||
$rows = $this
|
||||
$rows = $this->select("*, patvisit.CreateDate as PVCreateDate, patdiag.CreateDate as PDCreateDate, patvisitadt.CreateDate as PVACreateDate")
|
||||
->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
||||
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
||||
->join('location l', 'l.LocationID=pva.LocationID', 'left')
|
||||
@ -35,22 +38,26 @@ class PatVisitModel extends BaseModel {
|
||||
|
||||
public function createPatVisit($input) {
|
||||
$db = \Config\Database::connect();
|
||||
$modelPD = new PatDiagModel();
|
||||
$modelPVA = new PatVisitADTModel();
|
||||
try{
|
||||
$db->transStart();
|
||||
if (!isset($input['PVID']) || $input['PVID']=='') {
|
||||
$counter = new CounterModel();
|
||||
$input['PVID'] = $this->visnum_prefix .$counter->use(2);
|
||||
$modelCounter = new CounterModel();
|
||||
$input['PVID'] = $this->visnum_prefix .$modelCounter->use(2);
|
||||
}
|
||||
|
||||
$InternalPVID = $this->insert($input, true);
|
||||
|
||||
if(!empty($input['PatDiag'])) {
|
||||
$input['PatDiag']['InternalPVID'] = $InternalPVID;
|
||||
$db->table('patdiag')->insert($input['PatDiag']);
|
||||
//$db->table('patdiag')->insert($input['PatDiag']);
|
||||
$modelPD->insert($input['PatDiag']);
|
||||
}
|
||||
if(!empty($input['PatVisitADT'])) {
|
||||
$input['PatVisitADT']['InternalPVID'] = $InternalPVID;
|
||||
$db->table('patvisitadt')->insert($input['PatVisitADT']);
|
||||
//$db->table('patvisitadt')->insert($input['PatVisitADT']);
|
||||
$modelPVA->insert($input['PatVisitADT']);
|
||||
}
|
||||
|
||||
$db->transComplete();
|
||||
|
||||
@ -7,8 +7,6 @@ use App\Models\Patient\PatAttModel;
|
||||
use App\Models\Patient\PatComModel;
|
||||
use App\Models\Patient\PatIdtModel;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
|
||||
class PatientModel extends BaseModel {
|
||||
protected $table = 'patient';
|
||||
protected $primaryKey = 'InternalPID';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user