Skip to content

Commit

Permalink
ZANR als Erweiterung zu LANR eingeführt
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli B committed Feb 9, 2024
1 parent 0c6ffca commit 10cc436
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Aus Gründen der Übersichtlichkeit sind bei älteren Versionen die einzelnen Pa

## [Unreleased]
### Added
- ZANR-Klasse im med-Package
- Zeitpunkt- und Zeitraum-Klasse akzeptieren Date als of(..)-Parameter

## [5.2.0] - 2024-01-22
Expand Down
3 changes: 3 additions & 0 deletions src/main/asciidoc/images/package-med.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ package "med" {
class PZN
class SNOMED
class Versichertennummer
class ZANR

LANR <|-- ZANR

}

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/de/jfachwert/FachwertFactory.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2023 by Oliver Boehm
* Copyright (c) 2018-2024 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -186,6 +186,7 @@ class FachwertFactory private constructor() {
instance.register(Waehrung::class.java)
instance.register(IK::class.java)
instance.register(LANR::class.java)
instance.register(ZANR::class.java)
instance.register(BSNR::class.java)
instance.register(SNOMED::class.java)
instance.register(Versichertennummer::class.java)
Expand Down
18 changes: 16 additions & 2 deletions src/main/kotlin/de/jfachwert/med/LANR.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020 by Oliver Boehm
* Copyright (c) 2018-2024 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,6 +70,16 @@ open class LANR
val pruefziffer: Int
get() = code / 100 % 10

/**
* Fuer Zahnaerzte gibt es den Ersatzwert "999999991". Fuer diesen Fall
* liefert diese Funktion 'true' zurueck.
*
* @return true oder false
*/
open fun isZahnarzt(): Boolean {
return equals(ERSATZWERT_ZAHNARZT)
}

/**
* Hier wird die 7-stellige Arztnummer ueberprueft, ob die Pruefziffer
* gueltig ist. Diese wird nach dem Modulo10-Verfahren mit der Gewichtung
Expand Down Expand Up @@ -125,7 +135,7 @@ open class LANR

companion object {

private val VALIDATOR = LengthValidator<Int>(4, 9)
val VALIDATOR = LengthValidator<Int>(4, 9)
private val WEAK_CACHE = WeakHashMap<Int, LANR>()

/** Null-Konstante fuer Initialisierungen. */
Expand All @@ -136,6 +146,10 @@ open class LANR
@JvmField
val PSEUDO_NUMMER = of(999999900)

/** Ersatzwert fuer Zahnaerzte */
@JvmField
val ERSATZWERT_ZAHNARZT = of(999999991)

/**
* Liefert eine LANR zurueck.
*
Expand Down
77 changes: 77 additions & 0 deletions src/main/kotlin/de/jfachwert/med/ZANR.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2024 by Oli B.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 09.02.24 by oboehm
*/
package de.jfachwert.med

import de.jfachwert.KSimpleValidator
import de.jfachwert.pruefung.NullValidator
import java.util.*

/**
* Die Zahnarztnummer (ZANR) entspricht im wesentlichen der LANR.
* Sie ist seit 1.1.2023 verpflichtend (s.a.
* https://www.kzv-berlin.de/fuer-praxen/abrechnung/zahnarztnummer).
*
* @author oboehm
* @since 5.3 (09.02.24)
*/
open class ZANR
/**
* Erzeugt ein neues LANR-Objekt.
*
* @param code neunstellige Zahl
* @param validator Validator zur Pruefung der Zahl
*/
@JvmOverloads constructor(code: Int, validator: KSimpleValidator<Int> = VALIDATOR) : LANR(code, validator) {

override fun isZahnarzt(): Boolean {
return true
}

companion object {

private val WEAK_CACHE = WeakHashMap<Int, ZANR>()

/** Null-Konstante fuer Initialisierungen. */
@JvmField
val NULL = ZANR(0, NullValidator())

/**
* Liefert eine ZANR zurueck.
*
* @param code 9-stellige Nummer
* @return die ZANR
*/
@JvmStatic
fun of(code: Int): ZANR {
return WEAK_CACHE.computeIfAbsent(code) { n: Int -> ZANR(n) }
}

/**
* Liefert eine LANR zurueck.
*
* @param code 9-stellige Nummer
* @return die LANR
*/
@JvmStatic
fun of(code: String): ZANR {
return of(code.toInt())
}

}

}
14 changes: 13 additions & 1 deletion src/test/java/de/jfachwert/med/LANRTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 by Oliver Boehm
* Copyright (c) 2018-2024 by Oliver Boehm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -118,4 +118,16 @@ public void testIsPseudoNummer555555() {
assertTrue(LANR.of("555555102").isPseudoNummer());
}

@Test
public void testIsZahnarzt() {
LANR ersatzwert = LANR.of(999999991);
assertTrue(ersatzwert.isPseudoNummer());
assertTrue(ersatzwert.isZahnarzt());
}

@Test
public void testIstKeinZahnarzt() {
assertFalse(LANR.of(345678975).isZahnarzt());
}

}
48 changes: 48 additions & 0 deletions src/test/java/de/jfachwert/med/ZANRTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024 by Oli B.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express orimplied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* (c)reated 09.02.24 by oboehm
*/
package de.jfachwert.med;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Unit-Tests fuer ZANR.
*
* @author oboehm
*/
public class ZANRTest extends LANRTest {

/**
* Zum Testen verwenden wir die ZANR-Klasse
*
* @param nr LA-Nummer
* @return Test-Objekt zum Testen
*/
@Override
protected ZANR createFachwert(String nr) {
return ZANR.of(nr);
}

@Test
@Override
public void testIstKeinZahnarzt() {
assertTrue(ZANR.of(345678975).isZahnarzt());
}

}

0 comments on commit 10cc436

Please sign in to comment.