first commit
This commit is contained in:
65
lib/screen/registrasi/delete_patient_provider copy.dart
Normal file
65
lib/screen/registrasi/delete_patient_provider copy.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:mitra_corporate/repository/patient_repository.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class DeletePatientProviderState extends Equatable {
|
||||
final DateTime date;
|
||||
const DeletePatientProviderState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class DeletePatientProviderStateInit extends DeletePatientProviderState {
|
||||
DeletePatientProviderStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DeletePatientProviderStateLoading extends DeletePatientProviderState {
|
||||
DeletePatientProviderStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DeletePatientProviderStateError extends DeletePatientProviderState {
|
||||
final String message;
|
||||
DeletePatientProviderStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class DeletePatientProviderStateDone extends DeletePatientProviderState {
|
||||
final String msg;
|
||||
DeletePatientProviderStateDone({
|
||||
required this.msg,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class DeletePatientProviderNotifier
|
||||
extends StateNotifier<DeletePatientProviderState> {
|
||||
final Ref ref;
|
||||
DeletePatientProviderNotifier({
|
||||
required this.ref,
|
||||
}) : super(DeletePatientProviderStateInit());
|
||||
|
||||
void DeletePatent({required String patient_id, required String token}) async {
|
||||
try {
|
||||
state = DeletePatientProviderStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await PatientRepository(dio: dio)
|
||||
.deletePatient(patient_id: patient_id, token: token);
|
||||
state = DeletePatientProviderStateDone(msg: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = DeletePatientProviderStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = DeletePatientProviderStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final DeletePatientProvider = StateNotifierProvider<
|
||||
DeletePatientProviderNotifier, DeletePatientProviderState>(
|
||||
(ref) => DeletePatientProviderNotifier(ref: ref));
|
||||
156
lib/screen/registrasi/dialog_delete_patient.dart
Normal file
156
lib/screen/registrasi/dialog_delete_patient.dart
Normal file
@@ -0,0 +1,156 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
|
||||
class DialogDeletePatient extends StatelessWidget {
|
||||
const DialogDeletePatient(
|
||||
{super.key,
|
||||
required this.NIK,
|
||||
required this.delete,
|
||||
required this.patientID,
|
||||
required this.loading,
|
||||
required this.name});
|
||||
|
||||
final String name;
|
||||
final String NIK;
|
||||
final Function delete;
|
||||
final String patientID;
|
||||
final bool loading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
titlePadding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 24),
|
||||
vertical: Constant.getActualY(context: context, y: 24)),
|
||||
actionsPadding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 24),
|
||||
vertical: Constant.getActualY(context: context, y: 24)),
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 24),
|
||||
vertical: Constant.getActualY(context: context, y: 24)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
title: Text(
|
||||
'Konfirmasi hapus',
|
||||
style: Constant.h4_600(context: context),
|
||||
),
|
||||
content: Container(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: Constant.getActualY(context: context, y: 100),
|
||||
maxHeight: Constant.getActualY(context: context, y: 362),
|
||||
),
|
||||
height: Constant.getActualY(context: context, y: 240),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'Anda yakin menghapus pasien berikut ?',
|
||||
style: Constant.body1_600(context: context),
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 24),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 416),
|
||||
child: Card(
|
||||
elevation: 1,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: Constant.grey_200),
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
Constant.getActualX(context: context, x: 24),
|
||||
vertical:
|
||||
Constant.getActualY(context: context, y: 24)),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
"NIK",
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: Text(
|
||||
NIK,
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textBlack),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
Constant.getActualY(context: context, y: 12),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Text(
|
||||
"Nama",
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: Text(
|
||||
name,
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textBlack),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
actions: <Widget>[
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
surfaceTintColor: Constant.primaryBlue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: !loading ? () => Navigator.pop(context, 'Batal') : null,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: loading
|
||||
? LoadingAnimationWidget.staggeredDotsWave(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: Text('Batal',
|
||||
style: Constant.button_medium(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: !loading ? () => delete(patientID) : null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: loading
|
||||
? LoadingAnimationWidget.staggeredDotsWave(
|
||||
color: Colors.white, size: 20)
|
||||
: Text(
|
||||
'Yakin',
|
||||
style: Constant.button_medium(context: context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
951
lib/screen/registrasi/dialog_edit_patient.dart
Normal file
951
lib/screen/registrasi/dialog_edit_patient.dart
Normal file
@@ -0,0 +1,951 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/edit_patient_provider.dart';
|
||||
import 'package:age_calculator/age_calculator.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../model/registration_model.dart';
|
||||
import '../../provider/auth_provider.dart';
|
||||
import '../../widgets/custom_snackbar_widget.dart';
|
||||
import '../../widgets/custom_text_field.dart';
|
||||
import 'get_filter_provider.dart';
|
||||
|
||||
class DialogEditPatient extends HookConsumerWidget {
|
||||
const DialogEditPatient({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tempPatient = ref.watch(registrationEditPatientProvider);
|
||||
final auth = ref.watch(authProvider);
|
||||
//withoutnik apabila tanpa nik maka true
|
||||
final withoutNIK = useState(false);
|
||||
final getFilterLoading = useState(false);
|
||||
final sapaanKey = useState(1);
|
||||
final genderKey = useState(1000);
|
||||
final prefixCtr = useTextEditingController(text: "");
|
||||
final nameCtr = useTextEditingController(text: "");
|
||||
final suffixCtr = useTextEditingController(text: "");
|
||||
final nikCtr = useTextEditingController(text: "");
|
||||
final nipCtr = useTextEditingController(text: "");
|
||||
final hpCtr = useTextEditingController(text: "");
|
||||
final noRmCtr = useTextEditingController(text: "");
|
||||
final addressCtr = useTextEditingController(text: "");
|
||||
final diagnosisCtr = useTextEditingController(text: "");
|
||||
final noteCtr = useTextEditingController(text: "");
|
||||
final jabatanCtr = useTextEditingController(text: "");
|
||||
final kedudukanCtr = useTextEditingController(text: "");
|
||||
final lokasiCtr = useTextEditingController(text: "");
|
||||
final pekerjaanCtr = useTextEditingController(text: "");
|
||||
final sapaan = useState<List<CustomDropDownModel>>(List.empty());
|
||||
final selectedSaluation = useState(CustomDropDownModel());
|
||||
final gender = useState<List<CustomDropDownModel>>(List.empty());
|
||||
final selectedGender = useState(CustomDropDownModel());
|
||||
final editLoading = useState(false);
|
||||
//select salah satu sapaan
|
||||
onSelectSaluation(CustomDropDownModel value) {
|
||||
selectedSaluation.value = value;
|
||||
selectedGender.value =
|
||||
gender.value.firstWhere((element) => element.id == value.type);
|
||||
|
||||
genderKey.value = genderKey.value + 1;
|
||||
// sapaanKey.value = sapaanKey.value + 1;
|
||||
}
|
||||
|
||||
//update gender saat sapaan dipilih
|
||||
selectedSaluation.addListener(() {
|
||||
selectedGender.value = gender.value
|
||||
.firstWhere((element) => element.id == selectedSaluation.value.type);
|
||||
genderKey.value = genderKey.value + 1;
|
||||
});
|
||||
|
||||
//select gender
|
||||
onSelectGender(CustomDropDownModel value) {
|
||||
selectedGender.value = value;
|
||||
}
|
||||
|
||||
final dobRb = useState('date');
|
||||
final dobCtr = useTextEditingController(
|
||||
text: DateFormat('dd-MM-yyyy').format(DateTime.now()));
|
||||
final dobState = useState(DateTime.now());
|
||||
|
||||
final yearCtr = useTextEditingController(text: "0");
|
||||
final monthCtr = useTextEditingController(text: "0");
|
||||
final dayCtr = useTextEditingController(text: "0");
|
||||
|
||||
//perhitungan umur dari tanggal ke angka
|
||||
DateDuration calculateAge(DateTime birthDate) {
|
||||
DateTime currentDate = DateTime.now();
|
||||
var age = AgeCalculator.age(birthDate, today: currentDate);
|
||||
return age;
|
||||
}
|
||||
|
||||
dobState.addListener(
|
||||
() {
|
||||
// print(calculateAge(dobState.value));
|
||||
if (dobRb.value == "date") {
|
||||
var age = calculateAge(dobState.value);
|
||||
yearCtr.text = age.years.toString();
|
||||
monthCtr.text = age.months.toString();
|
||||
dayCtr.text = age.days.toString();
|
||||
}
|
||||
},
|
||||
);
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
nameCtr.text = tempPatient.patientData?.name ?? "";
|
||||
prefixCtr.text = tempPatient.patientData?.prefix ?? "";
|
||||
suffixCtr.text = tempPatient.patientData?.suffix ?? "";
|
||||
nikCtr.text = tempPatient.patientData?.nik ?? "";
|
||||
nipCtr.text = tempPatient.patientData?.nip ?? "";
|
||||
withoutNIK.value =
|
||||
tempPatient.patientData?.withoutNIK == 'Y' ? true : false;
|
||||
hpCtr.text = tempPatient.patientData?.hp ?? "";
|
||||
addressCtr.text = tempPatient.patientData?.address ?? "";
|
||||
diagnosisCtr.text = tempPatient.patientData?.diagnosis ?? "";
|
||||
noteCtr.text = tempPatient.patientData?.note ?? "";
|
||||
noRmCtr.text = tempPatient.patientData?.noRM ?? "";
|
||||
jabatanCtr.text = tempPatient.patientData?.jabatan ?? "";
|
||||
kedudukanCtr.text = tempPatient.patientData?.kedudukan ?? "";
|
||||
lokasiCtr.text = tempPatient.patientData?.lokasi ?? "";
|
||||
pekerjaanCtr.text = tempPatient.patientData?.pekerjaan ?? "";
|
||||
// DateFormat('dd-MM-yyyy').format(DateTime.now())
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy').format(DateTime.parse(
|
||||
tempPatient.patientData?.dob ?? DateTime.now().toString()));
|
||||
dobState.value = DateTime.parse(
|
||||
tempPatient.patientData?.dob ?? DateTime.now().toString());
|
||||
ref
|
||||
.read(GetFilterRegistrationProvider.notifier)
|
||||
.getData(token: auth!.token ?? "");
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
|
||||
ref.listen(
|
||||
GetFilterRegistrationProvider,
|
||||
(previous, next) {
|
||||
if (next is GetFilterRegistrationStateInit) {
|
||||
getFilterLoading.value = true;
|
||||
} else if (next is GetFilterRegistrationStateLoading) {
|
||||
getFilterLoading.value = true;
|
||||
} else if (next is GetFilterRegistrationStateError) {
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
getFilterLoading.value = false;
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is GetFilterRegistrationStateDone) {
|
||||
// print(jsonEncode(next.model));
|
||||
sapaan.value = next.model.titles!;
|
||||
gender.value = next.model.gender!;
|
||||
// selectedGender.value = next.model.gender![0];
|
||||
if (tempPatient.patientData?.saluation != null) {
|
||||
var sp = next.model.titles!.firstWhere(
|
||||
(element) => element.id == tempPatient.patientData?.saluation);
|
||||
selectedSaluation.value = sp;
|
||||
}
|
||||
if (tempPatient.patientData?.gender != null) {
|
||||
var gd = next.model.gender!.firstWhere(
|
||||
(element) => element.id == tempPatient.patientData?.gender);
|
||||
selectedGender.value = gd;
|
||||
}
|
||||
sapaanKey.value = sapaanKey.value + 1;
|
||||
genderKey.value = genderKey.value + 1;
|
||||
getFilterLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
saveEdit() {
|
||||
if (withoutNIK.value == false) {
|
||||
if (nikCtr.text.isEmpty) {
|
||||
SanckbarWidget(context, "NIK Harus diisi", snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
if (nikCtr.text.length < 16 || nikCtr.text.length > 16) {
|
||||
SanckbarWidget(
|
||||
context, "NIK berjumlah 16 digit", snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameCtr.text.isEmpty ||
|
||||
selectedGender.value.id == null ||
|
||||
selectedSaluation.value.id == null ||
|
||||
jabatanCtr.text.isEmpty ||
|
||||
kedudukanCtr.text.isEmpty ||
|
||||
lokasiCtr.text.isEmpty ||
|
||||
pekerjaanCtr.text.isEmpty) {
|
||||
// print(nameCtr.text);
|
||||
// print(selectedGender.value.name);
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Sapaan, Nama, Tanggal Lahir, Jenis Kelamin, jabatan, kedudukan, lokasi, dan pekerjaan Harus Diisi !",
|
||||
snackbarType.warning);
|
||||
} else {
|
||||
PatientData data = PatientData(
|
||||
noRM: noRmCtr.text,
|
||||
saluation: selectedSaluation.value.id,
|
||||
name: nameCtr.text,
|
||||
prefix: prefixCtr.text,
|
||||
suffix: suffixCtr.text,
|
||||
dob: dobState.value.toString(),
|
||||
nik: nikCtr.text,
|
||||
nip: nipCtr.text,
|
||||
withoutNIK: withoutNIK.value ? "Y" : "N",
|
||||
gender: selectedGender.value.id.toString(),
|
||||
address: addressCtr.text,
|
||||
diagnosis: diagnosisCtr.text,
|
||||
hp: hpCtr.text,
|
||||
jabatan: jabatanCtr.text,
|
||||
kedudukan: kedudukanCtr.text,
|
||||
lokasi: lokasiCtr.text,
|
||||
pekerjaan: pekerjaanCtr.text,
|
||||
note: noteCtr.text);
|
||||
ref.read(registrationEditPatientProvider.notifier).state =
|
||||
RegistrationModel(
|
||||
token: auth?.token ?? "",
|
||||
patientId: tempPatient.patientId,
|
||||
patientData: data,
|
||||
);
|
||||
print(jsonEncode(RegistrationModel(
|
||||
token: auth?.token ?? "",
|
||||
patientId: tempPatient.patientId,
|
||||
patientData: data,
|
||||
)));
|
||||
ref.read(EditPatientProviderProvider.notifier).editPatent(
|
||||
prm: RegistrationModel(
|
||||
token: auth?.token ?? "",
|
||||
patientId: tempPatient.patientId,
|
||||
patientData: data,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
ref.listen(
|
||||
EditPatientProviderProvider,
|
||||
(previous, next) {
|
||||
if (next is EditPatientProviderStateInit) {
|
||||
editLoading.value = true;
|
||||
} else if (next is EditPatientProviderStateLoading) {
|
||||
editLoading.value = true;
|
||||
} else if (next is EditPatientProviderStateError) {
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
editLoading.value = false;
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is EditPatientProviderStateDone) {
|
||||
SanckbarWidget(
|
||||
context, "Berhasil Mengubah Data patient", snackbarType.success);
|
||||
editLoading.value = false;
|
||||
Navigator.pop(context, "done");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
height: Constant.getActualY(context: context, y: 62),
|
||||
child: Text('Edit Pasien',
|
||||
style: Constant.h2_600(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 40)),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 120),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
DropdownMenu<CustomDropDownModel>(
|
||||
menuHeight:
|
||||
Constant.getActualY(context: context, y: 300),
|
||||
key: ValueKey(sapaanKey.value),
|
||||
initialSelection: selectedSaluation.value,
|
||||
trailingIcon: getFilterLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: null,
|
||||
width: Constant.getActualX(context: context, x: 120),
|
||||
hintText: "Sapaan",
|
||||
textStyle: Constant.body2_400(context: context),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
label: const Text(
|
||||
"Sapaan",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onSelected: (value) {
|
||||
onSelectSaluation(value!);
|
||||
selectedSaluation.value = value;
|
||||
},
|
||||
dropdownMenuEntries: sapaan.value
|
||||
.map<DropdownMenuEntry<CustomDropDownModel>>(
|
||||
(e) => DropdownMenuEntry(
|
||||
value: e, label: e.name ?? ""))
|
||||
.toList()),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 160),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'Prefix',
|
||||
labelText: "Prefix",
|
||||
controller: prefixCtr,
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 520),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Name',
|
||||
labelText: "Nama",
|
||||
controller: nameCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 160),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'Suffix',
|
||||
labelText: "suffix",
|
||||
controller: suffixCtr,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
Radio<String>(
|
||||
value: "date",
|
||||
groupValue: dobRb.value,
|
||||
onChanged: (value) {
|
||||
dobRb.value = value!;
|
||||
},
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 252),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
enabled: dobRb.value != "age",
|
||||
controller: dobCtr,
|
||||
style: Constant.body2_400(context: context),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: Icon(Icons.calendar_today),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
labelText: "Tanggal Lahir" //label text of field
|
||||
),
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
// locale: Locale("id"),
|
||||
context: context,
|
||||
initialDate: dobState.value,
|
||||
firstDate: DateTime(1800),
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
|
||||
//DateTime.now() - not to allow to choose before today.
|
||||
lastDate: DateTime(2100));
|
||||
|
||||
if (pickedDate != null) {
|
||||
print(
|
||||
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
|
||||
String formattedDate =
|
||||
DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
print(
|
||||
formattedDate); //formatted date output using intl package => 2021-03-16
|
||||
dobCtr.text =
|
||||
formattedDate; //set output date to TextField value.
|
||||
dobState.value = pickedDate;
|
||||
} else {}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
Radio<String>(
|
||||
value: "age",
|
||||
groupValue: dobRb.value,
|
||||
onChanged: (value) {
|
||||
dobRb.value = value!;
|
||||
},
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
// alignment: AlignmentDirectional.bottomCenter,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
Constant.getActualX(context: context, x: 16),
|
||||
vertical: Constant.getActualY(context: context, y: 12)),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey)),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
}
|
||||
},
|
||||
disable: dobRb.value != "date",
|
||||
hintText: 'Tahun',
|
||||
labelText: "",
|
||||
isDense: true,
|
||||
suffixIcon: SizedBox(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Tahun',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
controller: yearCtr,
|
||||
inputType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 16)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
DateTime currentDate = DateTime.now();
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
}
|
||||
},
|
||||
disable: dobRb.value != "date",
|
||||
hintText: 'Bulan',
|
||||
labelText: "",
|
||||
controller: monthCtr,
|
||||
inputType: TextInputType.number,
|
||||
isDense: true,
|
||||
suffixIcon: Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Bulan',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 16)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
disable: dobRb.value != "date",
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
if (int.parse(dayCtr.text) <= 31) {
|
||||
DateTime currentDate = DateTime.now();
|
||||
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
} else {
|
||||
dayCtr.text = "31";
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"hari tidak lebih dari 31",
|
||||
snackbarType.warning);
|
||||
}
|
||||
}
|
||||
},
|
||||
hintText: 'Hari',
|
||||
labelText: "",
|
||||
controller: dayCtr,
|
||||
inputType: TextInputType.number,
|
||||
isDense: true,
|
||||
suffixIcon: Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Hari',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -8,
|
||||
left: 10,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: const Text(
|
||||
"Umur",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
)))
|
||||
],
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 300),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'No RM',
|
||||
labelText: "No RM",
|
||||
controller: noRmCtr,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 240),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
inputType: TextInputType.number,
|
||||
controller: nikCtr,
|
||||
hintText: withoutNIK.value
|
||||
? "Pasien Tanpa NIK Data Historis Tidak Terkonsolidasi"
|
||||
: 'NIK',
|
||||
labelText: withoutNIK.value
|
||||
? "Pasien Tanpa NIK Data Historis Tidak Terkonsolidasi"
|
||||
: "NIK"),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
Center(
|
||||
child: Transform.scale(
|
||||
scale: 0.8,
|
||||
child: Checkbox(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
value: withoutNIK.value,
|
||||
onChanged: (value) {
|
||||
withoutNIK.value = value!;
|
||||
if (value == true) {}
|
||||
}),
|
||||
),
|
||||
),
|
||||
Text('Tanpa NIK',
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
// SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
// SizedBox(
|
||||
// width: Constant.getActualX(context: context, x: 250),
|
||||
// child: DropdownMenu<CustomDropDownModel>(
|
||||
// key: ValueKey(genderKey.value),
|
||||
// initialSelection: selectedGender.value,
|
||||
// trailingIcon: getFilterLoading.value
|
||||
// ? LoadingAnimationWidget.discreteCircle(
|
||||
// color: Constant.primaryBlue, size: 20)
|
||||
// : null,
|
||||
// width: Constant.getActualX(context: context, x: 250),
|
||||
// hintText: "Jenis Kelamin",
|
||||
// textStyle: Constant.body2_400(context: context),
|
||||
// inputDecorationTheme: InputDecorationTheme(
|
||||
// border: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// )),
|
||||
// label: const Text("jenis Kelamin"),
|
||||
// onSelected: (value) {
|
||||
// onSelectGender(value!);
|
||||
// selectedGender.value = value;
|
||||
// },
|
||||
// dropdownMenuEntries: gender.value
|
||||
// .map<DropdownMenuEntry<CustomDropDownModel>>((e) =>
|
||||
// DropdownMenuEntry(value: e, label: e.name ?? ""))
|
||||
// .toList())),
|
||||
// SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
// SizedBox(
|
||||
// width: Constant.getActualX(context: context, x: 365),
|
||||
// // height: Constant.getActualY(context: context, y: 56),
|
||||
// child: CustomTextField(
|
||||
// hintText: 'No Hp',
|
||||
// labelText: "No Hp",
|
||||
// controller: hpCtr,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
DropdownMenu<CustomDropDownModel>(
|
||||
key: ValueKey(genderKey.value),
|
||||
initialSelection: selectedGender.value,
|
||||
trailingIcon: getFilterLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: null,
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
hintText: "Jenis Kelamin",
|
||||
textStyle: Constant.body2_400(context: context),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
label: const Text("jenis Kelamin"),
|
||||
onSelected: (value) {
|
||||
onSelectGender(value!);
|
||||
selectedGender.value = value;
|
||||
},
|
||||
dropdownMenuEntries: gender.value
|
||||
.map<DropdownMenuEntry<CustomDropDownModel>>(
|
||||
(e) => DropdownMenuEntry(
|
||||
value: e, label: e.name ?? ""))
|
||||
.toList()),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
inputType: TextInputType.number,
|
||||
hintText: 'No Hp',
|
||||
labelText: "No Hp",
|
||||
controller: hpCtr,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
child: CustomTextField(
|
||||
hintText: "NIP",
|
||||
labelText: "NIP",
|
||||
controller: nipCtr,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
// Row(
|
||||
// children: [],
|
||||
// ),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Jabatan',
|
||||
labelText: "Jabatan",
|
||||
controller: jabatanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Kedudukan',
|
||||
labelText: "Kedudukan",
|
||||
controller: kedudukanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Lokasi',
|
||||
labelText: "Lokasi",
|
||||
controller: lokasiCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Pekerjaan',
|
||||
labelText: "Pekerjaan",
|
||||
controller: pekerjaanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
// height: Constant.getActualY(context: context, y: 120),
|
||||
child: CustomTextField(
|
||||
controller: addressCtr,
|
||||
hintText: 'Alamat',
|
||||
labelText: "Alamat",
|
||||
maxLines: 4,
|
||||
minLines: 1),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 30)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
// height: Constant.getActualY(context: context, y: 120),
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(color: Colors.grey.shade400, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: !editLoading.value
|
||||
? () {
|
||||
ref
|
||||
.read(registrationEditPatientProvider.notifier)
|
||||
.state = RegistrationModel();
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: Text('Batal',
|
||||
style: Constant.button_medium(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Constant.green,
|
||||
side: BorderSide(color: Constant.green, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: !editLoading.value
|
||||
? () {
|
||||
saveEdit();
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: editLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryRed, size: 20)
|
||||
: Text('Simpan',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
141
lib/screen/registrasi/dialog_pendaftaran_pasien.dart
Normal file
141
lib/screen/registrasi/dialog_pendaftaran_pasien.dart
Normal file
@@ -0,0 +1,141 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/app/constant.dart';
|
||||
|
||||
import 'package:mitra_corporate/screen/registrasi/form_data_pasien.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/form_detail_order.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/form_pemeriksaan.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/registrasi_sukses.dart';
|
||||
import 'package:mitra_corporate/widgets/stepper_registrasi.dart';
|
||||
|
||||
import '../../provider/registrasi_provider.dart';
|
||||
|
||||
class DialogPendaftaranPasien extends HookConsumerWidget {
|
||||
const DialogPendaftaranPasien({super.key});
|
||||
|
||||
// const DialogDataPasien({
|
||||
// Key? key,
|
||||
// }) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final bacaRegistrasiProvider = ref.watch(registrasiProvider);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
child: SimpleDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||
contentPadding: const EdgeInsets.all(40.0),
|
||||
children: [
|
||||
Column(children: [
|
||||
(bacaRegistrasiProvider == 3)
|
||||
? Text('')
|
||||
: SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1080),
|
||||
height: Constant.getActualY(context: context, y: 62),
|
||||
child: Text('Pendaftaran Pasien Baru',
|
||||
style: Constant.h2_600(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 40)),
|
||||
//Stepper
|
||||
(bacaRegistrasiProvider == 3)
|
||||
? Text('')
|
||||
: SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1080),
|
||||
height: Constant.getActualY(context: context, y: 100),
|
||||
child: StepperRegistrasi()),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
),
|
||||
// membaca perubahan value dari registrasi_provider.dart
|
||||
(bacaRegistrasiProvider == 0)
|
||||
? FormDataPasien()
|
||||
: (bacaRegistrasiProvider == 1)
|
||||
? FormPemeriksaan()
|
||||
: (bacaRegistrasiProvider == 2)
|
||||
? DetailOrder()
|
||||
: (bacaRegistrasiProvider == 3)
|
||||
? RegistrasiSukses()
|
||||
: Text('Tidak ada view'),
|
||||
|
||||
// if(bacaRegistrasiProvider == 1){
|
||||
// FormDataPasien()
|
||||
// } else{
|
||||
// if(bacaRegistrasiProvider == 2){
|
||||
// Text('2')
|
||||
// }else{
|
||||
// Text('3')
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
// Container(
|
||||
// // height: Constant.getActualY(context: context, y: 100),
|
||||
// // color: Colors.red,
|
||||
// padding: const EdgeInsets.only(left: 32, right: 32),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// (bacaRegistrasiProvider == 4)
|
||||
// ? Text('')
|
||||
// : OutlinedButton(
|
||||
// style: OutlinedButton.styleFrom(
|
||||
// backgroundColor: Colors.white,
|
||||
// side: BorderSide(
|
||||
// color: Constant.primaryBlue, width: 2),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(8))),
|
||||
// onPressed: () {
|
||||
// ref
|
||||
// .read(registrasiProvider.state)
|
||||
// .update((state) => state - 1);
|
||||
// },
|
||||
// child: SizedBox(
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
// child: Center(
|
||||
// child: Text('Batal',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textBlue)),
|
||||
// ),
|
||||
// )),
|
||||
// SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
// (bacaRegistrasiProvider == 4)
|
||||
// ? Text('')
|
||||
// : ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: Constant.primaryBlue,
|
||||
// side:
|
||||
// BorderSide(color: Constant.primaryBlue, width: 2),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// // onPressed: () {
|
||||
// // showDialog(
|
||||
// // context: context,
|
||||
// // builder: ((context) => DialogPemeriksaan()));
|
||||
// // },
|
||||
// onPressed: () {
|
||||
// ref
|
||||
// .read(registrasiProvider.state)
|
||||
// .update((state) => state + 1);
|
||||
// },
|
||||
// child: SizedBox(
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
// child: Center(
|
||||
// child: Text('Simpan Perubahan',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textWhite)),
|
||||
// ),
|
||||
// )),
|
||||
// ],
|
||||
// ),
|
||||
// )
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
65
lib/screen/registrasi/edit_patient_provider.dart
Normal file
65
lib/screen/registrasi/edit_patient_provider.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:mitra_corporate/repository/patient_repository.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class EditPatientProviderState extends Equatable {
|
||||
final DateTime date;
|
||||
const EditPatientProviderState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class EditPatientProviderStateInit extends EditPatientProviderState {
|
||||
EditPatientProviderStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class EditPatientProviderStateLoading extends EditPatientProviderState {
|
||||
EditPatientProviderStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class EditPatientProviderStateError extends EditPatientProviderState {
|
||||
final String message;
|
||||
EditPatientProviderStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class EditPatientProviderStateDone extends EditPatientProviderState {
|
||||
final String msg;
|
||||
EditPatientProviderStateDone({
|
||||
required this.msg,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class EditPatientProviderNotifier
|
||||
extends StateNotifier<EditPatientProviderState> {
|
||||
final Ref ref;
|
||||
EditPatientProviderNotifier({
|
||||
required this.ref,
|
||||
}) : super(EditPatientProviderStateInit());
|
||||
|
||||
void editPatent({required RegistrationModel prm}) async {
|
||||
try {
|
||||
state = EditPatientProviderStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await PatientRepository(dio: dio).editPatient(prm: prm);
|
||||
state = EditPatientProviderStateDone(msg: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = EditPatientProviderStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = EditPatientProviderStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final EditPatientProviderProvider = StateNotifierProvider<
|
||||
EditPatientProviderNotifier,
|
||||
EditPatientProviderState>((ref) => EditPatientProviderNotifier(ref: ref));
|
||||
931
lib/screen/registrasi/form_data_pasien.dart
Normal file
931
lib/screen/registrasi/form_data_pasien.dart
Normal file
@@ -0,0 +1,931 @@
|
||||
import 'package:age_calculator/age_calculator.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:mitra_corporate/app/constant.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/provider/auth_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/get_filter_provider.dart';
|
||||
import 'package:mitra_corporate/widgets/custom_snackbar_widget.dart';
|
||||
import 'package:mitra_corporate/widgets/custom_text_field.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../../provider/registrasi_provider.dart';
|
||||
|
||||
class FormDataPasien extends HookConsumerWidget {
|
||||
const FormDataPasien({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tempPatient = ref.watch(registrationDataProvider);
|
||||
final auth = ref.watch(authProvider);
|
||||
//withoutnik apabila tanpa nik maka true
|
||||
final withoutNIK = useState(false);
|
||||
final getFilterLoading = useState(false);
|
||||
final sapaanKey = useState(1);
|
||||
final genderKey = useState(1000);
|
||||
final prefixCtr = useTextEditingController(text: "");
|
||||
final nameCtr = useTextEditingController(text: "");
|
||||
final suffixCtr = useTextEditingController(text: "");
|
||||
final nikCtr = useTextEditingController(text: "");
|
||||
final nipCtr = useTextEditingController(text: "");
|
||||
final hpCtr = useTextEditingController(text: "");
|
||||
final noRmCtr = useTextEditingController(text: "");
|
||||
final addressCtr = useTextEditingController(text: "");
|
||||
final diagnosisCtr = useTextEditingController(text: "");
|
||||
final noteCtr = useTextEditingController(text: "");
|
||||
final jabatanCtr = useTextEditingController(text: "");
|
||||
final kedudukanCtr = useTextEditingController(text: "");
|
||||
final lokasiCtr = useTextEditingController(text: "");
|
||||
final pekerjaanCtr = useTextEditingController(text: "");
|
||||
final sapaan = useState<List<CustomDropDownModel>>(List.empty());
|
||||
final selectedSaluation = useState(CustomDropDownModel());
|
||||
final gender = useState<List<CustomDropDownModel>>(List.empty());
|
||||
final selectedGender = useState(CustomDropDownModel());
|
||||
|
||||
//select salah satu sapaan
|
||||
onSelectSaluation(CustomDropDownModel value) {
|
||||
selectedSaluation.value = value;
|
||||
selectedGender.value =
|
||||
gender.value.firstWhere((element) => element.id == value.type);
|
||||
|
||||
genderKey.value = genderKey.value + 1;
|
||||
// sapaanKey.value = sapaanKey.value + 1;
|
||||
}
|
||||
|
||||
//update gender saat sapaan dipilih
|
||||
selectedSaluation.addListener(() {
|
||||
selectedGender.value = gender.value
|
||||
.firstWhere((element) => element.id == selectedSaluation.value.type);
|
||||
genderKey.value = genderKey.value + 1;
|
||||
});
|
||||
|
||||
//select gender
|
||||
onSelectGender(CustomDropDownModel value) {
|
||||
selectedGender.value = value;
|
||||
}
|
||||
|
||||
final dobRb = useState('date');
|
||||
final dobCtr = useTextEditingController(
|
||||
text: DateFormat('dd-MM-yyyy').format(DateTime.now()));
|
||||
final dobState = useState(DateTime.now());
|
||||
|
||||
final yearCtr = useTextEditingController(text: "0");
|
||||
final monthCtr = useTextEditingController(text: "0");
|
||||
final dayCtr = useTextEditingController(text: "0");
|
||||
|
||||
//perhitungan umur dari tanggal ke angka
|
||||
DateDuration calculateAge(DateTime birthDate) {
|
||||
DateTime currentDate = DateTime.now();
|
||||
var age = AgeCalculator.age(birthDate, today: currentDate);
|
||||
return age;
|
||||
}
|
||||
|
||||
dobState.addListener(
|
||||
() {
|
||||
// print(calculateAge(dobState.value));
|
||||
if (dobRb.value == "date") {
|
||||
var age = calculateAge(dobState.value);
|
||||
yearCtr.text = age.years.toString();
|
||||
monthCtr.text = age.months.toString();
|
||||
dayCtr.text = age.days.toString();
|
||||
}
|
||||
},
|
||||
);
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
nameCtr.text = tempPatient.patientData?.name ?? "";
|
||||
prefixCtr.text = tempPatient.patientData?.prefix ?? "";
|
||||
suffixCtr.text = tempPatient.patientData?.suffix ?? "";
|
||||
nikCtr.text = tempPatient.patientData?.nik ?? "";
|
||||
nipCtr.text = tempPatient.patientData?.nip ?? "";
|
||||
withoutNIK.value =
|
||||
tempPatient.patientData?.withoutNIK == 'Y' ? true : false;
|
||||
hpCtr.text = tempPatient.patientData?.hp ?? "";
|
||||
addressCtr.text = tempPatient.patientData?.address ?? "";
|
||||
diagnosisCtr.text = tempPatient.patientData?.diagnosis ?? "";
|
||||
noteCtr.text = tempPatient.patientData?.note ?? "";
|
||||
noRmCtr.text = tempPatient.patientData?.noRM ?? "";
|
||||
jabatanCtr.text = tempPatient.patientData?.jabatan ?? "";
|
||||
kedudukanCtr.text = tempPatient.patientData?.kedudukan ?? "";
|
||||
lokasiCtr.text = tempPatient.patientData?.lokasi ?? "";
|
||||
pekerjaanCtr.text = tempPatient.patientData?.pekerjaan ?? "";
|
||||
// DateFormat('dd-MM-yyyy').format(DateTime.now())
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy').format(DateTime.parse(
|
||||
tempPatient.patientData?.dob ?? DateTime.now().toString()));
|
||||
dobState.value = DateTime.parse(
|
||||
tempPatient.patientData?.dob ?? DateTime.now().toString());
|
||||
ref
|
||||
.read(GetFilterRegistrationProvider.notifier)
|
||||
.getData(token: auth!.token ?? "");
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
|
||||
ref.listen(
|
||||
GetFilterRegistrationProvider,
|
||||
(previous, next) {
|
||||
if (next is GetFilterRegistrationStateInit) {
|
||||
getFilterLoading.value = true;
|
||||
} else if (next is GetFilterRegistrationStateLoading) {
|
||||
getFilterLoading.value = true;
|
||||
} else if (next is GetFilterRegistrationStateError) {
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
getFilterLoading.value = false;
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is GetFilterRegistrationStateDone) {
|
||||
// print(jsonEncode(next.model));
|
||||
sapaan.value = next.model.titles!;
|
||||
gender.value = next.model.gender!;
|
||||
// selectedGender.value = next.model.gender![0];
|
||||
if (tempPatient.patientData?.saluation != null) {
|
||||
var sp = next.model.titles!.firstWhere(
|
||||
(element) => element.id == tempPatient.patientData?.saluation);
|
||||
selectedSaluation.value = sp;
|
||||
}
|
||||
if (tempPatient.patientData?.gender != null) {
|
||||
var gd = next.model.gender!.firstWhere(
|
||||
(element) => element.id == tempPatient.patientData?.gender);
|
||||
selectedGender.value = gd;
|
||||
}
|
||||
sapaanKey.value = sapaanKey.value + 1;
|
||||
genderKey.value = genderKey.value + 1;
|
||||
getFilterLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
//Function ke step selanjutny(pilih pemeriksaan)
|
||||
nextStep() {
|
||||
if (withoutNIK.value == false) {
|
||||
if (nikCtr.text.isEmpty) {
|
||||
SanckbarWidget(context, "NIK Harus diisi", snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
if (nikCtr.text.length < 16 || nikCtr.text.length > 16) {
|
||||
SanckbarWidget(
|
||||
context, "NIK berjumlah 16 digit", snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (nameCtr.text.isEmpty ||
|
||||
selectedGender.value.id == null ||
|
||||
selectedSaluation.value.id == null ||
|
||||
jabatanCtr.text.isEmpty ||
|
||||
kedudukanCtr.text.isEmpty ||
|
||||
lokasiCtr.text.isEmpty ||
|
||||
pekerjaanCtr.text.isEmpty) {
|
||||
// print(nameCtr.text);
|
||||
// print(selectedGender.value.name);
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Sapaan, Nama, Tanggal Lahir, Jenis Kelamin, jabatan, kedudukan, lokasi, dan pekerjaan Harus Diisi !",
|
||||
snackbarType.warning);
|
||||
} else {
|
||||
var temp = ref.watch(registrationDataProvider);
|
||||
PatientData data = PatientData(
|
||||
noRM: noRmCtr.text,
|
||||
saluation: selectedSaluation.value.id,
|
||||
name: nameCtr.text,
|
||||
prefix: prefixCtr.text,
|
||||
suffix: suffixCtr.text,
|
||||
dob: dobState.value.toString(),
|
||||
nik: nikCtr.text,
|
||||
nip: nipCtr.text,
|
||||
withoutNIK: withoutNIK.value ? "Y" : "N",
|
||||
gender: selectedGender.value.id.toString(),
|
||||
address: addressCtr.text,
|
||||
diagnosis: diagnosisCtr.text,
|
||||
hp: hpCtr.text,
|
||||
jabatan: jabatanCtr.text,
|
||||
kedudukan: kedudukanCtr.text,
|
||||
lokasi: lokasiCtr.text,
|
||||
pekerjaan: pekerjaanCtr.text,
|
||||
note: noteCtr.text);
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: temp.orderID,
|
||||
token: auth?.token ?? "",
|
||||
patientId: temp.patientId ?? "new",
|
||||
patientData: data,
|
||||
specimens: temp.specimens,
|
||||
paket: temp.paket,
|
||||
bahan: temp.bahan,
|
||||
tests: temp.tests,
|
||||
total: temp.total);
|
||||
ref.read(registrasiProvider.state).update((state) => 1);
|
||||
}
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 20, left: 24, right: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 120),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
DropdownMenu<CustomDropDownModel>(
|
||||
menuHeight:
|
||||
Constant.getActualY(context: context, y: 300),
|
||||
key: ValueKey(sapaanKey.value),
|
||||
initialSelection: selectedSaluation.value,
|
||||
trailingIcon: getFilterLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: null,
|
||||
width: Constant.getActualX(context: context, x: 120),
|
||||
hintText: "Sapaan",
|
||||
textStyle: Constant.body2_400(context: context),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
label: const Text(
|
||||
"Sapaan",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onSelected: (value) {
|
||||
onSelectSaluation(value!);
|
||||
selectedSaluation.value = value;
|
||||
},
|
||||
dropdownMenuEntries: sapaan.value
|
||||
.map<DropdownMenuEntry<CustomDropDownModel>>(
|
||||
(e) => DropdownMenuEntry(
|
||||
value: e, label: e.name ?? ""))
|
||||
.toList()),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 160),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'Prefix',
|
||||
labelText: "Prefix",
|
||||
controller: prefixCtr,
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 520),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Name',
|
||||
labelText: "Nama",
|
||||
controller: nameCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 160),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'Suffix',
|
||||
labelText: "suffix",
|
||||
controller: suffixCtr,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
Radio<String>(
|
||||
value: "date",
|
||||
groupValue: dobRb.value,
|
||||
onChanged: (value) {
|
||||
dobRb.value = value!;
|
||||
},
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 252),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
enabled: dobRb.value != "age",
|
||||
controller: dobCtr,
|
||||
style: Constant.body2_400(context: context),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: Icon(Icons.calendar_today),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
labelText: "Tanggal Lahir" //label text of field
|
||||
),
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
// locale: Locale("id"),
|
||||
context: context,
|
||||
initialDate: dobState.value,
|
||||
firstDate: DateTime(1800),
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
|
||||
//DateTime.now() - not to allow to choose before today.
|
||||
lastDate: DateTime(2100));
|
||||
|
||||
if (pickedDate != null) {
|
||||
print(
|
||||
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
|
||||
String formattedDate =
|
||||
DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
print(
|
||||
formattedDate); //formatted date output using intl package => 2021-03-16
|
||||
dobCtr.text =
|
||||
formattedDate; //set output date to TextField value.
|
||||
dobState.value = pickedDate;
|
||||
} else {}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
Radio<String>(
|
||||
value: "age",
|
||||
groupValue: dobRb.value,
|
||||
onChanged: (value) {
|
||||
dobRb.value = value!;
|
||||
},
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
// alignment: AlignmentDirectional.bottomCenter,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
Constant.getActualX(context: context, x: 16),
|
||||
vertical: Constant.getActualY(context: context, y: 12)),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: Colors.grey)),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
}
|
||||
},
|
||||
disable: dobRb.value != "date",
|
||||
hintText: 'Tahun',
|
||||
labelText: "",
|
||||
isDense: true,
|
||||
suffixIcon: SizedBox(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Tahun',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
controller: yearCtr,
|
||||
inputType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 16)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
DateTime currentDate = DateTime.now();
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
}
|
||||
},
|
||||
disable: dobRb.value != "date",
|
||||
hintText: 'Bulan',
|
||||
labelText: "",
|
||||
controller: monthCtr,
|
||||
inputType: TextInputType.number,
|
||||
isDense: true,
|
||||
suffixIcon: Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Bulan',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 16)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 90),
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
child: CustomTextField(
|
||||
disable: dobRb.value != "date",
|
||||
onChange: (value) {
|
||||
if (dobRb.value == "age") {
|
||||
if (int.parse(dayCtr.text) <= 31) {
|
||||
DateTime currentDate = DateTime.now();
|
||||
|
||||
DateTime coba = Jiffy.now()
|
||||
.subtract(
|
||||
months: int.parse(monthCtr.text),
|
||||
years: int.parse(yearCtr.text),
|
||||
days: int.parse(dayCtr.text))
|
||||
.dateTime;
|
||||
// print(coba);
|
||||
|
||||
dobState.value = coba;
|
||||
dobCtr.text = DateFormat('dd-MM-yyyy')
|
||||
.format(dobState.value);
|
||||
} else {
|
||||
dayCtr.text = "31";
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"hari tidak lebih dari 31",
|
||||
snackbarType.warning);
|
||||
}
|
||||
}
|
||||
},
|
||||
hintText: 'Hari',
|
||||
labelText: "",
|
||||
controller: dayCtr,
|
||||
inputType: TextInputType.number,
|
||||
isDense: true,
|
||||
suffixIcon: Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 8),
|
||||
right: Constant.getActualX(
|
||||
context: context, x: 5),
|
||||
),
|
||||
child: Text(
|
||||
'Hari',
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
style: Constant.body3_400(context: context),
|
||||
hintStyle: Constant.body3_400(context: context),
|
||||
labelStyle: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -8,
|
||||
left: 10,
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
child: const Text(
|
||||
"Umur",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
)))
|
||||
],
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 300),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
hintText: 'No RM',
|
||||
labelText: "No RM",
|
||||
controller: noRmCtr,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 240),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
inputType: TextInputType.number,
|
||||
controller: nikCtr,
|
||||
hintText: withoutNIK.value
|
||||
? "Pasien Tanpa NIK Data Historis Tidak Terkonsolidasi"
|
||||
: 'NIK',
|
||||
labelText: withoutNIK.value
|
||||
? "Pasien Tanpa NIK Data Historis Tidak Terkonsolidasi"
|
||||
: "NIK"),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 20)),
|
||||
Center(
|
||||
child: Transform.scale(
|
||||
scale: 0.8,
|
||||
child: Checkbox(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4)),
|
||||
value: withoutNIK.value,
|
||||
onChanged: (value) {
|
||||
withoutNIK.value = value!;
|
||||
if (value == true) {}
|
||||
}),
|
||||
),
|
||||
),
|
||||
Text('Tanpa NIK',
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
// SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
// SizedBox(
|
||||
// width: Constant.getActualX(context: context, x: 250),
|
||||
// child: DropdownMenu<CustomDropDownModel>(
|
||||
// key: ValueKey(genderKey.value),
|
||||
// initialSelection: selectedGender.value,
|
||||
// trailingIcon: getFilterLoading.value
|
||||
// ? LoadingAnimationWidget.discreteCircle(
|
||||
// color: Constant.primaryBlue, size: 20)
|
||||
// : null,
|
||||
// width: Constant.getActualX(context: context, x: 250),
|
||||
// hintText: "Jenis Kelamin",
|
||||
// textStyle: Constant.body2_400(context: context),
|
||||
// inputDecorationTheme: InputDecorationTheme(
|
||||
// border: OutlineInputBorder(
|
||||
// borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// )),
|
||||
// label: const Text("jenis Kelamin"),
|
||||
// onSelected: (value) {
|
||||
// onSelectGender(value!);
|
||||
// selectedGender.value = value;
|
||||
// },
|
||||
// dropdownMenuEntries: gender.value
|
||||
// .map<DropdownMenuEntry<CustomDropDownModel>>((e) =>
|
||||
// DropdownMenuEntry(value: e, label: e.name ?? ""))
|
||||
// .toList())),
|
||||
// SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
// SizedBox(
|
||||
// width: Constant.getActualX(context: context, x: 365),
|
||||
// // height: Constant.getActualY(context: context, y: 56),
|
||||
// child: CustomTextField(
|
||||
// hintText: 'No Hp',
|
||||
// labelText: "No Hp",
|
||||
// controller: hpCtr,
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
DropdownMenu<CustomDropDownModel>(
|
||||
key: ValueKey(genderKey.value),
|
||||
initialSelection: selectedGender.value,
|
||||
trailingIcon: getFilterLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: null,
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
hintText: "Jenis Kelamin",
|
||||
textStyle: Constant.body2_400(context: context),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
label: const Text("jenis Kelamin"),
|
||||
onSelected: (value) {
|
||||
onSelectGender(value!);
|
||||
selectedGender.value = value;
|
||||
},
|
||||
dropdownMenuEntries: gender.value
|
||||
.map<DropdownMenuEntry<CustomDropDownModel>>(
|
||||
(e) => DropdownMenuEntry(
|
||||
value: e, label: e.name ?? ""))
|
||||
.toList()),
|
||||
],
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
inputType: TextInputType.number,
|
||||
hintText: 'No Hp',
|
||||
labelText: "No Hp",
|
||||
controller: hpCtr,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
child: CustomTextField(
|
||||
hintText: "NIP",
|
||||
labelText: "NIP",
|
||||
controller: nipCtr,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
// Row(
|
||||
// children: [],
|
||||
// ),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 304),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Jabatan',
|
||||
labelText: "Jabatan",
|
||||
controller: jabatanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Kedudukan',
|
||||
labelText: "Kedudukan",
|
||||
controller: kedudukanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Lokasi',
|
||||
labelText: "Lokasi",
|
||||
controller: lokasiCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 218),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"*",
|
||||
style: Constant.body2_400(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
),
|
||||
CustomTextField(
|
||||
hintText: 'Pekerjaan',
|
||||
labelText: "Pekerjaan",
|
||||
controller: pekerjaanCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
// height: Constant.getActualY(context: context, y: 120),
|
||||
child: CustomTextField(
|
||||
controller: addressCtr,
|
||||
hintText: 'Alamat',
|
||||
labelText: "Alamat",
|
||||
maxLines: 4,
|
||||
minLines: 1),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
// height: Constant.getActualY(context: context, y: 120),
|
||||
child: CustomTextField(
|
||||
controller: diagnosisCtr,
|
||||
hintText: 'Diagnosis',
|
||||
labelText: "Diagnosis",
|
||||
maxLines: 4,
|
||||
minLines: 1),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1032),
|
||||
// height: Constant.getActualY(context: context, y: 120),
|
||||
child: CustomTextField(
|
||||
controller: noteCtr,
|
||||
hintText: 'Catatan FO',
|
||||
labelText: "Catatan FO",
|
||||
maxLines: 4,
|
||||
minLines: 1),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(color: Colors.grey.shade400, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: () {
|
||||
ref.read(registrationDataProvider.notifier).state =
|
||||
RegistrationModel();
|
||||
ref.read(selectedTestProvider.notifier).state =
|
||||
List.empty(growable: true);
|
||||
ref.read(selectedPacketProvider.notifier).state =
|
||||
List.empty(growable: true);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: Text('Batal',
|
||||
style: Constant.button_medium(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Constant.green,
|
||||
side: BorderSide(color: Constant.green, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
nextStep();
|
||||
},
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: Text('Berikutnya',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
631
lib/screen/registrasi/form_detail_order.dart
Normal file
631
lib/screen/registrasi/form_detail_order.dart
Normal file
@@ -0,0 +1,631 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/model/test_model.dart';
|
||||
import 'package:mitra_corporate/provider/auth_provider.dart';
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/get_specimen_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/new_order_provider.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../widgets/custom_snackbar_widget.dart';
|
||||
import '../../widgets/tests_tabel_widget.dart';
|
||||
|
||||
class DetailOrder extends HookConsumerWidget {
|
||||
const DetailOrder({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final auth = ref.watch(authProvider);
|
||||
final tempRegistrationData = ref.watch(registrationDataProvider);
|
||||
final testListAll = ref.read(tempTestListProvider);
|
||||
final selectedTest = ref.read(selectedTestProvider);
|
||||
final dialogAction = ref.watch(dialogOrderActionProvider);
|
||||
|
||||
final testList = useState<List<Items>>(List.empty());
|
||||
final testScrollCtr = useScrollController();
|
||||
final specimenLoading = useState(false);
|
||||
final addOrderLoading = ref.watch(addOrderLoadingProvider);
|
||||
final tabctr = useTabController(initialLength: 2);
|
||||
final selectedTab = useState(0);
|
||||
final dateValidation = useState(false);
|
||||
|
||||
dateVal(bool value) {
|
||||
dateValidation.value = value;
|
||||
}
|
||||
|
||||
//get specimen & bahan from list of tests
|
||||
getSpecimen() {
|
||||
List<Map<String, String>> test = List.empty(growable: true);
|
||||
tempRegistrationData.tests?.forEach((element) {
|
||||
test.add({
|
||||
"id": element.id ?? "0",
|
||||
"tab": element.tab ?? "0",
|
||||
"sasCode": element.sasCode ?? "-"
|
||||
});
|
||||
});
|
||||
// print(jsonEncode(test));
|
||||
ref
|
||||
.read(GetSpecimenProvider.notifier)
|
||||
.getData(arrTest: test, token: auth?.token ?? "0");
|
||||
}
|
||||
|
||||
ref.listen(
|
||||
GetSpecimenProvider,
|
||||
(pref, next) {
|
||||
if (next is GetSpecimenStateInit) {
|
||||
specimenLoading.value = true;
|
||||
} else if (next is GetSpecimenStateLoading) {
|
||||
specimenLoading.value = true;
|
||||
} else if (next is GetSpecimenStateError) {
|
||||
specimenLoading.value = false;
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is GetSpecimenStateDone) {
|
||||
var tests = tempRegistrationData.tests;
|
||||
//assign specimn & bahan
|
||||
List<GetSpecimenModel> nw = next.model;
|
||||
List<Specimens> sp = List.empty(growable: true);
|
||||
List<Bahan> bhn = List.empty(growable: true);
|
||||
|
||||
for (var i = 0; i < tests!.length; i++) {
|
||||
var tes = tests[i];
|
||||
var cek = "${tes.tab}|${tes.id}";
|
||||
for (var j = 0; j < nw.length; j++) {
|
||||
var cek2 = "${nw[j].tab}|${nw[j].id}";
|
||||
if (cek == cek2) {
|
||||
tests[i].specimen = nw[j].specimen?.toSet().toList();
|
||||
tests[i].bahan = nw[j].bahan?.toSet().toList();
|
||||
|
||||
nw[j].specimen?.forEach((element) {
|
||||
var a = sp.firstWhere(
|
||||
(dt) => dt.id == element.id,
|
||||
orElse: () =>
|
||||
Specimens(ctr: TextEditingController(), id: "new"),
|
||||
);
|
||||
if (a.id == "new") {
|
||||
sp.add(element);
|
||||
}
|
||||
});
|
||||
nw[j].bahan?.forEach((element) {
|
||||
var a = bhn.firstWhere(
|
||||
(dt) => dt.id == element.id,
|
||||
orElse: () =>
|
||||
Bahan(ctr: TextEditingController(), id: "new"),
|
||||
);
|
||||
if (a.id == "new") {
|
||||
bhn.add(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
token: auth?.token,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
paket: tempRegistrationData.paket,
|
||||
tests: tests,
|
||||
specimens: sp.toSet().toList(),
|
||||
bahan: bhn.toSet().toList(),
|
||||
total: tempRegistrationData.total);
|
||||
specimenLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
List<Items> temp = List.empty(growable: true);
|
||||
for (var element in testListAll) {
|
||||
// "$idTab|$idTest"
|
||||
for (var i in element.items!) {
|
||||
String cek = "${element.tabId}|${i.testID}";
|
||||
String ck = selectedTest.firstWhere(
|
||||
(j) => j == cek,
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (ck != "-1") {
|
||||
temp.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
testList.value = temp;
|
||||
|
||||
getSpecimen();
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
|
||||
//delete tests & auto cek & delete specimen/bahan
|
||||
delete(String idTest, String idtab) {
|
||||
List<Tests> temp = tempRegistrationData.tests ?? [];
|
||||
List<String> selectedTest = ref.watch(selectedTestProvider);
|
||||
String cek = "$idtab|$idTest";
|
||||
double total = double.parse(tempRegistrationData.total!);
|
||||
|
||||
List<Specimens> oldSp = tempRegistrationData.specimens ?? [];
|
||||
List<Bahan> oldBhn = tempRegistrationData.bahan ?? [];
|
||||
|
||||
Tests removed = tempRegistrationData.tests!.firstWhere(
|
||||
(element) => element.id == idTest && element.tab == idtab);
|
||||
temp.removeWhere(
|
||||
(element) => element.id == idTest && element.tab == idtab);
|
||||
selectedTest.removeWhere((element) => element == cek);
|
||||
total = total - double.parse(removed.price!);
|
||||
// var tests = tempRegistrationData.tests;
|
||||
|
||||
// List<GetSpecimenModel> nw = next.model;
|
||||
List<Specimens> newSp = List.empty(growable: true);
|
||||
List<Bahan> newBhn = List.empty(growable: true);
|
||||
|
||||
for (var j = 0; j < temp.length; j++) {
|
||||
temp[j].specimen?.forEach((element) {
|
||||
var a = newSp.firstWhere(
|
||||
(dt) => dt.id == element.id,
|
||||
orElse: () => Specimens(ctr: TextEditingController(), id: "new"),
|
||||
);
|
||||
if (a.id == "new") {
|
||||
newSp.add(element);
|
||||
}
|
||||
});
|
||||
temp[j].bahan?.forEach((element) {
|
||||
var a = newBhn.firstWhere(
|
||||
(dt) => dt.id == element.id,
|
||||
orElse: () => Bahan(ctr: TextEditingController(), id: "new"),
|
||||
);
|
||||
if (a.id == "new") {
|
||||
newBhn.add(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
// print("old sp");
|
||||
// print(jsonEncode(oldSp));
|
||||
// print("new sp");
|
||||
// print(jsonEncode(newSp));
|
||||
//compare old dp and new sp to get deleted specimen
|
||||
List<Specimens> deletedSp = List.empty(growable: true);
|
||||
for (var i = 0; i < oldSp.length; i++) {
|
||||
Specimens sp = newSp.firstWhere((element) => element.id == oldSp[i].id,
|
||||
orElse: () =>
|
||||
Specimens(ctr: TextEditingController(), id: "deleted"));
|
||||
if (sp.id == "deleted") {
|
||||
deletedSp.add(oldSp[i]);
|
||||
}
|
||||
}
|
||||
List<Specimens> tempSp = tempRegistrationData.specimens ?? [];
|
||||
for (var e in deletedSp) {
|
||||
tempSp.removeWhere((element) => element.id == e.id);
|
||||
}
|
||||
// print("deleted sp");
|
||||
// print(jsonEncode(deletedSp));
|
||||
// print("old bhn");
|
||||
// print(jsonEncode(oldBhn));
|
||||
// print("new bhn");
|
||||
// print(jsonEncode(newBhn));
|
||||
//compare old bhn and new bhn to get deleted bahan
|
||||
List<Bahan> deletedBhn = List.empty(growable: true);
|
||||
for (var i = 0; i < oldBhn.length; i++) {
|
||||
Bahan sp = newBhn.firstWhere((element) => element.id == oldBhn[i].id,
|
||||
orElse: () => Bahan(ctr: TextEditingController(), id: "deleted"));
|
||||
if (sp.id == "deleted") {
|
||||
deletedBhn.add(oldBhn[i]);
|
||||
}
|
||||
}
|
||||
List<Bahan> tempBhn = tempRegistrationData.bahan ?? [];
|
||||
for (var e in deletedBhn) {
|
||||
tempBhn.removeWhere((element) => element.id == e.id);
|
||||
}
|
||||
// print("deleted bahan");
|
||||
// print(jsonEncode(deletedBhn));
|
||||
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
token: auth?.token,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
specimens: tempSp,
|
||||
paket: tempRegistrationData.paket,
|
||||
bahan: tempBhn,
|
||||
tests: temp,
|
||||
total: total.toString());
|
||||
ref.read(selectedTestProvider.notifier).state = selectedTest;
|
||||
if (selectedTest.isEmpty) {
|
||||
ref.read(registrasiProvider.state).update((state) => state - 1);
|
||||
}
|
||||
}
|
||||
|
||||
deletePaket(String idPaket) {
|
||||
List<Paket> temp = tempRegistrationData.paket ?? [];
|
||||
List<String> selectedPaket = ref.watch(selectedPacketProvider);
|
||||
|
||||
selectedPaket.removeWhere((element) => element == idPaket);
|
||||
temp.removeWhere((element) => element.id == idPaket);
|
||||
|
||||
ref.read(selectedPacketProvider.notifier).state = selectedPaket;
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
token: auth?.token,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
specimens: tempRegistrationData.specimens,
|
||||
paket: temp,
|
||||
bahan: tempRegistrationData.bahan,
|
||||
tests: tempRegistrationData.tests,
|
||||
total: tempRegistrationData.total);
|
||||
}
|
||||
|
||||
Future<DateTime?> pickDate(DateTime initialdate) => showDatePicker(
|
||||
// locale: Locale("id", "ID"),
|
||||
context: context,
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
cancelText: "Batal",
|
||||
confirmText: "Simpan",
|
||||
helpText: "Pilih Tanggal",
|
||||
initialDate: initialdate,
|
||||
firstDate: DateTime(1800),
|
||||
lastDate: DateTime(2100));
|
||||
|
||||
Future<TimeOfDay?> pickTime(TimeOfDay initialTime) => showTimePicker(
|
||||
context: context,
|
||||
initialTime: initialTime,
|
||||
cancelText: "Batal",
|
||||
confirmText: "Simpan",
|
||||
helpText: "Masukkan Jam dan Menit",
|
||||
hourLabelText: "Jam",
|
||||
minuteLabelText: "Menit",
|
||||
builder: (context, childWidget) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
// Using 24-Hour format
|
||||
alwaysUse24HourFormat: true),
|
||||
// If you want 12-Hour format, just change alwaysUse24HourFormat to false or remove all the builder argument
|
||||
child: childWidget!);
|
||||
},
|
||||
initialEntryMode: TimePickerEntryMode.input);
|
||||
|
||||
Future pickDateTime(String idtab, String idtest, String dt) async {
|
||||
print(dt);
|
||||
|
||||
// DateTime selectedDate = DateTime.parse(dt);
|
||||
// DateTime? date = await pickDate(selectedDate);
|
||||
// if (date == null) return;
|
||||
|
||||
// TimeOfDay? time = await pickTime(
|
||||
// TimeOfDay(hour: selectedDate.hour, minute: selectedDate.minute));
|
||||
// if (time == null) return;
|
||||
var test = tempRegistrationData.tests ?? [];
|
||||
for (var i = 0; i < test.length; i++) {
|
||||
if (test[i].id == idtest && test[i].tab == idtab) {
|
||||
test[i].date = dt;
|
||||
}
|
||||
}
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
specimens: tempRegistrationData.specimens,
|
||||
tests: test,
|
||||
token: auth?.token,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
bahan: tempRegistrationData.bahan,
|
||||
total: tempRegistrationData.total);
|
||||
}
|
||||
|
||||
Future dateValidationFunc(
|
||||
String idtab, String idtest, bool validate) async {
|
||||
// DateTime selectedDate = DateTime.parse(dt);
|
||||
// DateTime? date = await pickDate(selectedDate);
|
||||
// if (date == null) return;
|
||||
|
||||
// TimeOfDay? time = await pickTime(
|
||||
// TimeOfDay(hour: selectedDate.hour, minute: selectedDate.minute));
|
||||
// if (time == null) return;
|
||||
var test = tempRegistrationData.tests ?? [];
|
||||
for (var i = 0; i < test.length; i++) {
|
||||
if (test[i].id == idtest && test[i].tab == idtab) {
|
||||
test[i].dateVal = validate;
|
||||
}
|
||||
}
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
specimens: tempRegistrationData.specimens,
|
||||
tests: test,
|
||||
token: auth?.token,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
bahan: tempRegistrationData.bahan,
|
||||
total: tempRegistrationData.total);
|
||||
}
|
||||
|
||||
bool validateDate(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
SanckbarWidget(context, "Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
final splitted = value.split(" ");
|
||||
if (splitted.length == 2) {
|
||||
final date = splitted[0];
|
||||
final time = splitted[1];
|
||||
final splittedDate = date.split("-");
|
||||
final splittedTime = time.split(":");
|
||||
if (splittedDate.length == 3) {
|
||||
final day = int.tryParse(splittedDate[0]);
|
||||
final month = int.tryParse(splittedDate[1]);
|
||||
final year = int.tryParse(splittedDate[2]);
|
||||
if (day != null) {
|
||||
if (day > 31) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (month != null) {
|
||||
if (month > 12) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// if (year == null) {
|
||||
// return "Format salah";
|
||||
// }
|
||||
} else {
|
||||
SanckbarWidget(context, "Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
if (splittedTime.length == 2) {
|
||||
var hour = int.tryParse(splittedTime[0]);
|
||||
var sec = int.tryParse(splittedTime[1]);
|
||||
if (hour != null) {
|
||||
if (hour > 24) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (sec != null) {
|
||||
if (sec > 60) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SanckbarWidget(context, "Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
SanckbarWidget(context, "Format Waktu Pengambilan Sample Salah !",
|
||||
snackbarType.warning);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
addOrder() {
|
||||
print(jsonEncode(tempRegistrationData));
|
||||
for (var element in tempRegistrationData.tests!) {
|
||||
if (element.date == null || element.date!.isEmpty) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Waktu pengambilan sample ${element.name} Tidak boleh kosong",
|
||||
snackbarType.warning);
|
||||
continue;
|
||||
}
|
||||
if (validateDate(element.date)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var coba = Jiffy.parse(element.date!, pattern: 'dd-MM-yyyy HH:mm')
|
||||
.format(pattern: 'yyyy-MM-dd HH:mm');
|
||||
print(coba);
|
||||
}
|
||||
// print(jsonEncode(tempRegistrationData));
|
||||
// return;
|
||||
ref
|
||||
.read(NewOrderProviderProvider.notifier)
|
||||
.addOrder(prm: tempRegistrationData);
|
||||
}
|
||||
|
||||
ref.listen(
|
||||
NewOrderProviderProvider,
|
||||
(pref, next) {
|
||||
if (next is NewOrderProviderStateInit) {
|
||||
ref.read(addOrderLoadingProvider.notifier).state = true;
|
||||
} else if (next is NewOrderProviderStateLoading) {
|
||||
ref.read(addOrderLoadingProvider.notifier).state = true;
|
||||
} else if (next is NewOrderProviderStateError) {
|
||||
ref.read(addOrderLoadingProvider.notifier).state = false;
|
||||
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is NewOrderProviderStateDone) {
|
||||
ref.read(orderNumberProvider.notifier).state = next.number;
|
||||
print(next.number);
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Registrasi Berhasil. Order Number ${next.number}",
|
||||
snackbarType.success);
|
||||
|
||||
ref.read(addOrderLoadingProvider.notifier).state = false;
|
||||
|
||||
ref.read(registrasiProvider.state).update((state) => 3);
|
||||
print(jsonEncode(tempRegistrationData));
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return Material(
|
||||
child: Container(
|
||||
width: Constant.getActualX(context: context, x: 1160),
|
||||
// height: MediaQuery.of(context).size.height,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(context: context, x: 1160),
|
||||
// Constant.getActualX(context: context, x: 1160) * 0.71,
|
||||
child: TestsTableWidget(
|
||||
specimenLoading: specimenLoading,
|
||||
testScrollCtr: testScrollCtr,
|
||||
tempRegistrationData: tempRegistrationData,
|
||||
addOrderLoading: addOrderLoading,
|
||||
delete: delete,
|
||||
deletePaket: deletePaket,
|
||||
pickDateTime: pickDateTime),
|
||||
),
|
||||
// Container(
|
||||
// width:
|
||||
// Constant.getActualX(context: context, x: 1160) * 0.05,
|
||||
// ),
|
||||
// Container(
|
||||
// // color: Colors.red,
|
||||
// width:
|
||||
// Constant.getActualX(context: context, x: 1160) * 0.24,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Container(
|
||||
// width:
|
||||
// Constant.getActualX(context: context, x: 1160) *
|
||||
// 0.24,
|
||||
// child: TabBar(
|
||||
// controller: tabctr,
|
||||
// labelColor: Colors.black,
|
||||
// labelStyle: Constant.body3_500(context: context)
|
||||
// .copyWith(color: Colors.black),
|
||||
// indicatorColor: Constant.primaryBlue,
|
||||
// onTap: (value) => selectedTab.value = value,
|
||||
// tabs: [
|
||||
// Tab(
|
||||
// text: "Specimen",
|
||||
// ),
|
||||
// Tab(
|
||||
// text: "Bahan",
|
||||
// )
|
||||
// ]),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height:
|
||||
// Constant.getActualY(context: context, y: 20),
|
||||
// ),
|
||||
// if (selectedTab.value == 0)
|
||||
// SpecimenTableWidget(
|
||||
// specimenLoading: specimenLoading,
|
||||
// tempRegistrationData: tempRegistrationData,
|
||||
// addOrderLoading: addOrderLoading),
|
||||
// if (selectedTab.value == 1)
|
||||
// BahanTableWidget(
|
||||
// specimenLoading: specimenLoading,
|
||||
// tempRegistrationData: tempRegistrationData,
|
||||
// addOrderLoading: addOrderLoading)
|
||||
|
||||
// // SizedBox(
|
||||
// // height:
|
||||
// // Constant.getActualY(context: context, y: 20),
|
||||
// // ),
|
||||
// // BahanTableWidget(
|
||||
// // specimenLoading: specimenLoading,
|
||||
// // tempRegistrationData: tempRegistrationData,
|
||||
// // addOrderLoading: addOrderLoading),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(
|
||||
color: Colors.grey.shade400, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: addOrderLoading == false
|
||||
? () {
|
||||
// Navigator.pop(context);
|
||||
ref
|
||||
.read(registrasiProvider.state)
|
||||
.update((state) => state - 1);
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height:
|
||||
Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: addOrderLoading
|
||||
? LoadingAnimationWidget.staggeredDotsWave(
|
||||
color: Constant.green, size: 30)
|
||||
: Text('Sebelumnya',
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Constant.green,
|
||||
side: BorderSide(color: Constant.green, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
|
||||
// onPressed: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: ((context) => DialogPemeriksaan()));
|
||||
// },
|
||||
onPressed: addOrderLoading == false
|
||||
? () {
|
||||
addOrder();
|
||||
}
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height:
|
||||
Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: addOrderLoading
|
||||
? LoadingAnimationWidget.staggeredDotsWave(
|
||||
color: Colors.white, size: 30)
|
||||
: Text('Simpan',
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
}
|
||||
}
|
||||
658
lib/screen/registrasi/form_pemeriksaan.dart
Normal file
658
lib/screen/registrasi/form_pemeriksaan.dart
Normal file
@@ -0,0 +1,658 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mitra_corporate/model/auth_model.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/model/test_model.dart';
|
||||
import 'package:mitra_corporate/provider/auth_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/registrasi_prvider.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../provider/registrasi_provider.dart';
|
||||
import '../../widgets/custom_snackbar_widget.dart';
|
||||
import '../../widgets/custom_text_field.dart';
|
||||
|
||||
// buat model tipu2 sebagai penampung list dari data-data
|
||||
// DummyListPeriksa = idListPeriksa, idTipePeriksa, namaPeriksa
|
||||
// DummyTipePeriksa = idTipePeriksa, tipePeriksa
|
||||
class DummyListPeriksa {
|
||||
late int idListPeriksa;
|
||||
late int idTipePeriksa;
|
||||
late String namaPeriksa;
|
||||
|
||||
DummyListPeriksa(
|
||||
{required this.idListPeriksa,
|
||||
required this.idTipePeriksa,
|
||||
required this.namaPeriksa});
|
||||
}
|
||||
|
||||
class DummyTipePeriksa {
|
||||
late int idTipePeriksa;
|
||||
late String tipePeriksa;
|
||||
|
||||
DummyTipePeriksa({required this.idTipePeriksa, required this.tipePeriksa});
|
||||
}
|
||||
|
||||
// ubah stateless jadi HookConsumerWidget
|
||||
class FormPemeriksaan extends HookConsumerWidget {
|
||||
const FormPemeriksaan({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final tempRegistrationData = ref.watch(registrationDataProvider);
|
||||
final selectedtest = ref.watch(selectedTestProvider);
|
||||
final selectedPacket = ref.watch(selectedPacketProvider);
|
||||
// inisialisasi baca provider idTipePeriksaStateProvider
|
||||
final selectedTab = ref.watch(idTipePeriksaStateProvider);
|
||||
final AuthModel auth = ref.watch(authProvider) ?? AuthModel();
|
||||
final listTest = useState<List<TestModel>>(List.empty());
|
||||
final testLoading = useState(false);
|
||||
final searchCtr = useTextEditingController(text: "");
|
||||
final scrollCtr = useScrollController();
|
||||
final ctr = useState(AutoScrollController());
|
||||
|
||||
//get pemeriksaan from api
|
||||
getPemeriksaan() {
|
||||
ref
|
||||
.read(GetFPPProvider.notifier)
|
||||
.getData(mouID: auth.mUserMMouID ?? "0", token: auth.token ?? "0");
|
||||
}
|
||||
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
getPemeriksaan();
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
int index = listTest.value
|
||||
.indexWhere((element) => element.tabId == selectedTab);
|
||||
print(index);
|
||||
// scrollCtr.animateTo(double.parse(index.toString()),
|
||||
// curve: Curves.linear, duration: Duration(milliseconds: 100));
|
||||
// scrollCtr.jumpTo(double.parse(index.toString()));
|
||||
if (searchCtr.text.isNotEmpty) {
|
||||
ctr.value.scrollToIndex(index);
|
||||
}
|
||||
});
|
||||
return () {};
|
||||
}, [selectedTab]);
|
||||
// ref.watch(idTipePeriksaStateProvider.notifier).addListener((state) {
|
||||
// int index =
|
||||
// listTest.value.indexWhere((element) => element.tabId == selectedTab);
|
||||
// print(index);
|
||||
// if (index != -1) {
|
||||
// // scrollCtr.animateTo(double.parse(index.toString()),
|
||||
// // curve: Curves.linear, duration: Duration(milliseconds: 100));
|
||||
// // scrollCtr.jumpTo(double.parse(index.toString()));
|
||||
// }
|
||||
// });
|
||||
|
||||
ref.listen(
|
||||
GetFPPProvider,
|
||||
(pref, next) {
|
||||
if (next is GetFPPStateInit) {
|
||||
testLoading.value = true;
|
||||
} else if (next is GetFPPStateLoading) {
|
||||
testLoading.value = true;
|
||||
} else if (next is GetFPPStateError) {
|
||||
testLoading.value = false;
|
||||
print(next.message);
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is GetFPPStateDone) {
|
||||
listTest.value = next.model;
|
||||
ref.read(tempTestListProvider.notifier).state = next.model;
|
||||
|
||||
// tabController.length
|
||||
|
||||
testLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// searchCtr.addListener(() {
|
||||
// listTest.value.firstWhere((element) => element.items)
|
||||
// },);
|
||||
|
||||
return Material(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 500),
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
suffixIcon: const Icon(EvaIcons.search),
|
||||
controller: searchCtr,
|
||||
isPassword: false,
|
||||
hintText: "Cari Pemeriksaan",
|
||||
labelText: "Cari Pemeriksaan",
|
||||
),
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 12)),
|
||||
// Tab
|
||||
testLoading.value
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Colors.blue, size: 20)
|
||||
: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: Constant.getActualX(context: context, x: 1080)),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: Constant.getActualY(context: context, y: 70),
|
||||
child: ScrollConfiguration(
|
||||
behavior:
|
||||
ScrollConfiguration.of(context).copyWith(dragDevices: {
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
PointerDeviceKind.unknown
|
||||
}),
|
||||
child: ListView(
|
||||
controller: ctr.value,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: listTest.value
|
||||
.asMap()
|
||||
.entries
|
||||
.map((e) => AutoScrollTag(
|
||||
key: ValueKey(e.key),
|
||||
index: e.key,
|
||||
controller: ctr.value,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: selectedTab == e.value.tabId
|
||||
? BorderSide(
|
||||
width: 2,
|
||||
color: Constant.primaryRed)
|
||||
: const BorderSide(
|
||||
color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
shadowColor: Constant.primaryRed
|
||||
.withOpacity(0.5),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(idTipePeriksaStateProvider
|
||||
.state)
|
||||
.update((state) => e.value.tabId!);
|
||||
},
|
||||
child: Text(
|
||||
e.value.tab!,
|
||||
style:
|
||||
Constant.body3_500(context: context)
|
||||
.copyWith(color: Colors.black),
|
||||
)),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 14)),
|
||||
|
||||
// widget checkbox semua biar rapi
|
||||
listCheckboxWidget(
|
||||
search: searchCtr,
|
||||
listTest: listTest,
|
||||
loading: testLoading,
|
||||
),
|
||||
SizedBox(height: Constant.getActualY(context: context, y: 24)),
|
||||
SizedBox(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(color: Colors.grey.shade400, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: () {
|
||||
// Navigator.pop(context);
|
||||
ref
|
||||
.read(registrasiProvider.state)
|
||||
.update((state) => state - 1);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: Text('Sebelumnya',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
)),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 24)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Constant.green,
|
||||
side: BorderSide(color: Constant.green, width: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (selectedtest.isEmpty && selectedPacket.isEmpty) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Belum memilih Pemeriksaan atau paket",
|
||||
snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
List<Tests> ts = List.empty(growable: true);
|
||||
double total = 0;
|
||||
for (var i = 0; i < selectedtest.length; i++) {
|
||||
var splitted = selectedtest[i].split("|");
|
||||
var tabid = splitted[0];
|
||||
var testid = splitted[1];
|
||||
for (var j = 0; j < listTest.value.length; j++) {
|
||||
if (listTest.value[j].tabId == int.parse(tabid)) {
|
||||
var tests = listTest.value[j].items;
|
||||
for (var k = 0; k < tests!.length; k++) {
|
||||
if (tests[k].testID == testid) {
|
||||
ts.add(Tests(
|
||||
date: DateFormat('dd-MM-yyyy HH:mm')
|
||||
.format(DateTime.now())
|
||||
.toString(),
|
||||
id: tests[k].testID,
|
||||
name: tests[k].testName,
|
||||
price: tests[k].testPrice,
|
||||
sasCode: tests[k].sasCode,
|
||||
// specimen: "",
|
||||
tab: tabid,
|
||||
));
|
||||
total = total +
|
||||
double.parse(tests[k].testPrice ?? "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Paket> pkt = List.empty(growable: true);
|
||||
for (var i = 0; i < selectedPacket.length; i++) {
|
||||
var paket = listTest.value
|
||||
.firstWhere((element) => element.isPaket == "Y");
|
||||
paket.items?.forEach((element) {
|
||||
if (element.testID == selectedPacket[i]) {
|
||||
pkt.add(Paket(
|
||||
id: element.testID,
|
||||
arrTest: element.arrTest,
|
||||
detail: element.sasCode,
|
||||
price: element.testPrice,
|
||||
type: element.type,
|
||||
name: element.testName));
|
||||
total =
|
||||
total + double.parse(element.testPrice ?? "0");
|
||||
}
|
||||
});
|
||||
}
|
||||
bool paketValidation = false;
|
||||
bool testValidation = false;
|
||||
for (var e in pkt) {
|
||||
var test = e.arrTest?.split(",");
|
||||
test?.forEach((f) {
|
||||
for (var g in pkt) {
|
||||
if (e.id?.trim() != g.id?.trim()) {
|
||||
var testCek = g.arrTest!.split(",");
|
||||
var cek = testCek.firstWhere(
|
||||
(h) => h.trim() == f.trim(),
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (cek != "-1") {
|
||||
paketValidation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for (var e in pkt) {
|
||||
var test = e.arrTest?.split(",");
|
||||
test?.forEach((f) {
|
||||
for (var g in ts) {
|
||||
if (f.trim() == g.id?.trim()) {
|
||||
testValidation = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (paketValidation) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Paket Pilihan memiliki pemeriksaan yang sama ",
|
||||
snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
if (testValidation) {
|
||||
SanckbarWidget(
|
||||
context,
|
||||
"Paket Pilihan memiliki pemeriksaan yang sama dengan test pilihan",
|
||||
snackbarType.warning);
|
||||
return;
|
||||
}
|
||||
|
||||
ref.read(registrationDataProvider.notifier).state =
|
||||
RegistrationModel(
|
||||
orderID: tempRegistrationData.orderID,
|
||||
patientId: tempRegistrationData.patientId,
|
||||
token: auth.token,
|
||||
patientData: tempRegistrationData.patientData,
|
||||
specimens: tempRegistrationData.specimens,
|
||||
bahan: tempRegistrationData.bahan,
|
||||
tests: ts,
|
||||
paket: pkt,
|
||||
total: total.toString());
|
||||
ref.read(registrasiProvider.state).update((state) => 2);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 56),
|
||||
child: Center(
|
||||
child: Text('Berikutnya',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class listCheckboxWidget extends HookConsumerWidget {
|
||||
const listCheckboxWidget(
|
||||
{super.key,
|
||||
required this.listTest,
|
||||
required this.loading,
|
||||
required this.search});
|
||||
final ValueNotifier<List<TestModel>> listTest;
|
||||
final ValueNotifier<bool> loading;
|
||||
final TextEditingController search;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
bool? isChecked = false;
|
||||
final tests = useState<List<Items>>(List.empty());
|
||||
final isPaket = useState(false);
|
||||
|
||||
// inisialisasi state provider buat baca idTipePeriksa yang di klik
|
||||
final selectedTab = ref.watch(idTipePeriksaStateProvider);
|
||||
final selectedTest = ref.watch(selectedTestProvider);
|
||||
final selectedPacket = ref.watch(selectedPacketProvider);
|
||||
final scrollCtr = useScrollController();
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
if (loading.value == false && listTest.value.isNotEmpty) {
|
||||
// TestModel temp = listTest.value[0];
|
||||
var selected = listTest.value
|
||||
.firstWhere((element) => element.tabId == selectedTab);
|
||||
if (selected.isPaket == 'Y') {
|
||||
isPaket.value = true;
|
||||
} else {
|
||||
isPaket.value = false;
|
||||
}
|
||||
if (search.text.isNotEmpty) {
|
||||
List<Items> filter = selected.items!
|
||||
.where((element) =>
|
||||
element.testName!.toLowerCase().contains(search.text))
|
||||
.toList();
|
||||
tests.value = filter;
|
||||
} else {
|
||||
tests.value = selected.items ?? [];
|
||||
}
|
||||
}
|
||||
});
|
||||
return () {};
|
||||
}, [selectedTab, loading.value]);
|
||||
|
||||
search.addListener(
|
||||
() {
|
||||
if (loading.value == false && listTest.value.isNotEmpty) {
|
||||
for (var i = 0; i < listTest.value.length; i++) {
|
||||
List<Items> flt = listTest.value[i].items!
|
||||
.where((element) => element.testName!
|
||||
.toLowerCase()
|
||||
.contains(search.text.toLowerCase()))
|
||||
.toList();
|
||||
if (flt.isNotEmpty) {
|
||||
ref.read(idTipePeriksaStateProvider.notifier).state =
|
||||
listTest.value[i].tabId!;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var selected = listTest.value
|
||||
.firstWhere((element) => element.tabId == selectedTab);
|
||||
|
||||
if (search.text.isNotEmpty) {
|
||||
List<Items> filter = selected.items!
|
||||
.where((element) => element.testName!
|
||||
.toLowerCase()
|
||||
.contains(search.text.toLowerCase()))
|
||||
.toList();
|
||||
tests.value = filter;
|
||||
} else {
|
||||
tests.value = selected.items ?? [];
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
selectedItem(int idTab, String idTest) {
|
||||
List<String> temp = selectedTest.toSet().toList(growable: true);
|
||||
var data = "$idTab|$idTest";
|
||||
var cek = temp.firstWhere(
|
||||
(element) => element == data,
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (cek == "-1") {
|
||||
temp.add(data);
|
||||
} else {
|
||||
temp.remove(cek);
|
||||
}
|
||||
ref.read(selectedTestProvider.notifier).state = temp.toSet().toList();
|
||||
}
|
||||
|
||||
valueCek<Bool>(int idTab, String idTest) {
|
||||
var data = "$idTab|$idTest";
|
||||
var cek = selectedTest.firstWhere(
|
||||
(element) => element == data,
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (cek == "-1") {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
selectPacket(String idTest) {
|
||||
List<String> temp = selectedPacket.toSet().toList(growable: true);
|
||||
|
||||
var cek = temp.firstWhere(
|
||||
(element) => element == idTest,
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (cek == "-1") {
|
||||
temp.add(idTest);
|
||||
} else {
|
||||
temp.remove(cek);
|
||||
}
|
||||
ref.read(selectedPacketProvider.notifier).state = temp.toSet().toList();
|
||||
}
|
||||
|
||||
valueCekPacket<Bool>(String idTest) {
|
||||
var cek = selectedPacket.firstWhere(
|
||||
(element) => element == idTest,
|
||||
orElse: () => "-1",
|
||||
);
|
||||
if (cek == "-1") {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// buat data2 dari List Periksa
|
||||
|
||||
return Row(children: [
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1080),
|
||||
height: Constant.getActualY(context: context, y: 230),
|
||||
child: loading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 30),
|
||||
)
|
||||
: Scrollbar(
|
||||
controller: scrollCtr,
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
child: ScrollConfiguration(
|
||||
behavior:
|
||||
ScrollConfiguration.of(context).copyWith(dragDevices: {
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
PointerDeviceKind.unknown
|
||||
}),
|
||||
child: isPaket.value
|
||||
? ListView(
|
||||
controller: scrollCtr,
|
||||
children: tests.value
|
||||
.map(
|
||||
(e) => Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(4)),
|
||||
// value: valueCek(
|
||||
// selectedTab, e.testID!),
|
||||
value: valueCekPacket(e.testID!),
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
selectPacket(e.testID!);
|
||||
// selectedItem(
|
||||
// selectedTab, e.testID!);
|
||||
}),
|
||||
SizedBox(
|
||||
// constraints: BoxConstraints(
|
||||
// maxWidth:
|
||||
// ),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 380),
|
||||
child: Text('${e.testName}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant
|
||||
.textBlack)),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 30),
|
||||
child: Text(
|
||||
e.sasCode ?? "",
|
||||
style: Constant.caption2_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textGrey),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
)
|
||||
: GridView.count(
|
||||
controller: scrollCtr,
|
||||
shrinkWrap: true,
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 15,
|
||||
children: tests.value
|
||||
.map(
|
||||
(e) => Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(4)),
|
||||
// value: valueCek(selectedTab, e.testID!),
|
||||
value:
|
||||
valueCek(selectedTab, e.testID!),
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
selectedItem(
|
||||
selectedTab, e.testID!);
|
||||
}),
|
||||
SizedBox(
|
||||
// constraints: BoxConstraints(
|
||||
// maxWidth:
|
||||
// ),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 380),
|
||||
child: Text('${e.testName}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack)),
|
||||
),
|
||||
// Container(
|
||||
// // constraints: BoxConstraints(
|
||||
// // maxWidth:
|
||||
// // ),
|
||||
// // color: Colors.red,
|
||||
// // width:
|
||||
// // Constant.getActualX(context: context, x: 350),
|
||||
// child: Text(
|
||||
// Constant.convertToIdr(
|
||||
// int.parse(e.testPrice ?? "0"), 0),
|
||||
// style: Constant.body3_500(
|
||||
// context: context)
|
||||
// .copyWith(color: Constant.textBlack)),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
66
lib/screen/registrasi/get_filter_provider.dart
Normal file
66
lib/screen/registrasi/get_filter_provider.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/registration_filter_model.dart';
|
||||
import 'package:mitra_corporate/repository/registration_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class GetFilterRegistrationState extends Equatable {
|
||||
final DateTime date;
|
||||
const GetFilterRegistrationState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class GetFilterRegistrationStateInit extends GetFilterRegistrationState {
|
||||
GetFilterRegistrationStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFilterRegistrationStateLoading extends GetFilterRegistrationState {
|
||||
GetFilterRegistrationStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFilterRegistrationStateError extends GetFilterRegistrationState {
|
||||
final String message;
|
||||
GetFilterRegistrationStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFilterRegistrationStateDone extends GetFilterRegistrationState {
|
||||
final RegistrationFilterModel model;
|
||||
GetFilterRegistrationStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class GetFilterRegistrationNotifier
|
||||
extends StateNotifier<GetFilterRegistrationState> {
|
||||
final Ref ref;
|
||||
GetFilterRegistrationNotifier({
|
||||
required this.ref,
|
||||
}) : super(GetFilterRegistrationStateInit());
|
||||
|
||||
void getData({required String token}) async {
|
||||
try {
|
||||
state = GetFilterRegistrationStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp =
|
||||
await RegistrationRepository(dio: dio).getFilter(token: token);
|
||||
state = GetFilterRegistrationStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = GetFilterRegistrationStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = GetFilterRegistrationStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final GetFilterRegistrationProvider = StateNotifierProvider<
|
||||
GetFilterRegistrationNotifier, GetFilterRegistrationState>(
|
||||
(ref) => GetFilterRegistrationNotifier(ref: ref));
|
||||
67
lib/screen/registrasi/get_specimen_provider.dart
Normal file
67
lib/screen/registrasi/get_specimen_provider.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/repository/registration_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class GetSpecimenState extends Equatable {
|
||||
final DateTime date;
|
||||
const GetSpecimenState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class GetSpecimenStateInit extends GetSpecimenState {
|
||||
GetSpecimenStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetSpecimenStateLoading extends GetSpecimenState {
|
||||
GetSpecimenStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetSpecimenStateError extends GetSpecimenState {
|
||||
final String message;
|
||||
GetSpecimenStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetSpecimenStateDone extends GetSpecimenState {
|
||||
final List<GetSpecimenModel> model;
|
||||
GetSpecimenStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class GetSpecimenNotifier extends StateNotifier<GetSpecimenState> {
|
||||
final Ref ref;
|
||||
GetSpecimenNotifier({
|
||||
required this.ref,
|
||||
}) : super(GetSpecimenStateInit());
|
||||
|
||||
void getData(
|
||||
{required List<Map<String, String>> arrTest,
|
||||
required String token}) async {
|
||||
try {
|
||||
state = GetSpecimenStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await RegistrationRepository(dio: dio)
|
||||
.getSpecimen(arrTest: arrTest, token: token);
|
||||
state = GetSpecimenStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = GetSpecimenStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = GetSpecimenStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final GetSpecimenProvider =
|
||||
StateNotifierProvider<GetSpecimenNotifier, GetSpecimenState>(
|
||||
(ref) => GetSpecimenNotifier(ref: ref));
|
||||
64
lib/screen/registrasi/new_order_provider.dart
Normal file
64
lib/screen/registrasi/new_order_provider.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/repository/registration_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class NewOrderProviderState extends Equatable {
|
||||
final DateTime date;
|
||||
const NewOrderProviderState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class NewOrderProviderStateInit extends NewOrderProviderState {
|
||||
NewOrderProviderStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class NewOrderProviderStateLoading extends NewOrderProviderState {
|
||||
NewOrderProviderStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class NewOrderProviderStateError extends NewOrderProviderState {
|
||||
final String message;
|
||||
NewOrderProviderStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class NewOrderProviderStateDone extends NewOrderProviderState {
|
||||
final String number;
|
||||
NewOrderProviderStateDone({
|
||||
required this.number,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class NewOrderProviderNotifier extends StateNotifier<NewOrderProviderState> {
|
||||
final Ref ref;
|
||||
NewOrderProviderNotifier({
|
||||
required this.ref,
|
||||
}) : super(NewOrderProviderStateInit());
|
||||
|
||||
void addOrder({required RegistrationModel prm}) async {
|
||||
try {
|
||||
state = NewOrderProviderStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await RegistrationRepository(dio: dio).addOrder(prm: prm);
|
||||
state = NewOrderProviderStateDone(number: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = NewOrderProviderStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = NewOrderProviderStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final NewOrderProviderProvider =
|
||||
StateNotifierProvider<NewOrderProviderNotifier, NewOrderProviderState>(
|
||||
(ref) => NewOrderProviderNotifier(ref: ref));
|
||||
116
lib/screen/registrasi/registrasi_pasien_screen.dart
Normal file
116
lib/screen/registrasi/registrasi_pasien_screen.dart
Normal file
@@ -0,0 +1,116 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/provider/menu_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/dialog_pendaftaran_pasien.dart';
|
||||
|
||||
import 'package:mitra_corporate/screen/registrasi/table_pasien.dart';
|
||||
import 'package:mitra_corporate/widgets/header.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../provider/registrasi_provider.dart';
|
||||
import '../../widgets/custom_text_field.dart';
|
||||
|
||||
class RegistrasiPasienScreen extends HookConsumerWidget {
|
||||
const RegistrasiPasienScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isExpand = ref.watch(sideBarExpandProvider);
|
||||
|
||||
final keywordCtr =
|
||||
useTextEditingController(text: ref.read(keywordProvider));
|
||||
return Scaffold(
|
||||
// backgroundColor: Constant.grey_200,
|
||||
// backgroundColor: Color(0xffF9FAFB),
|
||||
body: Column(
|
||||
children: [
|
||||
Header(),
|
||||
Padding(
|
||||
// padding: const EdgeInsets.all(0),
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
// width: Constant.getActualX(context: context, x: 1079),
|
||||
// height: Constant.getActualY(context: context, y: 40),
|
||||
child: Text('Registrasi Pasien',
|
||||
style: Constant.h3_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 40),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 24),
|
||||
vertical: Constant.getActualY(context: context, y: 32),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
// height: Constant.getActualY(context: context, y: 56),
|
||||
child: CustomTextField(
|
||||
controller: keywordCtr,
|
||||
onChange: (value) {
|
||||
ref.read(keywordProvider.notifier).state =
|
||||
value;
|
||||
},
|
||||
isPassword: false,
|
||||
hintText: "Cari Nama, NIK, dan Nomor HP",
|
||||
labelText: "Cari Nama, NIK, dan Nomor HP",
|
||||
suffixIcon: Icon(EvaIcons.search),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 24)),
|
||||
SizedBox(
|
||||
width:
|
||||
Constant.getActualX(context: context, x: 171),
|
||||
height:
|
||||
Constant.getActualY(context: context, y: 56),
|
||||
// decoration: BoxDecoration(
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// color: Constant.primaryRed),
|
||||
child: ElevatedButton.icon(
|
||||
label: Text('Pasien Baru',
|
||||
style: Constant.button_large(context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
icon: Icon(EvaIcons.plus,
|
||||
color: Colors.white, size: 20.0),
|
||||
onPressed: () {
|
||||
ref
|
||||
.read(dialogOrderActionProvider.notifier)
|
||||
.state = 'new';
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: ((context) =>
|
||||
DialogPendaftaranPasien()));
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 24)),
|
||||
TablePasien()
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
64
lib/screen/registrasi/registrasi_prvider.dart
Normal file
64
lib/screen/registrasi/registrasi_prvider.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/test_model.dart';
|
||||
import 'package:mitra_corporate/repository/registration_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class GetFPPState extends Equatable {
|
||||
final DateTime date;
|
||||
const GetFPPState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class GetFPPStateInit extends GetFPPState {
|
||||
GetFPPStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFPPStateLoading extends GetFPPState {
|
||||
GetFPPStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFPPStateError extends GetFPPState {
|
||||
final String message;
|
||||
GetFPPStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class GetFPPStateDone extends GetFPPState {
|
||||
final List<TestModel> model;
|
||||
GetFPPStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class GetFPPNotifier extends StateNotifier<GetFPPState> {
|
||||
final Ref ref;
|
||||
GetFPPNotifier({
|
||||
required this.ref,
|
||||
}) : super(GetFPPStateInit());
|
||||
|
||||
void getData({required String mouID, required String token}) async {
|
||||
try {
|
||||
state = GetFPPStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await RegistrationRepository(dio: dio)
|
||||
.getFPP(mouID: mouID, token: token);
|
||||
state = GetFPPStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = GetFPPStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = GetFPPStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final GetFPPProvider = StateNotifierProvider<GetFPPNotifier, GetFPPState>(
|
||||
(ref) => GetFPPNotifier(ref: ref));
|
||||
70
lib/screen/registrasi/registrasi_sukses.dart
Normal file
70
lib/screen/registrasi/registrasi_sukses.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
|
||||
class RegistrasiSukses extends HookConsumerWidget {
|
||||
const RegistrasiSukses({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final orderNumber = ref.watch(orderNumberProvider);
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
// color: Colors.green,
|
||||
width: Constant.getActualX(context: context, x: 500),
|
||||
height: Constant.getActualY(context: context, y: 500),
|
||||
child: Image.asset(
|
||||
'images/order_success.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 20),
|
||||
),
|
||||
Text('Registrastion Success',
|
||||
style: Constant.h3_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 48),
|
||||
),
|
||||
SelectableText('Order Number : $orderNumber',
|
||||
style: Constant.h3_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 48),
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 48),
|
||||
child: OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
side: BorderSide(color: Constant.primaryRed, width: 1),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(registrasiProvider.notifier).state = 0;
|
||||
ref.read(idTipePeriksaStateProvider.notifier).state = 1;
|
||||
ref.read(registrationDataProvider.notifier).state =
|
||||
RegistrationModel();
|
||||
ref.read(selectedTestProvider.notifier).state =
|
||||
List.empty(growable: true);
|
||||
ref.read(tempTestListProvider.notifier).state =
|
||||
List.empty(growable: true);
|
||||
ref.read(selectedPacketProvider.notifier).state =
|
||||
List.empty(growable: true);
|
||||
},
|
||||
child: Text('Kembali ke Dashboard',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.primaryRed))),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
74
lib/screen/registrasi/search_patient_provider.dart
Normal file
74
lib/screen/registrasi/search_patient_provider.dart
Normal file
@@ -0,0 +1,74 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mitra_corporate/model/search_patient_model.dart';
|
||||
import 'package:mitra_corporate/repository/patient_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
abstract class SearchPatientState extends Equatable {
|
||||
final DateTime date;
|
||||
const SearchPatientState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class SearchPatientStateInit extends SearchPatientState {
|
||||
SearchPatientStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SearchPatientStateLoading extends SearchPatientState {
|
||||
SearchPatientStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SearchPatientStateError extends SearchPatientState {
|
||||
final String message;
|
||||
SearchPatientStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class SearchPatientStateDone extends SearchPatientState {
|
||||
final SearchPatientModel model;
|
||||
SearchPatientStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
//notifier
|
||||
class SearchPatientNotifier extends StateNotifier<SearchPatientState> {
|
||||
final Ref ref;
|
||||
SearchPatientNotifier({
|
||||
required this.ref,
|
||||
}) : super(SearchPatientStateInit());
|
||||
|
||||
void getData(
|
||||
{required String token,
|
||||
required String page,
|
||||
required String keyword,
|
||||
required String rpp,
|
||||
required String companyID}) async {
|
||||
try {
|
||||
state = SearchPatientStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await PatientRepository(dio: dio).search(
|
||||
companyID: companyID,
|
||||
keyword: keyword,
|
||||
page: page,
|
||||
rpp: rpp,
|
||||
token: token);
|
||||
state = SearchPatientStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = SearchPatientStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = SearchPatientStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//provider
|
||||
final SearchPatientProvider =
|
||||
StateNotifierProvider<SearchPatientNotifier, SearchPatientState>(
|
||||
(ref) => SearchPatientNotifier(ref: ref));
|
||||
488
lib/screen/registrasi/table_pasien.dart
Normal file
488
lib/screen/registrasi/table_pasien.dart
Normal file
@@ -0,0 +1,488 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:mitra_corporate/screen/registrasi/delete_patient_provider%20copy.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/dialog_delete_patient.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/dialog_edit_patient.dart';
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:data_table_2/data_table_2.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mitra_corporate/model/patient_Model.dart';
|
||||
import 'package:mitra_corporate/model/registration_model.dart';
|
||||
import 'package:mitra_corporate/model/search_patient_model.dart';
|
||||
import 'package:mitra_corporate/provider/auth_provider.dart';
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
import 'package:mitra_corporate/screen/registrasi/search_patient_provider.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../../app/constant.dart';
|
||||
import '../../provider/menu_provider.dart';
|
||||
import '../../widgets/custom_snackbar_widget.dart';
|
||||
import 'dialog_pendaftaran_pasien.dart';
|
||||
|
||||
class TablePasien extends HookConsumerWidget {
|
||||
const TablePasien({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isExpand = ref.watch(sideBarExpandProvider);
|
||||
final auth = ref.watch(authProvider);
|
||||
final rowsPerPage = useState(10);
|
||||
final searchLoading = useState(false);
|
||||
final deleteLoading = useState(false);
|
||||
final dataStart = useState(1);
|
||||
final dataEnd = useState(1);
|
||||
final currPage = useState(1);
|
||||
final patientList = useState<SearchPatientModel>(
|
||||
SearchPatientModel(patients: [], total: "0", totalPage: 0));
|
||||
final keyword = ref.watch(keywordProvider);
|
||||
final registrasiTabID = ref.watch(registrasiProvider);
|
||||
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final debouncer = Debouncer(milliseconds: 100);
|
||||
debouncer.run(() {
|
||||
ref.read(SearchPatientProvider.notifier).getData(
|
||||
token: auth?.token ?? "",
|
||||
page: currPage.value.toString(),
|
||||
keyword: keyword,
|
||||
rpp: rowsPerPage.value.toString(),
|
||||
companyID: auth?.mUserMCompanyID ?? "");
|
||||
});
|
||||
});
|
||||
return () {};
|
||||
}, [currPage.value, registrasiTabID]);
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
final debouncer = Debouncer(milliseconds: 100);
|
||||
currPage.value = 1;
|
||||
debouncer.run(() {
|
||||
ref.read(SearchPatientProvider.notifier).getData(
|
||||
token: auth?.token ?? "",
|
||||
page: "1",
|
||||
keyword: keyword,
|
||||
rpp: rowsPerPage.value.toString(),
|
||||
companyID: auth?.mUserMCompanyID ?? "");
|
||||
});
|
||||
});
|
||||
return () {};
|
||||
}, [
|
||||
keyword,
|
||||
rowsPerPage.value,
|
||||
]);
|
||||
|
||||
ref.listen(
|
||||
SearchPatientProvider,
|
||||
(pref, next) {
|
||||
if (next is SearchPatientStateInit) {
|
||||
searchLoading.value = true;
|
||||
} else if (next is SearchPatientStateLoading) {
|
||||
searchLoading.value = true;
|
||||
} else if (next is SearchPatientStateError) {
|
||||
searchLoading.value = false;
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is SearchPatientStateDone) {
|
||||
patientList.value = next.model;
|
||||
// print(jsonEncode(next.model));
|
||||
|
||||
dataStart.value =
|
||||
(currPage.value * rowsPerPage.value) - rowsPerPage.value + 1;
|
||||
dataEnd.value = currPage.value == next.model.totalPage
|
||||
? int.parse(next.model.total ?? "0")
|
||||
: dataStart.value + rowsPerPage.value - 1;
|
||||
|
||||
searchLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
openDialog(PatientModel e) {
|
||||
ref.read(registrationDataProvider.notifier).state = RegistrationModel(
|
||||
patientId: e.id,
|
||||
patientData: PatientData(
|
||||
noRM: e.noRM,
|
||||
address: e.address,
|
||||
dob: e.dob,
|
||||
gender: e.sexId,
|
||||
hp: e.hp,
|
||||
name: e.name,
|
||||
nik: e.nik,
|
||||
nip: e.nip,
|
||||
prefix: e.prefix,
|
||||
kedudukan: e.kedudukan,
|
||||
jabatan: e.jabatan,
|
||||
lokasi: e.lokasi,
|
||||
pekerjaan: e.pekerjaan,
|
||||
saluation: e.titleId,
|
||||
suffix: e.suffix),
|
||||
);
|
||||
ref.read(dialogOrderActionProvider.notifier).state = 'new';
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: ((context) => DialogPendaftaranPasien()));
|
||||
}
|
||||
|
||||
openDialogEdit(PatientModel e) {
|
||||
ref.read(registrationEditPatientProvider.notifier).state =
|
||||
RegistrationModel(
|
||||
patientId: e.id,
|
||||
patientData: PatientData(
|
||||
noRM: e.noRM,
|
||||
address: e.address,
|
||||
dob: e.dob,
|
||||
gender: e.sexId,
|
||||
hp: e.hp,
|
||||
name: e.name,
|
||||
nik: e.nik,
|
||||
nip: e.nip,
|
||||
prefix: e.prefix,
|
||||
kedudukan: e.kedudukan,
|
||||
jabatan: e.jabatan,
|
||||
lokasi: e.lokasi,
|
||||
pekerjaan: e.pekerjaan,
|
||||
saluation: e.titleId,
|
||||
suffix: e.suffix),
|
||||
);
|
||||
// showDialog<String>(
|
||||
// context: context,
|
||||
// barrierDismissible: false,
|
||||
// builder: (BuildContext context) => DialogSendQr(
|
||||
// arrOrderID: ["1", "2"],
|
||||
// orderNumber: "abc",
|
||||
// ),
|
||||
// );
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: ((context) => SimpleDialog(
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12))),
|
||||
contentPadding: const EdgeInsets.all(40.0),
|
||||
children: [DialogEditPatient()],
|
||||
))).then((value) {
|
||||
print(value);
|
||||
if (value == "done") {
|
||||
ref.read(SearchPatientProvider.notifier).getData(
|
||||
token: auth?.token ?? "",
|
||||
page: currPage.value.toString(),
|
||||
keyword: keyword,
|
||||
rpp: rowsPerPage.value.toString(),
|
||||
companyID: auth?.mUserMCompanyID ?? "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openDialogDelete(PatientModel e) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return DialogDeletePatient(
|
||||
NIK: e.nik ?? "",
|
||||
delete: (patientID) {
|
||||
print(patientID);
|
||||
ref.read(DeletePatientProvider.notifier).DeletePatent(
|
||||
patient_id: patientID, token: auth?.token ?? '');
|
||||
},
|
||||
patientID: e.id ?? "",
|
||||
loading: deleteLoading.value,
|
||||
name: e.name ?? "");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
ref.listen(
|
||||
DeletePatientProvider,
|
||||
(pref, next) {
|
||||
if (next is DeletePatientProviderStateInit) {
|
||||
deleteLoading.value = true;
|
||||
} else if (next is DeletePatientProviderStateLoading) {
|
||||
deleteLoading.value = true;
|
||||
} else if (next is DeletePatientProviderStateError) {
|
||||
deleteLoading.value = false;
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is DeletePatientProviderStateDone) {
|
||||
SanckbarWidget(
|
||||
context, "Berhasil mengapus data", snackbarType.success);
|
||||
Navigator.pop(context);
|
||||
ref.read(SearchPatientProvider.notifier).getData(
|
||||
token: auth?.token ?? "",
|
||||
page: currPage.value.toString(),
|
||||
keyword: keyword,
|
||||
rpp: rowsPerPage.value.toString(),
|
||||
companyID: auth?.mUserMCompanyID ?? "");
|
||||
deleteLoading.value = false;
|
||||
}
|
||||
},
|
||||
);
|
||||
return Material(
|
||||
// elevation: 8,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
|
||||
// width: Constant.getActualX(context: context, x: 1079),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
// color: Colors.red,
|
||||
),
|
||||
height: Constant.getActualY(context: context, y: 586),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
color: Colors.white,
|
||||
height: Constant.getActualY(context: context, y: 516),
|
||||
// height: Constant.getActualY(context: context, y: 300),
|
||||
child: DataTable2(
|
||||
dividerThickness: 1,
|
||||
headingRowColor: WidgetStatePropertyAll(Constant.grey_200),
|
||||
columnSpacing: 12,
|
||||
horizontalMargin: 15,
|
||||
minWidth: 600,
|
||||
empty: Text("Data tidak ditemukan"),
|
||||
columns: [
|
||||
DataColumn2(
|
||||
label: Text('Nama Pasien',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
size: ColumnSize.M,
|
||||
),
|
||||
DataColumn2(
|
||||
label: Text('Alamat',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
size: ColumnSize.L),
|
||||
DataColumn(
|
||||
label: Text('NIK',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text('DOB',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text('Nomor HP',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
DataColumn2(
|
||||
fixedWidth:
|
||||
Constant.getActualX(context: context, x: 120),
|
||||
label: Text('Aksi',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
// size: ColumnSize.S,
|
||||
),
|
||||
],
|
||||
rows: searchLoading.value
|
||||
? [
|
||||
DataRow(cells: [
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
DataCell(LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)),
|
||||
])
|
||||
]
|
||||
: patientList.value.patients!
|
||||
.map((e) => DataRow(
|
||||
onLongPress: () {
|
||||
// openDialog(e);
|
||||
},
|
||||
cells: [
|
||||
DataCell(SelectableText(e.name ?? "",
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack))),
|
||||
DataCell(SelectableText(e.address ?? "",
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack))),
|
||||
DataCell(SelectableText(e.nik ?? "",
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack))),
|
||||
DataCell(SelectableText(
|
||||
DateFormat('dd-MM-yyyy')
|
||||
.format(DateTime.parse(e.dob!)),
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack))),
|
||||
DataCell(SelectableText(e.hp ?? "",
|
||||
style: Constant.body3_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack))),
|
||||
DataCell(Row(
|
||||
children: [
|
||||
Tooltip(
|
||||
message: "Tambah order ${e.name}",
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
openDialog(e);
|
||||
},
|
||||
icon: Icon(
|
||||
EvaIcons.plusSquare,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Tooltip(
|
||||
message: "Edit Patient ${e.name}",
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
openDialogEdit(e);
|
||||
},
|
||||
icon: Icon(
|
||||
EvaIcons.edit2,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (e.statusDelete == "Y")
|
||||
Tooltip(
|
||||
message:
|
||||
"Delete Patient ${e.name}",
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
openDialogDelete(e);
|
||||
},
|
||||
icon: Icon(
|
||||
EvaIcons.closeCircle,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
]))
|
||||
.toList()),
|
||||
),
|
||||
Material(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Colors.white,
|
||||
child: SizedBox(
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// shape: BoxShape.rectangle,
|
||||
// borderRadius: BorderRadius.circular(8)),
|
||||
height: Constant.getActualY(context: context, y: 70),
|
||||
child: Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Text(
|
||||
"Rows per page :",
|
||||
style: Constant.body3_400(context: context),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
DropdownButton<int>(
|
||||
value: rowsPerPage.value,
|
||||
dropdownColor: Colors.white,
|
||||
elevation: 0,
|
||||
style: Constant.body3_400(context: context)
|
||||
.copyWith(color: Colors.black),
|
||||
underline: Container(),
|
||||
icon: Icon(Icons.keyboard_arrow_down_rounded),
|
||||
focusColor: Colors.white,
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 10,
|
||||
child: Text("10"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 15,
|
||||
child: Text("15"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 20,
|
||||
child: Text("20"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 30,
|
||||
child: Text("30"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 40,
|
||||
child: Text("40"),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 50,
|
||||
child: Text("50"),
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
rowsPerPage.value = value!;
|
||||
}),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
Text(
|
||||
"${dataStart.value} - ${dataEnd.value} of ${patientList.value.total}",
|
||||
style: Constant.body3_400(context: context),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
onPressed: currPage.value > 1
|
||||
? () {
|
||||
currPage.value = currPage.value - 1;
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.arrow_back_ios_new_rounded)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 10),
|
||||
),
|
||||
IconButton(
|
||||
iconSize: 20,
|
||||
onPressed: currPage.value <
|
||||
patientList.value.totalPage!.toInt()
|
||||
? () {
|
||||
currPage.value = currPage.value + 1;
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.arrow_forward_ios_outlined)),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Debouncer {
|
||||
Debouncer({required this.milliseconds});
|
||||
final int milliseconds;
|
||||
Timer? _timer;
|
||||
void run(VoidCallback action) {
|
||||
if (_timer?.isActive ?? false) {
|
||||
_timer?.cancel();
|
||||
}
|
||||
_timer = Timer(Duration(milliseconds: milliseconds), action);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user