Wednesday, December 30, 2015

Event Driven - Java

Button:
setup() {
    ...
    MapUtils.createDefaultEventDispatcher(this, map);
    ...
}

draw() {
    map.draw();
}

Add two buttons to control the background color:
Step1: Draw Buttons (using processing)
fill() rect() etc.
* Need to put into draw method because setup only execute once.

Step2: Add functionality for buttons
mousePressed(); mouseClicked(); mouseReleased();
need to check the coordinate where the mouse is released.

Listener Hierarchy:

We have introduced the class CommonMarker as the parent class of both EarthquakeMarker and CityMarker. Now CommonMarker is the class that overrides the draw() method, and it calls drawMarker() which each subclass will implement. We introduced CommonMarker because in this assignment there will be some drawing functionality that is common to all markers on our map, so we didn’t want to have to duplicate code between EarthquakeMarker and CityMarker. This process of restructuring our code is known as refactoring and it is very common in software engineering.

Implement the selectMarkerIfHover helper method in EarthquakeCityMap. This method is called in mouseMoved() method in EarthquakeCityMap, and mouseMoved() is called by the event handler when the user moves the mouse. selectMarkerIfHover should set the instance variable selected for the first Marker it finds that mouseX and mouseY is inside of.

Wednesday, December 23, 2015

Polymorphism

What:
多态

Why:
So the methods can be called based on the dynamic object type. (one of them).

Details:

Step1: Compiler interprets the code.
Step2: Runtime environment executes interpreted code.
Compile time rules:
Compiler only look at reference type. (solution: casting)
Can only look in reference type class for method.
Outputs a method signature.
Run time rules:
Follow exact runtime type of object to find method.
Must match compile time method signature
Run time type check: "instanceof"

