-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CCAP 636], Implement ccms data storage (#1115)
Co-authored-by: Ana Medrano <[email protected]>
- Loading branch information
1 parent
80f7f2f
commit db992bf
Showing
12 changed files
with
369 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.ilgcc.app.data; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface CCMSDataService { | ||
|
||
/** | ||
* Retrieves a county based on the given zip code. | ||
* | ||
* @param zipCode the zip code to search for | ||
* @return an Optional containing the matching county if found, or an empty Optional if not found | ||
*/ | ||
Optional<County> getCountyByZipCode(String zipCode); | ||
|
||
/** | ||
* Retrieves a provider based on the given provider ID. | ||
* | ||
* @param providerId the unique identifier of the provider | ||
* @return an Optional containing the provider if found, or an empty Optional if not found | ||
*/ | ||
Optional<Provider> getProviderById(BigInteger providerId); | ||
|
||
/** | ||
* Retrieves a resource organization associated with a given provider ID. | ||
* | ||
* @param providerId the unique identifier of the provider | ||
* @return an Optional containing the matching resource organization if found, or an empty Optional if not found | ||
*/ | ||
Optional<ResourceOrganization> getResourceOrganizationByProviderId(BigInteger providerId); | ||
|
||
/** | ||
* Retrieves a list of resource organizations based on the given caseload code. | ||
* | ||
* @param caseloadCode the caseload code to search for | ||
* @return a list of matching resource organizations | ||
*/ | ||
List<ResourceOrganization> getResourceOrganizationsByCaseloadCode(String caseloadCode); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.ilgcc.app.data; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.io.Serializable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Entity | ||
@Table(name = "zip_codes") | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Component | ||
@Builder | ||
public class County implements Serializable { | ||
|
||
@Id | ||
@Column(name = "zip_code") | ||
private String zipCode; | ||
|
||
@Column(name = "city") | ||
private String city; | ||
|
||
@Column(name = "county") | ||
private String county; | ||
|
||
@Column(name = "fips_county_code") | ||
private Integer fipsCountyCode; | ||
|
||
@Column(name = "dpa_county_code") | ||
private Integer dpaCountyCode; | ||
|
||
@Column(name = "caseload_code") | ||
private String caseloadCode; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.ilgcc.app.data; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CountyRepository extends JpaRepository<County, String> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/org/ilgcc/app/data/ResourceOrganization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.ilgcc.app.data; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import java.math.BigInteger; | ||
import java.util.Set; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.Builder; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Entity | ||
@Table(name = "resource_organizations") | ||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Component | ||
@Builder | ||
public class ResourceOrganization { | ||
@Id | ||
@Column(name = "resource_org_id") | ||
private BigInteger resourceOrgId; | ||
|
||
@Column(name = "caseload_code") | ||
private String caseloadCode; | ||
|
||
@Column(name = "name") | ||
private String name; | ||
|
||
@Column(name = "address") | ||
private String address; | ||
|
||
@Column(name = "phone") | ||
private String phone; | ||
|
||
@Column(name = "email") | ||
private String email; | ||
|
||
@Column(name = "sda") | ||
private Short sda; | ||
|
||
@OneToMany(mappedBy = "resourceOrganization", fetch =FetchType.LAZY) | ||
private Set<Provider> providers; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/ilgcc/app/data/ResourceOrganizationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.ilgcc.app.data; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ResourceOrganizationRepository extends JpaRepository<ResourceOrganization, Long> { | ||
|
||
List<ResourceOrganization> findByCaseloadCode(String caseloadCode); | ||
|
||
Optional<ResourceOrganization> findByProvidersProviderId(BigInteger providerId); | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/org/ilgcc/app/data/importer/CCMSDataServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.ilgcc.app.data.importer; | ||
|
||
import java.math.BigInteger; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.ilgcc.app.data.CCMSDataService; | ||
import org.ilgcc.app.data.County; | ||
import org.ilgcc.app.data.CountyRepository; | ||
import org.ilgcc.app.data.Provider; | ||
import org.ilgcc.app.data.ProviderRepository; | ||
import org.ilgcc.app.data.ResourceOrganization; | ||
import org.ilgcc.app.data.ResourceOrganizationRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class CCMSDataServiceImpl implements CCMSDataService { | ||
|
||
private final ProviderRepository providerRepository; | ||
private final CountyRepository countyRepository; | ||
private final ResourceOrganizationRepository resourceOrganizationRepository; | ||
|
||
public CCMSDataServiceImpl(ProviderRepository providerRepository, CountyRepository countyRepository, ResourceOrganizationRepository resourceOrganizationRepository) { | ||
this.providerRepository = providerRepository; | ||
this.countyRepository = countyRepository; | ||
this.resourceOrganizationRepository = resourceOrganizationRepository; | ||
} | ||
|
||
@Override | ||
public Optional<County> getCountyByZipCode(String zipCode) { | ||
return countyRepository.findById(zipCode); | ||
} | ||
|
||
@Override | ||
public Optional<Provider> getProviderById(BigInteger providerId) { | ||
return providerRepository.findById(providerId); | ||
} | ||
|
||
@Override | ||
public Optional<ResourceOrganization> getResourceOrganizationByProviderId(BigInteger providerId) { | ||
return resourceOrganizationRepository.findByProvidersProviderId(providerId); | ||
} | ||
|
||
@Override | ||
public List<ResourceOrganization> getResourceOrganizationsByCaseloadCode(String caseloadCode) { | ||
return resourceOrganizationRepository.findByCaseloadCode(caseloadCode); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ain/resources/db/migration/V2025.01.29.13.54.57__Add_Resource_ZipCode_Counties_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
DO | ||
$$ | ||
BEGIN | ||
-- Create 'resource_organizations' table if it does not exist | ||
IF | ||
NOT EXISTS (SELECT * FROM pg_tables WHERE tablename = 'resource_organizations') THEN | ||
CREATE TABLE resource_organizations | ||
( | ||
resource_org_id BIGINT PRIMARY KEY, | ||
caseload_code VARCHAR, | ||
name VARCHAR, | ||
address VARCHAR, | ||
phone VARCHAR, | ||
email VARCHAR, | ||
sda SMALLINT | ||
); | ||
|
||
END IF; | ||
|
||
|
||
-- Create 'zip_codes' table if it does not exist | ||
IF | ||
NOT EXISTS (SELECT * FROM pg_tables WHERE tablename = 'zip_codes') THEN | ||
CREATE TABLE zip_codes | ||
( | ||
zip_code BIGINT PRIMARY KEY, | ||
city VARCHAR, | ||
county VARCHAR, | ||
fips_county_code INT, | ||
dpa_county_code INT, | ||
caseload_code VARCHAR | ||
); | ||
|
||
END IF; | ||
|
||
-- Create indexes for case load and county | ||
CREATE INDEX caseload_code_idx ON resource_organizations (caseload_code); | ||
CREATE INDEX county_idx ON zip_codes (county); | ||
|
||
END | ||
$$; |
8 changes: 8 additions & 0 deletions
8
...ain/resources/db/migration/V2025.01.29.13.57.09__Update_providers_add_resource_org_id.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Add the 'resource_org_id' column to the 'providers' table | ||
ALTER TABLE providers ADD COLUMN resource_org_id BIGINT; | ||
|
||
-- Add foreign key constraint on the providers table | ||
ALTER TABLE providers | ||
ADD CONSTRAINT fk_providers_resource_org | ||
FOREIGN KEY (resource_org_id) REFERENCES resource_organizations(resource_org_id) | ||
ON DELETE CASCADE; |
Oops, something went wrong.