;; -*- lexical-binding: t -*- (require 'ksh-forms) (require 'ksh-report) ;; Datafile path and fields (setq forms-file (expand-file-name "data/scan3.dat" ksh-path)) (setq forms-number-of-fields (forms-enumerate (list 'ksh-scan3-ip-op-no 'ksh-scan3-patient-name 'ksh-scan3-age 'ksh-scan3-sex 'ksh-scan3-visit-date 'ksh-scan3-lmp-date 'ksh-scan3-lmp-edd 'ksh-scan3-scan 'ksh-scan3-survey-presentation 'ksh-scan3-survey-placenta 'ksh-scan3-survey-liquor 'ksh-scan3-survey-amniotic-fluid-index 'ksh-scan3-survey-umbilical-cord 'ksh-scan3-survey-fetal-activity 'ksh-scan3-survey-cardiac-activity 'ksh-scan3-survey-fetal-heart-rate 'ksh-scan3-biometry-bpd 'ksh-scan3-biometry-bpd-age 'ksh-scan3-biometry-bpd-percentile 'ksh-scan3-biometry-hc 'ksh-scan3-biometry-hc-age 'ksh-scan3-biometry-hc-percentile 'ksh-scan3-biometry-ac 'ksh-scan3-biometry-ac-age 'ksh-scan3-biometry-ac-percentile 'ksh-scan3-biometry-fl 'ksh-scan3-biometry-fl-age 'ksh-scan3-biometry-fl-percentile 'ksh-scan3-biometry-fetal-weight 'ksh-scan3-impression-gestational-age 'ksh-scan3-impression-menstrual-age 'ksh-scan3-impression-corrected-edd 'ksh-scan3-impression-notes 'ksh-scan3-sonologist))) ;; Default values for fields (setq default-field-values `((,ksh-scan3-sex . "F") (,ksh-scan3-survey-presentation . "cephalic") (,ksh-scan3-survey-placenta . "posterior") (,ksh-scan3-survey-liquor . "normal") (,ksh-scan3-survey-fetal-activity . "normal") (,ksh-scan3-survey-cardiac-activity . "normal") (,ksh-scan3-sonologist . "Dr. Bala Bharathy"))) ;; Format specification for form display (setq forms-format-list (append (list "Trimester 3 - Scan Report\n\n") (seq-mapcat 'form-entry '(("IP/OP No" . ksh-scan3-ip-op-no) ("Patient Name" . ksh-scan3-patient-name) ("Age" . ksh-scan3-age) ("Sex" . ksh-scan3-sex) ("Visit Date" . ksh-scan3-visit-date) ("LMP Date" . ksh-scan3-lmp-date) ("LMP EDD" . ksh-scan3-lmp-edd))) (list "Indications\n" "Growth Scan\n" "Real time B-mode ultrasonography of gravid uterus done.\n" "Route: Transabdominal\n" ksh-scan3-scan "\n\n") (list "Fetal Survey\n") (seq-mapcat 'form-entry '(("Presentation" . ksh-scan3-survey-presentation) ("Placenta" . ksh-scan3-survey-placenta) ("Liquor" . ksh-scan3-survey-liquor) ("Amniotic fluid index" . ksh-scan3-survey-amniotic-fluid-index) ("Umbilical cord" . ksh-scan3-survey-umbilical-cord) ("Fetal activity" . ksh-scan3-survey-fetal-activity) ("Cardiac activity" . ksh-scan3-survey-cardiac-activity) ("Fetal heart rate" . ksh-scan3-survey-fetal-heart-rate))) (list "Fetal Biometry\n") (seq-mapcat 'form-entry '(("BPD" . ksh-scan3-biometry-bpd) ("BPD-Age" . ksh-scan3-biometry-bpd-age) ("BPD-Percentile" . ksh-scan3-biometry-bpd-percentile) ("HC" . ksh-scan3-biometry-hc) ("HC-Age" . ksh-scan3-biometry-hc-age) ("HC-Percentile" . ksh-scan3-biometry-hc-percentile) ("AC" . ksh-scan3-biometry-ac) ("AC-Age" . ksh-scan3-biometry-ac-age) ("AC-Percentile" . ksh-scan3-biometry-ac-percentile) ("FL" . ksh-scan3-biometry-fl) ("FL-Age" . ksh-scan3-biometry-fl-age) ("FL-Percentile" . ksh-scan3-biometry-fl-percentile) ("Estimated fetal weight according to BPD, HC, AC, FL" . ksh-scan3-biometry-fetal-weight))) (list "Impression\n") (seq-mapcat 'form-entry '(("Gestational age" . ksh-scan3-impression-gestational-age) ("Menstrual age" . ksh-scan3-impression-menstrual-age) ("Corrected EDD" . ksh-scan3-impression-corrected-edd) ("Notes" . ksh-scan3-impression-notes) ("Sonologist" . ksh-scan3-sonologist))))) (setq form-to-org (lambda () (with-output-to-string (make-report-header "OB - 3/3 TRIMESTER SCAN REPORT") (seq-do 'single-line-org-entry `(("IP/OP No" . ,ksh-scan3-ip-op-no) ("Age" . ,ksh-scan3-age) ("Sex" . ,ksh-scan3-sex) ("Name of Patient" . ,ksh-scan3-patient-name) ("Visit Date" . ,ksh-scan3-visit-date) ("LMP Date" . ,ksh-scan3-lmp-date) ("LMP EDD" . ,ksh-scan3-lmp-edd))) (mapc 'princ `("* Indications\n" "** Growth Scan\n" "Real time B-mode ultrasonography of gravid uterus done.\n\n")) (seq-do 'single-line-org-entry `(("Route" . "Transabdominal"))) (text-if-non-blank (get-field ksh-scan3-scan)) (princ "* Fetal Survey\n") (seq-do 'single-line-org-entry `(("Presentation" . ,ksh-scan3-survey-presentation) ("Placenta" . ,ksh-scan3-survey-placenta) ("Liquor" . ,ksh-scan3-survey-liquor) ("Amniotic fluid index" . ,ksh-scan3-survey-amniotic-fluid-index) ("Umbilical cord" . ,ksh-scan3-survey-umbilical-cord) ("Fetal activity" . ,ksh-scan3-survey-fetal-activity) ("Cardiac activity" . ,ksh-scan3-survey-cardiac-activity) ("Fetal heart rate" . ,ksh-scan3-survey-fetal-heart-rate))) (insert-biometry "Fetal Biometry" `(("BPD" ,ksh-scan3-biometry-bpd ,ksh-scan3-biometry-bpd-age ,ksh-scan3-biometry-bpd-percentile) ("HC" ,ksh-scan3-biometry-hc ,ksh-scan3-biometry-hc-age ,ksh-scan3-biometry-hc-percentile) ("AC" ,ksh-scan3-biometry-ac ,ksh-scan3-biometry-ac-age ,ksh-scan3-biometry-ac-percentile) ("FL" ,ksh-scan3-biometry-fl ,ksh-scan3-biometry-fl-age ,ksh-scan3-biometry-fl-percentile))) (princ "* Impression\n") (princ (format "%s gestational age assigned as per biometry (CRL)\n\n" (get-field ksh-scan3-impression-gestational-age))) (seq-do 'single-line-org-entry `(("Menstrual age" . ,ksh-scan3-impression-menstrual-age) ("Corrected EDD" . ,ksh-scan3-impression-corrected-edd) ("Placenta" . ,ksh-scan3-survey-placenta) ("Presentation" . ,ksh-scan3-survey-presentation) ("Liquor" . ,ksh-scan3-survey-liquor) ("Estimated fetal weight according to BPD, HC, AC, FL" . ,ksh-scan3-biometry-fetal-weight))) (text-if-non-blank (get-field ksh-scan3-impression-notes)) (multi-line-org-entry `("Sonologist" . ,ksh-scan3-sonologist)))))