Abstract classes and Interface:
  Abstract:
    - Can make any class abstract with keyword:
      public abstract class Person {
    - Class must be abstract if any methods are:
      public abstract void monthlyStatement() { (concrete subclass must override this method)

Implementation vs. Interface:
Implementation: instance variables and methods which define common behavior
Interface: method signatures which define required behaviors
Abstract class can do both.
If only interface needed, use Interface.

  Interfaces:
    - Interfaces only define required methods
    - Classes can inherit from multiple Interfaces

If you just want to define a required method: Interface
If you want to define potentially required methods AND common behavior: Abstract class




Tuesday, December 22, 2015

Inheritance

What:
继承,子类继承父类。

Why:
Good for complex, large projects.
1. Keep common behavior in one class.
2. Split different behavior in separate classes.
3. Keep all of the objects in a single data structure.

How:
Use "extends"

Details:
What is inherited?
1. Public instance variables.
2. Public methods.
3. Private instance variables (can only be accessed via public methods eg. getter and setter).

Person p = new Student(); //correct, a student is a person

// Following is fine
Person[] p = new Person[3];
p[0] = new Person();
p[1] = new Student();
p[2] = new Faculty();
public class Person {
    private String name;
    public String getName() { return name; }
}

public class Student extends Person {
    private int id;
    public int getId() { return id; }
}

public class Faculty extends Person {
    private String id;
    public String getId() { return id; }
}

//In main method somewhere
Student s = new Student();
Person p = new Person();
Person q = new Person();
Faculty f = new Faculty();
Object o = new Faculty();

String n = s.getName(); // fine
p = s; // fine, all student is a person
int m = p.getId(); // bad, because compiler does not know that p is a student, you need to cast it as below
int m = ((Student)p).getId();
f = q; // bad, not all person is a faculty
o = s; //fine, anything is a object

Modifiers:
public: can access from any class
protected: can access from: same class, same package, any subclass
package: can access from: same class, same package
private: can only access from same class
一般来说,只用public和private

Revisit Constructor:
Student s = new Student();
new - allocates space
Student() is passed to constructor
From inside out:
Student() -> Person() -> Object()
Object() will initialize variables then Person(), then Student().

Compiler Rules:
1. No super class: then insert "extends Object"
2. No constructor: give one for you
2. In the constructor, the first line must be:
    this(args_optional);
  or super(args_optional);
  If none, then compiler inserts "super();"

Method Overriding:
Override: Subclass has same method name with the same parameters as the superclass
Overload: Same class has same method name with different parameters.




Thursday, December 17, 2015

Database - Python

dir() - list capabilities of a class 
type() - type of a variable/object (will show "instance" only)

Inheritance class PartyAnimal:
class FootballFan(PartyAnimal):

CRUD SQL:
CREATE TABLE Users(name VARCHAR(128), email VARCHAR(128))
INSERT INTO Users(name, email) VALUES ('testname', 'testname@test.it')
DELETE FROM Users WHERE email='testname@test.it'
UPDATE Users SET name='realname' WHERE email='realname@test.it'
SELECT * FROM Users
SELECT * FROM Users WHERE email='realname@test.it'
SELECT * FROM Users ORDER BY email

Counting Email from org:
import sqlite3

conn = sqlite3.connect('emaildb.sqlite')
cur = conn.cursor()

cur.execute('''
DROP TABLE IF EXISTS Counts''')

cur.execute('''
CREATE TABLE Counts (org TEXT, count INTEGER)''')

fname = raw_input('Enter file name: ')
if ( len(fname) < 1 ) : fname = 'mbox-short.txt'
fh = open(fname)
for line in fh:
    if not line.startswith('From: ') : continue
    pieces = line.split()
    email = pieces[1]
    emailpcs = email.split('@')
    org = emailpcs[1]
    print org
    cur.execute('SELECT count FROM Counts WHERE org = ? ', (org, ))
    row = cur.fetchone()
    if row is None:
        cur.execute('''INSERT INTO Counts (org, count)
                VALUES ( ?, 1 )''', ( org, ) )
    else : 
        cur.execute('UPDATE Counts SET count=count+1 WHERE org = ?',
            (org, ))
    # This statement commits outstanding changes to disk each 
    # time through the loop - the program can be made faster 
    # by moving the commit so it runs only after the loop completes
    conn.commit()

# https://www.sqlite.org/lang_select.html
sqlstr = 'SELECT org, count FROM Counts ORDER BY count DESC LIMIT 10'

print
print "Counts:"
for row in cur.execute(sqlstr) :
    print str(row[0]), row[1]

cur.close()

Database Design:
Step1:
Think about the central attribute of the application: Track in Music db.

Step2:
Create the table from the most non-central attribute: Start from the end of the arrows.

Step3:
Insert data.

Join:
select Album.title, Artist.name from Album join Artist on Album.artist_id = Artist.id

If no "on", then do full outer join.

Many-to-many relationship
We need to add a "connection" table with two foreign keys. (Usually no primary key).
Table 1: Course (id, title)
Table 2: User(id, name, email)
Add table:
Member(course_id, user_id)

SELECT User.name, Member.role, Course.title
FROM User JOIN Member JOIN Course
ON Member.user_id = User.id AND Member.course_id = Course.id
ORDER BY Course.title, Member.role DESC, User.name


Tuesday, December 8, 2015

Linked List

Nodes.
Each node has a value and a link to next node. (singly)

基本操作:
1. Create a Linked List
class Node {
 Node next = null;
 int data;
 public Node(int d) {
  data = d;
 }
 
 void appendToTail(int d) {
  Node end = new Node(d);
  Node n = this;
  while (n.next != null) { n = n.next; }
  n.next = end;
 }
}

2. Deleting a Node from Singly Linked List
    1) Delete a node, given head node and the value of the node to be deleted. (singly)
   
Node deleteNode(Node head, int d) {
  Node n = head;
  if (n.data == d) {
   return head.next;
  }
  while (n.next != null) {
   if (n.next.data == d) {
    n.next = n.next.next;
    return head; //head not change
   }
   n = n.next;
  }
  return head; //return head if d is not in the list
 }

    2) Delete a node from the middle, only access to that node. (Leetcode)
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
public class Solution {
    public void deleteNode(ListNode node) {
        if (node == null || node.next == null) return;
        node.val = node.next.val;
        node.next = node.next.next;
        node = node.next;
    }
}

3. Reverse a singly linked list
    1) Recursive

public class Solution {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) return head;
        ListNode second = head.next;
        head.next = null;
        ListNode node = reverseList(second);
        second.next = head;
        return node;
    }
}
    2) Iterative
public class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode temp = curr.next;
            curr.next = prev;
            prev = curr;
            curr = temp;
        }
        return prev;
    }
}

实际应用:

Thursday, November 12, 2015

Files - Python

Files - Python

