Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…lektronik into klaim
  • Loading branch information
dmsadjt committed Jul 24, 2024
2 parents a659f65 + 9d20a31 commit 933d3ee
Show file tree
Hide file tree
Showing 29 changed files with 498 additions and 380 deletions.
12 changes: 0 additions & 12 deletions app/Http/Controllers/ExpertSystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ public function kategoriUmur($id){
}
}

// public function getAlergi($id){
// $alergi =FhirResource::where('resourceType', 'AllergyIntolerance')
// ->where('encounter.reference', 'Encounter/'.$id)
// ->where('category', 'medication')
// ->get();

// $result = $alergi->map(function ($item) {
// return data_get($item, 'code.coding.0.display');
// })->toArray();
// return $result;
// }

public function rulePeresepanStore($id){
try {
DB::beginTransaction();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/MedicationDispense.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function show($medicationReq_id)
return [$data, $medicationReq];

} catch (\Throwable $th) {
Log::error($th->getMessage());
\Log::error($th->getMessage());
return response()->json([
'error' => 'Data tidak ditemukan',
'message' => $th->getMessage()
Expand Down
14 changes: 0 additions & 14 deletions app/Http/Controllers/MedicineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,12 @@ public function index(Request $request)
$sort = $request->query('sort', 'updated_at');
$direction = $request->query('direction', 'asc');

// Log the search query, page number, sort column, and sort direction
Log::info('Search query:', ['search' => $search]);
Log::info('Page number:', ['page' => $page]);
Log::info('Sort column:', ['sort' => $sort]);
Log::info('Sort direction:', ['direction' => $direction]);

// Get the paginated and sorted results
$medicines = Medicine::where('name', 'like', "%{$search}%")
->orWhere('medicine_code', 'like', "%{$search}%")
->orderBy($sort, $direction)
->paginate(10);

// Log the paginated and sorted results
Log::info('Paginated and sorted results:', ['medicines' => $medicines]);

// Return JSON response with paginated medicines
return response()->json($medicines);
}

Expand Down Expand Up @@ -64,18 +54,14 @@ public function store(Request $request)
'prices.treatment_price_9' => 'numeric',
]);

// Generate a unique ID for the document
$validatedData['_id'] = Str::uuid();

// Set the created_at and updated_at fields
$validatedData['created_at'] = now();
$validatedData['updated_at'] = now();

// Encode the ingredients and prices arrays to JSON
$validatedData['ingredients'] = json_encode($validatedData['ingredients']);
$validatedData['prices'] = json_encode($validatedData['prices']);

// Create the Medicine document
$medicine = Medicine::create($validatedData);

return response()->json($medicine, 201);
Expand Down
27 changes: 2 additions & 25 deletions app/Http/Controllers/MedicineTransactionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ public function store(Request $request)
'note' => $request->input('note'),
]);

// Kurangi quantity pada Medicine
$medicine->quantity += intval($request->input('quantity'));
$medicine->save();

return;
// return response()->json($medicinetransaction, 201);
} catch (ModelNotFoundException $e) {
return response()->json([
'error' => 'Medicine tidak ditemukan',
Expand All @@ -83,38 +81,30 @@ public function store(Request $request)
'message' => $th->getMessage()
], 500);
}
}


}

