Test y Ficha de identificacion completado
							parent
							
								
									963dcc2103
								
							
						
					
					
						commit
						d4e9431d38
					
				
											
												Binary file not shown.
											
										
									
								| @ -0,0 +1,90 @@ | ||||
| // | ||||
| //  FichaManager.swift | ||||
| //  RK-Journals | ||||
| // | ||||
| //  Created by Juan David López Regalado on 20/11/24. | ||||
| // | ||||
| 
 | ||||
| import Foundation | ||||
| import ResearchKit | ||||
| 
 | ||||
| class FichaManager { | ||||
|     static let shared = FichaManager() | ||||
|      | ||||
|     func createFichaTask() -> ORKTask { | ||||
|          | ||||
|         let bienvenida = ORKInstructionStep(identifier: "bienvenida") | ||||
|         bienvenida.title = "Ficha Identificación" | ||||
|         bienvenida.iconImage = UIImage(systemName: "person.text.rectangle") | ||||
|         bienvenida.detailText = "Por favor, llena la siguiente ficha de identificación con tus datos" | ||||
|          | ||||
|         // Nombre | ||||
|         let textQuestionStepTitle = "Nombre" | ||||
|         let textAnswerFormat = ORKTextAnswerFormat(maximumLength: 30) | ||||
|         textAnswerFormat.multipleLines = false | ||||
|         let textQuestionStep = ORKQuestionStep(identifier: "Nombre", title: textQuestionStepTitle, question: "¿Cuál es tu nombre?", answer: textAnswerFormat) | ||||
|         textQuestionStep.isOptional = false | ||||
|          | ||||
|         // Sexo | ||||
|         let multiGenderChoice = "Sexo" | ||||
|         let gendChoices = [ | ||||
|             ORKTextChoice(text: "Hombre", value: "hombre" as NSString), | ||||
|             ORKTextChoice(text: "Mujer", value: "mujer" as NSString), | ||||
|             ORKTextChoice(text: "Prefiero no decirlo", value: "Inf" as NSString)] | ||||
|          | ||||
|         let genderChoiceFormat = ORKTextChoiceAnswerFormat(style: .singleChoice, textChoices: gendChoices) | ||||
|         let multiGenderQuestionStep = ORKQuestionStep(identifier: "Sexo", title: multiGenderChoice,question: "¿Cuál es tu sexo?", answer: genderChoiceFormat) | ||||
|         multiGenderQuestionStep.isOptional = false | ||||
|          | ||||
|         // Edad | ||||
|         var ageChoices: [ORKTextChoice] = [] | ||||
|         for age in 16...50 { | ||||
|             let ageChoice = ORKTextChoice(text: "\(age) años", value: "\(age)" as NSString) | ||||
|             ageChoices.append(ageChoice) | ||||
|         } | ||||
|          | ||||
|         let ageQuestionStep = ORKQuestionStep( | ||||
|             identifier: "ageQuestionStep", | ||||
|             title: "Pregunta sobre Edad", | ||||
|             question: "¿Qué edad tienes?", | ||||
|             answer: ORKValuePickerAnswerFormat(textChoices: ageChoices) | ||||
|         ) | ||||
|         ageQuestionStep.isOptional = false // Hacemos que esta pregunta sea obligatoria | ||||
|          | ||||
|         // Peso | ||||
|         let pesoQuestionStep = ORKQuestionStep(identifier: "peso", title: "Peso", question: "¿Cuál es tu peso en kilogramos?", answer: ORKNumericAnswerFormat(style: .integer, unit: "kg")) | ||||
|         pesoQuestionStep.isOptional = false | ||||
| 
 | ||||
|         // Altura | ||||
|         let alturaQuestionStep = ORKQuestionStep(identifier: "altura", title: "Altura", question: "¿Cuál es tu altura en metros?", answer: ORKNumericAnswerFormat(style: .decimal, unit: "m")) | ||||
|         alturaQuestionStep.isOptional = false | ||||
|          | ||||
|          | ||||
|         // Sintomas | ||||
|         let symptomsChoices = [ | ||||
|             ORKTextChoice(text: "Dolor de cabeza", value: "dolor_de_cabeza" as NSString), | ||||
|             ORKTextChoice(text: "Fiebre", value: "fiebre" as NSString), | ||||
|             ORKTextChoice(text: "Tos", value: "tos" as NSString), | ||||
|             ORKTextChoice(text: "Dificultad para respirar", value: "dificultad_respirar" as NSString), | ||||
|             ORKTextChoice(text: "Dolor en el pecho", value: "dolor_pecho" as NSString), | ||||
|             ORKTextChoice(text: "Fatiga", value: "fatiga" as NSString), | ||||
|             ORKTextChoice(text: "Náuseas", value: "nauseas" as NSString), | ||||
|             ORKTextChoice(text: "Otros", value: "otros" as NSString) | ||||
|         ] | ||||
|          | ||||
|         // Crear la pregunta de síntomas | ||||
|         let symptomsStep = ORKQuestionStep( | ||||
|             identifier: "sintomas", | ||||
|             title: "¿Qué síntomas estás presentando?", | ||||
|             answer: ORKAnswerFormat.choiceAnswerFormat(with: .multipleChoice, textChoices: symptomsChoices) | ||||
|         ) | ||||
|         symptomsStep.isOptional = false | ||||
|          | ||||
|         let termino = ORKInstructionStep(identifier: "termino") | ||||
|         termino.title = "Gracias" | ||||
|         termino.iconImage = UIImage(systemName: "checkmark.circle.fill") | ||||
|         termino.detailText = "Gracias por llenar la ficha de identificación" | ||||
|          | ||||
|         return ORKOrderedTask(identifier: "FichaIdentificacion", steps: [bienvenida, textQuestionStep, multiGenderQuestionStep, ageQuestionStep, pesoQuestionStep, alturaQuestionStep, symptomsStep, termino]) | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,129 @@ | ||||
| import Foundation | ||||
| import ResearchKit | ||||
| 
 | ||||
| class TestManager { | ||||
|     static let shared = TestManager() | ||||
|      | ||||
|     func createTestTask() -> ORKTask { | ||||
|          | ||||
|         // Paso 1: Bienvenida | ||||
|         let bienvenidaStep = ORKInstructionStep(identifier: "bienvenida") | ||||
|         bienvenidaStep.title = "Evaluación de Ansiedad y Estado de Ánimo" | ||||
|         bienvenidaStep.text = "Este test nos ayudará a evaluar cómo te sientes actualmente. Responde con sinceridad." | ||||
|          | ||||
|         // Paso 2: Nivel de ansiedad (escala del 1 al 10) | ||||
|         let ansiedadPregunta = ORKQuestionStep( | ||||
|             identifier: "nivelAnsiedad", | ||||
|             title: "¿Qué tan ansioso/a te sientes en una escala del 1 al 10?", | ||||
|             answer: ORKScaleAnswerFormat( | ||||
|                 maximumValue: 10, | ||||
|                 minimumValue: 1, | ||||
|                 defaultValue: 5, | ||||
|                 step: 1 | ||||
|             ) | ||||
|         ) | ||||
|         ansiedadPregunta.isOptional = false | ||||
|          | ||||
|         // Paso 3: Estado de ánimo general (rueda de opciones) | ||||
|         let estadoAnimoChoices = [ | ||||
|             ORKTextChoice(text: "Muy feliz", value: "muy_feliz" as NSString), | ||||
|             ORKTextChoice(text: "Feliz", value: "feliz" as NSString), | ||||
|             ORKTextChoice(text: "Neutral", value: "neutral" as NSString), | ||||
|             ORKTextChoice(text: "Triste", value: "triste" as NSString), | ||||
|             ORKTextChoice(text: "Muy triste", value: "muy_triste" as NSString) | ||||
|         ] | ||||
|         let estadoAnimoPregunta = ORKQuestionStep( | ||||
|             identifier: "estadoAnimo", | ||||
|             title: "¿Cómo describirías tu estado de ánimo actual?", | ||||
|             answer: ORKValuePickerAnswerFormat(textChoices: estadoAnimoChoices) | ||||
|         ) | ||||
|         estadoAnimoPregunta.isOptional = false | ||||
|          | ||||
|          | ||||
|         // Paso 4: Frecuencia de síntomas (escala Likert) | ||||
|         let frecuenciaSintomasPregunta = ORKQuestionStep( | ||||
|             identifier: "frecuenciaSintomas", | ||||
|             title: "En la última semana, ¿con qué frecuencia has experimentado estos síntomas?", | ||||
|             answer: ORKAnswerFormat.textScale( | ||||
|                 with: [ | ||||
|                     ORKTextChoice(text: "Nunca", value: "nunca" as NSString), | ||||
|                     ORKTextChoice(text: "Rara vez", value: "rara_vez" as NSString), | ||||
|                     ORKTextChoice(text: "A veces", value: "a_veces" as NSString), | ||||
|                     ORKTextChoice(text: "Frecuentemente", value: "frecuentemente" as NSString), | ||||
|                     ORKTextChoice(text: "Todo el tiempo", value: "todo_el_tiempo" as NSString) | ||||
|                 ], | ||||
|                 defaultIndex: 2, // Neutral ("A veces") | ||||
|                 vertical: true | ||||
|             ) | ||||
|         ) | ||||
|         frecuenciaSintomasPregunta.isOptional = false | ||||
|          | ||||
|         // Paso 5: Situaciones específicas (múltiples opciones) | ||||
|         let situacionesChoices = [ | ||||
|             ORKTextChoice(text: "Dificultad para concentrarte", value: "concentracion" as NSString), | ||||
|             ORKTextChoice(text: "Pérdida de interés en actividades", value: "interes" as NSString), | ||||
|             ORKTextChoice(text: "Sensación de nerviosismo", value: "nerviosismo" as NSString), | ||||
|             ORKTextChoice(text: "Problemas para dormir", value: "sueño" as NSString), | ||||
|             ORKTextChoice(text: "Cambios en el apetito", value: "apetito" as NSString), | ||||
|             ORKTextChoice(text: "Ninguno de los anteriores", value: "ninguno" as NSString) | ||||
|         ] | ||||
|         let situacionesPregunta = ORKQuestionStep( | ||||
|             identifier: "situaciones", | ||||
|             title: "¿Cuáles de las siguientes situaciones has experimentado recientemente?", | ||||
|             answer: ORKAnswerFormat.choiceAnswerFormat(with: .multipleChoice, textChoices: situacionesChoices) | ||||
|         ) | ||||
|          | ||||
|         situacionesPregunta.isOptional = false | ||||
|          | ||||
|         // Paso 6: Tiempo al aire libre (respuesta numérica) | ||||
|         let tiempoAireLibrePregunta = ORKQuestionStep( | ||||
|             identifier: "tiempoAireLibre", | ||||
|             title: "¿Cuántas horas pasas al aire libre por día?", | ||||
|             answer: ORKNumericAnswerFormat(style: .integer, unit: "horas") | ||||
|         ) | ||||
|         tiempoAireLibrePregunta.isOptional = false | ||||
|          | ||||
|          | ||||
|         // Paso 7: Ejercicio (texto corto) | ||||
|         let ejercicioPregunta = ORKQuestionStep( | ||||
|             identifier: "ejercicio", | ||||
|             title: "¿Qué tipo de ejercicio realizas regularmente?", | ||||
|             answer: ORKTextAnswerFormat(maximumLength: 100) | ||||
|         ) | ||||
|         ejercicioPregunta.isOptional = false | ||||
|          | ||||
|         // Paso 8: Comentarios adicionales (texto largo) | ||||
|         let comentariosPregunta = ORKQuestionStep( | ||||
|             identifier: "comentarios", | ||||
|             title: "¿Hay algo más que quieras compartir sobre cómo te sientes?", | ||||
|             answer: { | ||||
|                 let formatoTexto = ORKTextAnswerFormat(maximumLength: 500) | ||||
|                 formatoTexto.multipleLines = true // Permite que el cuadro sea más grande | ||||
|                 return formatoTexto | ||||
|             }() | ||||
|         ) | ||||
|          | ||||
|         comentariosPregunta.isOptional = false | ||||
|                 | ||||
|         // Paso final: Agradecimiento | ||||
|         let finStep = ORKInstructionStep(identifier: "fin") | ||||
|         finStep.title = "¡Gracias por completar el test!" | ||||
|         finStep.text = "Tus respuestas serán analizadas para ofrecerte mejores recomendaciones." | ||||
|          | ||||
|         // Crear el test con todos los pasos | ||||
|         return ORKOrderedTask( | ||||
|             identifier: "AnxietyMoodTest", | ||||
|             steps: [ | ||||
|                 bienvenidaStep, | ||||
|                 ansiedadPregunta, | ||||
|                 estadoAnimoPregunta, | ||||
|                 frecuenciaSintomasPregunta, | ||||
|                 situacionesPregunta, | ||||
|                 tiempoAireLibrePregunta, | ||||
|                 ejercicioPregunta, | ||||
|                 comentariosPregunta, | ||||
|                 finStep | ||||
|             ] | ||||
|         ) | ||||
|     } | ||||
| } | ||||
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 289 KiB | 
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 234 KiB | 
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 757 KiB | 
											
												Binary file not shown.
											
										
									
								| After Width: | Height: | Size: 317 KiB | 
					Loading…
					
					
				
		Reference in New Issue