Member 12613359 Ответов: 1

Запрос объяснения кода java


Я новичок в Java и надеялся, что кто-нибудь объяснит, что означает этот код и что он делает:

mport com.intellisoftkenya.onetooner.api.imp.processor.Account99Includer;
import com.intellisoftkenya.onetooner.api.imp.processor.AccountTypeTxTypeSetter;
import com.intellisoftkenya.onetooner.api.imp.processor.DhisIdMapper;
import com.intellisoftkenya.onetooner.api.imp.processor.DrugSupporterProcessor;
import com.intellisoftkenya.onetooner.api.imp.processor.DrugsInRegimenProcessor;
import com.intellisoftkenya.onetooner.api.imp.processor.DrugsInUseProcessor;
import com.intellisoftkenya.onetooner.api.imp.processor.IdentifierTypeCreator;
import com.intellisoftkenya.onetooner.api.imp.processor.LookupValuePkProcessor;
import com.intellisoftkenya.onetooner.api.imp.processor.MasterDrugListImporter;
import com.intellisoftkenya.onetooner.api.imp.processor.PatientServiceTypeProcessor;
import com.intellisoftkenya.onetooner.api.imp.processor.UnitsInOutUpdater;
import com.intellisoftkenya.onetooner.api.imp.processor.UnnecessaryServiceTypesRemover;
import com.intellisoftkenya.onetooner.api.imp.processor.VisitTypeServiceTypeSetter;
import com.intellisoftkenya.onetooner.api.imp.processor.VisitUpdater;
import com.intellisoftkenya.onetooner.api.imp.translator.AccountTypeValueTranslator;
import com.intellisoftkenya.onetooner.api.imp.translator.AccountValueInferrer;
import com.intellisoftkenya.onetooner.api.imp.translator.DrugCategoryValueTranslator;
import com.intellisoftkenya.onetooner.api.processor.ExtraProcessor;
import com.intellisoftkenya.onetooner.api.translator.ValueInferrer;
import com.intellisoftkenya.onetooner.api.translator.ValueTranslator;
import com.intellisoftkenya.onetooner.business.Constants;
import com.intellisoftkenya.onetooner.data.Column;
import com.intellisoftkenya.onetooner.data.LookupValue;
import com.intellisoftkenya.onetooner.data.OneToOne;
import com.intellisoftkenya.onetooner.data.Parameter;
import com.intellisoftkenya.onetooner.data.ParameterizedQuery;
import com.intellisoftkenya.onetooner.data.Reference;
import com.intellisoftkenya.onetooner.data.Table;
import com.intellisoftkenya.onetooner.data.WhereCondition;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class TableConfigurator {
    public List<OneToOne> configureTables() throws Exception {
        ArrayList<OneToOne> oneToOneTables = new ArrayList<OneToOne>();
        oneToOneTables.add(this.configurePatientStatus());
        oneToOneTables.add(this.configureAccount());
        oneToOneTables.add(this.configureDosage());
        oneToOneTables.add(this.configureGenericName());
        oneToOneTables.add(this.configureFacility());
        oneToOneTables.add(this.configureIndication());
        oneToOneTables.add(this.configureRegimenChangeReason());
        oneToOneTables.add(this.configureRegimenType());
        oneToOneTables.add(this.configureRegimen());
        oneToOneTables.add(this.configureRegion());
        oneToOneTables.add(this.configureDistrict());
        oneToOneTables.add(this.configureSupportingOrganization());
        oneToOneTables.add(this.configurePatientSource());
        oneToOneTables.add(this.configureServiceType());
        oneToOneTables.add(this.configureDispensingUnit());
        oneToOneTables.add(this.configureVisitType());
        oneToOneTables.add(this.configureTransactionType());
        oneToOneTables.add(this.configureDrug());
        oneToOneTables.add(this.configurePerson());
        oneToOneTables.add(this.configurePersonAddress());
        oneToOneTables.add(this.configurePatient());
        oneToOneTables.add(this.configurePatientIdentifier_ArtId());
        oneToOneTables.add(this.configurePatientIdentifier_OpipdId());
        oneToOneTables.add(this.configureVisit());
        oneToOneTables.add(this.configureTransaction_Stock());
        oneToOneTables.add(this.configureTransaction_Patient());
        oneToOneTables.add(this.configureTransactionItem_Stock());
        oneToOneTables.add(this.configureTransactionItem_Patient());
        oneToOneTables.add(this.configureBatchTransactionItem());
        oneToOneTables.add(this.configurePatientTransactionItem());
        return oneToOneTables;
    }

    private OneToOne configurePatientStatus() {
        OneToOne oto = new OneToOne(31, new Table("tblCurrentStatus", Table.orderBy("CurrentStatusID")), new Table("patient_status"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("CurrentStatusID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("CurrentStatus", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureAccount() {
        OneToOne oto = new OneToOne(23, new Table("tblARVStockTranSourceorDestination", Table.orderBy("SDNo")), new Table("account"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("SDNo_", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("SourceorDestination_", 12), new Column("name", 12));
        Column accountTypeId = new Column("account_type_id", 4);
        accountTypeId.setReference(new Reference("account_type", true, Reference.NullAction.THROW_EXCEPTION, new AccountTypeValueTranslator()));
        columnMappings.put(new Column("SourceorDestination_", 12), accountTypeId);
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new Account99Includer());
        oto.setParameterizedQuery("SELECT MIN(SDNo) AS SDNo_, MIN(SourceorDestination) AS SourceorDestination_\nFROM tblARVStockTranSourceorDestination WHERE SourceorDestination IS NOT NULL\nGROUP BY SDNo\nUNION\nSELECT MIN(SCode) AS SCode_, MIN(Source) AS Source_ FROM\ntblSource WHERE Source IS NOT NULL\nGROUP BY SCode\nUNION\nSELECT MIN(DCode) AS DCode_, MIN(Destination) AS Destination_\nFROM tblDestination WHERE Destination IS NOT NULL\nGROUP BY Dcode");
        return oto;
    }

    private OneToOne configureDosage() {
        OneToOne oto = new OneToOne(27, new Table("tblDose", Table.orderBy("dose")), new Table("dosage"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("dose", 12), new Column("name", 12));
        columnMappings.put(new Column("value", 3), new Column("value", 3));
        columnMappings.put(new Column("frequency", 4), new Column("frequency", 4));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureGenericName() {
        OneToOne oto = new OneToOne(13, new Table("tblGenericName", Table.orderBy("GenID")), new Table("generic_name"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("GenID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("GenericName", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureFacility() {
        OneToOne oto = new OneToOne(30, new Table("tblHealthFacilities", Table.orderBy("MFLCode")), new Table("facility"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("MFLCode", 4), new Column("code", 4));
        columnMappings.put(new Column("FacilityName", 12), new Column("name", 12));
        columnMappings.put(new Column("District", 12), new Column("district", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureIndication() {
        OneToOne oto = new OneToOne(26, new Table("tblIndication", Table.orderBy("indicationCode")), new Table("indication"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("indicationCode", 12), new Column("legacy_pk", 12));
        columnMappings.put(new Column("IndicationName", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureRegimenChangeReason() {
        OneToOne oto = new OneToOne(22, new Table("tblReasonforChange", Table.orderBy("ReasonForChangeID")), new Table("regimen_change_reason"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ReasonForChangeID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("ReasonforChange", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureRegimenType() {
        OneToOne oto = new OneToOne(16, new Table("tblRegimenCategory", Table.orderBy("CategoryID")), new Table("regimen_type"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("CategoryID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("CategoryName", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureRegimen() {
        OneToOne oto = new OneToOne(15, new Table("tblRegimen", Table.orderBy("Regimencode")), new Table("regimen"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("Regimencode", 12), new Column("code", 12));
        columnMappings.put(new Column("Regimen", 12), new Column("name", 12));
        columnMappings.put(new Column("Line", 4), new Column("line", 4));
        columnMappings.put(new Column("Remarks", 12), new Column("comments", 12));
        columnMappings.put(new Column("show", 16), new Column("visible", 16));
        Column serviceType = new Column("service_type_id", 4);
        serviceType.setReference(new Reference("service_type", "legacy_pk"));
        columnMappings.put(new Column("TypeoService", 4), serviceType);
        Column regimenType = new Column("regimen_type_id", 4);
        regimenType.setReference(new Reference("regimen_type", "legacy_pk"));
        columnMappings.put(new Column("Category", 4), regimenType);
        Column regimenStatus = new Column("regimen_status_id", 4);
        regimenStatus.setReference(new Reference("regimen_status", true));
        columnMappings.put(new Column("Status", 12), regimenStatus);
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureRegion() {
        OneToOne oto = new OneToOne(29, new Table("tblRegion", Table.orderBy("Rcode")), new Table("region"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("Rcode_", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("Region_", 12), new Column("name", 12));
        oto.setParameterizedQuery("SELECT MIN(Rcode) AS Rcode_, MIN(Region) AS Region_\nFROM tblRegion GROUP BY Rcode ORDER BY Rcode");
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureDistrict() {
        OneToOne oto = new OneToOne(28, new Table("tblDistricts", Table.orderBy("DCode")), new Table("district"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("DCode", 4), new Column("code", 4));
        columnMappings.put(new Column("DistrictName", 12), new Column("name", 12));
        Column region = new Column("region_id", 4);
        region.setReference(new Reference("region", true));
        columnMappings.put(new Column("Region", 12), region);
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureSupportingOrganization() {
        OneToOne oto = new OneToOne(21, new Table("tblClientSupportDetails", Table.orderBy("ClientSupportID")), new Table("supporting_organization"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ClientSupportID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("ClientSupportDesciption", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configurePatientSource() {
        OneToOne oto = new OneToOne(14, new Table("tblSourceOfClient", Table.orderBy("SourceID")), new Table("patient_source"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("SourceID", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("SourceOfClient", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureServiceType() {
        OneToOne oto = new OneToOne(20, new Table("tblTypeOfService", Table.orderBy("TypeOfServiceID")), new Table("service_type"));
        oto.setExplicitWhereConditions("WHERE id NOT IN (SELECT DISTINCT service_type_id FROM drug WHERE standard = 1)");
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("TypeOfServiceID_", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("TypeofService_", 12), new Column("name", 12));
        oto.setParameterizedQuery("SELECT MIN(TypeOfServiceID) AS TypeOfServiceID_, MIN(TypeofService) AS TypeofService_\nFROM tblTypeOfService GROUP BY TypeOfServiceID ORDER BY TypeOfServiceID");
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new UnnecessaryServiceTypesRemover());
        return oto;
    }

    private OneToOne configureDispensingUnit() {
        OneToOne oto = new OneToOne(19, new Table("tblUnit", Table.orderBy("Unit")), new Table("dispensing_unit"));
        oto.setExplicitWhereConditions("WHERE id NOT IN (SELECT DISTINCT dispensing_unit_id FROM drug WHERE standard = 1)");
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("Unit", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureVisitType() {
        OneToOne oto = new OneToOne(18, new Table("tblVisitTransaction", Table.orderBy("TransactionCode")), new Table("visit_type"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("TransactionCode", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("VisitTranName", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new VisitTypeServiceTypeSetter());
        return oto;
    }

    private OneToOne configureTransactionType() {
        OneToOne oto = new OneToOne(10, new Table("tblStockTransactionType", Table.orderBy("TransactionType")), new Table("transaction_type"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("TransactionType", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("TransactionDescription", 12), new Column("name", 12));
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new AccountTypeTxTypeSetter());
        oto.addPreUpdate("DELETE FROM `account_type_transaction_type`");
        return oto;
    }

    private OneToOne configureDrug() {
        OneToOne oto = new OneToOne(11, new Table("tblARVDrugStockMain", Table.orderBy("ARVDrugsID")), new Table("drug"));
        oto.addWhereCondition(new WhereCondition("standard =", false, 16));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ARVDrugsID", 12), new Column("name", 12));
        columnMappings.put(new Column("StdDuration", 4), new Column("duration", 4));
        columnMappings.put(new Column("StdQty", 4), new Column("quantity", 3));
        columnMappings.put(new Column("Packsizes", 4), new Column("pack_size", 4));
        columnMappings.put(new Column("ReorderLevel", 4), new Column("reorder_point", 4));
        Column category = new Column("drug_category_id", 4);
        category.setReference(new Reference("drug_category", true, new DrugCategoryValueTranslator()));
        columnMappings.put(new Column("DrugCategory", 4), category);
        Column unit = new Column("dispensing_unit_id", 4);
        unit.setReference(new Reference("dispensing_unit"));
        columnMappings.put(new Column("Unit", 12), unit);
        Column genericName = new Column("generic_name_id", 4);
        genericName.setReference(new Reference("generic_name", "legacy_pk"));
        columnMappings.put(new Column("GenericName", 12), genericName);
        Column dosage = new Column("dosage_id", 4);
        dosage.setReference(new Reference("dosage"));
        columnMappings.put(new Column("StdDose", 12), dosage);
        columnMappings.put(new Column("InUse", 16), new Column("voided", 16));
        oto.setColumnMappings(columnMappings);
        oto.addPreProcessor(new MasterDrugListImporter());
        oto.addPostProcessor(new DrugSupporterProcessor());
        oto.addPostProcessor(new DrugsInRegimenProcessor());
        oto.addPostProcessor(new DhisIdMapper());
        oto.addPostProcessor(new DrugsInUseProcessor());
        oto.addPreUpdate("DELETE FROM `drug_supporting_organization`");
        oto.addPreUpdate("DELETE FROM drug_category WHERE id NOT IN (SELECT drug_category_id FROM drug)");
        oto.addPreUpdate("DELETE FROM drug_type WHERE id NOT IN (SELECT drug_type_id FROM drug)");
        oto.addPreUpdate("DELETE FROM `regimen_drug`");
        oto.addPreUpdate("UPDATE `drug` SET `dhis_id` = NULL");
        return oto;
    }

    private OneToOne configurePerson() {
        OneToOne oto = new OneToOne(5, new Table("tblARTPatientMasterInformation", Table.orderBy("ArtID")), new Table("person"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ArtID", 12), new Column("legacy_pk", 12));
        columnMappings.put(new Column("Firstname", 12), new Column("first_name", 12));
        columnMappings.put(new Column("Surname", 12), new Column("surname", 12));
        columnMappings.put(new Column("LastName", 12), new Column("other_names", 12));
        columnMappings.put(new Column("Sex", 12), new Column("sex", 12));
        columnMappings.put(new Column("DateofBirth", 91), new Column("date_of_birth", 91));
        Column birthDistrict = new Column("birth_district_id", 4);
        birthDistrict.setReference(new Reference("district", "code"));
        columnMappings.put(new Column("PlaceofBirth", 12), birthDistrict);
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configurePersonAddress() {
        OneToOne oto = new OneToOne(2, new Table("tblARTPatientMasterInformation", Table.orderBy("ArtID")), new Table("person_address"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ArtID", 12), new Column("legacy_pk", 12));
        columnMappings.put(new Column("Address", 12), new Column("physical_address", 12));
        columnMappings.put(new Column("PatientCellphone", 4), new Column("tel_no1", 12));
        columnMappings.put(new Column("AlternateContact", 12), new Column("tel_no2", 12));
        Column patientId = new Column("person_id", 4);
        patientId.setReference(new Reference("person", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ArtID", 12), patientId);
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configurePatient() {
        OneToOne oto = new OneToOne(4, new Table("tblARTPatientMasterInformation", Table.orderBy("ArtID")), new Table("patient"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ArtID", 12), new Column("legacy_pk", 12));
        columnMappings.put(new Column("DateTherapyStarted", 91), new Column("enrollment_date", 91));
        columnMappings.put(new Column("OtherDeaseConditions", 12), new Column("chronic_illnesses", 12));
        columnMappings.put(new Column("ADRorSideEffects", 12), new Column("drug_allergies", 12));
        columnMappings.put(new Column("PatientSmoke", 16), new Column("smoker", 16));
        columnMappings.put(new Column("PatientDrinkAlcohol", 16), new Column("drinker", 16));
        Column patientId = new Column("person_id", 4);
        patientId.setReference(new Reference("person", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ArtID", 12), patientId);
        Column patientSource = new Column("patient_source_id", 4);
        patientSource.setReference(new Reference("patient_source", "legacy_pk"));
        columnMappings.put(new Column("SourceofClient", 12), patientSource);
        Column supportingOrganization = new Column("supporting_organization_id", 4);
        supportingOrganization.setReference(new Reference("supporting_organization", "legacy_pk"));
        columnMappings.put(new Column("ClientSupportedBy", 12), supportingOrganization);
        Column patientStatus = new Column("patient_status_id", 4);
        patientStatus.setReference(new Reference("patient_status", "legacy_pk"));
        columnMappings.put(new Column("CurrentStatus", 4), patientStatus);
        Column transferFromFacility = new Column("from_facility_id", 4);
        transferFromFacility.setReference(new Reference("facility", "code"));
        columnMappings.put(new Column("TransferFrom", 12), transferFromFacility);
        Column startRegimen = new Column("start_regimen_id", 4);
        startRegimen.setReference(new Reference("regimen", "code"));
        columnMappings.put(new Column("RegimenStarted", 4), startRegimen);
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new PatientServiceTypeProcessor());
        oto.addPreUpdate("DELETE FROM `patient_service_type`");
        return oto;
    }

    private OneToOne configurePatientIdentifier_ArtId() {
        OneToOne oto = new OneToOne(1, new Table("tblARTPatientMasterInformation", Table.orderBy("ArtID")), new Table("patient_identifier"));
        oto.addWhereCondition(new WhereCondition("identifier_type_id =", Constants.ART_IDENTIFIER_TYPE_ID, 4));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("ArtID", 12), new Column("identifier", 12));
        columnMappings.put(new Column(null, 4), new Column("identifier_type_id", 4, Constants.ART_IDENTIFIER_TYPE_ID));
        Column patientId = new Column("patient_id", 4);
        patientId.setReference(new Reference("patient", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ArtID", 12), patientId);
        oto.setColumnMappings(columnMappings);
        oto.addPreProcessor(new IdentifierTypeCreator());
        return oto;
    }

    private OneToOne configurePatientIdentifier_OpipdId() {
        OneToOne oto = new OneToOne(1, new Table("tblARTPatientMasterInformation", Table.orderBy("OPIPNO")), new Table("patient_identifier"));
        oto.addWhereCondition(new WhereCondition("identifier_type_id =", Constants.OPIP_IDENTIFIER_TYPE_ID, 4));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("OPIPNO", 12), new Column("identifier", 12));
        columnMappings.put(new Column(null, 4), new Column("identifier_type_id", 4, Constants.OPIP_IDENTIFIER_TYPE_ID));
        Column patientId = new Column("patient_id", 4);
        patientId.setReference(new Reference("patient", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ArtID", 12), patientId);
        oto.setColumnMappings(columnMappings);
        oto.setParameterizedQuery("SELECT ArtID, OPIPNO FROM tblARTPatientMasterInformation WHERE OPIPNO IS NOT NULL ORDER BY OPIPNO");
        oto.addPreProcessor(new IdentifierTypeCreator());
        return oto;
    }

    private OneToOne configureVisit() {
        OneToOne oto = new OneToOne(3, new Table("tblARTPatientTransactions", Table.orderBy("MIN(PatientTranNo)")), new Table("visit"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("PatientTranNo_", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("DateofVisit", 91), new Column("start_date", 91));
        columnMappings.put(new Column("DateofVisit", 91), new Column("end_date", 91));
        columnMappings.put(new Column("Weight_", 3), new Column("weight", 3));
        columnMappings.put(new Column("pillCount_", 4), new Column("pill_count", 4));
        columnMappings.put(new Column("Adherence_", 3), new Column("adherence", 3));
        columnMappings.put(new Column("Comment_", 12), new Column("comments", 12));
        Column visitType = new Column("visit_type_id", 4);
        visitType.setReference(new Reference("visit_type", "legacy_pk"));
        columnMappings.put(new Column("TransactionCode_", 4), visitType);
        Column regimen = new Column("regimen_id", 4);
        regimen.setReference(new Reference("regimen", "code"));
        columnMappings.put(new Column("Regimen_", 12), regimen);
        Column regimenChangeReason = new Column("regimen_change_reason_id", 4);
        regimenChangeReason.setReference(new Reference("regimen_change_reason", "name"));
        columnMappings.put(new Column("ReasonsForChange_", 12), regimenChangeReason);
        Column patientId = new Column("patient_id", 4);
        patientId.setReference(new Reference("patient", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ARTID", 12), patientId);
        oto.setParameterizedQuery("SELECT\nMIN(PatientTranNo) AS PatientTranNo_,\nDateofVisit,\nMIN(TransactionCode) AS TransactionCode_,\nMIN(Weight) AS Weight_,\nMIN(pillCount) AS pillCount_,\nMIN(Adherence) AS Adherence_,\nMIN(Comment) AS Comment_,MIN(Indication) AS Indication_,\nMIN(Regimen) AS Regimen_,\nMIN(ReasonsForChange) AS ReasonsForChange_,\nARTID\nFROM\ntblARTPatientTransactions\nGROUP BY\nDateofVisit, ARTID\nORDER BY MIN(PatientTranNo)");
        oto.setColumnMappings(columnMappings);
        oto.addPostProcessor(new VisitUpdater());
        return oto;
    }

    private OneToOne configureTransaction_Stock() {
        OneToOne oto = new OneToOne(9, new Table("tblARVDrugStockTransactions", Table.orderBy("StockTranNo")), new Table("transaction"));
        oto.addWhereCondition(new WhereCondition("legacy_pk LIKE", "Stck%", 12));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        Column transactionTypeId = new Column("transaction_type_id", 4);
        transactionTypeId.setReference(new Reference("transaction_type", "legacy_pk", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("TransactionType_", 12), transactionTypeId);
        columnMappings.put(new Column("StockTranNo_", 4), new Column("legacy_pk", 12, "Stck"));
        columnMappings.put(new Column("RefOrderNo_", 4), new Column("reference_no", 12));
        columnMappings.put(new Column("TranDate_", 91), new Column("date", 91));
        columnMappings.put(new Column("Remarks_", 12), new Column("comments", 12));
        oto.setParameterizedQuery("SELECT MIN(StockTranNo) AS StockTranNo_, MIN(TransactionType) AS TransactionType_,\nMIN(RefOrderNo) AS RefOrderNo_, MIN(TranDate) AS TranDate_, MIN(Remarks) AS Remarks_\nFROM tblARVDrugStockTransactions WHERE Remarks NOT LIKE 'Dispensed to Patient No: %'\nOR Remarks IS NULL\nGROUP BY StockTranNo\nORDER BY StockTranNo ASC");
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureTransaction_Patient() throws SQLException {
        OneToOne oto = new OneToOne(9, new Table("tblARTPatientTransactions", Table.orderBy("MIN(PatientTranNo)")), new Table("transaction"));
        oto.addWhereCondition(new WhereCondition("legacy_pk LIKE", "Prsn%", 12));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column(null, 12), new Column("transaction_type_id", 4, new LookupValue("transaction_type", "Dispensed to Patients")));
        columnMappings.put(new Column("PatientTranNo_", 4), new Column("legacy_pk", 12, "Prsn"));
        Column visitId = new Column("visit_id", 4);
        visitId.setReference(new Reference("visit", "legacy_pk"));
        columnMappings.put(new Column("PatientTranNo_", 4), visitId);
        Column indication = new Column("indication_id", 4);
        indication.setReference(new Reference("indication", "legacy_pk"));
        columnMappings.put(new Column("Indication_", 12), indication);
        columnMappings.put(new Column("DateofVisit", 91), new Column("date", 91));
        columnMappings.put(new Column("Comment_", 12), new Column("comments", 12));
        oto.setParameterizedQuery("SELECT\nMIN(PatientTranNo) AS PatientTranNo_,\nDateofVisit,\nMIN(Comment) AS Comment_,\nMIN(Indication) AS Indication_,\nARTID\nFROM\ntblARTPatientTransactions\nGROUP BY\nDateofVisit, ARTID\nORDER BY MIN(PatientTranNo)");
        oto.setColumnMappings(columnMappings);
        oto.addPreProcessor(new LookupValuePkProcessor());
        return oto;
    }

    private OneToOne configureTransactionItem_Stock() {
        OneToOne oto = new OneToOne(8, new Table("tblARVDrugStockTransactions", Table.orderBy("StockTranNo")), new Table("transaction_item"));
        oto.addWhereCondition(new WhereCondition("legacy_pk LIKE", "Stck%", 12));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        Column drugId = new Column("drug_id", 4);
        drugId.setReference(new Reference("drug", "name", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("ARVDrugsID_", 12), drugId);
        Column transactionId = new Column("transaction_id", 4);
        transactionId.setReference(new Reference("transaction", "legacy_pk", "Stck", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("StockTranNo_", 4), transactionId);
        Column accountId = new Column("account_id", 4);
        Reference reference = new Reference("account", "name", Reference.NullAction.THROW_EXCEPTION);
        reference.setInferable(true);
        reference.setValueInferrer(new AccountValueInferrer());
        accountId.setReference(reference);
        columnMappings.put(new Column("SourceorDestination_", 12), accountId);
        columnMappings.put(new Column("StockTranNo_", 4), new Column("legacy_pk", 12, "Stck"));
        columnMappings.put(new Column("BatchNo_", 12), new Column("batch_no", 12));
        columnMappings.put(new Column("Qty_", 91), new Column("units_in", 3));
        columnMappings.put(new Column("Qty_", 12), new Column("units_out", 3));
        String sql = "SELECT MIN(StockTranNo) AS StockTranNo_, MIN(ARVDrugsID) AS ARVDrugsID_, MIN(SourceorDestination)\nAS SourceorDestination_, MIN(BatchNo) AS BatchNo_, MIN(Qty) AS Qty_ FROM tblARVDrugStockTransactions\nWHERE Remarks NOT LIKE ? OR Remarks IS NULL\nGROUP BY StockTranNo\nORDER BY StockTranNo ASC";
        ArrayList<Parameter> params = new ArrayList<Parameter>();
        params.add(new Parameter("Dispensed to Patient No: %", 12));
        oto.setParameterizedQuery(new ParameterizedQuery(sql, params));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configureTransactionItem_Patient() throws SQLException {
        OneToOne oto = new OneToOne(8, new Table("tblARTPatientTransactions", Table.orderBy("PatientTranNo")), new Table("transaction_item"));
        oto.addWhereCondition(new WhereCondition("legacy_pk LIKE", "Prsn%", 12));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        Column drugId = new Column("drug_id", 4);
        drugId.setReference(new Reference("drug", "name", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("Drugname_", 12), drugId);
        Column transactionId = new Column("transaction_id", 4);
        transactionId.setReference(new Reference("transaction", "legacy_pk", true, "Prsn", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("PatientTranNo_", 4), transactionId);
        columnMappings.put(new Column(null, 12), new Column("account_id", 4, new LookupValue("account", "PATIENTS")));
        columnMappings.put(new Column("PatientTranNo_", 4), new Column("legacy_pk", 12, "Prsn"));
        columnMappings.put(new Column("BatchNo_", 12), new Column("batch_no", 12));
        columnMappings.put(new Column("ARVQty_", 91), new Column("units_in", 3));
        columnMappings.put(new Column("ARVQty_", 12), new Column("units_out", 3));
        oto.setParameterizedQuery("SELECT\nMIN(PatientTranNo) AS PatientTranNo_,\nMIN(Drugname) AS Drugname_,\nMIN(BatchNo) AS BatchNo_,\nMIN(ARVQty) AS ARVQty_\nFROM\ntblARTPatientTransactions\nGROUP BY PatientTranNo\nORDER BY PatientTranNo ASC");
        oto.setColumnMappings(columnMappings);
        oto.addPreProcessor(new LookupValuePkProcessor());
        oto.addPostProcessor(new UnitsInOutUpdater());
        return oto;
    }

    private OneToOne configureBatchTransactionItem() {
        OneToOne oto = new OneToOne(6, new Table("tblARVDrugStockTransactions", Table.orderBy("StockTranNo")), new Table("batch_transaction_item"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("StockTranNo", 12), new Column("legacy_pk", 12));
        columnMappings.put(new Column("Npacks", 4), new Column("no_of_packs", 4));
        columnMappings.put(new Column("PackSize", 4), new Column("pack_size", 4));
        columnMappings.put(new Column("Expirydate", 91), new Column("date_of_expiry", 91));
        Column patientId = new Column("transaction_item_id", 4);
        patientId.setReference(new Reference("transaction_item", "legacy_pk", "Stck", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("StockTranNo", 12), patientId);
        String sql = "SELECT StockTranNo, Npacks, PackSize, BatchNo, Expirydate \nFROM tblARVDrugStockTransactions\nWHERE (Remarks NOT LIKE ?\nOR Remarks IS NULL)\nAND PackSize IS NOT NULL\nAND Npacks IS NOT NULL\nORDER BY StockTranNo ASC";
        ArrayList<Parameter> params = new ArrayList<Parameter>();
        params.add(new Parameter("Dispensed to Patient No: %", 12));
        oto.setParameterizedQuery(new ParameterizedQuery(sql, params));
        oto.setColumnMappings(columnMappings);
        return oto;
    }

    private OneToOne configurePatientTransactionItem() {
        OneToOne oto = new OneToOne(7, new Table("tblARTPatientTransactions", Table.orderBy("PatientTranNo")), new Table("patient_transaction_item"));
        LinkedHashMap<Column, Column> columnMappings = new LinkedHashMap<Column, Column>();
        columnMappings.put(new Column("PatientTranNo_", 4), new Column("legacy_pk", 4));
        columnMappings.put(new Column("duration_", 4), new Column("duration", 4));
        Column transactionItemId = new Column("transaction_item_id", 4);
        transactionItemId.setReference(new Reference("transaction_item", "legacy_pk", "Prsn", Reference.NullAction.THROW_EXCEPTION));
        columnMappings.put(new Column("PatientTranNo_", 12), transactionItemId);
        Column dosage = new Column("dosage_id", 4);
        dosage.setReference(new Reference("dosage"));
        columnMappings.put(new Column("Dose_", 12), dosage);
        columnMappings.put(new Column("Dose_", 12), new Column("dosage_name", 12));
        oto.setParameterizedQuery("SELECT\nMIN(PatientTranNo) AS PatientTranNo_,\nMIN(duration) AS duration_,\nMIN(Dose) AS Dose_\nFROM\ntblARTPatientTransactions\nGROUP BY PatientTranNo\nORDER BY PatientTranNo ASC");
        oto.setColumnMappings(columnMappings);
        return oto;
    }
}
Privacy Policy


Что я уже пробовал:

Я попробовал исследовать онлайн, и объяснения были немного сложными, поскольку они представлены как для людей, которые продвинуты в кодировании Java.

[no name]

Ряндев, я загрузил остальную часть кода. Я надеюсь, что теперь это стало яснее

1 Ответов

Рейтинг:
2

ZurdoDev

Это создание экземпляра класса OneToOne. Я предполагаю, что он имеет в виду это, OneToOne (EclipseLink 2.0.2, build 'v20100323-r6872' API Reference)[^]

Но мы не можем знать наверняка, так как не можем видеть остальную часть кода.

Проще всего поставить точку останова, запустить код, а затем шаг за шагом пройти через строку и посмотреть, что он делает.