diff --git a/glific/src/main/java/org/avni_integration_service/glific/bigQuery/domain/FlowResult.java b/glific/src/main/java/org/avni_integration_service/glific/bigQuery/domain/FlowResult.java index a307305c..51b4c29d 100644 --- a/glific/src/main/java/org/avni_integration_service/glific/bigQuery/domain/FlowResult.java +++ b/glific/src/main/java/org/avni_integration_service/glific/bigQuery/domain/FlowResult.java @@ -9,13 +9,15 @@ public class FlowResult { private final Map fields; private final Map results; + public static String STUDENT_CONTACT_NUMBER = "contact_phone"; + public FlowResult(Map fields) { this.fields = fields; results = readValue((String)this.fields.get("results"), Map.class); } public String getContactPhone() { - return (String) fields.get("contact_phone"); + return (String) fields.get(STUDENT_CONTACT_NUMBER); } public String getInsertedAt() { diff --git a/glific/src/test/java/org/avni_integration_service/glific/bigQuery/builder/SchemaBuilder.java b/glific/src/test/java/org/avni_integration_service/glific/bigQuery/builder/SchemaBuilder.java index c183a3d5..147e29f0 100644 --- a/glific/src/test/java/org/avni_integration_service/glific/bigQuery/builder/SchemaBuilder.java +++ b/glific/src/test/java/org/avni_integration_service/glific/bigQuery/builder/SchemaBuilder.java @@ -4,10 +4,12 @@ import com.google.cloud.bigquery.LegacySQLTypeName; import com.google.cloud.bigquery.Schema; +import static org.avni_integration_service.glific.bigQuery.domain.FlowResult.STUDENT_CONTACT_NUMBER; + public class SchemaBuilder { public Schema flowResultSchema() { - return Schema.of(Field.of("contact_phone", LegacySQLTypeName.STRING), + return Schema.of(Field.of(STUDENT_CONTACT_NUMBER, LegacySQLTypeName.STRING), Field.of("flowresult_id", LegacySQLTypeName.STRING), Field.of("inserted_at", LegacySQLTypeName.DATETIME), Field.of("results", LegacySQLTypeName.STRING), diff --git a/integration-common/src/main/java/org/avni_integration_service/common/MessageUnprocessableException.java b/integration-common/src/main/java/org/avni_integration_service/common/MessageUnprocessableException.java new file mode 100644 index 00000000..58bd427b --- /dev/null +++ b/integration-common/src/main/java/org/avni_integration_service/common/MessageUnprocessableException.java @@ -0,0 +1,10 @@ +package org.avni_integration_service.common; + +/** + * Use this exception to indicate that the current message cannot be processed due to problems with this message + */ +public class MessageUnprocessableException extends Exception { + public MessageUnprocessableException(String message) { + super(message); + } +} diff --git a/integration-common/src/main/java/org/avni_integration_service/common/PlatformException.java b/integration-common/src/main/java/org/avni_integration_service/common/PlatformException.java new file mode 100644 index 00000000..c5a3ff99 --- /dev/null +++ b/integration-common/src/main/java/org/avni_integration_service/common/PlatformException.java @@ -0,0 +1,14 @@ +package org.avni_integration_service.common; + +/** + * Use this exception to indicate that integration service module cannot process any messages due to problems in configuration of integration service, integration system, or avni. + */ +public class PlatformException extends Exception { + public PlatformException(String message) { + super(message); + } + + public PlatformException(Throwable cause) { + super(cause); + } +} diff --git a/integration-common/src/main/java/org/avni_integration_service/common/UnknownException.java b/integration-common/src/main/java/org/avni_integration_service/common/UnknownException.java new file mode 100644 index 00000000..9494d5aa --- /dev/null +++ b/integration-common/src/main/java/org/avni_integration_service/common/UnknownException.java @@ -0,0 +1,10 @@ +package org.avni_integration_service.common; + +/** + * Use this to indicate the source of problem in processing is unknown + */ +public class UnknownException extends Exception { + public UnknownException(Throwable cause) { + super(cause); + } +} diff --git a/integration-data/src/main/java/org/avni_integration_service/integration_data/domain/framework/MappingException.java b/integration-data/src/main/java/org/avni_integration_service/integration_data/domain/framework/MappingException.java index 4186a4cf..10c180a3 100644 --- a/integration-data/src/main/java/org/avni_integration_service/integration_data/domain/framework/MappingException.java +++ b/integration-data/src/main/java/org/avni_integration_service/integration_data/domain/framework/MappingException.java @@ -1,22 +1,7 @@ package org.avni_integration_service.integration_data.domain.framework; public class MappingException extends RuntimeException { - public MappingException() { - } - public MappingException(String message) { super(message); } - - public MappingException(String message, Throwable cause) { - super(message, cause); - } - - public MappingException(Throwable cause) { - super(cause); - } - - public MappingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } } diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/domain/LahiStudentConstants.java b/lahi/src/main/java/org/avni_integration_service/lahi/domain/LahiStudentConstants.java index fc61efe8..8d3b93cb 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/domain/LahiStudentConstants.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/domain/LahiStudentConstants.java @@ -1,8 +1,5 @@ package org.avni_integration_service.lahi.domain; -import java.util.Arrays; -import java.util.List; - public interface LahiStudentConstants { String FIRST_NAME = "avni_first_name"; String LAST_NAME = "avni_last_name"; @@ -13,7 +10,6 @@ public interface LahiStudentConstants { String DISTRICT = "avni_district_name"; String CITY_NAME = "avni_city_name"; String SCHOOL = "avni_school_name"; - String STUDENT_CONTACT_NUMBER = "contact_phone"; String ALTERNATE_NUMBER = "avni_alternate_contact"; String EMAIL = "avni_email"; String HIGHEST_QUALIFICATION = "avni_highest_qualification"; @@ -27,19 +23,4 @@ public interface LahiStudentConstants { String STREAM = "avni_stream"; String QUALIFICATION_STREAM = "avni_other_qualification_stream"; String FLOWRESULT_ID = "flowresult_id"; - - List MandatoryFields = - Arrays.asList( - FIRST_NAME, - LAST_NAME, - DATE_OF_BIRTH, - GENDER, - FATHER_NAME, - STUDENT_CONTACT_NUMBER, - HIGHEST_QUALIFICATION, - ACADEMIC_YEAR, - QUALIFICATION_STREAM, - OTHER_QUALIFICATION, - VOCATIONAL - ); } diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/domain/Student.java b/lahi/src/main/java/org/avni_integration_service/lahi/domain/Student.java index cfff7f1f..4d90b95c 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/domain/Student.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/domain/Student.java @@ -1,22 +1,33 @@ package org.avni_integration_service.lahi.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import org.apache.log4j.Logger; +import org.avni_integration_service.common.PlatformException; +import org.avni_integration_service.common.MessageUnprocessableException; import org.avni_integration_service.glific.bigQuery.domain.FlowResult; +import org.avni_integration_service.lahi.util.DateTimeUtil; +import org.springframework.util.StringUtils; +import java.time.LocalDate; +import java.time.Period; import java.util.*; +import java.util.stream.Collectors; @JsonIgnoreProperties(ignoreUnknown = true) public class Student implements LahiStudentConstants { - private static final Logger logger = Logger.getLogger(Student.class); - private static final List Core_Fields = Arrays.asList(FIRST_NAME,LAST_NAME,DATE_OF_BIRTH, GENDER); - private static final List PRIMITIVE_OBS_FIELDS = Arrays.asList(OTHER_STATE, DISTRICT, CITY_NAME, SCHOOL, -// STUDENT_CONTACT_NUMBER, ALTERNATE_NUMBER, - EMAIL, OTHER_QUALIFICATION, FATHER_NAME, QUALIFICATION_STREAM); - private static final List CODED_OBS_FIELDS = Arrays.asList(STATE, HIGHEST_QUALIFICATION, + private static final List MandatoryFields = + Arrays.asList( + FIRST_NAME, + LAST_NAME, + DATE_OF_BIRTH, + GENDER + ); + + private static final List OtherPrimitiveFields = Arrays.asList(EMAIL, OTHER_QUALIFICATION, FATHER_NAME, QUALIFICATION_STREAM); + private static final List OtherCodedFields = Arrays.asList(HIGHEST_QUALIFICATION, QUALIFICATION_STATUS, ACADEMIC_YEAR, VOCATIONAL, TRADE, STREAM); + private static final List Genders = Arrays.asList("Male", "Female", "Other"); - private FlowResult flowResult; + private final FlowResult flowResult; public Student(FlowResult flowResult) { this.flowResult = flowResult; @@ -73,9 +84,20 @@ public String getFlowResultId() { public Map getObservations() { HashMap observations = new HashMap<>(); - PRIMITIVE_OBS_FIELDS.forEach(fieldName -> observations.put(fieldName, getInput(fieldName))); - CODED_OBS_FIELDS.forEach(fieldName -> observations.put(fieldName, getCategory(fieldName))); + OtherPrimitiveFields.forEach(fieldName -> observations.put(fieldName, getInput(fieldName))); + OtherCodedFields.forEach(fieldName -> observations.put(fieldName, getCategory(fieldName))); return observations; } + + public void validate() throws PlatformException, MessageUnprocessableException { + List missingFields = MandatoryFields.stream().filter(field -> !StringUtils.hasLength(getInput(field))).collect(Collectors.toList()); + if (missingFields.size() > 0) + throw new PlatformException(String.format("Missing fields: %s", String.join(",", missingFields))); + if (!Genders.contains(getGender())) + throw new PlatformException(String.format("Gender value is wrong: %s", getGender())); + boolean ageLessThan14 = Period.between(Objects.requireNonNull(DateTimeUtil.toLocalDate(getDateOfBirth(), DateTimeUtil.DD_MM_YYYY)), LocalDate.now()).getYears() < 14; + if (ageLessThan14) + throw new MessageUnprocessableException(String.format("Age is less than 14: %s", getDateOfBirth())); + } } diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/domain/StudentValidator.java b/lahi/src/main/java/org/avni_integration_service/lahi/domain/StudentValidator.java deleted file mode 100644 index 69a90a8e..00000000 --- a/lahi/src/main/java/org/avni_integration_service/lahi/domain/StudentValidator.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.avni_integration_service.lahi.domain; - -import org.apache.log4j.Logger; -import org.avni_integration_service.lahi.util.DateTimeUtil; -import org.springframework.stereotype.Component; - -import java.time.LocalDate; -import java.time.Period; -import java.util.Map; - -@Component -public class StudentValidator { - private static final Logger logger = Logger.getLogger(StudentValidator.class); - - public void validateMandatoryField(Map map) { - long count = LahiStudentConstants.MandatoryFields.stream().filter(field -> { - if (map.getOrDefault(field, null) == null) { - logger.error(String.format("%s missing for id:%s", field, map.get("id"))); - return false; - } - return true; - }).count(); - if (count != 0) { - throw new RuntimeException("Mandatory field for avni not found"); - } - } - - public void checkAge(String dateOfBirth) { - boolean isNotValid = false; - if (dateOfBirth == null) { - isNotValid = true; - } - if (Period.between(DateTimeUtil.toLocalDate(dateOfBirth, DateTimeUtil.DD_MM_YYYY), LocalDate.now()).getYears() < 14) { - isNotValid = true; - } - if (isNotValid) { - throw new RuntimeException("Invalid age value specified"); - } - } -} diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/repository/AvniStudentRepository.java b/lahi/src/main/java/org/avni_integration_service/lahi/repository/AvniStudentRepository.java index 3da1cf46..1ca1ec2a 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/repository/AvniStudentRepository.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/repository/AvniStudentRepository.java @@ -18,7 +18,7 @@ public class AvniStudentRepository { public static final String STUDENT_SUBJECT_TYPE = "Student"; public static final String CONTACT_PHONE_NUMBER = "Student contact number"; public static final String ALTERNATE_PHONE_NUMBER = "Alternate (Whatsapp number)"; - public static final String FATHERS_NAME_CONCEPT = ""; + public static final String FATHERS_NAME_CONCEPT = "Father's name"; private static final Logger logger = Logger.getLogger(AvniStudentRepository.class); private final AvniSubjectRepository avniSubjectRepository; diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/service/AvniStudentService.java b/lahi/src/main/java/org/avni_integration_service/lahi/service/AvniStudentService.java index f7d55c71..84b791e7 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/service/AvniStudentService.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/service/AvniStudentService.java @@ -2,6 +2,8 @@ import org.apache.log4j.Logger; import org.avni_integration_service.avni.domain.Subject; +import org.avni_integration_service.common.MessageUnprocessableException; +import org.avni_integration_service.common.UnknownException; import org.avni_integration_service.lahi.repository.AvniStudentRepository; import org.springframework.stereotype.Service; @@ -16,13 +18,17 @@ public AvniStudentService(AvniStudentRepository avniStudentRepository) { this.avniStudentRepository = avniStudentRepository; } - public void saveStudent(Subject subject) { + public void saveStudent(Subject subject) throws MessageUnprocessableException, UnknownException { List matchingStudents = avniStudentRepository.findMatchingStudents(subject); if (matchingStudents.size() > 0) { logger.warn(String.format("Found %d students with matching details, skipping", matchingStudents.size())); - return; + throw new MessageUnprocessableException("Avni has at least one such existing student"); } - avniStudentRepository.addSubject(subject); + try { + avniStudentRepository.addSubject(subject); + } catch (Exception e) { + throw new UnknownException(e); + } } } diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/service/StudentMapper.java b/lahi/src/main/java/org/avni_integration_service/lahi/service/StudentMapper.java index 3796fc2d..00a9e03a 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/service/StudentMapper.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/service/StudentMapper.java @@ -2,6 +2,8 @@ import org.apache.logging.log4j.util.Strings; import org.avni_integration_service.avni.domain.Subject; +import org.avni_integration_service.common.PlatformException; +import org.avni_integration_service.integration_data.domain.framework.MappingException; import org.avni_integration_service.lahi.config.LahiMappingDbConstants; import org.avni_integration_service.lahi.domain.LahiStudentConstants; import org.avni_integration_service.lahi.domain.Student; @@ -22,9 +24,14 @@ public StudentMapper(ObservationMapper observationMapper) { this.observationMapper = observationMapper; } - public Subject mapToSubject(Student lahiStudent) { + public Subject mapToSubject(Student lahiStudent) throws PlatformException { Subject subject = this.subjectWithoutObservations(lahiStudent); - observationMapper.mapObservations(subject, lahiStudent.getObservations(), LahiMappingDbConstants.MAPPING_GROUP_STUDENT, LahiMappingDbConstants.MAPPING_TYPE_OBS); + try { + observationMapper.mapObservations(subject, lahiStudent.getObservations(), LahiMappingDbConstants.MAPPING_GROUP_STUDENT, LahiMappingDbConstants.MAPPING_TYPE_OBS); + } catch (MappingException mappingException) { + throw new PlatformException(mappingException); + } + Map observations = subject.getObservations(); LahiMappingDbConstants.DEFAULT_STUDENT_OBS_VALUE_MAP.forEach(observations::put); setOtherAddress(subject, lahiStudent); diff --git a/lahi/src/main/java/org/avni_integration_service/lahi/worker/StudentWorker.java b/lahi/src/main/java/org/avni_integration_service/lahi/worker/StudentWorker.java index a34623b8..9a6b5a9a 100644 --- a/lahi/src/main/java/org/avni_integration_service/lahi/worker/StudentWorker.java +++ b/lahi/src/main/java/org/avni_integration_service/lahi/worker/StudentWorker.java @@ -2,6 +2,9 @@ import org.apache.log4j.Logger; import org.avni_integration_service.avni.domain.Subject; +import org.avni_integration_service.common.MessageUnprocessableException; +import org.avni_integration_service.common.PlatformException; +import org.avni_integration_service.common.UnknownException; import org.avni_integration_service.lahi.domain.Student; import org.avni_integration_service.lahi.domain.Students; import org.avni_integration_service.lahi.service.*; @@ -32,9 +35,14 @@ public void processStudents() { Subject subject = studentMapper.mapToSubject(student); avniStudentService.saveStudent(subject); lahiIntegrationDataService.studentProcessed(student); - } catch (Throwable t) { - logger.error("Error while process glific student", t); - studentErrorService.studentProcessingError(student, t); + } catch (PlatformException e) { + logger.error("Platform level issue. Stop processing.", e); + throw new RuntimeException(e); + } catch (MessageUnprocessableException e) { + logger.error("Problem with message. Continue processing.", e); + } catch (UnknownException e) { + logger.error("Unknown error. Adding to error record.", e); + studentErrorService.studentProcessingError(student, e); } } } diff --git a/lahi/src/test/resources/firstTimeDataSetup.sql b/lahi/src/test/resources/firstTimeDataSetup.sql index 9ee50ae4..0784b6c9 100644 --- a/lahi/src/test/resources/firstTimeDataSetup.sql +++ b/lahi/src/test/resources/firstTimeDataSetup.sql @@ -45,19 +45,19 @@ INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type VALUES (DEFAULT, 'avni_academic_year', 'Academic year for the qualification', 'Coded', (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2017-18', '2017-18', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2017', '2017-18', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2018-19', '2018-19', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2018', '2018-19', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2019-20', '2019-20', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2019', '2019-20', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2020-21', '2020-21', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2020', '2020-21', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2021-22', '2021-22', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2021', '2021-22', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2022-23', '2022-23', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2022', '2022-23', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) -VALUES (DEFAULT, '2023-24', '2023-24', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); +VALUES (DEFAULT, '2023', '2023-24', null, (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided) VALUES (DEFAULT, 'avni_qualification_status', 'Qualification status', 'Coded', (select id from integration_system where name = 'lahi' and system_type = 'lahi'), (select id from mapping_group where name = 'Student' and mapping_group.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), (select id from mapping_type where name = 'Observations' and mapping_type.integration_system_id = (select id from integration_system where name = 'lahi' and system_type = 'lahi')), uuid_generate_v4(), false); INSERT INTO public.mapping_metadata (id, int_system_value, avni_value, data_type_hint, integration_system_id, mapping_group_id, mapping_type_id, uuid, is_voided)