1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
;; -*- lexical-binding: t -*-
(require 'ksh-forms)
(require 'ksh-report)
;; Datafile path and fields
(setq forms-file (expand-file-name "data/scan2.dat" ksh-path))
(setq forms-number-of-fields
(forms-enumerate
(list 'ksh-scan2-ip-op-no 'ksh-scan2-patient-name 'ksh-scan2-age 'ksh-scan2-sex
'ksh-scan2-visit-date 'ksh-scan2-lmp-date 'ksh-scan2-lmp-edd
'ksh-scan2-scan
'ksh-scan2-maternal-cervix 'ksh-scan2-maternal-internal-os
'ksh-scan2-survey-presentation 'ksh-scan2-survey-placenta 'ksh-scan2-survey-liquor
'ksh-scan2-survey-umbilical-cord 'ksh-scan2-survey-fetal-activity 'ksh-scan2-survey-cardiac-activity
'ksh-scan2-biometry-bpd 'ksh-scan2-biometry-bpd-age 'ksh-scan2-biometry-bpd-percentile
'ksh-scan2-biometry-hc 'ksh-scan2-biometry-hc-age 'ksh-scan2-biometry-hc-percentile
'ksh-scan2-biometry-ac 'ksh-scan2-biometry-ac-age 'ksh-scan2-biometry-ac-percentile
'ksh-scan2-biometry-fl 'ksh-scan2-biometry-fl-age 'ksh-scan2-biometry-fl-percentile
'ksh-scan2-biometry-fetal-weight
'ksh-scan2-extended-foot-length 'ksh-scan2-extended-tcd
'ksh-scan2-anatomy-intracranial 'ksh-scan2-anatomy-neck 'ksh-scan2-anatomy-spine
'ksh-scan2-anatomy-face 'ksh-scan2-anatomy-lungs 'ksh-scan2-anatomy-heart
'ksh-scan2-anatomy-abdominal-situs 'ksh-scan2-anatomy-kidneys-bladder
'ksh-scan2-anatomy-long-bones
'ksh-scan2-impression-gestational-age 'ksh-scan2-impression-menstrual-age
'ksh-scan2-impression-corrected-edd 'ksh-scan2-impression-notes
'ksh-scan2-sonologist)))
;; Default values for fields
(setq default-field-values
`((,ksh-scan2-sex . "F")
(,ksh-scan2-survey-presentation . "cephalic")
(,ksh-scan2-survey-placenta . "posterior")
(,ksh-scan2-survey-liquor . "normal")
(,ksh-scan2-survey-fetal-activity . "present")
(,ksh-scan2-survey-cardiac-activity . "present")
(,ksh-scan2-anatomy-intracranial . "normal")
(,ksh-scan2-anatomy-neck . "normal. No evidence of significant open neural tube defect")
(,ksh-scan2-anatomy-spine . "normal")
(,ksh-scan2-anatomy-face . "normal")
(,ksh-scan2-anatomy-lungs . "normal")
(,ksh-scan2-anatomy-heart . "normal")
(,ksh-scan2-anatomy-abdominal-situs . "normal")
(,ksh-scan2-anatomy-kidneys-bladder . "normal")
(,ksh-scan2-anatomy-long-bones . "normal for the period of gestation")
(,ksh-scan2-sonologist . "Dr. Mekalai")))
;; Format specification for form display
(setq forms-format-list
(append
(list "Trimester 2 - Scan Report\n\n")
(seq-mapcat 'form-entry
'(("IP/OP No" . ksh-scan2-ip-op-no)
("Patient Name" . ksh-scan2-patient-name)
("Age" . ksh-scan2-age)
("Sex" . ksh-scan2-sex)
("Visit Date" . ksh-scan2-visit-date)
("LMP Date" . ksh-scan2-lmp-date)
("LMP EDD" . ksh-scan2-lmp-edd)))
(list "Indications\n" "Target Scan\n"
"Real time B-mode ultrasonography of gravid uterus done.\n"
"Route: Transabdominal\n" ksh-scan2-scan "\n\n")
(list "Maternal\n")
(seq-mapcat 'form-entry
'(("Cervix" . ksh-scan2-maternal-cervix)
("Internal os" . ksh-scan2-maternal-internal-os)))
(list "Fetal Survey\n")
(seq-mapcat 'form-entry
'(("Presentation" . ksh-scan2-survey-presentation)
("Placenta" . ksh-scan2-survey-placenta)
("Liquor" . ksh-scan2-survey-liquor)
("Umbilical cord" . ksh-scan2-survey-umbilical-cord)
("Fetal activity" . ksh-scan2-survey-fetal-activity)
("Cardiac activity" . ksh-scan2-survey-cardiac-activity)))
(list "Fetal Biometry\n")
(seq-mapcat 'form-entry
'(("BPD" . ksh-scan2-biometry-bpd)
("BPD-Age" . ksh-scan2-biometry-bpd-age)
("BPD-Percentile" . ksh-scan2-biometry-bpd-percentile)
("HC" . ksh-scan2-biometry-hc)
("HC-Age" . ksh-scan2-biometry-hc-age)
("HC-Percentile" . ksh-scan2-biometry-hc-percentile)
("AC" . ksh-scan2-biometry-ac)
("AC-Age" . ksh-scan2-biometry-ac-age)
("AC-Percentile" . ksh-scan2-biometry-ac-percentile)
("FL" . ksh-scan2-biometry-fl)
("FL-Age" . ksh-scan2-biometry-fl-age)
("FL-Percentile" . ksh-scan2-biometry-fl-percentile)
("Estimated fetal weight according to BPD, HC, AC, FL" . ksh-scan2-biometry-fetal-weight)))
(list "Extended Biometry\n")
(seq-mapcat 'form-entry
'(("Foot Length" . ksh-scan2-extended-foot-length)
("TCD" . ksh-scan2-extended-tcd)))
(list "Fetal Anatomy\n")
(seq-mapcat 'form-entry
'(("Intracranial structures" . ksh-scan2-anatomy-intracranial)
("Neck" . ksh-scan2-anatomy-neck)
("Spine" . ksh-scan2-anatomy-spine)
("Fetal face" . ksh-scan2-anatomy-face)
("Both lungs" . ksh-scan2-anatomy-lungs)
("Heart" . ksh-scan2-anatomy-heart)
("Abdominal situs" . ksh-scan2-anatomy-abdominal-situs)
("Both kidneys and bladder" . ksh-scan2-anatomy-kidneys-bladder)
("All long bones" . ksh-scan2-anatomy-long-bones)))
(list "Impression\n")
(seq-mapcat 'form-entry
'(("Gestational age" . ksh-scan2-impression-gestational-age)
("Menstrual age" . ksh-scan2-impression-menstrual-age)
("Corrected EDD" . ksh-scan2-impression-corrected-edd)
("Notes" . ksh-scan2-impression-notes)
("Sonologist" . ksh-scan2-sonologist)))))
(setq form-to-org
(lambda ()
(with-output-to-string
(make-report-header "OB - 2/3 TRIMESTER SCAN REPORT")
(seq-do 'single-line-org-entry
`(("IP/OP No" . ,ksh-scan2-ip-op-no)
("Age" . ,ksh-scan2-age)
("Sex" . ,ksh-scan2-sex)
("Name of Patient" . ,ksh-scan2-patient-name)
("Visit Date" . ,ksh-scan2-visit-date)
("LMP Date" . ,ksh-scan2-lmp-date)
("LMP EDD" . ,ksh-scan2-lmp-edd)))
(mapc 'princ `("* Indications\n" "** Target Scan\n"
"Real time B-mode ultrasonography of gravid uterus done.\n\n"))
(single-line-org-entry '("Route" . "Transabdominal"))
(princ (get-field ksh-scan2-scan))
(princ "\n\n* Maternal\n")
(seq-do 'single-line-org-entry
`(("Cervix" . ,ksh-scan2-maternal-cervix)
("Internal os" . ,ksh-scan2-maternal-internal-os)))
(princ "* Fetal Survey\n")
(seq-do 'single-line-org-entry
`(("Presentation" . ,ksh-scan2-survey-presentation)
("Placenta" . ,ksh-scan2-survey-placenta)
("Liquor" . ,ksh-scan2-survey-liquor)
("Umbilical cord" . ,ksh-scan2-survey-umbilical-cord)
("Fetal activity" . ,ksh-scan2-survey-fetal-activity)
("Cardiac activity" . ,ksh-scan2-survey-cardiac-activity)))
(insert-biometry
"Fetal Biometry"
`(("BPD" ,ksh-scan2-biometry-bpd ,ksh-scan2-biometry-bpd-age ,ksh-scan2-biometry-bpd-percentile)
("HC" ,ksh-scan2-biometry-hc ,ksh-scan2-biometry-hc-age ,ksh-scan2-biometry-hc-percentile)
("AC" ,ksh-scan2-biometry-ac ,ksh-scan2-biometry-ac-age ,ksh-scan2-biometry-ac-percentile)
("FL" ,ksh-scan2-biometry-fl ,ksh-scan2-biometry-fl-age ,ksh-scan2-biometry-fl-percentile)))
(princ "* Extended Biometry\n")
(seq-do 'single-line-org-entry
`(("Foot Length" . ,ksh-scan2-extended-foot-length)
("TCD" . ,ksh-scan2-extended-tcd)))
(princ "* Fetal Anatomy\n")
(seq-do 'single-line-org-entry
`(("Intracranial structures" . ,ksh-scan2-anatomy-intracranial)
("Neck" . ,ksh-scan2-anatomy-neck)
("Spine" . ,ksh-scan2-anatomy-spine)
("Fetal face" . ,ksh-scan2-anatomy-face)
("Both lungs" . ,ksh-scan2-anatomy-lungs)
("Heart" . ,ksh-scan2-anatomy-heart)
("Abdominal situs" . ,ksh-scan2-anatomy-abdominal-situs)
("Both kidneys and bladder" . ,ksh-scan2-anatomy-kidneys-bladder)
("All long bones" . ,ksh-scan2-anatomy-long-bones)))
(princ "* Impression\n")
(princ (format "%s corresponding to a gestational age of %s assigned as per biometry (CRL)\n\n"
(get-field ksh-scan2-scan) (get-field ksh-scan2-impression-gestational-age)))
(seq-do 'single-line-org-entry
`(("Menstrual age" . ,ksh-scan2-impression-menstrual-age)
("Corrected EDD" . ,ksh-scan2-impression-corrected-edd)
("Placenta" . ,ksh-scan2-survey-placenta)
("Presentation" . ,ksh-scan2-survey-presentation)
("Liquor" . ,ksh-scan2-survey-liquor)
("Estimated fetal weight according to BPD, HC, AC, FL" . ,ksh-scan2-biometry-fetal-weight)))
(text-if-non-blank (get-field ksh-scan2-impression-notes))
(multi-line-org-entry `("Sonologist" . ,ksh-scan2-sonologist)))))
|