Skip to content

Commit 3472f8d

Browse files
committed
Remove response conditions and require response literals not be padded
1 parent a0cc48f commit 3472f8d

25 files changed

Lines changed: 60 additions & 200 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "technique"
3-
version = "0.6.6"
3+
version = "0.7.0"
44
edition = "2024"
55
description = "A domain specific language for procedures."
66
authors = [ "Andrew Cowie" ]

examples/prototype/SurgicalSafetyChecklist.tq

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ before_anesthesia :
3434
5. Does the patient have a:
3535
- Known allergy?
3636
'No' | 'Yes'
37-
- Difficult airway or aspiration risk?
38-
'No' | 'Yes' and equipment/assistance available
39-
- Risk of blood loss > 500 mL?
40-
'No' | 'Yes' and two IVs planned and fluids available
37+
- Difficult airway or aspiration risk? If so, ensure equipment and
38+
assistance available.
39+
'No' | 'Yes'
40+
- Risk of blood loss > 500 mL? If so, plan for two IVs and ensure
41+
fluids available.
42+
'No' | 'Yes'
4143

4244
before_incision :
4345

src/domain/checklist/adapter.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ fn step_from_scope(scope: &language::Scope, inherited_role: Option<&str>) -> Ste
157157
value: response
158158
.value()
159159
.to_string(),
160-
condition: response
161-
.condition()
162-
.map(String::from),
163160
});
164161
}
165162
children.extend(steps_from_scope(subscope, inherited_role));
@@ -277,29 +274,6 @@ checks :
277274
assert_eq!(steps[1].role, Some("surgeon".into()));
278275
}
279276

280-
#[test]
281-
fn responses_with_conditions() {
282-
let doc = extract(trim(
283-
r#"
284-
checks :
285-
286-
1. Is the patient ready?
287-
'Yes' | 'No' if complications
288-
"#,
289-
));
290-
let proc = as_procedure(&doc.items[0]);
291-
let step = &proc.steps[0];
292-
assert_eq!(
293-
step.responses
294-
.len(),
295-
2
296-
);
297-
assert_eq!(step.responses[0].value, "Yes");
298-
assert_eq!(step.responses[0].condition, None);
299-
assert_eq!(step.responses[1].value, "No");
300-
assert_eq!(step.responses[1].condition, Some("if complications".into()));
301-
}
302-
303277
#[test]
304278
fn sibling_procedures_are_peers() {
305279
let doc = extract(trim(

src/domain/checklist/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ pub struct Step {
4949
pub children: Vec<Step>,
5050
}
5151

52-
/// A response option with an optional condition.
52+
/// A response option.
5353
pub struct Response {
5454
pub value: String,
55-
pub condition: Option<String>,
5655
}

src/domain/checklist/typst.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ impl Render for Response {
105105
fn render(&self, out: &mut Markup) {
106106
out.call("render-response");
107107
out.param("value", &self.value);
108-
out.param_opt("condition", &self.condition);
109108
out.close();
110109
}
111110
}

src/domain/engine.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,6 @@ impl<'i> Response<'i> {
248248
pub fn value(&self) -> &'i str {
249249
self.value
250250
}
251-
252-
/// Returns the optional condition.
253-
pub fn condition(&self) -> Option<&'i str> {
254-
self.condition
255-
}
256251
}
257252

258253
/// Render an Expression as human-readable text.

src/domain/procedure/adapter.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ fn nodes_from_scope(scope: &language::Scope) -> Vec<Node> {
118118
value: response
119119
.value()
120120
.to_string(),
121-
condition: response
122-
.condition()
123-
.map(String::from),
124121
});
125122
}
126123
children.extend(nodes_from_scope(child));
@@ -168,9 +165,6 @@ fn node_from_step(scope: &language::Scope) -> Node {
168165
value: response
169166
.value()
170167
.to_string(),
171-
condition: response
172-
.condition()
173-
.map(String::from),
174168
});
175169
}
176170
children.extend(nodes_from_scope(subscope));

src/domain/procedure/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ pub enum Node {
6868
},
6969
}
7070

71-
/// A response option with an optional condition.
71+
/// A response option.
7272
pub struct Response {
7373
pub value: String,
74-
pub condition: Option<String>,
7574
}

src/domain/procedure/typst.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ impl Render for Response {
218218
fn render(&self, out: &mut Markup) {
219219
out.call("render-response");
220220
out.param("value", &self.value);
221-
out.param_opt("condition", &self.condition);
222221
out.close();
223222
}
224223
}

0 commit comments

Comments
 (0)