forked from vganshin/aidbox-ui-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
438 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(box/set-header! "Content-Type" "text/vnd.turbo-stream.html; charset=utf-8") | ||
|
||
(let [params (box/route-params) | ||
result (box/delete {:id (:id params) :resourceType "Patient"})] | ||
(when (= (:resourceType result) "Patient") | ||
[:turbo-stream {:target (str "patient-" (:id result)) | ||
:action "remove"}] | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
(box/set-header! "Content-Type" "text/vnd.turbo-stream.html; charset=utf-8") | ||
|
||
(let [params (box/url-params) | ||
patient (when (:patient-id params) | ||
(box/read {:id (:patient-id params) :resourceType "Patient"}))] | ||
[:turbo-stream {:target "modal" | ||
:action "update"} | ||
[:template | ||
[:section {:id "edit-patient" | ||
:class "fixed top-0 bottom-0 right-0 left-0 z-10"} | ||
[:script | ||
"function removeModal(e) { | ||
if(e.target.id == 'edit-patient-root') { | ||
e.target.parentElement.remove(); | ||
} | ||
}" | ||
] | ||
[:div | ||
{:class "min-h-screen p-6 bg-gray-100 flex items-center justify-center bg-opacity-80" | ||
:id "edit-patient-root" | ||
:onclick "removeModal(event)" | ||
} | ||
[:div | ||
{:class "container max-w-screen-lg mx-auto" | ||
:id "edit-patient-modal"} | ||
[:div | ||
[:div | ||
{:class "bg-white rounded shadow-lg p-4 px-4 md:p-8 mb-6"} | ||
[:div | ||
{:class "grid gap-4 gap-y-2 text-sm grid-cols-1 lg:grid-cols-3"} | ||
[:div | ||
{:class "text-gray-600"} | ||
[:p {:class "font-medium text-lg"} "Personal Details"] | ||
[:p "Please fill out all the fields."]] | ||
[:form {:action "/ui/patients/save" :method "POST" | ||
:class "lg:col-span-2"} | ||
(when (:id patient) | ||
[:input {:type "hidden" | ||
:name "id" | ||
:value (:id patient)}] | ||
) | ||
[:div | ||
{:class | ||
"grid gap-4 gap-y-2 text-sm grid-cols-1 md:grid-cols-5"} | ||
[:div | ||
{:class "md:col-span-5"} | ||
[:label {:for "full_name"} "First Name"] | ||
[:input | ||
{:type "text", | ||
:name "given", | ||
:id "full_name", | ||
:required true | ||
:class "h-10 border mt-1 rounded px-4 w-full bg-gray-50", | ||
:value (get-in patient [:name 0 :given 0])}]] | ||
[:div | ||
{:class "md:col-span-5"} | ||
[:label {:for "full_name"} "Last Name"] | ||
[:input | ||
{:type "text", | ||
:name "family", | ||
:id "full_name", | ||
:required true | ||
:class "h-10 border mt-1 rounded px-4 w-full bg-gray-50", | ||
:value (get-in patient [:name 0 :family])}]] | ||
[:div | ||
{:class "md:col-span-3"} | ||
[:label {:for "birth-date"} "Date of Birth"] | ||
[:input | ||
{:type "date", | ||
:name "birth-date", | ||
:required true | ||
:id "birth-date", | ||
:class "h-10 border mt-1 rounded px-4 w-full bg-gray-50", | ||
:value (get-in patient [:birthDate]) | ||
:placeholder ""}]] | ||
[:div | ||
{:class "md:col-span-2"} | ||
[:label {:for "gender"} "Gender"] | ||
[:select {:name "gender" | ||
:required true | ||
:class "h-10 border mt-1 rounded px-4 w-full bg-gray-50"} | ||
[:option {:value "male" :selected (= (:gender patient) "male")} "Male"] | ||
[:option {:value "female" :selected (= (:gender patient) "female")} "Female"]]] | ||
|
||
[:div | ||
{:class "md:col-span-5 text-right"} | ||
[:div | ||
{:class "inline-flex items-end"} | ||
[:button | ||
{:class | ||
"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"} | ||
"Submit"]]]]]]]]]]]] | ||
|
||
]) | ||
|
||
#_[:turbo-stream {:target "modal" | ||
:action "update"} | ||
[:template | ||
[:span "hello"]] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[:html | ||
[:title "Aidbox | Patients | Forms"] | ||
[:script {:src "https://cdn.tailwindcss.com"}] | ||
[:link {:href "/static/assets/img/fav.svg" :rel "shortcut icon" :type "image/x-icon"}] | ||
[:body | ||
[:script {:src "/ui/$dev-mode"}] | ||
(let [forms (box/sql "select * from questionnaire") | ||
_ (m/set :forms forms)] | ||
[:div | ||
(for [f forms] | ||
[:div | ||
[:span (get-in f [:resource :title])]])] | ||
) | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
(box/set-header! "Content-Type" "text/vnd.turbo-stream.html; charset=utf-8") | ||
|
||
(let [params (box/form-params) | ||
patient (cond-> {:resourceType "Patient" | ||
:name [{:given [(get-in params [:given])] | ||
:family (get-in params [:family])}] | ||
:gender (get-in params [:gender]) | ||
:birthDate (get-in params [:birth-date])} | ||
(:id params) | ||
(assoc :id (:id params))) | ||
saved-patient (box/create patient)] | ||
|
||
(if (= (:resourceType saved-patient) "Patient") | ||
[:<> | ||
[:turbo-stream {:target "edit-patient" | ||
:action "remove"}] | ||
|
||
[:turbo-stream (if-not (:id params) | ||
{:target "patients" | ||
:action "append"} | ||
{:target (str "patient-" (:id patient)) | ||
:action "replace"}) | ||
[:template | ||
[:div {:class "contents" | ||
:id (str "patient-" (:id saved-patient))} | ||
[:div | ||
{:class "px-4 py-4 text-sm font-medium whitespace-nowrap flex items-center border-b"} | ||
[:h2 | ||
{:class "font-medium text-gray-800 dark:text-white"} | ||
(str (get-in saved-patient [:name 0 :given 0]) ", " | ||
(get-in saved-patient [:name 0 :family]))]] | ||
[:div | ||
{:class "px-12 py-4 text-sm font-medium whitespace-nowrap flex items-center border-b"} | ||
(when-let [birth-date (get-in saved-patient [:birthDate])] | ||
[:div | ||
{:class | ||
"inline px-3 py-1 text-sm font-normal rounded-full text-emerald-500 gap-x-2 bg-emerald-100/60 dark:bg-gray-800"} | ||
birth-date])] | ||
[:div | ||
{:class "px-4 py-4 text-sm whitespace-nowrap flex items-center border-b"} | ||
[:div | ||
[:h4 {:class "text-gray-700 dark:text-gray-200"} (get-in saved-patient [:gender])]]] | ||
[:div | ||
{:class "px-4 py-4 text-sm whitespace-nowrap flex items-center border-b"} | ||
[:form {:action "/ui/patients/edit" | ||
:class "mb-0"} | ||
[:input {:type "hidden" | ||
:name "patient-id" | ||
:value (:id saved-patient)}] | ||
[:button | ||
{:class | ||
"px-3 py-2 text-gray-500 transition-colors duration-200 rounded-lg dark:text-gray-300 hover:bg-gray-100"} | ||
[:i.fas.fa-pencil]]] | ||
[:a | ||
{:class | ||
"px-3 py-2 text-gray-500 transition-colors duration-200 rounded-lg dark:text-gray-300 hover:bg-gray-100" | ||
:href (str "/ui/patients/" (str (:id saved-patient))) | ||
:data-turbo-method "DELETE" | ||
:data-turbo-confirm "Do you want to delete patient?"} | ||
[:i.fas.fa-trash]]]]] | ||
|
||
] | ||
] | ||
[:turbo-stream {:target "edit-patient-modal" | ||
:action "update"} | ||
[:template [:div {:class "bg-white p-10" }][:code (pr-str saved-patient)]]] | ||
) | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
(box/set-header! "Content-Type" "text/vnd.turbo-stream.html; charset=utf-8") | ||
|
||
(let [params (box/url-params) | ||
patients (->> (box/sql ["select resource || jsonb_build_object('id', id) resource from Patient | ||
where resource::text ilike ?" (str "%" (:query params) "%")]) | ||
(mapv :resource)) | ||
_ (m/set :patients patients) | ||
] | ||
|
||
[:turbo-stream {:target "patients" | ||
:action "update"} | ||
(into [:template] | ||
(map (fn [p] | ||
[:div {:class "contents" | ||
:id (str "patient-" (:id p))} | ||
[:div | ||
{:class "px-4 py-4 text-sm font-medium whitespace-nowrap flex items-center border-b"} | ||
[:h2 | ||
{:class "font-medium text-gray-800 dark:text-white"} | ||
(str (get-in p [:name 0 :given 0]) ", " | ||
(get-in p [:name 0 :family]))]] | ||
[:div | ||
{:class "px-12 py-4 text-sm font-medium whitespace-nowrap flex items-center border-b"} | ||
(when-let [birth-date (get-in p [:birthDate])] | ||
[:div | ||
{:class | ||
"inline px-3 py-1 text-sm font-normal rounded-full text-emerald-500 gap-x-2 bg-emerald-100/60 dark:bg-gray-800"} | ||
birth-date])] | ||
[:div | ||
{:class "px-4 py-4 text-sm whitespace-nowrap flex items-center border-b"} | ||
[:div | ||
[:h4 {:class "text-gray-700 dark:text-gray-200"} (get-in p [:gender])]]] | ||
[:div | ||
{:class "px-4 py-4 text-sm whitespace-nowrap flex items-center border-b"} | ||
[:form {:action "/ui/patients/edit" | ||
:class "mb-0"} | ||
[:input {:type "hidden" | ||
:name "patient-id" | ||
:value (:id p)}] | ||
[:button | ||
{:class | ||
"px-3 py-2 text-gray-500 transition-colors duration-200 rounded-lg dark:text-gray-300 hover:bg-gray-100"} | ||
[:i.fas.fa-pencil]]] | ||
[:a | ||
{:class | ||
"px-3 py-2 text-gray-500 transition-colors duration-200 rounded-lg dark:text-gray-300 hover:bg-gray-100" | ||
:href (str "/ui/patients/" (str (:id p))) | ||
:data-turbo-method "DELETE" | ||
:data-turbo-confirm "Do you want to delete patient?"} | ||
[:i.fas.fa-trash]]]]) patients)) | ||
|
||
|
||
] | ||
) |
Oops, something went wrong.