Open a file:
open(): return a handle to operate the file
syntax:
handle = open(filename, mode)
fhandle = open('mbox.txt', 'r')
handle is not the actual data from the file, it is a "connection".


The newline character:
\n
it is one character.

Can treat a file handle as a sequence: (a sequence is an ordered set)
xhandle = open('mbox.txt')
for cheese in xhandle:
    print cheese

Read the Whole file (into a single string inlucding the newlines):
inp = xhandle.read()

Searching through the file:
for and if
line.startwith('xxx')
line.rstrip() #strip the white space(s) at the right of the line

Skipping with continue:
use continue in for and if

'xxx' in line
not 'xxx' in line

Prompt for the file name:
fname = raw_input('Enter the file name: ')

Try to open a file:
fname = raw_input...
try:
    fhand = open(fname)
except:
    print "Cannot open the file: ", fname
    exit()

Python Data Structures

<String>
### String Processing

# String literals
s1 = "Rixner's funny"
s2 = 'Warren wears nice ties!'
s3 = " t-shirts!"
#print s1, s2
#print s3

# Combining strings
a = ' and '
s4 = "Warren" + a + "Rixner" + ' are nuts!'
print s4

# Characters and slices
print s1[3]
print len(s1)
print s1[0:6] + s2[6:]
print s2[:13] + s1[9:] + s3

# Converting strings
s5 = str(375)
print s5[1:]
i1 = int(s5[1:])
print i1 + 38

Another example:
# Handle single quantity
def convert_units(val, name):
    result = str(val) + " " + name
    if val > 1:
        result = result + "s"
    return result
        
# convert xx.yy to xx dollars and yy cents
def convert(val):
    # Split into dollars and cents
    dollars = int(val)
    cents = int(round(100 * (val - dollars)))

    # Convert to strings
    dollars_string = convert_units(dollars, "dollar")
    cents_string = convert_units(cents, "cent")

    # return composite string
    if dollars == 0 and cents == 0:
        return "Broke!"
    elif dollars == 0:
        return cents_string
    elif cents == 0:
        return dollars_string
    else:
        return dollars_string + " and " + cents_string
    
    
# Tests
print convert(11.23)
print convert(11.20) 
print convert(1.12)
print convert(12.01)
print convert(1.01)
print convert(0.01)
print convert(1.00)
print convert(0)

dir function: return the available built-in functions of a type.

<Sets>

Sets: Keep track of a collection of objects.

List - ordered sequence
Dictionary - Key-Value Mapping
Sets - unordered collection of data with no duplicates

list:
[1, 2, 2, 3, 1]

set:
set([1, 2, 3])

set1.add()
set2.remove()
set3.difference_update(set2)

<List>

List
a = [1, 2, 3]
b = a  #b point to where a is pointing
c = list(a) #c point to a new list copied from a
list is mutable

list can be empty
list can contain different of types

list is a ordered sequence
lis1.sort()

Tuple
a = (1, 2, 3)

tuple is immutable (a[1] = 4, throws an type error)

Methods:
lst = [1, 82, -6, 4,  3, 8]

len(lst) give the number of elements in list
sum(lst)
max(lst)
min(lst)
avg = sum(lst)/len(lst)

range(n) returns a list [0, ..., n-1] //usually used to construct a loop

82 in list => T/F
if 4 in list:
    print "4 is there"

lst.index(8) => 5

lst.append(632) => [1, 82, -6, 4, 3, 8, 632]

lst.pop() => [1, 82, -6, 4, 3, 8]

lst.pop(4) => [1, 82, -6, 4, 8]

lst.remove(82) => [1, -6, 4, 8]

list1 + list2 to concatenate two lists.

use ":" to slice lists
list1[:]
list1[1:3]

split() split a string into a word list.
or split(";")

<Dictionary>

Dictionary
compare to List:
List - a linear collection of values that stays in order / use index (position) to lookup element
Dictionary - A bag (unordered) of values, each with its own label / use key (label) to lookup values

Properties or Map or HashMap in Java
Associate Arrays Perl/PHP
Property Bag C#/.net

Mapping
    Key -> Values

d = {1:2, 3:4}
d[1] -> 2

d = dict()
d = {} # empty dictionary
d = {"abc":1, "cd":2}
d["abc"] = 1
d["abc"] = d["abc"]+1
d = {"abc":2, "cd":2}

