Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ public FilingInformation fromNode(JsonNode node, InfoCollector collector) throws
entities.setProcedureRemedy(procRemRes.expect(""));
}

/// Damage Amount
var damageAmountRes =
parser.vetDamageAmount(isInitialFiling, caseCat, getStringMember(node, "damage_amount"));
if (damageAmountRes.isErr()) {
var damageAmountBuilder = collector.varBuilder().name("damage_amount");
collector.addCodeError(damageAmountRes.expectErr(""), damageAmountBuilder);
} else {
entities.setDamageAmount(damageAmountRes.expect(""));
}

entities.setReturnDate(extractReturnDate(node.get("return_date"), collector));
entities.setMiscInfo(node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class FilingInformation {
private CaseType caseTypeCode;
private Optional<NameAndCode> caseSubtypeCode;
private Optional<NameAndCode> procedureRemedy;
private Optional<NameAndCode> damageAmount;
private Map<String, String> crossRefs;
private String paymentId;
private List<FilingDoc> filingDocs = List.of();
Expand Down Expand Up @@ -170,6 +171,10 @@ public Optional<NameAndCode> getProcedureRemedy() {
return procedureRemedy;
}

public Optional<NameAndCode> getDamageAmount() {
return damageAmount;
}

public Map<String, String> getCrossRefs() {
return crossRefs;
}
Expand Down Expand Up @@ -254,6 +259,10 @@ public void setProcedureRemedy(Optional<NameAndCode> procedureRemedy) {
this.procedureRemedy = procedureRemedy;
}

public void setDamageAmount(Optional<NameAndCode> damageAmount) {
this.damageAmount = damageAmount;
}

public void setCrossRefs(Map<String, String> crossRefs) {
this.crossRefs = crossRefs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public Result<FilingComponent, CodeError> vetFilingComponent(
public Result<Optional<DocumentTypeTableRow>, CodeError> vetDocType(
String docTypeStr, FilingCode filing);

public Result<Optional<NameAndCode>, CodeError> vetDamageAmount(
boolean initial, CaseCategory cat, Optional<String> maybeDamageAmount);

public Result<Optional<NameAndCode>, CodeError> vetProcedureRemedy(
Optional<String> maybeProRem, boolean initial, CaseCategory cat);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import ecf4.latest.tyler.ecf.extensions.common.ProcedureRemedyType;
import ecf4.latest.tyler.ecf.extensions.common.ServicePartyDataType;
import edu.suffolk.litlab.efsp.Jurisdiction;
import edu.suffolk.litlab.efsp.ecfcodes.tyler.CaseCategory;
import edu.suffolk.litlab.efsp.ecfcodes.tyler.CodeDatabase;
import edu.suffolk.litlab.efsp.ecfcodes.tyler.ComboCaseCodes;
import edu.suffolk.litlab.efsp.ecfcodes.tyler.CourtLocationInfo;
Expand Down Expand Up @@ -630,14 +629,16 @@ public List<FilingAssociationType> lateStageFilingAssociationAdd(
}

Optional<ProcedureRemedyType> resPlus =
addDamageAmountType(
makeProcedureRemedyType(info.getProcedureRemedy()),
isInitialFiling,
comboCodes.cat,
courtLocation.code,
miscInfo,
collector,
serializer);
makeProcedureRemedyType(info.getProcedureRemedy())
.map(
pr -> {
info.getDamageAmount()
.ifPresent(
da -> {
pr.setDamageAmountCode(Ecf4Helper.convertText(da.getCode()));
});
return pr;
});
if (resPlus.isPresent()) {
ecfAug.setProcedureRemedy(resPlus.get());
}
Expand Down Expand Up @@ -716,66 +717,6 @@ private Optional<ProcedureRemedyType> makeProcedureRemedyType(Optional<NameAndCo
});
}

private Optional<ProcedureRemedyType> addDamageAmountType(
Optional<ProcedureRemedyType> existingType,
boolean initial,
CaseCategory cat,
String courtLocationId,
JsonNode miscInfo,
InfoCollector collector,
EcfCourtSpecificSerializer serializer)
throws SQLException, FilingError {
List<NameAndCode> damageAmounts = cd.getDamageAmount(courtLocationId, cat.getCode());
DataFieldRow damageConfig = cd.getDataField(courtLocationId, "DamageAmount");
String damgBehavior = (initial) ? cat.damageamountinitial : cat.damageamountsubsequent;
if (!damgBehavior.isEmpty() && !damgBehavior.equals("Not Available")) {
damageConfig =
serializer.allDataFields.getFieldRow(
"CivilCaseDamageAmount" + ((initial) ? "Initial" : "Subsequent"));
}
JsonNode jsonDmg = miscInfo.get("damage_amount");
InterviewVariable docVar;
if (damageAmounts.isEmpty()) {
docVar = collector.requestVar("procedure_remedy", "Procedure Remedy", "text");
} else {
docVar =
collector.requestVar(
"procedure_remedy",
"Procedure Remedy",
"choices",
damageAmounts.stream().map(nac -> nac.getName()).collect(Collectors.toList()),
Optional.ofNullable(jsonDmg).map(JsonNode::toString));
}
if (jsonDmg != null && !jsonDmg.isNull() && jsonDmg.isTextual()) {
if (damageConfig.isvisible) {
Optional<NameAndCode> maybeDmg =
damageAmounts.stream()
.filter(nac -> nac.getName().equals(jsonDmg.asText()))
.findFirst();
if (maybeDmg.isPresent()) {
ProcedureRemedyType type = existingType.orElse(new ProcedureRemedyType());
type.setDamageAmountCode(Ecf4Helper.convertText(maybeDmg.get().getCode()));
return Optional.of(type);
} else {
collector.addWrong(docVar);
}
} else {
log.info(
"Dropping damage_amount "
+ jsonDmg.asText()
+ ", since isvisible is false for "
+ courtLocationId);
}
} else {
if (damageConfig.isrequired) {
collector.addRequired(docVar);
} else {
collector.addOptional(docVar);
}
}
return existingType;
}

/**
* Makes a civil case to include in queries like FeesQuery and ReviewFiling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,46 @@ public Result<Optional<NameAndCode>, CodeError> vetProcedureRemedy(
return Result.ok(Optional.empty());
}

public Result<Optional<NameAndCode>, CodeError> vetDamageAmount(
boolean initial, CaseCategory cat, Optional<String> maybeDamageAmount) {
String courtLocationId = this.court.code;
DataFieldRow damageConfig = allDataFields.getFieldRow("DamageAmount");
String damgBehavior = (initial) ? cat.damageamountinitial : cat.damageamountsubsequent;
if (!damgBehavior.isEmpty() && !damgBehavior.equals("Not Available")) {
damageConfig =
allDataFields.getFieldRow(
"CivilCaseDamageAmount" + ((initial) ? "Initial" : "Subsequent"));
}

List<NameAndCode> damageAmounts = cd.getDamageAmount(courtLocationId, cat.getCode());
if (maybeDamageAmount.isEmpty()) {
if (damageConfig.isrequired) {
return Result.err(
new RequiredCodeNotPresent(damageAmounts.stream().map(da -> da.getCode()).toList()));
} else {
return Result.ok(Optional.empty());
}
}
String damageAmountCode = maybeDamageAmount.get();
if (damageConfig.isvisible) {
Optional<NameAndCode> maybeDmg =
damageAmounts.stream().filter(nac -> nac.getName().equals(damageAmountCode)).findFirst();
if (maybeDmg.isPresent()) {
return Result.ok(maybeDmg);
} else {
return Result.err(
new NoMatchingCode(
damageAmountCode, damageAmounts.stream().map(da -> da.getCode()).toList()));
}
} else {
log.info(
"Dropping damage_amount {}, since isvisible is false for {}",
damageAmountCode,
courtLocationId);
return Result.ok(Optional.empty());
}
}

/**
* Doesn't return optional because we can set the People names to null / blank.
*
Expand Down
Loading