diff --git a/backend/app/src/main/java/com/moh/phlat/backend/model/SourceData.java b/backend/app/src/main/java/com/moh/phlat/backend/model/SourceData.java index b6d7ebd6..ce18e828 100644 --- a/backend/app/src/main/java/com/moh/phlat/backend/model/SourceData.java +++ b/backend/app/src/main/java/com/moh/phlat/backend/model/SourceData.java @@ -117,7 +117,10 @@ public class SourceData { private String pcnClinicStatus; @Column(name="hds_effective_start_date") - private String hdsEffectiveStartDate; + private String hdsEffectiveStartDate; + + @Column(name="fac_civic_address") + private String facCivicAddress; @Column(name="fac_address_unit") private String facAddressUnit; @@ -186,7 +189,5 @@ public class SourceData { private Date updatedAt; @Column(name="updated_by") - private String updatedBy; - - + private String updatedBy; } diff --git a/backend/app/src/main/java/com/moh/phlat/backend/service/FileService.java b/backend/app/src/main/java/com/moh/phlat/backend/service/FileService.java index 683e8c77..87b89ebf 100644 --- a/backend/app/src/main/java/com/moh/phlat/backend/service/FileService.java +++ b/backend/app/src/main/java/com/moh/phlat/backend/service/FileService.java @@ -3,6 +3,6 @@ import org.springframework.web.multipart.MultipartFile; public interface FileService { - boolean hasCsvFormat(MultipartFile file, String tableName); - void processAndSaveData(MultipartFile file, Long controlTableId, String authenticateUserId); + boolean hasCsvFormat(MultipartFile file, String tableName); + void processAndSaveData(MultipartFile file, Long controlTableId, String authenticateUserId); } diff --git a/backend/app/src/main/java/com/moh/phlat/backend/service/FileServiceImpl.java b/backend/app/src/main/java/com/moh/phlat/backend/service/FileServiceImpl.java index 598f760c..70f8e0dd 100644 --- a/backend/app/src/main/java/com/moh/phlat/backend/service/FileServiceImpl.java +++ b/backend/app/src/main/java/com/moh/phlat/backend/service/FileServiceImpl.java @@ -139,7 +139,7 @@ private static SourceData createSourceData(Long controlTableId, String doNotLoad String hdsProviderIdentifierType1, String hdsProviderIdentifierType2, String hdsProviderIdentifierType3, String hdsMspFacilityNumber, String hdsType, String hdsSubType, - String hdsName, + String hdsName, String hdsPreferredNameFlag, String hdsEmail, String hdsWebsite, String hdsBusTelAreaCode, String hdsBusTelNumber, String hdsTelExtension, String hdsCellAreaCode, String hdsCellNumber, String hdsFaxAreaCode, String hdsFaxNumber, @@ -148,7 +148,8 @@ private static SourceData createSourceData(Long controlTableId, String doNotLoad String pcnPciFlag, String sourceStatus, String pcnClinicStatus, - String hdsEffectiveStartDate, + String hdsEffectiveStartDate, + String facCivicAddress, String facAddressUnit, String facBuildingName, String physicalAddr1, String physicalAddr2, String physicalAddr3, @@ -161,7 +162,7 @@ private static SourceData createSourceData(Long controlTableId, String doNotLoad String mailPcode, String mailCountry, Date createdAt, String createdBy, Date updatedAt, String updatedBy) { return SourceData.builder() - .controlTableId(controlTableId) + .controlTableId(controlTableId) .doNotLoadFlag(doNotLoadFlag) .stakeholder(stakeholder) .stakeholderId(stakeholderId) @@ -193,6 +194,7 @@ private static SourceData createSourceData(Long controlTableId, String doNotLoad .sourceStatus(sourceStatus) .pcnClinicStatus(pcnClinicStatus) .hdsEffectiveStartDate(hdsEffectiveStartDate) + .facCivicAddress(facCivicAddress) .facAddressUnit(facAddressUnit) .facBuildingName(facBuildingName) .physicalAddr1(physicalAddr1) @@ -258,7 +260,8 @@ private List csvToSourceData(InputStream inputStream, Long controlTa csvRecords.get("PCN_PCI_FLAG"), csvRecords.get("SOURCE_STATUS"), csvRecords.get("PCN_CLINIC_STATUS"), - csvRecords.get("HDS_EFFECTIVE_START_DATE"), + csvRecords.get("HDS_EFFECTIVE_START_DATE"), + csvRecords.get("FAC_CIVIC_ADDRESS"), csvRecords.get("FAC_ADDRESS_UNIT"), csvRecords.get("FAC_BUILDING_NAME"), csvRecords.get("PHYSICAL_ADDR1"), @@ -309,62 +312,63 @@ private void copyInputSourceDataToProcessData(Long controlTableId, String authen Iterable inputSourceData = sourceDataRepository.getAllSourceDataByControlTableId(controlTableId); for (SourceData s : inputSourceData ) { - ProcessData processData = new ProcessData(); - processData.setId(s.getId()); - processData.setControlTableId(s.getControlTableId()); - processData.setDoNotLoadFlag(s.getDoNotLoadFlag()); - processData.setStakeholderId(s.getStakeholderId()); - processData.setStakeholder(s.getStakeholder()); - processData.setHdsIpcId(s.getHdsIpcId()); - processData.setHdsCpnId(s.getHdsCpnId()); - processData.setHdsProviderIdentifier1(s.getHdsProviderIdentifier1()); - processData.setHdsProviderIdentifier2(s.getHdsProviderIdentifier2()); - processData.setHdsProviderIdentifier3(s.getHdsProviderIdentifier3()); - processData.setHdsProviderIdentifierType1(s.getHdsProviderIdentifierType1()); - processData.setHdsProviderIdentifierType2(s.getHdsProviderIdentifierType2()); - processData.setHdsProviderIdentifierType3(s.getHdsProviderIdentifierType3()); - processData.setHdsMspFacilityNumber(s.getHdsMspFacilityNumber()); - processData.setHdsType(s.getHdsType()); - processData.setHdsSubType(s.getHdsSubType()); - processData.setHdsName(s.getHdsName()); - processData.setHdsPreferredNameFlag(s.getHdsPreferredNameFlag()); - processData.setHdsEmail(s.getHdsEmail()); - processData.setHdsWebsite(s.getHdsWebsite()); - processData.setHdsBusTelAreaCode(s.getHdsBusTelAreaCode()); - processData.setHdsBusTelNumber(s.getHdsBusTelNumber()); - processData.setHdsTelExtension(s.getHdsTelExtension()); - processData.setHdsCellAreaCode(s.getHdsCellAreaCode()); - processData.setHdsCellNumber(s.getHdsCellNumber()); - processData.setHdsFaxAreaCode(s.getHdsFaxAreaCode()); - processData.setHdsFaxNumber(s.getHdsFaxNumber()); - processData.setPcnServiceDeliveryType(s.getPcnServiceDeliveryType()); - processData.setPcnClinicType(s.getPcnClinicType()); - processData.setPcnPciFlag(s.getPcnPciFlag()); - processData.setSourceStatus(s.getSourceStatus()); - processData.setPcnClinicStatus(s.getPcnClinicStatus()); - processData.setHdsEffectiveStartDate(s.getHdsEffectiveStartDate()); - processData.setFacAddressUnit(s.getFacAddressUnit()); - processData.setFacBuildingName(s.getFacBuildingName()); - processData.setPhysicalAddr1(s.getPhysicalAddr1()); - processData.setPhysicalAddr2(s.getPhysicalAddr2()); - processData.setPhysicalAddr3(s.getPhysicalAddr3()); - processData.setPhysicalAddr4(s.getPhysicalAddr4()); - processData.setPhysicalCity(s.getPhysicalCity()); - processData.setPhysicalProvince(s.getPhysicalProvince()); - processData.setPhysicalPcode(s.getPhysicalPcode()); - processData.setPhysicalCountry(s.getPhysicalCountry()); - processData.setPhysicalAddrPrpsTypeCd(s.getPhysicalAddrPrpsTypeCd()); - processData.setMailAddr1(s.getMailAddr1()); - processData.setMailAddr2(s.getMailAddr2()); - processData.setMailAddr3(s.getMailAddr3()); - processData.setMailAddr4(s.getMailAddr4()); - processData.setMailCity(s.getMailCity()); - processData.setMailBc(s.getMailBc()); - processData.setMailPcode(s.getMailPcode()); - processData.setMailCountry(s.getMailCountry()); - processData.setMailAddrValidationStatus(""); - processData.setCreatedAt(s.getCreatedAt()); - processData.setCreatedBy(authenticateUserId); + ProcessData processData = new ProcessData(); + processData.setId(s.getId()); + processData.setControlTableId(s.getControlTableId()); + processData.setDoNotLoadFlag(s.getDoNotLoadFlag()); + processData.setStakeholderId(s.getStakeholderId()); + processData.setStakeholder(s.getStakeholder()); + processData.setHdsIpcId(s.getHdsIpcId()); + processData.setHdsCpnId(s.getHdsCpnId()); + processData.setHdsProviderIdentifier1(s.getHdsProviderIdentifier1()); + processData.setHdsProviderIdentifier2(s.getHdsProviderIdentifier2()); + processData.setHdsProviderIdentifier3(s.getHdsProviderIdentifier3()); + processData.setHdsProviderIdentifierType1(s.getHdsProviderIdentifierType1()); + processData.setHdsProviderIdentifierType2(s.getHdsProviderIdentifierType2()); + processData.setHdsProviderIdentifierType3(s.getHdsProviderIdentifierType3()); + processData.setHdsMspFacilityNumber(s.getHdsMspFacilityNumber()); + processData.setHdsType(s.getHdsType()); + processData.setHdsSubType(s.getHdsSubType()); + processData.setHdsName(s.getHdsName()); + processData.setHdsPreferredNameFlag(s.getHdsPreferredNameFlag()); + processData.setHdsEmail(s.getHdsEmail()); + processData.setHdsWebsite(s.getHdsWebsite()); + processData.setHdsBusTelAreaCode(s.getHdsBusTelAreaCode()); + processData.setHdsBusTelNumber(s.getHdsBusTelNumber()); + processData.setHdsTelExtension(s.getHdsTelExtension()); + processData.setHdsCellAreaCode(s.getHdsCellAreaCode()); + processData.setHdsCellNumber(s.getHdsCellNumber()); + processData.setHdsFaxAreaCode(s.getHdsFaxAreaCode()); + processData.setHdsFaxNumber(s.getHdsFaxNumber()); + processData.setPcnServiceDeliveryType(s.getPcnServiceDeliveryType()); + processData.setPcnClinicType(s.getPcnClinicType()); + processData.setPcnPciFlag(s.getPcnPciFlag()); + processData.setSourceStatus(s.getSourceStatus()); + processData.setPcnClinicStatus(s.getPcnClinicStatus()); + processData.setHdsEffectiveStartDate(s.getHdsEffectiveStartDate()); + processData.setFacCivicAddr(s.getFacCivicAddress()); + processData.setFacAddressUnit(s.getFacAddressUnit()); + processData.setFacBuildingName(s.getFacBuildingName()); + processData.setPhysicalAddr1(s.getPhysicalAddr1()); + processData.setPhysicalAddr2(s.getPhysicalAddr2()); + processData.setPhysicalAddr3(s.getPhysicalAddr3()); + processData.setPhysicalAddr4(s.getPhysicalAddr4()); + processData.setPhysicalCity(s.getPhysicalCity()); + processData.setPhysicalProvince(s.getPhysicalProvince()); + processData.setPhysicalPcode(s.getPhysicalPcode()); + processData.setPhysicalCountry(s.getPhysicalCountry()); + processData.setPhysicalAddrPrpsTypeCd(s.getPhysicalAddrPrpsTypeCd()); + processData.setMailAddr1(s.getMailAddr1()); + processData.setMailAddr2(s.getMailAddr2()); + processData.setMailAddr3(s.getMailAddr3()); + processData.setMailAddr4(s.getMailAddr4()); + processData.setMailCity(s.getMailCity()); + processData.setMailBc(s.getMailBc()); + processData.setMailPcode(s.getMailPcode()); + processData.setMailCountry(s.getMailCountry()); + processData.setMailAddrValidationStatus(""); + processData.setCreatedAt(s.getCreatedAt()); + processData.setCreatedBy(authenticateUserId); // set default values if (controlTable.getLoadTypeHds()) { diff --git a/backend/app/src/main/resources/db/migration/V5__add_civic_address.sql b/backend/app/src/main/resources/db/migration/V5__add_civic_address.sql new file mode 100644 index 00000000..9356e958 --- /dev/null +++ b/backend/app/src/main/resources/db/migration/V5__add_civic_address.sql @@ -0,0 +1,48 @@ +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_name='source_data' and column_name='fac_civic_address' + ) THEN + ALTER TABLE source_data + ADD COLUMN fac_civic_address VARCHAR(240); + END IF; +END$$; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_name='process_data' and column_name='databc_input_civic_address' + ) THEN + ALTER TABLE process_data + ADD COLUMN databc_input_civic_address VARCHAR(240); + END IF; +END$$; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_name='process_data' and column_name='databc_output_civic_address' + ) THEN + ALTER TABLE process_data + ADD COLUMN databc_output_civic_address VARCHAR(240); + END IF; +END$$; + +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM table_column_info + WHERE table_name='SOURCE_DATA' and column_name='FAC_CIVIC_ADDRESS' + ) THEN + INSERT INTO table_column_info(table_name, column_name, header_name,variable_name, title) VALUES ( + 'SOURCE_DATA', 'FAC_CIVIC_ADDRESS', 'FAC_CIVIC_ADDRESS', 'facCivicAddress','Facility Civic Address' + ); + END IF; +END$$;