if reference a key which is not in the dict, trace error.
to check, use:
"key" in dict1 (True or False)

Methods:
get
dict1.get(key, default): return the value for key, if key does not exist, then return the default value.

list(dict1) list all the keys
dict1.keys() list all the keys
dict1.values() list all the values
dict1.items() list of (key, value) tuples.

Two iteration variables:
for aaa.bbb in dict1.items():

Typical application:
1) Most common names (many counters)
use name as key, go through all the names, and for each "name", do dict["name"]+1

2) most common word and the number of appearances
same as above
bigcount = None
bignumber = None
for word.count in dict1.items():
    if bigcount is None or count > bigcount:
        bigword = word
        bigcount = count

<Tuples>
Tuples are like list. Use index to lookup, and ordered.
x = ('Glenn', 'Jen', 'Steve')
x[2] -> Steve
max(x)
for i in x

Tuple is immutable. So cannot do: sort(), append(), reverse()
use dir(tuple1) to check what methods are available.
count() and index()

Tuples are more efficient. (faster since do have to save space for modification)

Can put tuple on the LHS of assignment:
(a, b) = ('jack', 'Annie')
(x, y) = (1, 2)
a, b = ('jack', 'Annie')
a -> 'jack'

Dictionary items() return list of tuples

for (k, v) in dict1.items():

tups = dict1.items()

tuples are comparable (compare one by one)
(0, 1, 20000) < (0, 2, 3) -> True
so use dict1.items() and sort, we can sort by keys (since only look at the first one)
or use t = sorted(dict1.items())
if want to sort by value,
tmp = [] (or list())
then for k, v in dict1.items():
            tmp.append((v,k))
        tmp.sort(reverse=True)

applications:
top 10 common used words
print sorted([(v,k) for k, v in dict1.items()] )

Tuesday, November 10, 2015

Web - Python

Python - Web





















Python built-in library for TCP sockets
import socket

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com', 80))

Application:


Write a web browser:
A http request in python:
import socket

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com', 80))

mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')

while True:
    data = mysock.recv(512)
    if ( len(data) < 1 ) :
        break
    print data
mysock.close()

urllib:
import urllib

fhand = urllib.urlopen('http://www.py4inf.com/code/romeo.txt')

for line in fhand:
    print line.strip()

<HTML>
Use beautifulsoup to parse HTML.
Download beautifulsoup.py and put it with your python code.
http://www.crummy.com/software/BeautifulSoup/

import urllib
from BeautifulSoup import *

url = raw_input("Enter - ")

html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)

# Retrieve a list of anchor tags
# Each tag is like a dictionary of HTML Attributes

tags = soup('a')

for tag in tags:
    print tag.get('href', None)



<XML>











































use xml.etree.elementtree
import urllib
import xml.etree.ElementTree as ET

serviceurl = 'http://maps.googleapis.com/maps/api/geocode/xml?'

while True:
    address = raw_input('Enter location: ')
    if len(address) < 1 : break

    url = serviceurl + urllib.urlencode({'sensor':'false', 'address': address})
    print 'Retrieving', url
    uh = urllib.urlopen(url)
    data = uh.read()
    print 'Retrieved',len(data),'characters'
    print data
    tree = ET.fromstring(data)


    results = tree.findall('result')
    lat = results[0].find('geometry').find('location').find('lat').text
    lng = results[0].find('geometry').find('location').find('lng').text
    location = results[0].find('formatted_address').text

    print 'lat',lat,'lng',lng
    print location

<JSON>
import json

info = json.loads(data)
info is a dictionary in Python.
So can use dictionary method to access the value associated with some key.

json list -> [{"key1":"v1"}, {"key2":"v2"}]
after loads, it is a list in Python

JSON vs. XML
JSON is easier to use, but XML is more expressive.
js = json.loads(data)
json.dumps(js. indent=4) # good formatting

<WEB Service Technology>
REST - Representational State Transfer - Remote resources which we create, read, update and delete remotely.



import json
import urllib

url = raw_input("Enter json location: ")

print "Retrieving ", url

urljson = urllib.urlopen(url)
data = urljson.read()
info = json.loads(data)
print 'Retrieved ', len(data), " characters"

print "Count ", len(info["comments"])

#print json.dumps(info, indent=4)
sumofcount = sum([item["count"] for item in info["comments"]])
print "Sum ", sumofcount
#for item in info["comments"]:
#    sumofcount += item["count"]

