use of se.inera.intyg.infra.integration.hsa.model.Mottagning in project webcert by sklintyg.
the class StatModuleApiController method addStatsForMottagningar.
private void addStatsForMottagningar(Vardenhet vardenhet, List<VardenhetStats> veStatsList, Map<String, Long> intygStats, Map<String, Long> fragaSvarStats) {
List<Mottagning> mottagningar = vardenhet.getMottagningar();
if (mottagningar == null || mottagningar.isEmpty()) {
return;
}
VardenhetStats moStats;
for (Mottagning mo : mottagningar) {
String moNamn = Joiner.on(SEPARATOR).join(vardenhet.getNamn(), mo.getNamn());
moStats = new VardenhetStats(moNamn, mo.getId());
moStats.setOhanteradeFragaSvar(getSafeStatValueFromMap(mo.getId(), fragaSvarStats));
moStats.setOsigneradeIntyg(getSafeStatValueFromMap(mo.getId(), intygStats));
veStatsList.add(moStats);
}
}
use of se.inera.intyg.infra.integration.hsa.model.Mottagning in project webcert by sklintyg.
the class HoSPersonHelper method createVardenhetFromIntygUser.
public static Vardenhet createVardenhetFromIntygUser(String enhetId, IntygUser user) {
AbstractVardenhet enhet = HoSPersonHelper.findVardenhetEllerMottagning(user, enhetId).orElseThrow(() -> new IllegalStateException("User '" + user.getHsaId() + "' has no MIU for care unit '" + enhetId + "'"));
if (enhet instanceof se.inera.intyg.infra.integration.hsa.model.Vardenhet) {
se.inera.intyg.infra.integration.hsa.model.Vardenhet hsaVardenhet = (se.inera.intyg.infra.integration.hsa.model.Vardenhet) enhet;
se.inera.intyg.infra.integration.hsa.model.Vardgivare hsaVardgivare = HoSPersonHelper.findVardgivare(user, hsaVardenhet.getVardgivareHsaId()).orElseThrow(() -> new IllegalStateException("Unable to find parent vÄrdgivare for vardenhet '" + enhetId + "'"));
Vardenhet vardenhet = new Vardenhet();
vardenhet.setEnhetsnamn(hsaVardenhet.getNamn());
vardenhet.setEnhetsid(hsaVardenhet.getId());
vardenhet.setArbetsplatsKod(hsaVardenhet.getArbetsplatskod());
vardenhet.setPostadress(hsaVardenhet.getPostadress());
vardenhet.setPostnummer(hsaVardenhet.getPostnummer());
vardenhet.setPostort(hsaVardenhet.getPostort());
vardenhet.setTelefonnummer(hsaVardenhet.getTelefonnummer());
se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
vardgivare.setVardgivarid(hsaVardgivare.getId());
vardgivare.setVardgivarnamn(hsaVardgivare.getNamn());
vardenhet.setVardgivare(vardgivare);
return vardenhet;
}
if (enhet instanceof Mottagning) {
Mottagning m = (Mottagning) enhet;
se.inera.intyg.infra.integration.hsa.model.Vardgivare hsaVardgivare = HoSPersonHelper.findVardgivareForMottagning(user, m.getId()).orElseThrow(() -> new IllegalStateException("Unable to find parent vÄrdgivare for mottagning '" + enhetId + "'"));
Vardenhet vardenhet = new Vardenhet();
vardenhet.setEnhetsnamn(m.getNamn());
vardenhet.setEnhetsid(m.getId());
vardenhet.setArbetsplatsKod(m.getArbetsplatskod());
vardenhet.setPostadress(m.getPostadress());
vardenhet.setPostnummer(m.getPostnummer());
vardenhet.setPostort(m.getPostort());
vardenhet.setTelefonnummer(m.getTelefonnummer());
se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
vardgivare.setVardgivarid(hsaVardgivare.getId());
vardgivare.setVardgivarnamn(hsaVardgivare.getNamn());
vardenhet.setVardgivare(vardgivare);
return vardenhet;
}
throw new IllegalArgumentException("AbstractVardenhet instance passed to createVardenhetFromIntygUser was of unsupported type: " + enhet.getClass().getName());
}
use of se.inera.intyg.infra.integration.hsa.model.Mottagning in project webcert by sklintyg.
the class WebCertUserServiceTest method buildMottagning2.
private Mottagning buildMottagning2() {
Mottagning mottagning = new Mottagning(MOTTAGNING_2, "Mottagningen 2");
mottagning.setParentHsaId(VARDENHET_1);
return mottagning;
}
use of se.inera.intyg.infra.integration.hsa.model.Mottagning in project webcert by sklintyg.
the class StatModuleApiControllerTest method setupDataAndExpectations.
@Before
public void setupDataAndExpectations() {
fragaSvarStatsMap = new HashMap<>();
fragaSvarStatsMap.put("VE1", 2L);
fragaSvarStatsMap.put("VE1M1", 3L);
fragaSvarStatsMap.put("VE1M2", 3L);
fragaSvarStatsMap.put("VE2", 2L);
fragaSvarStatsMap.put("VE3", 1L);
arendeStatsMap = new HashMap<>();
arendeStatsMap.put("VE1", 2L);
arendeStatsMap.put("VE1M1", 3L);
arendeStatsMap.put("VE1M2", 3L);
arendeStatsMap.put("VE2", 2L);
arendeStatsMap.put("VE3", 1L);
intygStatsMap = new HashMap<>();
intygStatsMap.put("VE1M1", 1L);
intygStatsMap.put("VE1M2", 2L);
intygStatsMap.put("VE2", 2L);
mockUser = new WebCertUser();
Role role = AUTHORITIES_RESOLVER.getRole(AuthoritiesConstants.ROLE_LAKARE);
mockUser.setRoles(AuthoritiesResolverUtil.toMap(role));
mockUser.setAuthorities(AuthoritiesResolverUtil.toMap(role.getPrivileges(), Privilege::getName));
ve1 = new Vardenhet("VE1", "Vardenhet1");
ve1.getMottagningar().add(new Mottagning("VE1M1", "Mottagning1"));
ve1.getMottagningar().add(new Mottagning("VE1M2", "Mottagning2"));
ve2 = new Vardenhet("VE2", "Vardenhet2");
ve2.getMottagningar().add(new Mottagning("VE2M1", "Mottagning3"));
ve3 = new Vardenhet("VE3", "Vardenhet3");
ve4 = new Vardenhet("VE4", "Vardenhet4");
Vardgivare vg = new Vardgivare("VG1", "Vardgivaren");
vg.setVardenheter(Arrays.asList(ve1, ve2, ve3, ve4));
mockUser.setVardgivare(Collections.singletonList(vg));
mockUser.setValdVardgivare(vg);
when(authoritiesHelper.getIntygstyperForPrivilege(any(UserDetails.class), anyString())).thenReturn(Stream.of("fk7263").collect(Collectors.toSet()));
when(webCertUserService.getUser()).thenReturn(mockUser);
}
use of se.inera.intyg.infra.integration.hsa.model.Mottagning in project webcert by sklintyg.
the class WebCertUserServiceTest method buildMottagning1.
private Mottagning buildMottagning1() {
Mottagning mottagning = new Mottagning(MOTTAGNING_1, "Mottagningen");
mottagning.setParentHsaId(VARDENHET_1);
return mottagning;
}
Aggregations