|
1 |
| -import 'package:fhir_r4/fhir_r4.dart'; |
2 | 1 | import 'package:flutter/material.dart';
|
3 | 2 | import 'package:get/get.dart';
|
4 | 3 | import 'package:symptom_tracker/services/services.dart';
|
5 | 4 | import 'package:symptom_tracker/shared/shared.dart';
|
6 |
| -import 'package:url_launcher/url_launcher.dart'; |
7 | 5 |
|
8 | 6 | class FhirView extends StatelessWidget {
|
9 |
| - final lastName = TextEditingController(text: ''); |
10 |
| - final firstName = TextEditingController(text: ''); |
11 |
| - |
12 |
| - @override |
13 |
| - void dispose() { |
14 |
| - lastName.dispose(); |
15 |
| - firstName.dispose(); |
16 |
| - } |
17 |
| - |
18 | 7 | @override
|
19 | 8 | Widget build(BuildContext context) {
|
20 |
| - return Column( |
21 |
| - mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
22 |
| - children: [ |
23 |
| - Row( |
24 |
| - children: <Widget>[ |
25 |
| - _nameContainer(lastName, 'Last name'), |
26 |
| - _nameContainer(firstName, 'First name'), |
27 |
| - ], |
28 |
| - ), |
29 |
| - _linkContainer(firstName, lastName), |
30 |
| - _patient(firstName, lastName), |
31 |
| - _fhir, |
32 |
| - ], |
| 9 | + return GetBuilder<FhirManager>( |
| 10 | + init: FhirManager(), |
| 11 | + builder: (data) => data.isBusy |
| 12 | + ? Center(child: CircularProgressIndicator()) |
| 13 | + : Column( |
| 14 | + mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 15 | + children: [ |
| 16 | + //* Aidbox FHIR calls |
| 17 | + SharedActionButton( |
| 18 | + title: 'Aidbox: Vitals', |
| 19 | + onPressed: () => data.aidboxVitals(), |
| 20 | + ), |
| 21 | + |
| 22 | + //* Hapi FHIR calls |
| 23 | + Row( |
| 24 | + mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 25 | + children: <Widget>[ |
| 26 | + _nameContainer(data.lastName, 'Last name'), |
| 27 | + _nameContainer(data.firstName, 'First name'), |
| 28 | + ], |
| 29 | + ), |
| 30 | + Row( |
| 31 | + mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 32 | + children: <Widget>[ |
| 33 | + SmallActionButton(title: 'Hapi: Search', onPressed: () => data.hapiSearch()), |
| 34 | + SmallActionButton(title: 'Hapi: Create', onPressed: () => data.hapiCreate()), |
| 35 | + ], |
| 36 | + ) |
| 37 | + ], |
| 38 | + ), |
33 | 39 | );
|
34 | 40 | }
|
35 |
| -} |
36 | 41 |
|
37 |
| -Container _linkContainer( |
38 |
| - TextEditingController first, TextEditingController last) => |
39 |
| - Container( |
40 |
| - child: InkWell( |
41 |
| - child: Text( |
42 |
| - 'Click to see new patient', |
43 |
| - style: TextStyle( |
44 |
| - color: Colors.purple, |
45 |
| - fontSize: 18, |
46 |
| - decoration: TextDecoration.underline, |
47 |
| - ), |
| 42 | + Container _nameContainer(TextEditingController name, String text) => Container( |
| 43 | + width: Get.width / 3, |
| 44 | + margin: EdgeInsets.symmetric(horizontal: 8), |
| 45 | + child: TextField( |
| 46 | + controller: name, |
| 47 | + decoration: InputDecoration(hintText: text), |
48 | 48 | ),
|
49 |
| - onTap: () async => await launch('http://hapi.fhir.org/baseR4/' |
50 |
| - 'Patient?given=${first.text}&family=${last.text}&_pretty=true'), |
51 |
| - ), |
52 |
| - ); |
53 |
| - |
54 |
| -Container _nameContainer(TextEditingController name, String text) => Container( |
55 |
| - width: 200, |
56 |
| - child: TextField( |
57 |
| - controller: name, |
58 |
| - decoration: InputDecoration(hintText: text), |
59 |
| - ), |
60 |
| - ); |
61 |
| - |
62 |
| -SharedActionButton _patient( |
63 |
| - TextEditingController first, TextEditingController last) => |
64 |
| - SharedActionButton( |
65 |
| - title: 'Create Patient', |
66 |
| - onPressed: () async { |
67 |
| - await FhirService().createPatient(first.text, last.text); |
68 |
| - }, |
69 |
| - ); |
70 |
| - |
71 |
| -SharedActionButton _fhir = SharedActionButton( |
72 |
| - title: 'Get FHIR data', |
73 |
| - onPressed: () async { |
74 |
| - List<Quantity> data = await FhirService().getResponse(); |
75 |
| - Get.defaultDialog( |
76 |
| - content: Container( |
77 |
| - height: 500, |
78 |
| - width: 300, |
79 |
| - child: ListView( |
80 |
| - shrinkWrap: true, |
81 |
| - children: <Widget>[ |
82 |
| - ...data.map((f) { |
83 |
| - return Row( |
84 |
| - mainAxisAlignment: MainAxisAlignment.spaceBetween, |
85 |
| - children: <Widget>[ |
86 |
| - Text('${f.value}'), |
87 |
| - Text('${f.unit}'), |
88 |
| - ], |
89 |
| - ); |
90 |
| - }) |
91 |
| - ], |
92 |
| - ), |
93 |
| - )); |
94 |
| - print(data); |
95 |
| - }, |
96 |
| -); |
| 49 | + ); |
| 50 | +} |
0 commit comments