#print "Sum ", sumofcount
#print type(info["comments"]["count"])
#print "Sum ", sum(info["comments"]["count"])


import urllib
import twurl
import json

TWITTER_URL = 'https://api.twitter.com/1.1/friends/list.json'

while True:
    print ''
    acct = raw_input('Enter Twitter Account:')
    if ( len(acct) < 1 ) : break
    url = twurl.augment(TWITTER_URL,
        {'screen_name': acct, 'count': '5'} )
    print 'Retrieving', url
    connection = urllib.urlopen(url)
    data = connection.read()
    headers = connection.info().dict
    print 'Remaining', headers['x-rate-limit-remaining']
    js = json.loads(data)
    print json.dumps(js, indent=4)

    for u in js['users'] :
        print u['screen_name']
        s = u['status']['text']
        print '  ',s[:50]

Wednesday, October 28, 2015

宝宝疫苗schedule

http://www.mitbbs.com/pc/pccon_3509_47752.html

打算送宝宝回国的JMs或带着宝宝刚来美国的JMs可能会关心宝宝的疫苗接种问题, 我只清楚这里的疫苗接种情况, 对国内疫苗接种的具体情况我基本上是从网上了解到的,将我了解及看到的有关资料先贴出来供大家需要时参考啊(并有待更新)。

一、中美疫苗接种的异

如果宝宝刚出生不久要回中国待一段时间的话,那么有必要了解一下中美疫苗接种的不同之处。这里主要比较一岁半之前的情况。

相比之下,美国要求接种的疫苗比中国多一些,包括了中国所有必须接种的疫苗(除了BCG卡介苗),而中国比美国少了PCV7(肺炎球菌耦联),HIB(B型流感嗜血杆菌),MMR(麻风腮--麻疹、风疹、腮腺炎)和VAR(水痘)。中国必须打的疫苗是免费的,可以去街道疫苗接种中心打。回国后可尽快联系,确定接种日程

相同的疫苗可以互相代替打,中国的疫苗与美国的疫苗区别只是菌株的不同,提供的免疫能力应该是差不多的。在中国和美国的疫苗接种记录要注意保存,换了地方之后可以继续打,打的疫苗是互相承认的

二、中美不同疫苗的注意事项

● PCV7:在中美不同的疫苗中,特别要注意的是PCV7(美国一岁之前要打4针),中国没有PCV7只有PCV23,前者是小孩打的,后者是成人打的,两者不可互相替换。在国内打PCV7需要通过涉外的医院进口,进口疫苗需要外国护照。价格较高,每针1000-2000元人民币。如果宝宝在美国有医疗保险的,可以询问一下保险是否cover。

● HIB:HIB在中国不纳入全民免疫计划,属于自费针。一针100多元。

● MMR:在中国不纳入全民免疫计划,属于自费针。一针约80元。

● VAR:在中国不纳入全民免疫计划,属于自费针。一针约100多元。

● BCG:卡介苗在中国是必须要打的,免费的,而美国不是必须的。打了卡介苗之后,现有的皮试很可能会呈阳性,因此需要保存疫苗接种记录或者要求进行进一步的测试。

● 美国有轮状病毒疫苗(Rota),专门预防婴儿严重拉肚子的,中国好象还没有.

三、中美相同疫苗的注意事项

● DTaP(DTP):在中美相同的疫苗中,特别要注意的是DTap。美国打得是无细胞的疫苗,而中国免费打得是有细胞的疫苗。宝宝对无细胞的疫苗比对有细胞的疫苗反应要小。打了无细胞的不能再改打有细胞的,打了有细胞的可以改打无细胞的。所以推荐国内选择自费打无细胞的,价格约10几元。 (好像国内现在也开始改为无细胞了。)

● IPV/OPV:美国使用的是IPV就是注射疫苗,而中国使用的是OPV就是口服糖丸。糖丸有约十万分之一的可能性在首次服用时反而引发脊髓灰质炎(个人认为这个可能性小到可以忽略。而且如果在美国打过一针IPV的话就跟不用担心了)。另外吃糖丸的时候不能拉肚子,不然疫苗在产生作用之前会被排出体外。国内没有IPV,涉外医院IPV的价格约300元。