public function update(Request $request, $id)
{
try {

$medicineTransaction = MedicineTransaction::findOrFail($id);

// Ambil medicine berdasarkan id_medicine yang baru
$medicine = Medicine::findOrFail($medicineTransaction->id_medicine);
$medicine->quantity += $medicineTransaction->quantity;
$medicine->save();

// Update atribut-atribut yang dibutuhkan
$medicineTransaction->id_transaction = $request->input('id_transaction');
$medicineTransaction->id_medicine = $request->input('id_medicine');
$medicineTransaction->quantity = intval($request->input('quantity'));
$medicineTransaction->note = $request->input('note');

// Simpan perubahan
$medicineTransaction->save();

// Kurangi quantity pada Medicine
$medicine = Medicine::findOrFail($request->input('id_medicine'));
$medicine->quantity -= intval($request->input('quantity'));
$medicine->save();
// Jika ada pengubahan quantity, proses juga pengurangan atau penambahan pada Medicine sesuai kebutuhan bisnis

return Inertia::location(route('medicinetransaction'));
// return response()->json($medicineTransaction, 200);
} catch (ModelNotFoundException $e) {
return response()->json([
'error' => 'Medicine Transaction tidak ditemukan',
Expand All @@ -132,32 +122,25 @@ public function update(Request $request, $id)
public function destroy(Request $request, $id)
{
try {
// Temukan MedicineTransaction yang akan dihapus
$medicineTransaction = MedicineTransaction::findOrFail($id);

// Pastikan user yang sedang login memiliki izin untuk menghapus transaksi
if ($request->user()->id != $medicineTransaction->user_id) {
// Hapus MedicineTransaction
MedicineTransaction::destroy($id);

// Update quantity pada Medicine terkait
$medicine = Medicine::findOrFail($medicineTransaction->id_medicine);
$medicine->quantity += $medicineTransaction->quantity; // Tambahkan quantity yang dihapus
$medicine->quantity += $medicineTransaction->quantity;
$medicine->save();

return Inertia::location(route('medicinetransaction'));
} else {
// Jika user mencoba menghapus transaksi sendiri, kembalikan pesan error
return response()->json('Tidak dapat menghapus transaksi Anda sendiri', 403);
}
} catch (ModelNotFoundException $e) {
// Tangkap error jika MedicineTransaction tidak ditemukan
return response()->json([
'error' => 'MedicineTransaction tidak ditemukan',
'message' => $e->getMessage()
], 404);
} catch (\Throwable $th) {
// Tangkap error umum
Log::error($th->getMessage());
return response()->json([
'error' => 'Gagal menghapus MedicineTransaction',
Expand All @@ -166,12 +149,6 @@ public function destroy(Request $request, $id)
}
}


// public function getRoles()
// {
// return Role::all()->pluck('name');
// }

public function getmedicine(Request $request)
{
$search = $request->query('search');
Expand Down
9 changes: 9 additions & 0 deletions app/Http/Controllers/ObatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public function getRequestStock(Request $request){
$query->where('code.code_kfa', 'like', '%' . addcslashes($code, '%_') . '%');
}

if ($request->query('prioritas')) {
$prioritas = $request->query('prioritas');
$query->where('prioritas', 'like', '%' . addcslashes($prioritas, '%_') . '%');
}

$datas = $query->paginate(15)->withQueryString();
$formattedDatas = $datas->map(function ($data) {
//tambahan
Expand All @@ -78,6 +83,10 @@ public function getRequestStock(Request $request){
return [
'code' => data_get($data, 'code.code_kfa'),
'name' => data_get($data, 'code.display'),
'stok' => data_get($data, 'stok'),
'satuan' => data_get($data, 'satuan'),
'prioritas' => data_get($data, 'prioritas'),
'note' => data_get($data, 'note'),
'opsi' => $opsi,
];
});
Expand Down
10 changes: 9 additions & 1 deletion app/Http/Controllers/RequestStockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ public function store(Request $request)
$validatedData = $request->validate([
'code.code_kfa' => 'required',
'code.display' => 'required',
'prioritas' => 'required|string',
'stok' => 'required|integer',
'satuan' => 'required|string',
'note' => 'nullable|string'
]);
try {
DB::beginTransaction();
$created = RequestStock::create([
'code' => [
'code_kfa' => $validatedData['code']['code_kfa'],
'display' => $validatedData['code']['display'],
]
],
'prioritas' => $validatedData['prioritas'],
'stok' => $validatedData['stok'],
'satuan' => $validatedData['satuan'],
'note' => $validatedData['note']
]);
DB::commit();
return response()->json(['message' => 'Data stored successfully'], 201);
Expand Down
14 changes: 0 additions & 14 deletions app/Models/MedicineTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,5 @@ public function medicine()
{
return $this->belongsTo(Medicine::class, 'id_medicine');
}

/**
* Scope a query to filter by medicine name.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $name
* @return \Illuminate\Database\Eloquent\Builder
*/
// public function scopeWhereMedicineName($query, $name)
// {
// return $query->whereHas('medicine', function ($query) use ($name) {
// $query->where('name', 'like', '%' . addcslashes($name, '%_') . '%');
// });
// }
}

2 changes: 1 addition & 1 deletion app/Models/RequestStock.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class RequestStock extends Model
use HasFactory;
protected $connection = 'mongodb';
protected $collection = 'request_stock';
// protected $fillable = ['code_kfa', 'display'];
protected $guarded = [];
}

2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-fpm
FROM php:8.0-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y \
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added rekam-medis-elektronik.zip
Binary file not shown.
7 changes: 0 additions & 7 deletions resources/js/Components/LineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,25 @@ const props = defineProps({
});
const trimData = (data) => {
// Trim trailing null values
for (let i = data.length - 1; i >= 0; i--) {
if (data[i] === null) {
data.pop();
} else {
break;
}
}
// Ensure maximum of 12 values
return data.slice(0, 12);
};
const mergedSeries = computed(() => {
const merged = [];
// Combine original series with forecast data
props.series.forEach(originalSeries => {
const targetSeries = {
name: originalSeries.name,
data: originalSeries.data.map(value => (value === 0 ? null : value))
};
// Check if there is forecast data for this series
const forecastData = props.forecastSeries?.find(forecast => forecast.name === originalSeries.name);
if (forecastData) {
forecastData.data.forEach((value, index) => {
Expand All @@ -57,7 +53,6 @@ const mergedSeries = computed(() => {
});
});
// Add any forecast series that do not have a corresponding original series
props.forecastSeries?.forEach(forecast => {
if (!merged.find(series => series.name === forecast.name)) {
merged.push({
Expand All @@ -67,8 +62,6 @@ const mergedSeries = computed(() => {
}
});
console.log("Merged Series Data:", merged);
return merged;
});
</script>
6 changes: 2 additions & 4 deletions resources/js/Layouts/AuthenticatedLayoutNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,14 @@ import NavLink from '@/Components/NavLink.vue';
</ResponsiveNavLink>
<ResponsiveNavLink :href="route('rekammedis')" :active="route().current('rekammedis')"> Rekam Medis
</ResponsiveNavLink>
<ResponsiveNavLink v-if="$page.props.auth.user.roles[0].name === 'admin'" :href="route('usermanagement')"
:active="route().current('usermanagement')"> User Management </ResponsiveNavLink>
<ResponsiveNavLink :href="route('usermanagement')" :active="route().current('usermanagement')"> User
Management </ResponsiveNavLink>
<ResponsiveNavLink :href="route('medicinetransaction')" :active="route().current('medicinetransaction')">
Transaksi </ResponsiveNavLink>
<ResponsiveNavLink v-if="$page.props.auth.user.roles[0].name === 'admin'" :href="route('usermanagement')"
:active="route().current('usermanagement')"> User Management </ResponsiveNavLink>
<ResponsiveNavLink :href="route('medication')" :active="route().current('medication')">Medication
</ResponsiveNavLink>
<!-- <ResponsiveNavLink :href="route('expertsystems.index')" :active="route().current('expertsystems.index')">
Expert Systems</ResponsiveNavLink> -->
<ResponsiveNavLink :href="route('finance')" :active="route().current('finance')">Finance</ResponsiveNavLink>
</template>
</AuthenticatedLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<template>
<div class="mt-2">
<table v-if="expertSystem && expertSystem.length && expertSystem[0].length" class="w-full text-left rtl:text-right text-neutral-grey-200 ">
<thead class="text-neutral-black-300 uppercase bg-gray-50 border-b">
<thead class="text-neutral-black-300 uppercase bg-gray-50">
<tr>

<th scope="col" class="px-3 py-2 w-4/6 border">Nama</th>
<th scope="col" class="px-3 py-2 w-2/6 border">Instruksi</th>
<th scope="col" class="px-3 py-2 w-4/6 ">Nama</th>
<th scope="col" class="px-3 py-2 w-2/6">Instruksi Dosis</th>
</tr>
</thead>
<tbody>
<template v-for="(group, index) in expertSystem" :key="index">
<tr v-for="(medicine, i) in group" :key="i" class="bg-original-white-0 ">

<td class="px-3 py-1 w-4/6 border">{{ medicine.display }}</td>
<td class="px-3 py-1 w-2/6 border">{{ medicine.dosageInstruction }}</td>
<td class="px-3 py-1 w-4/6">{{ medicine.display }}</td>
<td class="px-3 py-1 w-2/6">{{ medicine.dosageInstruction }}</td>
<hr>
</tr>

</template>
</tbody>
</table>
Expand Down
Loading

0 comments on commit 933d3ee

Please sign in to comment.