File: infant_mortality.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (83 lines) | stat: -rw-r--r-- 2,473 bytes parent folder | download | duplicates (5)
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
/*
 * @progname       infant_mortality.ll
 * @version        1
 * @author         Eggert
 * @category       
 * @output         Text
 * @description    

This program finds families that have lost multiple children.
You give it the threshold for the number of young deaths, and the
threshold for the age at death, and it finds all the appropriate
families.

infant_mortality - a LifeLines program
         by Jim Eggert (eggertj@atc.ll.mit.edu)
         Version 1,  19 September 1994

*/


global(yob)
global(yod)

proc main() {
    getintmsg(numthresh,"Enter threshold for number of young deaths")
    getintmsg(agethresh,"Enter threshold for age at death")
    forfam(family,fnum) {
        if (ge(nchildren(family),numthresh)) {
            set(countdeaths,0)
            set(maxageatdeath,0)
            children(family,child,cnum) {
                call get_dyear(child)
                if (yod) {
                    call get_byear(child)
                    if (yob) {
                        set(ageatdeath,sub(yod,yob))
                        if (le(ageatdeath,agethresh)) {
                            set(countdeaths,add(countdeaths,1))
                            if (gt(ageatdeath,maxageatdeath)) {
                                set(maxageatdeath,ageatdeath)
                            }
                        }
                    }
                }
            }
            if (ge(countdeaths,numthresh)) {
                key(family) " "
                name(husband(family)) " and " name(wife(family))
                "\nlost " d(countdeaths)
                " children by the age of " d(maxageatdeath)
                ".\n"
                children(family,child,cnum) {
                    call get_byear(child)
                    call get_dyear(child)
                    name(child) " ("
                    if (yob) { d(yob) }
                    "-"
                    if (yod) { d(yod) }
                    ") "
                    if (and(yob,yod)) { d(sub(yod,yob)) }
                    "\n"
                }
                "\n"
            }
        }
    }
}

proc get_dyear(person) {
    set(yod,0)
    if (d,death(person)) { extractdate(d,dod,mod,yod) }
    if (not(yod)) {
        if (d,burial(person)) { extractdate(d,dod,mod,yod) }
    }
}

proc get_byear(person) {
    set(yob,0)
    if (b,birth(person)) { extractdate(b,dob,mob,yob) }
    if (not(yob)) {
        if (b,baptism(person)) { extractdate(b,dob,mob,yob) }
    }
}