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