其他疫苗基本相同,可能具体接种时间会有些区别,但区别不大,可以自己掌握到底按美国的计划打还是按中国的计划打。

四、中美宝宝疫苗接种时间表

● Vaccine Schedule 美国
Visit Age Vaccines Given 

Birth     Hepatitis B (in hospital)       乙肝疫苗 
1 Month No Immunizations 
2 Month Pediarix(DTaP,HepB,IPV)  百白破三联疫苗+乙肝疫苗+脊髓灰质炎疫苗
       Prevnar(PCV)       肺炎球菌结合疫苗
       Hib       B型流感嗜血杆菌疫苗
       RotaTeq       轮状病毒疫苗
4 Month Pediarix(DTaP,HepB,IPV) 
       Prevnar(PCV)
       Hib
       RotaTeq 
6 Month Pediarix(DTaP,HepB,IPV) 
       Prevnar(PCV)
       RotaTeq 
9 Month No Immunizations 
12 Month Varicella(chickenpox)       水痘疫苗
       Prevnar(PCV)
       Hib 
15 Month MMR        麻风腮(麻疹、腮腺炎、德国麻疹) 三联疫苗
       HepA       甲肝疫苗
18 Month DTaP 
2 Years HepA 
4-6 Years DTaP
       IPV       注射式脊髓灰(小儿麻痹)疫苗
       MMR
       Varicella 
11-12Years Boostrix(TdaP)       白破混合制剂
       Menactra (MCV4)       流行性脑脊髓膜炎疫苗
       HPV       人乳头瘤病毒疫苗 
College MCV4

● 接种时间表 中 国

儿童预防接种时间表1

初生  卡介苗 皮下划痕法 
2个月 小儿麻痹疫苗(Ⅰ)  口服糖丸 
3个月 小儿麻痹疫苗(ⅠⅡ)  口服糖丸 
6个月  百、白、破(第一针)  注射 
7个月  百、白、破(第二针)  注射 
8个月  麻疹疫苗        注射 
9~10个月 百、白、破(第三针)  注射 
1岁     小儿麻痹疫苗(ⅠⅡⅢ) 口服糖丸注射 
       百、白、破、麻疹疫苗、 
       乙脑疫苗 
2岁     小儿麻痹疫苗(ⅠⅡⅢ) 口服糖丸注射 
       乙型炎疫苗        
4岁     卡介苗         皮上划痕法 
6岁     百、白、破       注射 

儿童预防接种时间表2

疫苗种类   程序   疫苗名称
一类(免费) 出生时  卡介苗 乙肝1
       1足月   乙肝2
       2足月   糖丸1
       3足月   糖丸2 百白破1
       4足月   糖丸3 百白破2
       5足月   百白破3
       6足月   乙肝3
       8足月   麻苗1
       9足月   乙脑(减毒)1
      一岁半 百白破4 麻苗2/麻腮风1(二类)
      一岁七个月  乙脑(减毒)2
      四周岁    糖丸4+麻腮风2(二类)
      六周岁    乙脑(减毒)2
      六周岁1个月 白破(加强)
二类(自费)一周岁    HIB
      一岁三个月  水痘
      一岁半    麻腮风
      二周岁    甲肝 流脑A+C1
      四周岁    麻腮风
      五周岁    流脑A+C2
      6-35月龄   每年注射流感2针

我国卫生部制定的《儿童计划免疫程序》
年龄 接种疫苗
出生 卡介苗(BCG)、乙肝疫苗(HepB)
1个月 乙肝疫苗(HepB)
2个月 脊髓灰质炎三价混合疫苗(PV)
3个月 脊髓灰质炎三价混合疫苗(PV) 百白破混合制剂(DTPa)
4个月 脊髓灰质炎三价混合疫苗(PV) 百白破混合制剂(DTPa)
5个月 百白破混合制剂(DTPa)
6个月 乙肝疫苗(HepB)
8个月 麻疹疫苗(Measles)
1.5-2.0岁 百白破混合制剂(DTPa)复种
4岁 脊髓灰质炎三价混合疫苗(PV)复种
7岁 麻疹疫苗(Measles)复种 白破混合制剂(DTaP)复种
12岁 乙肝疫苗(HepB)复种


北京市的儿童计划免疫程序介绍如下: 

新生儿:出生后24小时内接种乙肝疫苗(第一针)出生后48小时~1个月内接种卡介苗

