Skip to content

Commit

Permalink
feat: add mapper for claims
Browse files Browse the repository at this point in the history
  • Loading branch information
pcvolkmer committed May 13, 2024
1 parent 80857d4 commit 33dfa3d
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/java/de/ukw/ccc/dnpmexport/mapper/FollowUpMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* MIT License
*
* Copyright (c) 2024 Comprehensive Cancer Center Mainfranken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.ukw.ccc.dnpmexport.mapper;

public abstract class FollowUpMapper<D> extends ProcedureMapper<D> {

private static final String FORM_NAME = "DNPM FollowUp";

public FollowUpMapper(final MapperUtils mapperUtils) {
super(mapperUtils);
}

@Override
protected String formName() {
return FORM_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* MIT License
*
* Copyright (c) 2024 Comprehensive Cancer Center Mainfranken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.ukw.ccc.dnpmexport.mapper;

import de.itc.onkostar.api.Procedure;
import de.ukw.ccc.bwhc.dto.Claim;

import java.util.Optional;

public class FollowUpToClaimMapper extends FollowUpMapper<Optional<Claim>> {

static final String FIELD_NAME_ISSUED_ON = "AusstellungsdatumAntrag";
static final String FIELD_NAME_THERAPY = "LinkTherapieempfehlung";

public FollowUpToClaimMapper(final MapperUtils mapperUtils) {
super(mapperUtils);
}

@Override
public Optional<Claim> apply(Procedure procedure) {
if (!canApply(procedure)) {
return Optional.empty();
}

var issuedOn = procedure.getValue(FIELD_NAME_ISSUED_ON).getDate();
var therapyId = procedure.getValue(FIELD_NAME_THERAPY).getString();

final var builder = Claim.builder()
.withId(anonymizeId(procedure))
.withPatient(getPatientId(procedure));

if (null != issuedOn) {
builder.withIssuedOn(dateFormat().format(issuedOn));
}

if (null != therapyId) {
builder.withTherapy(anonymizeString(therapyId));
}

return Optional.of(builder.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* MIT License
*
* Copyright (c) 2024 Comprehensive Cancer Center Mainfranken
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.ukw.ccc.dnpmexport.mapper;

import de.itc.onkostar.api.IOnkostarApi;
import de.itc.onkostar.api.Item;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.time.Instant;
import java.util.Date;

import static de.ukw.ccc.dnpmexport.mapper.FollowUpToClaimMapper.FIELD_NAME_ISSUED_ON;
import static de.ukw.ccc.dnpmexport.mapper.FollowUpToClaimMapper.FIELD_NAME_THERAPY;
import static de.ukw.ccc.dnpmexport.test.TestUtils.createFollowUpProcedure;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(MockitoExtension.class)
public class FollowUpToClaimMapperTest {

private IOnkostarApi onkostarApi;
private FollowUpToClaimMapper mapper;

@BeforeEach
void setUp(
@Mock IOnkostarApi onkostarApi
) {
this.onkostarApi = onkostarApi;
this.mapper = new FollowUpToClaimMapper(new MapperUtils(onkostarApi));
}

@Test
void shouldMapToClaim() {
var procedure = createFollowUpProcedure(this.onkostarApi);
procedure.setValue(FIELD_NAME_ISSUED_ON, new Item(FIELD_NAME_ISSUED_ON, Date.from(Instant.parse("2024-05-13T12:00:00Z"))));
procedure.setValue(FIELD_NAME_THERAPY, new Item(FIELD_NAME_THERAPY, "1234"));

var claim = this.mapper.apply(procedure);

assertThat(claim).isNotEmpty();
assertThat(claim.get().getId()).matches("UNKNOWN[a-z0-9]+");
assertThat(claim.get().getPatient()).isEqualTo("2000123456");
assertThat(claim.get().getIssuedOn()).isEqualTo("2024-05-13");
assertThat(claim.get().getTherapy()).matches("UNKNOWN[a-z0-9]+");
}

}
10 changes: 10 additions & 0 deletions src/test/java/de/ukw/ccc/dnpmexport/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public static Procedure createKlinikAnamneseProcedure(IOnkostarApi onkostarApi)
return procedure;
}

public static Procedure createFollowUpProcedure(IOnkostarApi onkostarApi) {
var procedure = new Procedure(onkostarApi);
procedure.setId(1);
procedure.setFormName("DNPM FollowUp");
procedure.setPatient(createPatient(onkostarApi));
procedure.addDisease(createDisease(onkostarApi));

return procedure;
}

public static Patient createPatient(IOnkostarApi onkostarApi) {
var patient = new Patient(onkostarApi);
patient.setId(123456);
Expand Down

0 comments on commit 33dfa3d

Please sign in to comment.