Update perbaikan patient deathdatetime dan faker patient
This commit is contained in:
parent
76d34ac899
commit
ca19ab35c1
@ -8,6 +8,9 @@ use CodeIgniter\Router\RouteCollection;
|
|||||||
$routes->options('(:any)', function() { return ''; });
|
$routes->options('(:any)', function() { return ''; });
|
||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
|
|
||||||
|
// Faker
|
||||||
|
$routes->get('faker/faker-patient/(:num)', 'faker\FakerPatient::sendMany/$1');
|
||||||
|
|
||||||
$routes->group('api', ['filter' => 'auth'], function($routes) {
|
$routes->group('api', ['filter' => 'auth'], function($routes) {
|
||||||
$routes->get('dashboard', 'Dashboard::index');
|
$routes->get('dashboard', 'Dashboard::index');
|
||||||
$routes->get('result', 'Result::index');
|
$routes->get('result', 'Result::index');
|
||||||
|
|||||||
153
app/Controllers/faker/FakerPatient.php
Normal file
153
app/Controllers/faker/FakerPatient.php
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers\faker;
|
||||||
|
|
||||||
|
use App\Controllers\BaseController;
|
||||||
|
use Faker\Factory;
|
||||||
|
use CodeIgniter\HTTP\CURLRequest;
|
||||||
|
|
||||||
|
class FakerPatient extends BaseController
|
||||||
|
{
|
||||||
|
// public function send()
|
||||||
|
// {
|
||||||
|
// $faker = Factory::create('id_ID');
|
||||||
|
|
||||||
|
// // generate data dummy sesuai struktur JSON kamu
|
||||||
|
// $data = [
|
||||||
|
// "PatientID" => "P" . str_pad($faker->randomNumber(5), 7, "0", STR_PAD_LEFT),
|
||||||
|
// "AlternatePID" => "ALT" . $faker->unique()->numerify('######'),
|
||||||
|
// "Prefix" => $faker->title,
|
||||||
|
// "NameFirst" => $faker->firstName,
|
||||||
|
// "NameMiddle" => $faker->firstName,
|
||||||
|
// "NameMaiden" => $faker->firstName,
|
||||||
|
// "NameLast" => $faker->lastName,
|
||||||
|
// "Suffix" => "S.Kom",
|
||||||
|
// "NameAlias" => $faker->userName,
|
||||||
|
// "Gender" => $faker->numberBetween(1, 9),
|
||||||
|
// "PlaceOfBirth" => $faker->city,
|
||||||
|
// "Birthdate" => $faker->date('Y-m-d'),
|
||||||
|
// "ZIP" => $faker->postcode,
|
||||||
|
// "Street_1" => $faker->streetAddress,
|
||||||
|
// "Street_2" => "RT " . $faker->numberBetween(1, 10) . " RW " . $faker->numberBetween(1, 10),
|
||||||
|
// "Street_3" => "Blok " . $faker->numberBetween(1, 20),
|
||||||
|
// "City" => $faker->city,
|
||||||
|
// "Province" => $faker->state,
|
||||||
|
// "EmailAddress1" => $faker->unique()->safeEmail,
|
||||||
|
// "EmailAddress2" => $faker->unique()->safeEmail,
|
||||||
|
// "Phone" => $faker->phoneNumber,
|
||||||
|
// "MobilePhone" => $faker->phoneNumber,
|
||||||
|
// "Race" => (string) $faker->numberBetween(100, 200),
|
||||||
|
// "Country" => (string) $faker->numberBetween(300, 400),
|
||||||
|
// "MaritalStatus" => (string) $faker->numberBetween(10, 20),
|
||||||
|
// "Religion" => (string) $faker->numberBetween(200, 210),
|
||||||
|
// "Ethnic" => (string) $faker->numberBetween(210, 220),
|
||||||
|
// "Citizenship" => "WNI",
|
||||||
|
// "DeathIndicator" => (string) $faker->numberBetween(10, 20),
|
||||||
|
// "DeathDateTime" => $faker->date('Y-m-d H:i:s'),
|
||||||
|
// "LinkTo" => (string) $faker->numberBetween(1, 5),
|
||||||
|
// "Custodian" => (string) $faker->numberBetween(1, 5),
|
||||||
|
// "PatIdt" => [
|
||||||
|
// "IdentifierType" => "KTP",
|
||||||
|
// "Identifier" => $faker->nik(), // bisa pakai ekstensi faker-ktp, kalau tidak pakai randomNumber
|
||||||
|
// ],
|
||||||
|
// "PatAtt" => [
|
||||||
|
// [ "Address" => "/api/upload/" . $faker->word . ".jpg" ]
|
||||||
|
// ],
|
||||||
|
// "PatCom" => $faker->sentence,
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// // pakai CURL bawaan CI4 untuk POST ke API
|
||||||
|
// $client = service('curlrequest');
|
||||||
|
// $response = $client->post(
|
||||||
|
// base_url('/api/patient'), // endpoint kamu
|
||||||
|
// [
|
||||||
|
// 'headers' => [
|
||||||
|
// 'Content-Type' => 'application/json'
|
||||||
|
// ],
|
||||||
|
// 'body' => json_encode($data)
|
||||||
|
// ]
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // balikan response dari API kamu
|
||||||
|
// return $this->response->setJSON([
|
||||||
|
// 'status' => 'sent',
|
||||||
|
// // 'request' => $data,
|
||||||
|
// // 'response' => json_decode($response->getBody(), true),
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function sendMany($count = 2) // default 10 data
|
||||||
|
{
|
||||||
|
$faker = Factory::create('id_ID');
|
||||||
|
$client = service('curlrequest');
|
||||||
|
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
for ($i = 0; $i < $count; $i++) {
|
||||||
|
$data = [
|
||||||
|
"PatientID" => "P" . (string) $i,
|
||||||
|
"AlternatePID" => "ALT" . (string) $i,
|
||||||
|
"Prefix" => $faker->title,
|
||||||
|
"NameFirst" => $faker->firstName,
|
||||||
|
"NameMiddle" => $faker->firstName,
|
||||||
|
"NameMaiden" => $faker->firstName,
|
||||||
|
"NameLast" => $faker->lastName,
|
||||||
|
"Suffix" => "S.Kom",
|
||||||
|
"NameAlias" => $faker->userName,
|
||||||
|
"Gender" => $faker->numberBetween(5, 6),
|
||||||
|
"PlaceOfBirth" => $faker->city,
|
||||||
|
"Birthdate" => $faker->date('Y-m-d'),
|
||||||
|
"ZIP" => $faker->postcode,
|
||||||
|
"Street_1" => $faker->streetAddress,
|
||||||
|
"Street_2" => "RT " . $faker->numberBetween(1, 10) . " RW " . $faker->numberBetween(1, 10),
|
||||||
|
"Street_3" => "Blok " . $faker->numberBetween(1, 20),
|
||||||
|
"City" => $faker->city,
|
||||||
|
"Province" => $faker->state,
|
||||||
|
"EmailAddress1" => "A" . (string)$i.'@gmail.com',
|
||||||
|
"EmailAddress2" => "B" . (string)$i.'@gmail.com',
|
||||||
|
"Phone" => $faker->phoneNumber,
|
||||||
|
"MobilePhone" => $faker->phoneNumber,
|
||||||
|
"Race" => (string) $faker->numberBetween(100, 200),
|
||||||
|
"Country" => (string) $faker->numberBetween(300, 400),
|
||||||
|
"MaritalStatus" => (string) $faker->numberBetween(10, 20),
|
||||||
|
"Religion" => (string) $faker->numberBetween(200, 210),
|
||||||
|
"Ethnic" => (string) $faker->numberBetween(210, 220),
|
||||||
|
"Citizenship" => "WNI",
|
||||||
|
"DeathIndicator" => (string) $faker->numberBetween(10, 20),
|
||||||
|
"DeathDateTime" => $faker->date('Y-m-d H:i:s'),
|
||||||
|
"LinkTo" => (string) $faker->numberBetween(1, 5),
|
||||||
|
"Custodian" => '1',
|
||||||
|
"PatIdt" => [
|
||||||
|
"IdentifierType" => "KTP",
|
||||||
|
"Identifier" => $faker->nik() ?? $faker->numerify('################')
|
||||||
|
],
|
||||||
|
"PatAtt" => [
|
||||||
|
[ "Address" => "/api/upload/" . $faker->word . ".jpg" ]
|
||||||
|
],
|
||||||
|
"PatCom" => $faker->sentence,
|
||||||
|
];
|
||||||
|
|
||||||
|
// kirim ke API patient
|
||||||
|
$response = $client->post(
|
||||||
|
base_url('/api/patient'),
|
||||||
|
[
|
||||||
|
'headers' => [
|
||||||
|
'Content-Type' => 'application/json'
|
||||||
|
],
|
||||||
|
'body' => json_encode($data)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$results[] = [
|
||||||
|
'request' => $data,
|
||||||
|
'response' => json_decode($response->getBody(), true),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => 'success',
|
||||||
|
'count' => $count,
|
||||||
|
'data' => $results
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -284,6 +284,7 @@ class PatientModel extends Model {
|
|||||||
// $patient["CreateDate"] = $this->formatedDate($patient["CreateDate"]);
|
// $patient["CreateDate"] = $this->formatedDate($patient["CreateDate"]);
|
||||||
// $patient["DelDate"] = $this->formatedDate($patient["DelDate"]);
|
// $patient["DelDate"] = $this->formatedDate($patient["DelDate"]);
|
||||||
$patient["DeathDateTime"] = $this->formattedDate($patient["DeathDateTime"]);
|
$patient["DeathDateTime"] = $this->formattedDate($patient["DeathDateTime"]);
|
||||||
|
$patient["CreateDate"] = $this->formattedDate($patient["CreateDate"]);
|
||||||
$patient["BirthdateConversion"] = $this->formatedDateForDisplay($patient["Birthdate"]);
|
$patient["BirthdateConversion"] = $this->formatedDateForDisplay($patient["Birthdate"]);
|
||||||
$patient["LinkTo"] = $this->getLinkedPatients($patient['LinkTo']);
|
$patient["LinkTo"] = $this->getLinkedPatients($patient['LinkTo']);
|
||||||
$patient["Custodian"] = $this->getCustodian($patient['Custodian']);
|
$patient["Custodian"] = $this->getCustodian($patient['Custodian']);
|
||||||
@ -384,6 +385,7 @@ class PatientModel extends Model {
|
|||||||
|
|
||||||
// Preventif 0000-00-00
|
// Preventif 0000-00-00
|
||||||
private function isValidDateTime($datetime) {
|
private function isValidDateTime($datetime) {
|
||||||
|
if (empty($datetime) || $datetime=="") {return null; }
|
||||||
try {
|
try {
|
||||||
// Kalau input hanya Y-m-d (tanpa jam)
|
// Kalau input hanya Y-m-d (tanpa jam)
|
||||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $datetime)) {
|
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $datetime)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user