1月龄:乙肝疫苗(第二针),与第一针相隔1月 

2月龄:三价小儿麻痹糖丸疫苗(第一次) 

3月龄:三价小儿麻痹糖丸疫苗(第二次),百白破疫苗(第一针) 

4月龄:三价小儿麻痹糖丸疫苗(第三次),百白破疫苗(第二针) 

5月龄:百白破疫苗(第三针) 

6月龄:乙肝疫苗(第三针) 

8月龄:麻疹疫苗 

满1岁:乙脑疫苗两针,两针相隔7~10天(乙脑疫苗为每年5月份季节性接种) 

1~2岁:百白破疫苗(加强),与上次间隔10~14个月流脑(加强)麻疹(复种),与上次间隔
10~14个月 

2岁:乙脑(加强) 

3岁:乙脑(再加强) 

4岁:三价小儿麻痹糖丸疫苗(加强) 

7岁:(小学一年级学生)百白破(加强一针),乙脑(加强一针),卡介苗(加强一针) 

12岁:卡介苗(农村人口加强一针) 

13岁:(初中一年级学生)乙脑(加强一针),白喉类毒素一针,麻疹(加强一针) 

18岁:成人白喉类毒素、麻疹各加强一针。以上介绍是北京市计划免疫程序。各省市根据当地气温.流行病的实际情况等,计免程序可略有变动。 

★ 一则关于扩大国家免疫规划的新闻, 计划免疫的疫苗可能已经或不久会增多:

中山市将从2008年9月1日起,按照广东省国家免疫规划疫苗免疫程序,实施扩大国家免疫规划,儿童可免费接种的疫苗从7种增加到12种。卫生部门预计,全市每年将有超过20万名适龄儿童可享受免费接种;增加免费疫苗后,每年可为家长多减负约1200万元。 
  
12种疫苗预防11种传染病 
  
除原已实施的7种国家免疫规划疫苗外,新纳入扩大国家免疫规划的疫苗有5种,包括A群流脑疫苗、A+C流脑疫苗、麻风二联疫苗、麻腮二联疫苗和麻腮风三联疫苗,全细胞百白破疫苗逐步被无细胞百白破疫苗替代;乙肝疫苗、卡介苗、脊灰疫苗、百白破疫苗、白破疫苗、麻疹疫苗、乙脑疫苗等7种现行的免疫规划疫苗,按照广东省国家免疫规划疫苗免疫程序,所有达到应种月(年)龄的全市范围适龄儿童,均可免费接种。 
  
适龄儿童通过接种上述12种疫苗,可预防乙型肝炎、结核病、脊髓灰质炎、百日咳、白喉、破伤风、麻疹、流行性脑脊髓膜炎、流行性乙型脑炎、风疹、流行性腮腺炎等11种传染病。 
  
市区3家医院可接种 
  
市疾病预防控制中心相关负责人表示,根据广东省的部署,2008年甲肝减毒活疫苗只在广州、深圳、东莞、韶关等四个市范围内实施,甲肝疫苗在中山市仍为自愿且自费接种的疫苗。家长还可自费选择其他疫苗,包括替代第一类疫苗的同品种第二类疫苗。 
  
另据了解,中山城区目前可进行疫苗接种的主要有3家医院,分别是华侨医院、苏华赞医院和东区医院。市疾病预防控制中心提醒,市民应在指定时间内,携带儿童到市各接种门诊进行疫苗接种,避免错过免费接种疫苗时间。


