Merge branch 'main' of https://github.com/mahdahar/clqms-be
This commit is contained in:
commit
c73d09fe52
@ -20,7 +20,7 @@ class Contact extends Controller {
|
|||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$model = new ContactModel();
|
$model = new ContactModel();
|
||||||
$rows = $model->getContactsWithDetail();
|
$rows = $model->getContacts();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
|
|||||||
@ -3,13 +3,17 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
use CodeIgniter\Controller;
|
use CodeIgniter\Controller;
|
||||||
use CodeIgniter\Database\RawSql;
|
|
||||||
|
|
||||||
use App\Models\CounterModel;
|
use App\Models\CounterModel;
|
||||||
|
use App\Models\PatVisitModel;
|
||||||
|
|
||||||
class PatVisit extends Controller {
|
class PatVisit extends Controller {
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
|
protected $db;
|
||||||
|
protected $visnum_prefix;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
$this->visnum_prefix = "DV";
|
$this->visnum_prefix = "DV";
|
||||||
@ -17,10 +21,7 @@ class PatVisit extends Controller {
|
|||||||
|
|
||||||
public function show($PVID = null) {
|
public function show($PVID = null) {
|
||||||
try {
|
try {
|
||||||
$row = $this->db->table('patvisit pv')
|
$row = new PatVisitModel()->show($PVID);
|
||||||
->join('patdiag pd', 'pd.InternalPVID=pv.InternalPVID', 'left')
|
|
||||||
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
|
||||||
->get()->getResultArray();
|
|
||||||
|
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
|
|||||||
@ -13,11 +13,12 @@ class CreatePVTables extends Migration {
|
|||||||
'PVID' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
'PVID' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
||||||
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'EpisodeID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'EpisodeID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
|
'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
||||||
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
||||||
$this->forge->addKey('InternalPVID', true);
|
$this->forge->addKey('InternalPVID', true);
|
||||||
$this->forge->addUniqueKey('PVID');
|
$this->forge->addUniqueKey('PVID');
|
||||||
$this->forge->createTable('patvisit');
|
$this->forge->createTable('patvisit');
|
||||||
@ -28,11 +29,11 @@ class CreatePVTables extends Migration {
|
|||||||
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'DiagCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'DiagCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'Diagnosis' => ['type' => 'TEXT', 'null' => true],
|
'Diagnosis' => ['type' => 'TEXT', 'null' => true],
|
||||||
|
'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'ArchivedDate' => ['type' => 'DATETIME', 'null' => true],
|
'ArchivedDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
||||||
$this->forge->addKey('InternalPVID', true);
|
$this->forge->addKey('InternalPVID', true);
|
||||||
$this->forge->createTable('patdiag');
|
$this->forge->createTable('patdiag');
|
||||||
|
|
||||||
@ -46,11 +47,11 @@ class CreatePVTables extends Migration {
|
|||||||
'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
|
'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
||||||
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
]);
|
]);
|
||||||
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
||||||
$this->forge->addKey('PVADTID', true);
|
$this->forge->addKey('PVADTID', true);
|
||||||
$this->forge->createTable('patvisitadt');
|
$this->forge->createTable('patvisitadt');
|
||||||
|
|
||||||
@ -74,8 +75,8 @@ class CreatePVTables extends Migration {
|
|||||||
'EventID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'EventID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'ActivityID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'ActivityID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'Reason' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'Reason' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
|
'LogDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP'
|
||||||
]);
|
]);
|
||||||
$this->forge->addField('LogDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
||||||
$this->forge->addKey('PatVisLogID', true);
|
$this->forge->addKey('PatVisLogID', true);
|
||||||
$this->forge->createTable('patvisitlog');
|
$this->forge->createTable('patvisitlog');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,8 +37,8 @@ class CreateContactTable extends Migration {
|
|||||||
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'ContactStartDate' => [ 'type' => 'DATE', 'null' => true ],
|
'ContactStartDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
'ContactEndDate' => [ 'type' => 'DATE', 'null' => true ],
|
'ContactEndDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('ContactDetID', true);
|
$this->forge->addKey('ContactDetID', true);
|
||||||
$this->forge->addUniqueKey(['SiteID','ContactID']);
|
$this->forge->addUniqueKey(['SiteID','ContactID']);
|
||||||
@ -50,8 +50,8 @@ class CreateContactTable extends Migration {
|
|||||||
'AbbTex' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
|
'AbbTex' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
|
||||||
'FullText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
'FullText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
||||||
'Description' => [ 'type' => 'TEXT', 'null' => true ],
|
'Description' => [ 'type' => 'TEXT', 'null' => true ],
|
||||||
|
'CreateDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
||||||
]);
|
]);
|
||||||
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
||||||
$this->forge->addKey('OccupationID', true);
|
$this->forge->addKey('OccupationID', true);
|
||||||
$this->forge->createTable('occupation');
|
$this->forge->createTable('occupation');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,32 +18,40 @@ class ContactModel extends Model {
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getContacts() {
|
||||||
|
$rows = $this->select("ContactID, NameFirst, NameLast, Title, Initial, Specialty")->get()->getResultArray();
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
public function getContactWithDetail($ContactID) {
|
public function getContactWithDetail($ContactID) {
|
||||||
$rows = $this->where('contact.ContactID', $ContactID)->join('contactdetail cd', 'contact.ContactID=cd.ContactID','left')->get()->getResultArray();
|
$rows = $this->where('contact.ContactID', $ContactID)->join('contactdetail cd', 'contact.ContactID=cd.ContactID','left')->get()->getResultArray();
|
||||||
$contact = [
|
$contact = [];
|
||||||
'ContactID' => $rows[0]['ContactID'],
|
|
||||||
'NameFirst' => $rows[0]['NameFirst'] ?? null,
|
|
||||||
'NameLast' => $rows[0]['NameLast'] ?? null,
|
|
||||||
'Title' => $rows[0]['Title'] ?? null,
|
|
||||||
'Initial' => $rows[0]['Initial'] ?? null,
|
|
||||||
'Birthdate' => $rows[0]['Birthdate'] ?? null,
|
|
||||||
'EmailAddress1' => $rows[0]['EmailAddress1'] ?? null,
|
|
||||||
'EmailAddress2' => $rows[0]['EmailAddress2'] ?? null,
|
|
||||||
'Phone' => $rows[0]['Phone'] ?? null,
|
|
||||||
'MobilePhone1' => $rows[0]['MobilePhone1'] ?? null,
|
|
||||||
'MobilePhone2' => $rows[0]['MobilePhone2'] ?? null,
|
|
||||||
'Specialty' => $rows[0]['Specialty'] ?? null,
|
|
||||||
'SubSpecialty' => $rows[0]['SubSpecialty'] ?? null,
|
|
||||||
'Details' => []
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
|
if(empty($contact['NameFirst'])) {
|
||||||
|
$contact = [
|
||||||
|
'ContactID' => $ContactID,
|
||||||
|
'NameFirst' => $row['NameFirst'] ?? null,
|
||||||
|
'NameLast' => $row['NameLast'] ?? null,
|
||||||
|
'Title' => $row['Title'] ?? null,
|
||||||
|
'Initial' => $row['Initial'] ?? null,
|
||||||
|
'Birthdate' => $row['Birthdate'] ?? null,
|
||||||
|
'EmailAddress1' => $row['EmailAddress1'] ?? null,
|
||||||
|
'EmailAddress2' => $row['EmailAddress2'] ?? null,
|
||||||
|
'Phone' => $row['Phone'] ?? null,
|
||||||
|
'MobilePhone1' => $row['MobilePhone1'] ?? null,
|
||||||
|
'MobilePhone2' => $row['MobilePhone2'] ?? null,
|
||||||
|
'Specialty' => $row['Specialty'] ?? null,
|
||||||
|
'SubSpecialty' => $row['SubSpecialty'] ?? null,
|
||||||
|
'Details' => []
|
||||||
|
];
|
||||||
|
}
|
||||||
if (!empty($row['ContactDetID'])) {
|
if (!empty($row['ContactDetID'])) {
|
||||||
$contact['Details'][] = [
|
$contact['Details'][] = [
|
||||||
'SiteID' => $row['SiteID'] ?? null,
|
'SiteID' => $row['SiteID'] ?? null,
|
||||||
'ContactDetID' => $row['ContactDetID'],
|
'ContactDetID' => $row['ContactDetID'],
|
||||||
'ContactCode' => $row['ContactCode'] ?? null,
|
'ContactCode' => $row['ContactCode'] ?? null,
|
||||||
'ContactEmail' => $row['DetailPhone'] ?? null,
|
'ContactEmail' => $row['ContactEmail'] ?? null,
|
||||||
'OccupationID' => $row['OccupationID'] ?? null,
|
'OccupationID' => $row['OccupationID'] ?? null,
|
||||||
'JobTitle' => $row['JobTitle'] ?? null,
|
'JobTitle' => $row['JobTitle'] ?? null,
|
||||||
'Department' => $row['Department'] ?? null,
|
'Department' => $row['Department'] ?? null,
|
||||||
|
|||||||
39
app/Models/PatVisitModel.php
Normal file
39
app/Models/PatVisitModel.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class PatVisitModel extends Model {
|
||||||
|
protected $table = 'patvisit';
|
||||||
|
protected $primaryKey = 'InternalPVID';
|
||||||
|
protected $allowedFields = ['PVID', 'InternalPID', 'EpisodeID', 'EndDate'];
|
||||||
|
|
||||||
|
protected $useTimestamps = true;
|
||||||
|
protected $dateFormat = 'datetime';
|
||||||
|
protected $createdField = 'CreateDate';
|
||||||
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
|
public function show($PVID) {
|
||||||
|
$rows = $this->join('patdiag pd', 'pd.InternalPVID=pv.InternalPVID', 'left')
|
||||||
|
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
||||||
|
->where('PVID',$PVID)->get()->getResultArray();
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function use($CounterID) {
|
||||||
|
$row = $this->where('CounterID',$CounterID)->get()->getResultArray();
|
||||||
|
$cValue = $row[0]['CounterValue'];
|
||||||
|
$cStart = $row[0]['CounterStart'];
|
||||||
|
$cEnd = $row[0]['CounterEnd'];
|
||||||
|
$cReset = $row[0]['CounterReset'];
|
||||||
|
$cPad = strlen((string)$cEnd);
|
||||||
|
// next value > end, back to start
|
||||||
|
if($cValue > $cEnd) { $cValue = $cStart; }
|
||||||
|
$cnum = str_pad($cValue, $cPad, "0", STR_PAD_LEFT);
|
||||||
|
$cValue_next = $cValue+1;
|
||||||
|
$this->set('CounterValue', $cValue_next)->where('CounterID',$CounterID)->update();
|
||||||
|
return $cnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user