select id, past_illnesses, guid,  drug_allergy, family_history, surgical_history, reproductive_history, orgid,menstrual_history, smoking, drink, motion, diet, psychology, pid from medical_history
    
    
    
    
        insert into medical_history
        
            past_illnesses,
            drug_allergy,
            family_history,
            surgical_history,
            reproductive_history,
            menstrual_history,
            smoking,
            drink,
            motion,
            diet,
            psychology,
            pid,
            guid,
            orgid,
         
        
            #{pastIllnesses},
            #{drugAllergy},
            #{familyHistory},
            #{surgicalHistory},
            #{reproductiveHistory},
            #{menstrualHistory},
            #{smoking},
            #{drink},
            #{motion},
            #{diet},
            #{psychology},
            #{pid},
            #{guid},
            #{orgid},
         
    
    
        update medical_history
        
            past_illnesses = #{pastIllnesses},
            drug_allergy = #{drugAllergy},
            family_history = #{familyHistory},
            surgical_history = #{surgicalHistory},
            reproductive_history = #{reproductiveHistory},
            menstrual_history = #{menstrualHistory},
            smoking = #{smoking},
            drink = #{drink},
            motion = #{motion},
            diet = #{diet},
            psychology = #{psychology},
            pid = #{pid},
            guid = #{guid},
            orgid = #{orgid},
        
        where id = #{id}
    
    
        delete from medical_history where id = #{id}
    
    
        delete from medical_history where id in
        
            #{id}