★★ 更多关于疫苗的缩写全称请JMs参看下面这个贴子
(http://www.mitbbs.com/pc/pccon.php?id=3509&nid=39540),

★★★ 疫苗接种的时间请参看这两个贴子
(http://www.mitbbs.com/article_t/NextGeneration/31344727.html)
(http://www.mitbbs.com/pc/pccon.php?id=3509&nid=39701)。


★★★附 在加拿大的宝宝回国打疫苗问题(是网上一个JM根据自己的经验写的)★★★

1. 加拿大注射白百破+儿麻+流感 五联针,中国注射白百破三联针,口服儿麻糖丸,而流感疫苗Hib(安儿宝)不作为必须免疫注射。

结论:建议注射Hib(安儿宝)

2. 加拿大注射MMR(麻疹,德国麻疹,腮腺炎)三联针,而中国分别注射麻疹和腮腺炎疫苗,无德国麻疹疫苗,且第一针注射时间均早于一周岁。加拿大卫生部视一周岁前注射无效。

结论:在中国注射第一针(麻疹和腮腺炎)时一定晚于一周岁,否则回加拿大后要补种。


3. 加拿大注射流脑C疫苗,中国注射流脑A疫苗

结论:在中国一定注射流脑A+C型流脑疫苗,否则回加拿大后要补

4. 在中国要求注射乙脑疫苗,在加拿大不要求

结论:在中国生活时要求免疫注射的都需要注射,防止感染相关的疾病。
在中国没有的而加拿大要求的(例如德国麻疹疫苗),回加后要补种,这样才能体现出“享受”两国的“优惠性”

5. 如果孩子打算在国内住上1,2年的话,还是尽量按国内的标准打。预防针的免疫程序设定都是按照当地的具体环境制定的。之所以五合一麻烦一些,是因为五合一其中的脊髓灰质炎加拿大是IPV(灭活),中国的是OPV(减毒),两者如果混合用,时间和剂量上配合的不好,容易建立不起来足够的免疫机制.

6. 尽量不服用国内的脊髓灰质炎糖丸。理由如下
国外是IPV,针剂,灭活菌,国内是OPV,减毒菌,口服。糖丸和针剂混用对儿童免疫基础建立没有好处,而且容易引起VAPP(由疫苗引起的感染小儿麻痹)。如果呆在国内到2岁,可以服用糖丸。因为只有一针针剂,反应应该不大。用糖丸建立免疫机制。如果孩子打算一岁左右就回到加拿大,到时候再打针剂,特别的危险。

7. 如果你在北京上海,当然是最好不用自己带,因为太麻烦了。象乙肝等其他的针剂在当地的防疫站就可以打,咱们的孩子都属于流动儿童,跟本地儿童在免疫上享受同等待遇,只交注射费.所以我觉得除了五合一和肺炎球菌在外资医院打,其他的都可以按照中国的免疫程序在防疫站打即可.当然据防疫站的人说,外国的防疫苗比中国的防疫苗好,反应小. 打电话给四大疫苗生产公司中国办事处,无五合一,IPV。
北京上海的外资医院有,200美元左右一针。只能抱孩子去北京上海打,不能拿回来。被逼无奈,只能托人从加拿大带疫苗。

8.五合一中HIB在国内是一岁以上的孩子才打,所以剂量不同,不能混合使用。肺炎球菌疫苗在国内是不同类型的。乙肝疫苗是全球通用的,所以在国内打这个没问题。

9. 北京可以给外籍儿童注射疫苗的医院

Bejing United Family Hospital
2 Jiangtai Road
Chao Yang District
Tel.: 010/6433 3960

国际SOS报警中心 - 中国 China
Beijing 
Beijing International (SOS) Clinic

Open 24 hours a day
Tel: 86 10 6462 9100
Fax: 86 10 6462 9111 

中日友好医院的国际部

总之只要建立档案,,有了国内的小绿本,就可以自由的转去自己住的地区的防疫站了,条件估计就差了,所以还是要自己决定

10. 上海有两家外资医院都可以打5合1和肺炎球菌, 要实现预定,他们从外面进口,一家是和睦家,另外一家好象叫联合诊所之类的. 价格差不多,肺炎球菌和加拿大的是一样的,prenar, 惠氏生产的. 和睦家的疫苗接种是按照美国的schedule,不过他们也可以根据家长提出的要求,按照你所希望的顺序接种.

价格大概是这样:定2次的5和1和肺炎球菌,共4针,一共花了500多加币.

11. 这里是和睦家医院的疫苗种类:卡介苗(BCG),乙型肝炎疫苗(Hep B1),五合一,B型流感菌疫苗(H.influenza type B),脊髓灰质炎疫苗(Polio),麻疹风疹流行性腮腺炎育苗(Measles,Mumps,Rubella),水痘疫苗(Varicella),甲型肝炎疫苗(HepatitisA),流脑(Meningococcal A,C,W,Y),流感(Influenza),乙型脑炎(Japanese Encephalitis B),伤寒疫苗(Typhoid),肺炎球菌疫苗(Pneumococcal),还有一些可以按照所在国家帮你接种,打算带宝宝回国打针的最好带上自己的黄卡和这里医生给的疫苗本。